More fixes, redid a bunch of SPRK, so far everything I've tested works fine.
This commit is contained in:
parent
a9f4b5fe34
commit
d58100dc07
@ -104,13 +104,16 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if ((r&0xFF)==PT_CBNW)
|
||||
{
|
||||
if(!parts[i].tmp && parts[r>>8].tmp)
|
||||
if(!parts[i].tmp)
|
||||
{
|
||||
parts[i].tmp = parts[r>>8].tmp;
|
||||
if((r>>8)>i) //If the other particle hasn't been life updated
|
||||
parts[i].tmp--;
|
||||
if (parts[r>>8].tmp)
|
||||
{
|
||||
parts[i].tmp = parts[r>>8].tmp;
|
||||
if((r>>8)>i) //If the other particle hasn't been life updated
|
||||
parts[i].tmp--;
|
||||
}
|
||||
}
|
||||
else if(parts[i].tmp && !parts[r>>8].tmp)
|
||||
else if(!parts[r>>8].tmp)
|
||||
{
|
||||
parts[r>>8].tmp = parts[i].tmp;
|
||||
if((r>>8)>i) //If the other particle hasn't been life updated
|
||||
|
@ -77,14 +77,11 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS)
|
||||
parts[i].life--;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!parts[r>>8].life)
|
||||
{
|
||||
if (!parts[r>>8].life)
|
||||
{
|
||||
parts[r>>8].life = parts[i].life;
|
||||
if((r>>8)>i) //If the other particle hasn't been life updated
|
||||
parts[r>>8].life++;
|
||||
}
|
||||
parts[r>>8].life = parts[i].life;
|
||||
if((r>>8)>i) //If the other particle hasn't been life updated
|
||||
parts[r>>8].life++;
|
||||
}
|
||||
}
|
||||
else if((r&0xFF)==PT_NSCN && oldl==1)
|
||||
|
@ -82,7 +82,7 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS)
|
||||
r = sim->photons[y+ry][x+rx];
|
||||
if(!r)
|
||||
continue;
|
||||
if ((r&0xFF) == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[r>>8].ctype || !parts[i].tmp))
|
||||
if (parts[r>>8].type == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[r>>8].ctype || !parts[i].tmp))
|
||||
parts[i].life = 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -50,13 +50,8 @@ Element_ELEC::Element_ELEC()
|
||||
int Element_ELEC::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, rt, rx, ry, nb, rrx, rry;
|
||||
float rr, rrr;
|
||||
parts[i].pavg[0] = x;
|
||||
parts[i].pavg[1] = y;
|
||||
if(pmap[y][x]==PT_GLOW)//move into movement code
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_PHOT);
|
||||
}
|
||||
for (rx=-2; rx<=2; rx++)
|
||||
for (ry=-2; ry<=2; ry++)
|
||||
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) {
|
||||
@ -110,6 +105,12 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
|
||||
parts[r>>8].tmp2 += 5;
|
||||
parts[r>>8].life = 1000;
|
||||
break;
|
||||
case PT_GLOW:
|
||||
if (!rx && !ry)//if on GLOW
|
||||
sim->part_change_type(i, x, y, PT_PHOT);
|
||||
break;
|
||||
case PT_NONE: //seems to speed up ELEC even if it isn't used
|
||||
break;
|
||||
default:
|
||||
if ((sim->elements[rt].Properties & PROP_CONDUCTS) && (rt!=PT_NBLE||parts[i].temp<2273.15))
|
||||
{
|
||||
@ -117,7 +118,7 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -163,6 +163,9 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
|
||||
case PT_EXOT:
|
||||
if (!(rand()%20))
|
||||
parts[r>>8].life = 1500;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -107,42 +107,43 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
|
||||
parts[r>>8].life = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10)
|
||||
{
|
||||
if (parts[i].ctype==PT_PHOT) {//create photons a different way
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry = -1; ry < 2; ry++)
|
||||
if (rx || ry)
|
||||
{
|
||||
int r = sim->create_part(-1, x + rx, y + ry,parts[i].ctype);
|
||||
if (r != -1)
|
||||
if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled)
|
||||
{
|
||||
if (parts[i].ctype==PT_PHOT) {//create photons a different way
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry = -1; ry < 2; ry++)
|
||||
if (rx || ry)
|
||||
{
|
||||
parts[r].vx = rx * 3;
|
||||
parts[r].vy = ry * 3;
|
||||
if (r>i)
|
||||
int r = sim->create_part(-1, x + rx, y + ry,parts[i].ctype);
|
||||
if (r != -1)
|
||||
{
|
||||
// Make sure movement doesn't happen until next frame, to avoid gaps in the beams of photons produced
|
||||
parts[r].flags |= FLAG_SKIPMOVE;
|
||||
parts[r].vx = rx * 3;
|
||||
parts[r].vy = ry * 3;
|
||||
if (r>i)
|
||||
{
|
||||
// Make sure movement doesn't happen until next frame, to avoid gaps in the beams of photons produced
|
||||
parts[r].flags |= FLAG_SKIPMOVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parts[i].ctype==PT_LIFE)//create life a different way
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
sim->create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8));
|
||||
}
|
||||
else if (parts[i].ctype==PT_LIFE)//create life a different way
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
sim->create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8));
|
||||
|
||||
else if (parts[i].ctype!=PT_LIGH || !(rand()%30))
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
|
||||
if (np>-1)
|
||||
else if (parts[i].ctype!=PT_LIGH || !(rand()%30))
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
parts[np].ctype = parts[i].tmp;
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
|
||||
if (np>-1)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
parts[np].ctype = parts[i].tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,8 @@ Element_PCLN::Element_PCLN()
|
||||
|
||||
//#TPT-Directive ElementHeader Element_PCLN static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_PCLN::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, rx, ry, rt;
|
||||
{
|
||||
int r, rx, ry, rt;
|
||||
if (parts[i].life>0 && parts[i].life!=10)
|
||||
parts[i].life--;
|
||||
for (rx=-2; rx<3; rx++)
|
||||
|
@ -61,50 +61,34 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
|
||||
if (!(rand()%10)) Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry)) {
|
||||
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) {
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((r&0xFF)==PT_ISOZ && !(rand()%400))
|
||||
if ((r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS)
|
||||
{
|
||||
parts[i].vx *= 0.90;
|
||||
parts[i].vy *= 0.90;
|
||||
sim->create_part(r>>8, x+rx, y+ry, PT_PHOT);
|
||||
rrr = (rand()%360)*3.14159f/180.0f;
|
||||
rr = (rand()%128+128)/127.0f;
|
||||
parts[r>>8].vx = rr*cosf(rrr);
|
||||
parts[r>>8].vy = rr*sinf(rrr);
|
||||
sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS;
|
||||
if (!(rand()%400))
|
||||
{
|
||||
parts[i].vx *= 0.90;
|
||||
parts[i].vy *= 0.90;
|
||||
sim->create_part(r>>8, x+rx, y+ry, PT_PHOT);
|
||||
rrr = (rand()%360)*3.14159f/180.0f;
|
||||
rr = (rand()%128+128)/127.0f;
|
||||
parts[r>>8].vx = rr*cosf(rrr);
|
||||
parts[r>>8].vy = rr*sinf(rrr);
|
||||
sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS;
|
||||
}
|
||||
}
|
||||
if ((r&0xFF)==PT_ISZS && !(rand()%400))
|
||||
else if((r&0xFF) == PT_QRTZ && !ry && !rx)//if on QRTZ
|
||||
{
|
||||
parts[i].vx *= 0.90;
|
||||
parts[i].vy *= 0.90;
|
||||
sim->create_part(r>>8, x+rx, y+ry, PT_PHOT);
|
||||
rr = (rand()%228+128)/127.0f;
|
||||
rrr = (rand()%360)*3.14159f/180.0f;
|
||||
parts[r>>8].vx = rr*cosf(rrr);
|
||||
parts[r>>8].vy = rr*sinf(rrr);
|
||||
sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS;
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
parts[i].vx = 3.0f*cosf(a);
|
||||
parts[i].vy = 3.0f*sinf(a);
|
||||
if(parts[i].ctype == 0x3FFFFFFF)
|
||||
parts[i].ctype = 0x1F<<(rand()%26);
|
||||
parts[i].life++; //Delay death
|
||||
}
|
||||
}
|
||||
r = pmap[y][x];
|
||||
if((r&0xFF) == PT_QRTZ)// && parts[i].ctype==0x3FFFFFFF)
|
||||
{
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
parts[i].vx = 3.0f*cosf(a);
|
||||
parts[i].vy = 3.0f*sinf(a);
|
||||
if(parts[i].ctype == 0x3FFFFFFF)
|
||||
parts[i].ctype = 0x1F<<(rand()%26);
|
||||
parts[i].life++; //Delay death
|
||||
}
|
||||
//r = pmap[y][x];
|
||||
//rt = r&0xFF;
|
||||
/*if (rt==PT_CLNE || rt==PT_PCLN || rt==PT_BCLN || rt==PT_PBCN) {
|
||||
if (!parts[r>>8].ctype)
|
||||
parts[r>>8].ctype = PT_PHOT;
|
||||
}*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
||||
pushParticle(sim, r>>8,count,original);
|
||||
}
|
||||
else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
|
||||
{
|
||||
{
|
||||
int nnx;
|
||||
for (nnx=0; nnx<80; nnx++)
|
||||
if (!sim->portalp[sim->parts[r>>8].tmp][count][nnx].type)
|
||||
@ -462,7 +462,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -479,7 +479,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
||||
pushParticle(sim, r>>8,count,original);
|
||||
}
|
||||
else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
|
||||
{
|
||||
{
|
||||
int nnx;
|
||||
for (nnx=0; nnx<80; nnx++)
|
||||
if (!sim->portalp[sim->parts[r>>8].tmp][count][nnx].type)
|
||||
@ -488,9 +488,9 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((r&0xFF) == PT_NONE) //Move particles out of pipe automatically, much faster at ends
|
||||
{
|
||||
}
|
||||
else if ((r&0xFF) == PT_NONE) //Move particles out of pipe automatically, much faster at ends
|
||||
{
|
||||
rx = pos_1_rx[coords];
|
||||
ry = pos_1_ry[coords];
|
||||
np = sim->create_part(-1,x+rx,y+ry,sim->parts[i].tmp&0xFF);
|
||||
@ -498,7 +498,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
||||
{
|
||||
transfer_pipe_to_part(sim->parts+i, sim->parts+np);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
|
@ -48,7 +48,7 @@ Element_PQRT::Element_PQRT()
|
||||
|
||||
//#TPT-Directive ElementHeader Element_PQRT static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_PQRT::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
{
|
||||
int r, tmp, trade, rx, ry, np;
|
||||
// absorb SLTW
|
||||
if (parts[i].ctype!=-1)
|
||||
@ -65,50 +65,47 @@ int Element_PQRT::update(UPDATE_FUNC_ARGS)
|
||||
parts[i].ctype ++;
|
||||
}
|
||||
}
|
||||
// grow if absorbed SLTW
|
||||
if (parts[i].ctype>0)
|
||||
{
|
||||
for ( trade = 0; trade<5; trade ++)
|
||||
{
|
||||
rx = rand()%3-1;
|
||||
ry = rand()%3-1;
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r && parts[i].ctype!=0)
|
||||
{
|
||||
np = sim->create_part(-1,x+rx,y+ry,PT_QRTZ);
|
||||
if (np>-1)
|
||||
{
|
||||
parts[np].tmp = parts[i].tmp;
|
||||
parts[i].ctype--;
|
||||
if (rand()%2)
|
||||
{
|
||||
parts[np].ctype=-1;//dead qrtz
|
||||
}
|
||||
else if (!parts[i].ctype && !(rand()%15))
|
||||
{
|
||||
parts[i].ctype=-1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// diffuse absorbed SLTW
|
||||
// grow and diffuse
|
||||
if (parts[i].ctype>0)
|
||||
{
|
||||
bool stopgrow=false;
|
||||
int rnd, sry, srx;
|
||||
for ( trade = 0; trade<9; trade ++)
|
||||
{
|
||||
rx = rand()%5-2;
|
||||
ry = rand()%5-2;
|
||||
rnd = rand()%0x3FF;
|
||||
rx = (rnd%5)-2;
|
||||
srx = (rnd%3)-1;
|
||||
rnd = rnd>>3;
|
||||
ry = (rnd%5)-2;
|
||||
sry = (rnd%3)-1;
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
{
|
||||
if (!stopgrow)//try to grow
|
||||
{
|
||||
if (!pmap[y+sry][x+srx] && parts[i].ctype!=0)
|
||||
{
|
||||
np = sim->create_part(-1,x+srx,y+sry,PT_QRTZ);
|
||||
if (np>-1)
|
||||
{
|
||||
parts[np].tmp = parts[i].tmp;
|
||||
parts[i].ctype--;
|
||||
if (rand()%2)
|
||||
{
|
||||
parts[np].ctype=-1;//dead qrtz
|
||||
}
|
||||
else if (!parts[i].ctype && !(rand()%15))
|
||||
{
|
||||
parts[i].ctype=-1;
|
||||
}
|
||||
stopgrow=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//diffusion
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((r&0xFF)==PT_PQRT && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion
|
||||
else if ((r&0xFF)==PT_PQRT && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )
|
||||
{
|
||||
tmp = parts[i].ctype - parts[r>>8].ctype;
|
||||
if (tmp ==1)
|
||||
|
@ -66,36 +66,36 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
rx = sim->portal_rx[count];
|
||||
ry = sim->portal_ry[count];
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
fe = 1;
|
||||
if (!r || (!(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) && (r&0xFF)!=PT_SPRK))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
r = sim->photons[y+ry][x+rx];
|
||||
if (!r)
|
||||
fe = 1;
|
||||
if (!r || (!(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) && (r&0xFF)!=PT_SPRK))
|
||||
{
|
||||
r = sim->photons[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2 || (r&0xFF)==PT_FIGH)
|
||||
continue;// Handling these is a bit more complicated, and is done in STKM_interact()
|
||||
|
||||
if ((r&0xFF) == PT_SOAP)
|
||||
sim->detach(r>>8);
|
||||
|
||||
for ( nnx=0; nnx<80; nnx++)
|
||||
if (!sim->portalp[parts[i].tmp][count][nnx].type)
|
||||
{
|
||||
sim->portalp[parts[i].tmp][count][nnx] = parts[r>>8];
|
||||
if ((r&0xFF)==PT_SPRK)
|
||||
sim->part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype);
|
||||
else
|
||||
sim->kill_part(r>>8);
|
||||
fe = 1;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2 || (r&0xFF)==PT_FIGH)
|
||||
continue;// Handling these is a bit more complicated, and is done in STKM_interact()
|
||||
|
||||
if ((r&0xFF) == PT_SOAP)
|
||||
sim->detach(r>>8);
|
||||
|
||||
for ( nnx=0; nnx<80; nnx++)
|
||||
if (!sim->portalp[parts[i].tmp][count][nnx].type)
|
||||
{
|
||||
sim->portalp[parts[i].tmp][count][nnx] = parts[r>>8];
|
||||
if ((r&0xFF)==PT_SPRK)
|
||||
sim->part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype);
|
||||
else
|
||||
sim->kill_part(r>>8);
|
||||
fe = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ Element_QRTZ::Element_QRTZ()
|
||||
|
||||
//#TPT-Directive ElementHeader Element_QRTZ static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_QRTZ::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
{
|
||||
int r, tmp, trade, rx, ry, np;
|
||||
parts[i].pavg[0] = parts[i].pavg[1];
|
||||
parts[i].pavg[1] = sim->pv[y/CELL][x/CELL];
|
||||
@ -71,51 +71,47 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
|
||||
parts[i].ctype ++;
|
||||
}
|
||||
}
|
||||
// grow if absorbed SLTW
|
||||
if (parts[i].ctype>0)
|
||||
{
|
||||
for ( trade = 0; trade<5; trade ++)
|
||||
{
|
||||
rx = rand()%3-1;
|
||||
ry = rand()%3-1;
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r && parts[i].ctype!=0)
|
||||
{
|
||||
np = sim->create_part(-1,x+rx,y+ry,PT_QRTZ);
|
||||
if (np>-1)
|
||||
{
|
||||
parts[np].tmp = parts[i].tmp;
|
||||
parts[i].ctype--;
|
||||
if (rand()%2)
|
||||
{
|
||||
parts[np].ctype=-1;//dead qrtz
|
||||
}
|
||||
else if (!parts[i].ctype && !(rand()%15))
|
||||
{
|
||||
parts[i].ctype=-1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// diffuse absorbed SLTW
|
||||
// grow and diffuse
|
||||
if (parts[i].ctype>0)
|
||||
{
|
||||
bool stopgrow=false;
|
||||
int rnd, sry, srx;
|
||||
for ( trade = 0; trade<9; trade ++)
|
||||
{
|
||||
rx = rand()%5-2;
|
||||
ry = rand()%5-2;
|
||||
rnd = rand()%0x3FF;
|
||||
rx = (rnd%5)-2;
|
||||
srx = (rnd%3)-1;
|
||||
rnd >>= 3;
|
||||
ry = (rnd%5)-2;
|
||||
sry = (rnd%3)-1;
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
{
|
||||
if (!stopgrow)//try to grow
|
||||
{
|
||||
if (!pmap[y+sry][x+srx] && parts[i].ctype!=0)
|
||||
{
|
||||
np = sim->create_part(-1,x+srx,y+sry,PT_QRTZ);
|
||||
if (np>-1)
|
||||
{
|
||||
parts[np].tmp = parts[i].tmp;
|
||||
parts[i].ctype--;
|
||||
if (rand()%2)
|
||||
{
|
||||
parts[np].ctype=-1;//dead qrtz
|
||||
}
|
||||
else if (!parts[i].ctype && !(rand()%15))
|
||||
{
|
||||
parts[i].ctype=-1;
|
||||
}
|
||||
stopgrow=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//diffusion
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((r&0xFF)==PT_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion
|
||||
else if ((r&0xFF)==PT_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )
|
||||
{
|
||||
tmp = parts[i].ctype - parts[r>>8].ctype;
|
||||
if (tmp ==1)
|
||||
|
@ -84,6 +84,8 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PT_NONE:
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
@ -210,10 +210,8 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
|
||||
if ((r&0xFF) == PT_OIL)
|
||||
{
|
||||
float ax, ay;
|
||||
parts[i].vy = (parts[i].vy-0.1f)*0.5f;
|
||||
parts[i].vx *= 0.5f;
|
||||
ax = (parts[i].vx + parts[r>>8].vx)/2;
|
||||
ay = (parts[i].vy + parts[r>>8].vy)/2;
|
||||
ax = (parts[i].vx*0.5f + parts[r>>8].vx)/2;
|
||||
ay = ((parts[i].vy-0.1f)*0.5f + parts[r>>8].vy)/2;
|
||||
parts[i].vx = parts[r>>8].vx = ax;
|
||||
parts[i].vy = parts[r>>8].vy = ay;
|
||||
}
|
||||
|
@ -63,23 +63,22 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
parts[i].life = 4;
|
||||
if (ct == PT_WATR)
|
||||
parts[i].life = 64;
|
||||
if (ct == PT_SLTW)
|
||||
else if (ct == PT_SLTW)
|
||||
parts[i].life = 54;
|
||||
if (ct == PT_SWCH)
|
||||
else if (ct == PT_SWCH)
|
||||
parts[i].life = 14;
|
||||
return 0;
|
||||
}
|
||||
if (ct==PT_SPRK)
|
||||
switch(ct)
|
||||
{
|
||||
case PT_SPRK:
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
else if (ct==PT_NTCT || ct==PT_PTCT)
|
||||
{
|
||||
case PT_NTCT:
|
||||
case PT_PTCT:
|
||||
Element_NTCT::update(UPDATE_FUNC_SUBCALL_ARGS);
|
||||
}
|
||||
else if (ct==PT_ETRD)
|
||||
{
|
||||
break;
|
||||
case PT_ETRD:
|
||||
if (parts[i].life==1)
|
||||
{
|
||||
nearp = sim->nearest_part(i, PT_ETRD, -1);
|
||||
@ -94,9 +93,8 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
parts[nearp].ctype = PT_ETRD;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ct==PT_NBLE)
|
||||
{
|
||||
break;
|
||||
case PT_NBLE:
|
||||
if (parts[i].life<=1&&parts[i].tmp!=1)
|
||||
{
|
||||
parts[i].life = rand()%150+50;
|
||||
@ -107,9 +105,8 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
parts[i].temp = 3500;
|
||||
sim->pv[y/CELL][x/CELL] += 1;
|
||||
}
|
||||
}
|
||||
else if (ct==PT_TESC) // tesla coil code
|
||||
{
|
||||
break;
|
||||
case PT_TESC:
|
||||
if (parts[i].tmp>300)
|
||||
parts[i].tmp=300;
|
||||
for (rx=-1; rx<2; rx++)
|
||||
@ -141,8 +138,8 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ct==PT_IRON) {
|
||||
break;
|
||||
case PT_IRON:
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
@ -150,16 +147,18 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) ||
|
||||
((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) ||
|
||||
((r&0xFF) == PT_WATR && 30>(rand()/(RAND_MAX/1000))))
|
||||
if ((r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || (r&0xFF)==PT_WATR)
|
||||
{
|
||||
if (rand()<RAND_MAX/3)
|
||||
int rnd = rand()%100;
|
||||
if (!rnd)
|
||||
sim->part_change_type(r>>8,x+rx,y+ry,PT_O2);
|
||||
else
|
||||
else if (3>rnd)
|
||||
sim->part_change_type(r>>8,x+rx,y+ry,PT_H2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for (rx=-2; rx<3; rx++)
|
||||
for (ry=-2; ry<3; ry++)
|
||||
@ -172,69 +171,134 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
conduct_sprk = 1;
|
||||
// ct = spark from material, rt = spark to material. Make conduct_sprk = 0 if conduction not allowed
|
||||
pavg = sim->parts_avg(r>>8, i,PT_INSL);
|
||||
if ((rt==PT_SWCH||(rt==PT_SPRK&&parts[r>>8].ctype==PT_SWCH)) && pavg!=PT_INSL && parts[i].life<4) // make sparked SWCH turn off correctly
|
||||
switch (rt)
|
||||
{
|
||||
if (rt==PT_SWCH&&ct==PT_PSCN&&parts[r>>8].life<10) {
|
||||
parts[r>>8].life = 10;
|
||||
case PT_SWCH:
|
||||
if (pavg!=PT_INSL && parts[i].life<4)
|
||||
{
|
||||
if(ct==PT_PSCN && parts[r>>8].life<10) {
|
||||
parts[r>>8].life = 10;
|
||||
}
|
||||
else if (ct==PT_NSCN)
|
||||
{
|
||||
parts[r>>8].ctype = PT_NONE;
|
||||
parts[r>>8].life = 9;
|
||||
}
|
||||
}
|
||||
if (ct==PT_NSCN) {
|
||||
sim->part_change_type(r>>8,x+rx,y+ry,PT_SWCH);
|
||||
parts[r>>8].ctype = PT_NONE;
|
||||
parts[r>>8].life = 9;
|
||||
break;
|
||||
case PT_SPRK:
|
||||
if (pavg!=PT_INSL && parts[i].life<4)
|
||||
{
|
||||
if (parts[r>>8].ctype==PT_SWCH)
|
||||
{
|
||||
if (ct==PT_NSCN)
|
||||
{
|
||||
sim->part_change_type(r>>8,x+rx,y+ry,PT_SWCH);
|
||||
parts[r>>8].ctype = PT_NONE;
|
||||
parts[r>>8].life = 9;
|
||||
}
|
||||
}
|
||||
else if(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT)
|
||||
if (ct==PT_METL)
|
||||
{
|
||||
parts[r>>8].temp = 473.0f;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
case PT_PUMP:
|
||||
case PT_GPMP:
|
||||
case PT_HSWC:
|
||||
case PT_PBCN:
|
||||
if (parts[i].life<4)// PROP_PTOGGLE, Maybe? We seem to use 2 different methods for handling actived elements, this one seems better. Yes, use this one for new elements, PCLN is different for compatibility with existing saves
|
||||
{
|
||||
if (ct==PT_PSCN) parts[r>>8].life = 10;
|
||||
else if (ct==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9;
|
||||
}
|
||||
continue;
|
||||
case PT_LCRY:
|
||||
if (abs(rx)<2&&abs(ry)<2 && parts[i].life<4)
|
||||
{
|
||||
if (ct==PT_PSCN && parts[r>>8].tmp == 0) parts[r>>8].tmp = 2;
|
||||
else if (ct==PT_NSCN && parts[r>>8].tmp == 3) parts[r>>8].tmp = 1;
|
||||
}
|
||||
continue;
|
||||
case PT_PPIP:
|
||||
if (parts[i].life == 3 && pavg!=PT_INSL)
|
||||
{
|
||||
if (ct == PT_NSCN || ct == PT_PSCN || ct == PT_INST)
|
||||
Element_PPIP::flood_trigger(sim, x+rx, y+ry, ct);
|
||||
}
|
||||
continue;
|
||||
case PT_NTCT: case PT_PTCT: case PT_INWR:
|
||||
if (ct==PT_METL && pavg!=PT_INSL && parts[i].life<4)
|
||||
{
|
||||
parts[r>>8].temp = 473.0f;
|
||||
if (rt==PT_NTCT||rt==PT_PTCT)
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_GPMP||rt==PT_HSWC||rt==PT_PBCN) && parts[i].life<4) // PROP_PTOGGLE, Maybe? We seem to use 2 different methods for handling actived elements, this one seems better. Yes, use this one for new elements, PCLN is different for compatibility with existing saves
|
||||
{
|
||||
if (ct==PT_PSCN) parts[r>>8].life = 10;
|
||||
else if (ct==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9;
|
||||
}
|
||||
else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_LCRY&&abs(rx)<2&&abs(ry)<2) && parts[i].life<4)
|
||||
{
|
||||
if (ct==PT_PSCN && parts[r>>8].tmp == 0) parts[r>>8].tmp = 2;
|
||||
else if (ct==PT_NSCN && parts[r>>8].tmp == 3) parts[r>>8].tmp = 1;
|
||||
}
|
||||
|
||||
if (rt == PT_PPIP && parts[i].life == 3 && pavg!=PT_INSL)
|
||||
{
|
||||
if (ct == PT_NSCN || ct == PT_PSCN || ct == PT_INST)
|
||||
Element_PPIP::flood_trigger(sim, x+rx, y+ry, ct);
|
||||
}
|
||||
if (ct==PT_METL && (rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR||(rt==PT_SPRK&&(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT))) && pavg!=PT_INSL && parts[i].life<4)
|
||||
{
|
||||
parts[r>>8].temp = 473.0f;
|
||||
if (rt==PT_NTCT||rt==PT_PTCT)
|
||||
continue;
|
||||
}
|
||||
//the crazy conduct checks
|
||||
if (pavg == PT_INSL) continue;
|
||||
if (!((sim->elements[rt].Properties&PROP_CONDUCTS)||rt==PT_INST||rt==PT_QRTZ)) continue;
|
||||
if (abs(rx)+abs(ry)>=4 &&ct!=PT_SWCH&&rt!=PT_SWCH)
|
||||
continue;
|
||||
//if (rt==ct && rt!=PT_INST) goto conduct;
|
||||
if (ct==PT_NTCT && !(rt==PT_PSCN || rt==PT_NTCT || (rt==PT_NSCN&&parts[i].temp>373.0f)))
|
||||
if (rt==ct && rt!=PT_INST) goto conduct;
|
||||
|
||||
switch (ct)
|
||||
{
|
||||
case PT_INST:
|
||||
if (rt==PT_NSCN)
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (ct==PT_PTCT && !(rt==PT_PSCN || rt==PT_PTCT || (rt==PT_NSCN&&parts[i].temp<373.0f)))
|
||||
case PT_SWCH:
|
||||
if (rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR)
|
||||
continue;
|
||||
goto conduct;
|
||||
case PT_ETRD:
|
||||
if (rt==PT_METL||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (ct==PT_INWR && !(rt==PT_NSCN || rt==PT_INWR || rt==PT_PSCN))
|
||||
case PT_NTCT:
|
||||
if (rt==PT_PSCN || (rt==PT_NSCN && parts[i].temp>373.0f))
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (ct==PT_NSCN && rt==PT_PSCN)
|
||||
case PT_PTCT:
|
||||
if (rt==PT_PSCN || (rt==PT_NSCN && parts[i].temp<373.0f))
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (ct==PT_ETRD && !(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN))
|
||||
}
|
||||
switch (rt)
|
||||
{
|
||||
case PT_QRTZ:
|
||||
if ((ct==PT_NSCN||ct==PT_METL||ct==PT_PSCN||ct==PT_QRTZ) && (parts[r>>8].temp<173.15||sim->pv[(y+ry)/CELL][(x+rx)/CELL]>8))
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (ct==PT_INST && rt!=PT_NSCN) continue;
|
||||
else if (ct==PT_SWCH && (rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR))
|
||||
case PT_NTCT:
|
||||
if (ct==PT_NSCN || (ct==PT_PSCN&&parts[r>>8].temp>373.0f))
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (rt==PT_QRTZ && !((ct==PT_NSCN||ct==PT_METL||ct==PT_PSCN||ct==PT_QRTZ) && (parts[r>>8].temp<173.15||sim->pv[(y+ry)/CELL][(x+rx)/CELL]>8)))
|
||||
case PT_PTCT:
|
||||
if (ct==PT_NSCN || (ct==PT_PSCN&&parts[r>>8].temp<373.0f))
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (rt==PT_NTCT && !(ct==PT_NSCN || ct==PT_NTCT || (ct==PT_PSCN&&parts[r>>8].temp>373.0f)))
|
||||
case PT_INWR:
|
||||
if (ct==PT_NSCN || ct==PT_PSCN)
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (rt==PT_PTCT && !(ct==PT_NSCN || ct==PT_PTCT || (ct==PT_PSCN&&parts[r>>8].temp<373.0f)))
|
||||
case PT_INST:
|
||||
if (ct==PT_PSCN)
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (rt==PT_INWR && !(ct==PT_NSCN || ct==PT_INWR || ct==PT_PSCN))
|
||||
case PT_NBLE:
|
||||
if (parts[r>>8].tmp != 1)
|
||||
goto conduct;
|
||||
continue;
|
||||
else if (rt==PT_INST && ct!=PT_PSCN)
|
||||
continue;
|
||||
else if (rt==PT_NBLE && parts[r>>8].tmp == 1)
|
||||
case PT_PSCN:
|
||||
if (ct!=PT_NSCN)
|
||||
goto conduct;
|
||||
continue;
|
||||
}
|
||||
conduct:
|
||||
if (rt==PT_WATR||rt==PT_SLTW) {
|
||||
if (parts[r>>8].life==0 && parts[i].life<3)
|
||||
|
Loading…
Reference in New Issue
Block a user