Finished first pass-through for all elements.

Will get a few more places later.
This commit is contained in:
cracker64 2013-02-28 00:40:36 -05:00
parent 08d1a68ce0
commit c65081d3ed
36 changed files with 367 additions and 381 deletions

View File

@ -48,7 +48,7 @@ Element_DCEL::Element_DCEL()
//#TPT-Directive ElementHeader Element_DCEL static int update(UPDATE_FUNC_ARGS)
int Element_DCEL::update(UPDATE_FUNC_ARGS)
{
{
int r, rx, ry;
float multiplier;
if (parts[i].life!=0)
@ -60,18 +60,18 @@ int Element_DCEL::update(UPDATE_FUNC_ARGS)
{
multiplier = 1.0f/1.1f;
}
parts[i].tmp = 0;
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) && !(rx && ry))
{
r = pmap[y+ry][x+rx];
if(!r)
r = sim->photons[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))
{
parts[i].tmp = 0;
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) && !(rx && ry))
{
r = pmap[y+ry][x+rx];
if (!r)
r = sim->photons[y+ry][x+rx];
if (!r)
continue;
if (sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))
{
parts[r>>8].vx *= multiplier;
parts[r>>8].vy *= multiplier;
parts[i].tmp = 1;

View File

@ -75,7 +75,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) {
}
}
if ((parts[i].tmp>245) && (parts[i].life>1000))
if (rt!=PT_EXOT && rt!=PT_BREC && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PRTI && rt!=PT_PRTO && rt!=PT_PCLN && rt!=PT_PHOT && rt!=PT_VOID && rt!=PT_NBHL && rt!=PT_WARP && rt!=PT_NEUT)
if (rt!=PT_EXOT && rt!=PT_BREC && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PRTI && rt!=PT_PRTO && rt!=PT_PCLN && rt!=PT_VOID && rt!=PT_NBHL && rt!=PT_WARP)
{
sim->create_part(i, x, y, rt);
return 0;

View File

@ -59,12 +59,15 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SPRK && parts[r>>8].life>0 && parts[r>>8].life<4)
if ((r&0xFF)==PT_SPRK)
{
if (parts[r>>8].ctype==PT_PSCN)
parts[i].life = 10;
else if (parts[r>>8].ctype==PT_NSCN)
parts[i].life = 9;
if (parts[r>>8].life>0 && parts[r>>8].life<4)
{
if (parts[r>>8].ctype==PT_PSCN)
parts[i].life = 10;
else if (parts[r>>8].ctype==PT_NSCN)
parts[i].life = 9;
}
}
else if ((r&0xFF)==PT_PCLN)
{

View File

@ -55,36 +55,48 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_WATR && 1>(rand()%250))
switch (r&0xFF)
{
np = sim->create_part(r>>8,x+rx,y+ry,PT_PLNT);
if (np<0) continue;
parts[np].life = 0;
}
else if ((r&0xFF)==PT_LAVA && 1>(rand()%250))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
}
else if (((r&0xFF)==PT_SMKE || (r&0xFF)==PT_CO2) && (1>rand()%250))
{
sim->kill_part(r>>8);
parts[i].life = rand()%60 + 60;
}
else if (surround_space && ((r&0xFF)==PT_WOOD) && (1>rand()%20) && (abs(rx+ry)<=2) && (sim->VINE_MODE || parts[i].tmp==1) )
{
int nnx = rand()%3 -1;
int nny = rand()%3 -1;
if (x+rx+nnx>=0 && y+ry+nny>0 && x+rx+nnx<XRES && y+ry+nny<YRES && (nnx || nny))
case PT_WATR:
if (!(rand()%250))
{
if (pmap[y+ry+nny][x+rx+nnx])
continue;
np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE);
np = sim->create_part(r>>8,x+rx,y+ry,PT_PLNT);
if (np<0) continue;
parts[np].temp = parts[i].temp;
parts[np].life = 0;
}
break;
case PT_LAVA:
if (!(rand()%250))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
}
break;
case PT_SMKE:
case PT_CO2:
if (!(rand()%250))
{
sim->kill_part(r>>8);
parts[i].life = rand()%60 + 60;
}
break;
case PT_WOOD:
if (surround_space && !(rand()%20) && (abs(rx+ry)<=2) && (sim->VINE_MODE || parts[i].tmp==1))
{
int nnx = rand()%3 -1;
int nny = rand()%3 -1;
if (x+rx+nnx>=0 && y+ry+nny>0 && x+rx+nnx<XRES && y+ry+nny<YRES && (nnx || nny))
{
if (pmap[y+ry+nny][x+rx+nnx])
continue;
np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE);
if (np<0) continue;
parts[np].temp = parts[i].temp;
}
}
break;
default:
continue;
}
}
if (parts[i].life==2)
@ -123,4 +135,4 @@ int Element_PLNT::graphics(GRAPHICS_FUNC_ARGS)
}
Element_PLNT::~Element_PLNT() {}
Element_PLNT::~Element_PLNT() {}

View File

@ -48,8 +48,8 @@ Element_PLUT::Element_PLUT()
//#TPT-Directive ElementHeader Element_PLUT static int update(UPDATE_FUNC_ARGS)
int Element_PLUT::update(UPDATE_FUNC_ARGS)
{
if (1>rand()%100 && ((int)(5.0f*sim->pv[y/CELL][x/CELL]))>(rand()%1000))
{
if (!(rand()%100) && ((int)(5.0f*sim->pv[y/CELL][x/CELL]))>(rand()%1000))
{
sim->create_part(i, x, y, PT_NEUT);
}
@ -57,4 +57,4 @@ int Element_PLUT::update(UPDATE_FUNC_ARGS)
}
Element_PLUT::~Element_PLUT() {}
Element_PLUT::~Element_PLUT() {}

View File

@ -85,7 +85,7 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
else if (sparkedBy==PT_INST) prop = PPIP_TMPFLAG_TRIGGER_REVERSE << 3;
if (prop==0 || (pmap[y][x]&0xFF)!=PT_PPIP || (parts[pmap[y][x]>>8].tmp & prop))
return;
return;
coord_stack = new unsigned short[coord_stack_limit][2];
coord_stack[coord_stack_size][0] = x;
@ -103,7 +103,7 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
{
if ((pmap[y][x1-1]&0xFF)!=PT_PPIP)
{
break;
break;
}
x1--;
}
@ -112,7 +112,7 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
{
if ((pmap[y][x2+1]&0xFF)!=PT_PPIP)
{
break;
break;
}
x2++;
}

View File

@ -49,17 +49,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, t;
t = parts[i].type;
if (t == PT_QRTZ)
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = sim->pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3))
{
sim->part_change_type(i,x,y,PT_PQRT);
}
}
int r, tmp, trade, rx, ry, np;
// absorb SLTW
if (parts[i].ctype!=-1)
for (rx=-2; rx<3; rx++)
@ -69,7 +59,7 @@ int Element_PQRT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
else if ((r&0xFF)==PT_SLTW && (1>rand()%2500))
else if ((r&0xFF)==PT_SLTW && !(rand()%2500))
{
sim->kill_part(r>>8);
parts[i].ctype ++;
@ -92,15 +82,14 @@ int Element_PQRT::update(UPDATE_FUNC_ARGS)
{
parts[np].tmp = parts[i].tmp;
parts[i].ctype--;
if (5>rand()%10)
if (rand()%2)
{
parts[np].ctype=-1;//dead qrtz
}
else if (!parts[i].ctype && 1>rand()%15)
else if (!parts[i].ctype && !(rand()%15))
{
parts[i].ctype=-1;
}
break;
}
}
@ -119,7 +108,7 @@ int Element_PQRT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==t && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion
if ((r&0xFF)==PT_PQRT && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion
{
tmp = parts[i].ctype - parts[r>>8].ctype;
if (tmp ==1)
@ -165,4 +154,4 @@ int Element_PQRT::graphics(GRAPHICS_FUNC_ARGS)
}
Element_PQRT::~Element_PQRT() {}
Element_PQRT::~Element_PQRT() {}

View File

@ -71,10 +71,10 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
fe = 1;
if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (!(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) && (r&0xFF)!=PT_SPRK))
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 || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (!(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) && (r&0xFF)!=PT_SPRK))
if (!r)
continue;
}

View File

@ -69,12 +69,9 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
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)
continue;
if (!r)
{
fe = 1;
for ( nnx =0 ; nnx<80; nnx++)
{
int randomness = (count + rand()%3-1 + 4)%8;//add -1,0,or 1 to count
@ -192,4 +189,4 @@ int Element_PRTO::graphics(GRAPHICS_FUNC_ARGS)
}
Element_PRTO::~Element_PRTO() {}
Element_PRTO::~Element_PRTO() {}

View File

@ -93,75 +93,73 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF) == PT_PSTN) {
if ((r&0xFF) == PT_PSTN)
{
bool movedPiston = false;
bool foundEnd = false;
int pistonEndX, pistonEndY;
int pistonCount = 0;
int newSpace = 0;
int armCount = 0;
directionX = rx;
directionY = ry;
{
bool foundEnd = false;
int pistonEndX, pistonEndY;
int pistonCount = 0;
int newSpace = 0;
int armCount = 0;
for (nxx = 0, nyy = 0, nxi = directionX, nyi = directionY; ; nyy += nyi, nxx += nxi) {
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) {
break;
}
r = pmap[y+nyi+nyy][x+nxi+nxx];
if((r&0xFF)==PT_PSTN) {
if(parts[r>>8].ctype)
armCount++;
else if (armCount)
{
pistonEndX = x+nxi+nxx;
pistonEndY = y+nyi+nyy;
foundEnd = true;
break;
}
else
pistonCount++;
} else {
for (nxx = 0, nyy = 0, nxi = directionX, nyi = directionY; ; nyy += nyi, nxx += nxi) {
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) {
break;
}
r = pmap[y+nyi+nyy][x+nxi+nxx];
if((r&0xFF)==PT_PSTN) {
if(parts[r>>8].ctype)
armCount++;
else if (armCount)
{
pistonEndX = x+nxi+nxx;
pistonEndY = y+nyi+nyy;
foundEnd = true;
break;
}
else
pistonCount++;
} else {
pistonEndX = x+nxi+nxx;
pistonEndY = y+nyi+nyy;
foundEnd = true;
break;
}
if(foundEnd) {
if(state == PISTON_EXTEND) {
if(armCount+pistonCount > armLimit)
pistonCount = armLimit-armCount;
if(pistonCount > 0) {
newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, false);
if(newSpace) {
//Create new piston section
for(int j = 0; j < newSpace; j++) {
int nr = sim->create_part(-3, pistonEndX+(nxi*j), pistonEndY+(nyi*j), PT_PSTN);
if (nr!=-1) {
parts[nr].ctype = 1;
}
}
if(foundEnd) {
if(state == PISTON_EXTEND) {
if(armCount+pistonCount > armLimit)
pistonCount = armLimit-armCount;
if(pistonCount > 0) {
newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, false);
if(newSpace) {
//Create new piston section
for(int j = 0; j < newSpace; j++) {
int nr = sim->create_part(-3, pistonEndX+(nxi*j), pistonEndY+(nyi*j), PT_PSTN);
if (nr!=-1) {
parts[nr].ctype = 1;
}
movedPiston = true;
}
movedPiston = true;
}
} else if(state == PISTON_RETRACT) {
if(pistonCount > armCount)
pistonCount = armCount;
if(armCount) {
//Remove arm section
int lastPistonX = pistonEndX - nxi; //Go back to the very last piston arm particle
int lastPistonY = pistonEndY - nyi;
for(int j = 0; j < pistonCount; j++) {
sim->delete_part(lastPistonX+(nxi*-j), lastPistonY+(nyi*-j), 0);
}
MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true);
//newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true);
movedPiston = true;
}
} else if(state == PISTON_RETRACT) {
if(pistonCount > armCount)
pistonCount = armCount;
if(armCount) {
//Remove arm section
int lastPistonX = pistonEndX - nxi; //Go back to the very last piston arm particle
int lastPistonY = pistonEndY - nyi;
for(int j = 0; j < pistonCount; j++) {
sim->delete_part(lastPistonX+(nxi*-j), lastPistonY+(nyi*-j), 0);
}
MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true);
//newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true);
movedPiston = true;
}
}
}
if (movedPiston)
break;
}
@ -328,4 +326,4 @@ int Element_PSTN::graphics(GRAPHICS_FUNC_ARGS)
return 0;
}
Element_PSTN::~Element_PSTN() {}
Element_PSTN::~Element_PSTN() {}

View File

@ -50,9 +50,12 @@ Element_PUMP::Element_PUMP()
int Element_PUMP::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
if (parts[i].life==10)
if (parts[i].life!=10)
{
if (parts[i].life>0)
parts[i].life--;
}
else
{
if (parts[i].temp>=256.0+273.15)
parts[i].temp=256.0+273.15;

View File

@ -59,14 +59,17 @@ int Element_PVOD::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SPRK && parts[r>>8].life>0 && parts[r>>8].life<4)
if ((r&0xFF)==PT_SPRK)
{
if (parts[r>>8].ctype==PT_PSCN)
parts[i].life = 10;
else if (parts[r>>8].ctype==PT_NSCN)
parts[i].life = 9;
if (parts[r>>8].life>0 && parts[r>>8].life<4)
{
if (parts[r>>8].ctype==PT_PSCN)
parts[i].life = 10;
else if (parts[r>>8].ctype==PT_NSCN)
parts[i].life = 9;
}
}
if ((r&0xFF)==PT_PVOD)
else if ((r&0xFF)==PT_PVOD)
{
if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
parts[i].life = 9;
@ -88,4 +91,4 @@ int Element_PVOD::graphics(GRAPHICS_FUNC_ARGS)
}
Element_PVOD::~Element_PVOD() {}
Element_PVOD::~Element_PVOD() {}

View File

@ -49,16 +49,12 @@ 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, t;
t = parts[i].type;
if (t == PT_QRTZ)
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];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3))
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = sim->pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3))
{
sim->part_change_type(i,x,y,PT_PQRT);
}
sim->part_change_type(i,x,y,PT_PQRT);
}
// absorb SLTW
if (parts[i].ctype!=-1)
@ -69,7 +65,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
else if ((r&0xFF)==PT_SLTW && (1>rand()%2500))
else if ((r&0xFF)==PT_SLTW && !(rand()%2500))
{
sim->kill_part(r>>8);
parts[i].ctype ++;
@ -92,11 +88,11 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
{
parts[np].tmp = parts[i].tmp;
parts[i].ctype--;
if (5>rand()%10)
if (rand()%2)
{
parts[np].ctype=-1;//dead qrtz
}
else if (!parts[i].ctype && 1>rand()%15)
else if (!parts[i].ctype && !(rand()%15))
{
parts[i].ctype=-1;
}
@ -119,7 +115,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==t && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion
if ((r&0xFF)==PT_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion
{
tmp = parts[i].ctype - parts[r>>8].ctype;
if (tmp ==1)
@ -165,4 +161,4 @@ int Element_QRTZ::graphics(GRAPHICS_FUNC_ARGS)
}
Element_QRTZ::~Element_QRTZ() {}
Element_QRTZ::~Element_QRTZ() {}

View File

@ -52,8 +52,8 @@ int Element_REPL::update(UPDATE_FUNC_ARGS)
int r, rx, ry, ri;
for(ri = 0; ri <= 10; ri++)
{
rx = (rand()%20)-10;
ry = (rand()%20)-10;
rx = (rand()%21)-10;
ry = (rand()%21)-10;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
@ -70,4 +70,4 @@ int Element_REPL::update(UPDATE_FUNC_ARGS)
}
Element_REPL::~Element_REPL() {}
Element_REPL::~Element_REPL() {}

View File

@ -12,7 +12,7 @@ Element_RIME::Element_RIME()
Advection = 0.00f;
AirDrag = 0.00f * CFDS;
AirLoss = 0.00f;
Loss = 1.00f;
Loss = 0.00f;
Collision = 0.00f;
Gravity = 0.0f;
Diffusion = 0.00f;
@ -50,8 +50,6 @@ Element_RIME::Element_RIME()
int Element_RIME::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
parts[i].vx = 0;
parts[i].vy = 0;
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))
@ -74,4 +72,4 @@ int Element_RIME::update(UPDATE_FUNC_ARGS)
}
Element_RIME::~Element_RIME() {}
Element_RIME::~Element_RIME() {}

View File

@ -59,7 +59,7 @@ int Element_SHLD1::update(UPDATE_FUNC_ARGS)
continue;
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
{
if (55>rand()%200&&parts[i].life==0)
if (11>rand()%40)
{
sim->part_change_type(i,x,y,PT_SHLD2);
parts[i].life = 7;
@ -74,7 +74,7 @@ int Element_SHLD1::update(UPDATE_FUNC_ARGS)
}
}
}
else if ((r&0xFF)==PT_SHLD3&&4>rand()%10)
else if ((r&0xFF)==PT_SHLD3&&2>rand()%5)
{
sim->part_change_type(i,x,y,PT_SHLD2);
parts[i].life = 7;
@ -85,4 +85,4 @@ int Element_SHLD1::update(UPDATE_FUNC_ARGS)
Element_SHLD1::~Element_SHLD1() {}
Element_SHLD1::~Element_SHLD1() {}

View File

@ -55,13 +55,15 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS)
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].life>0)
sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
if (!r)
{
if ( parts[i].life>0)
sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
continue;
}
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
{
if (25>rand()%200&&parts[i].life==0)
if (!(rand()%8))
{
sim->part_change_type(i,x,y,PT_SHLD3);
parts[i].life = 7;
@ -77,7 +79,7 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS)
}
}
}
else if ((r&0xFF)==PT_SHLD4&&4>rand()%10)
else if ((r&0xFF)==PT_SHLD4&&2>rand()%5)
{
sim->part_change_type(i,x,y,PT_SHLD3);
parts[i].life = 7;
@ -88,4 +90,4 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS)
Element_SHLD2::~Element_SHLD2() {}
Element_SHLD2::~Element_SHLD2() {}

View File

@ -57,16 +57,14 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
{
if (1>rand()%2500)
if (!(rand()%2500))
{
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
sim->part_change_type(i,x,y,PT_SHLD2);
}
else
continue;
continue;
}
if ((r&0xFF)==PT_SHLD1 && parts[i].life>3)
{
@ -75,7 +73,7 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS)
}
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
{
if (18>rand()%3000&&parts[i].life==0)
if (3>rand()%500)
{
sim->part_change_type(i,x,y,PT_SHLD4);
parts[i].life = 7;
@ -98,4 +96,4 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS)
Element_SHLD3::~Element_SHLD3() {}
Element_SHLD3::~Element_SHLD3() {}

View File

@ -57,15 +57,14 @@ int Element_SHLD4::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
{
if (1>rand()%5500)
if (!(rand()%5500))
{
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
sim->part_change_type(i,x,y,PT_SHLD2);
}
else
continue;
continue;
}
if ((r&0xFF)==PT_SHLD2 && parts[i].life>3)
@ -89,4 +88,4 @@ int Element_SHLD4::update(UPDATE_FUNC_ARGS)
}
Element_SHLD4::~Element_SHLD4() {}
Element_SHLD4::~Element_SHLD4() {}

View File

@ -121,7 +121,7 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1)
if ((r&0xFF)!=PT_DMND&& !(rand()%3))
{
if ((r&0xFF)==PT_SING && parts[r>>8].life >10)
{
@ -133,7 +133,7 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
{
if (parts[i].life+3 > 255)
{
if (parts[r>>8].type!=PT_SING && 1>rand()%100)
if (parts[r>>8].type!=PT_SING && !(rand()%100))
{
int np;
np = sim->create_part(r>>8,x+rx,y+ry,PT_SING);

View File

@ -55,24 +55,37 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SALT && 1>(rand()%10000))
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
if ((r&0xFF)==PT_PLNT&&5>(rand()%1000))
sim->kill_part(r>>8);
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500))
switch (r&0xFF)
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
parts[i].ctype = PT_WATR;
}
if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){
sim->kill_part(r>>8);
if(1>(rand()%150)){
sim->kill_part(i);
return 1;
case PT_SALT:
if (!(rand()%10000))
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
break;
case PT_PLNT:
if (!(rand()%200))
sim->kill_part(r>>8);
break;
case PT_RBDM:
case PT_LRBD:
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
parts[i].ctype = PT_WATR;
}
break;
case PT_FIRE:
if (parts[r>>8].ctype!=PT_WATR)
{
sim->kill_part(r>>8);
if(!(rand()%150)){
sim->kill_part(i);
return 1;
}
}
break;
default:
continue;
}
}
return 0;

View File

@ -61,7 +61,7 @@ int Element_SNOW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && 1>(rand()%1000))
if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && !(rand()%1000))
{
sim->part_change_type(i,x,y,PT_SLTW);
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);

View File

@ -89,9 +89,7 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
if ((parts[i].ctype&6) != 6 && (parts[i].ctype&6))
{
int target;
target = i;
while((parts[target].ctype&6) != 6 && (parts[target].ctype&6))
{
if (parts[target].ctype&2)
@ -99,7 +97,6 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
target = parts[target].tmp;
sim->detach(target);
}
if (parts[target].ctype&4)
{
target = parts[target].tmp2;
@ -107,20 +104,14 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
}
}
}
if ((parts[i].ctype&6) != 6)
parts[i].ctype = 0;
if ((parts[i].ctype&6) == 6 && (parts[parts[i].tmp].ctype&6) == 6 && parts[parts[i].tmp].tmp == i)
sim->detach(i);
}
parts[i].vy -= 0.1f;
parts[i].vy *= 0.5f;
parts[i].vy = (parts[i].vy-0.1f)*0.5f;
parts[i].vx *= 0.5f;
}
if(!(parts[i].ctype&2))
{
for (rx=-2; rx<3; rx++)
@ -130,7 +121,6 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((parts[r>>8].type == PT_SOAP) && (parts[r>>8].ctype&1) && !(parts[r>>8].ctype&4))
Element_SOAP::attach(parts, i, r>>8);
}
@ -145,73 +135,59 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r && !sim->bmap[(y+ry)/CELL][(x+rx)/CELL])
continue;
if (parts[i].temp>0)
{
if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL]
|| (r && sim->elements[r&0xFF].State != ST_GAS
&& (r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS))
|| (r && sim->elements[r&0xFF].State != ST_GAS
&& (r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS))
{
sim->detach(i);
continue;
}
}
if ((r&0xFF) == PT_SOAP && parts[r>>8].ctype == 1)
if ((r&0xFF) == PT_SOAP)
{
int buf;
buf = parts[i].tmp;
parts[i].tmp = r>>8;
parts[buf].tmp2 = r>>8;
parts[r>>8].tmp2 = i;
parts[r>>8].tmp = buf;
parts[r>>8].ctype = 7;
}
if ((r&0xFF) == PT_SOAP && parts[r>>8].ctype == 7 && parts[i].tmp != r>>8 && parts[i].tmp2 != r>>8)
{
int buf;
parts[parts[i].tmp].tmp2 = parts[r>>8].tmp2;
parts[parts[r>>8].tmp2].tmp = parts[i].tmp;
parts[r>>8].tmp2 = i;
parts[i].tmp = r>>8;
if (parts[r>>8].ctype == 1)
{
int buf;
buf = parts[i].tmp;
parts[i].tmp = r>>8;
parts[buf].tmp2 = r>>8;
parts[r>>8].tmp2 = i;
parts[r>>8].tmp = buf;
parts[r>>8].ctype = 7;
}
else if (parts[r>>8].ctype == 7 && parts[i].tmp != r>>8 && parts[i].tmp2 != r>>8)
{
int buf;
parts[parts[i].tmp].tmp2 = parts[r>>8].tmp2;
parts[parts[r>>8].tmp2].tmp = parts[i].tmp;
parts[r>>8].tmp2 = i;
parts[i].tmp = r>>8;
}
}
}
}
if(parts[i].ctype&2)
{
float d, dx, dy;
dx = parts[i].x - parts[parts[i].tmp].x;
dy = parts[i].y - parts[parts[i].tmp].y;
d = 9/(pow(dx, 2)+pow(dy, 2)+9)-0.5;
parts[parts[i].tmp].vx -= dx*d;
parts[parts[i].tmp].vy -= dy*d;
parts[i].vx += dx*d;
parts[i].vy += dy*d;
if ((parts[parts[i].tmp].ctype&2) && (parts[parts[i].tmp].ctype&1)
&& (parts[parts[parts[i].tmp].tmp].ctype&2) && (parts[parts[parts[i].tmp].tmp].ctype&1))
{
int ii;
ii = parts[parts[parts[i].tmp].tmp].tmp;
dx = parts[ii].x - parts[parts[i].tmp].x;
dy = parts[ii].y - parts[parts[i].tmp].y;
d = 81/(pow(dx, 2)+pow(dy, 2)+81)-0.5;
parts[parts[i].tmp].vx -= dx*d*0.5f;
parts[parts[i].tmp].vy -= dy*d*0.5f;
parts[ii].vx += dx*d*0.5f;
parts[ii].vy += dy*d*0.5f;
}
@ -224,7 +200,6 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
parts[i].ctype = 1;
parts[i].life = 10;
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
@ -232,27 +207,18 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF) == PT_OIL)
{
float ax, ay;
parts[i].vy -= 0.1f;
parts[i].vy *= 0.5f;
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;
parts[i].vx = ax;
parts[i].vy = ay;
parts[r>>8].vx = ax;
parts[r>>8].vy = ay;
parts[i].vx = parts[r>>8].vx = ax;
parts[i].vy = parts[r>>8].vy = ay;
}
}
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
@ -267,12 +233,10 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
tg = (parts[r>>8].dcolour>>8)&0xFF;
tb = (parts[r>>8].dcolour)&0xFF;
ta = (parts[r>>8].dcolour>>24)&0xFF;
nr = (tr*blend);
ng = (tg*blend);
nb = (tb*blend);
na = (ta*blend);
parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24;
}
}

View File

@ -59,30 +59,43 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_FRZW) && parts[i].life<limit && 500>rand()%absorbChanceDenom)
switch (r&0xFF)
{
parts[i].life++;
sim->kill_part(r>>8);
}
if ((r&0xFF)==PT_SLTW && parts[i].life<limit && 50>rand()%absorbChanceDenom)
{
parts[i].life++;
if (rand()%4)
case PT_WATR:
case PT_DSTW:
case PT_FRZW:
if (parts[i].life<limit && 500>rand()%absorbChanceDenom)
{
parts[i].life++;
sim->kill_part(r>>8);
else
sim->part_change_type(r>>8, x+rx, y+ry, PT_SALT);
}
if ((r&0xFF)==PT_CBNW && parts[i].life<limit && 100>rand()%absorbChanceDenom)
{
parts[i].life++;
sim->part_change_type(r>>8, x+rx, y+ry, PT_CO2);
}
if ((r&0xFF)==PT_PSTE && parts[i].life<limit && 20>rand()%absorbChanceDenom)
{
parts[i].life++;
sim->create_part(r>>8, x+rx, y+ry, PT_CLST);
}
break;
case PT_SLTW:
if (parts[i].life<limit && 50>rand()%absorbChanceDenom)
{
parts[i].life++;
if (rand()%4)
sim->kill_part(r>>8);
else
sim->part_change_type(r>>8, x+rx, y+ry, PT_SALT);
}
break;
case PT_CBNW:
if (parts[i].life<limit && 100>rand()%absorbChanceDenom)
{
parts[i].life++;
sim->part_change_type(r>>8, x+rx, y+ry, PT_CO2);
}
break;
case PT_PSTE:
if (parts[i].life<limit && 20>rand()%absorbChanceDenom)
{
parts[i].life++;
sim->create_part(r>>8, x+rx, y+ry, PT_CLST);
}
break;
default:
continue;
}
}
}

View File

@ -78,29 +78,35 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
{
Element_NTCT::update(UPDATE_FUNC_SUBCALL_ARGS);
}
else if (ct==PT_ETRD&&parts[i].life==1)
else if (ct==PT_ETRD)
{
nearp = sim->nearest_part(i, PT_ETRD, -1);
if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL)
if (parts[i].life==1)
{
sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0);
sim->part_change_type(i,x,y,ct);
ct = parts[i].ctype = PT_NONE;
parts[i].life = 20;
sim->part_change_type(nearp,(int)(parts[nearp].x+0.5f),(int)(parts[nearp].y+0.5f),PT_SPRK);
parts[nearp].life = 9;
parts[nearp].ctype = PT_ETRD;
nearp = sim->nearest_part(i, PT_ETRD, -1);
if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL)
{
sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0);
sim->part_change_type(i,x,y,ct);
ct = parts[i].ctype = PT_NONE;
parts[i].life = 20;
sim->part_change_type(nearp,(int)(parts[nearp].x+0.5f),(int)(parts[nearp].y+0.5f),PT_SPRK);
parts[nearp].life = 9;
parts[nearp].ctype = PT_ETRD;
}
}
}
else if (ct==PT_NBLE&&parts[i].life<=1&&parts[i].tmp!=1)
else if (ct==PT_NBLE)
{
parts[i].life = rand()%150+50;
sim->part_change_type(i,x,y,PT_PLSM);
parts[i].ctype = PT_NBLE;
if (parts[i].temp > 5273.15)
parts[i].tmp |= 4;
parts[i].temp = 3500;
sim->pv[y/CELL][x/CELL] += 1;
if (parts[i].life<=1&&parts[i].tmp!=1)
{
parts[i].life = rand()%150+50;
sim->part_change_type(i,x,y,PT_PLSM);
parts[i].ctype = PT_NBLE;
if (parts[i].temp > 5273.15)
parts[i].tmp |= 4;
parts[i].temp = 3500;
sim->pv[y/CELL][x/CELL] += 1;
}
}
else if (ct==PT_TESC) // tesla coil code
{
@ -162,7 +168,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = parts[r>>8].type;
rt = r&0xFF;
conduct_sprk = 1;
@ -211,28 +217,28 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
}
if (ct==PT_NTCT && !(rt==PT_PSCN || rt==PT_NTCT || (rt==PT_NSCN&&parts[i].temp>373.0f)))
conduct_sprk = 0;
if (ct==PT_PTCT && !(rt==PT_PSCN || rt==PT_PTCT || (rt==PT_NSCN&&parts[i].temp<373.0f)))
else if (ct==PT_PTCT && !(rt==PT_PSCN || rt==PT_PTCT || (rt==PT_NSCN&&parts[i].temp<373.0f)))
conduct_sprk = 0;
if (ct==PT_INWR && !(rt==PT_NSCN || rt==PT_INWR || rt==PT_PSCN))
else if (ct==PT_INWR && !(rt==PT_NSCN || rt==PT_INWR || rt==PT_PSCN))
conduct_sprk = 0;
if (ct==PT_NSCN && rt==PT_PSCN)
else if (ct==PT_NSCN && rt==PT_PSCN)
conduct_sprk = 0;
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))
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))
conduct_sprk = 0;
if (ct==PT_INST&&rt!=PT_NSCN) conduct_sprk = 0;
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))
else if (ct==PT_INST && rt!=PT_NSCN) conduct_sprk = 0;
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))
conduct_sprk = 0;
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)))
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)))
conduct_sprk = 0;
if (rt==PT_NTCT && !(ct==PT_NSCN || ct==PT_NTCT || (ct==PT_PSCN&&parts[r>>8].temp>373.0f)))
else if (rt==PT_NTCT && !(ct==PT_NSCN || ct==PT_NTCT || (ct==PT_PSCN&&parts[r>>8].temp>373.0f)))
conduct_sprk = 0;
if (rt==PT_PTCT && !(ct==PT_NSCN || ct==PT_PTCT || (ct==PT_PSCN&&parts[r>>8].temp<373.0f)))
else if (rt==PT_PTCT && !(ct==PT_NSCN || ct==PT_PTCT || (ct==PT_PSCN&&parts[r>>8].temp<373.0f)))
conduct_sprk = 0;
if (rt==PT_INWR && !(ct==PT_NSCN || ct==PT_INWR || ct==PT_PSCN))
else if (rt==PT_INWR && !(ct==PT_NSCN || ct==PT_INWR || ct==PT_PSCN))
conduct_sprk = 0;
if (rt==PT_INST&&ct!=PT_PSCN)
else if (rt==PT_INST && ct!=PT_PSCN)
conduct_sprk = 0;
if (rt == PT_NBLE && parts[r>>8].tmp == 1)
else if (rt==PT_NBLE && parts[r>>8].tmp == 1)
conduct_sprk = 0;
if (conduct_sprk) {
@ -287,4 +293,4 @@ int Element_SPRK::graphics(GRAPHICS_FUNC_ARGS)
}
Element_SPRK::~Element_SPRK() {}
Element_SPRK::~Element_SPRK() {}

View File

@ -48,8 +48,9 @@ Element_THDR::Element_THDR()
//#TPT-Directive ElementHeader Element_THDR static int update(UPDATE_FUNC_ARGS)
int Element_THDR::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
{
int r, rx, ry, rt;
bool kill;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
@ -57,14 +58,15 @@ int Element_THDR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK)
rt = r&0xFF;
if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !(rt==PT_WATR||rt==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK)
{
parts[i].type = PT_NONE;
parts[r>>8].ctype = parts[r>>8].type;
sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
parts[r>>8].life = 4;
kill = true;
}
else if ((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_SPRK&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT&&(r&0xFF))
else if (rt!=PT_CLNE&&rt!=PT_THDR&&rt!=PT_SPRK&&rt!=PT_DMND&&rt!=PT_FIRE)
{
sim->pv[y/CELL][x/CELL] += 100.0f;
if (sim->legacy_enable&&1>(rand()%200))
@ -73,12 +75,10 @@ int Element_THDR::update(UPDATE_FUNC_ARGS)
sim->part_change_type(i,x,y,PT_FIRE);
}
else
{
parts[i].type = PT_NONE;
}
kill=true;
}
}
if (parts[i].type==PT_NONE) {
if (kill) {
sim->kill_part(i);
return 1;
}

View File

@ -59,7 +59,7 @@ int Element_THRM::update(UPDATE_FUNC_ARGS)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)) // TODO: could this go in update_PYRO?
{
if (1>(rand()%500)) {
if (!(rand()%500)) {
sim->part_change_type(i,x,y,PT_LAVA);
parts[i].ctype = PT_BMTL;
parts[i].temp = 3500.0f;
@ -77,4 +77,4 @@ int Element_THRM::update(UPDATE_FUNC_ARGS)
}
Element_THRM::~Element_THRM() {}
Element_THRM::~Element_THRM() {}

View File

@ -91,7 +91,6 @@ void Element_TRON::init_graphics()
//#TPT-Directive ElementHeader Element_TRON static int update(UPDATE_FUNC_ARGS)
int Element_TRON::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, np;
if (parts[i].tmp&TRON_WAIT)
{
parts[i].tmp &= ~TRON_WAIT;

View File

@ -61,7 +61,7 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = parts[r>>8].type;
rt = r&0xFF;
if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL)
{
if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0)
@ -82,7 +82,7 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx];
if(!r)
continue;
if (parts[r>>8].temp > parts[i].temp && parts[r>>8].type != PT_TSNS && parts[r>>8].type != PT_METL)
if ((r&0xFF)!=PT_TSNS && (r&0xFF)!=PT_METL && parts[r>>8].temp > parts[i].temp)
parts[i].life = 1;
}
return 0;

View File

@ -50,15 +50,7 @@ Element_VIBR::Element_VIBR()
int Element_VIBR::update(UPDATE_FUNC_ARGS) {
int r, rx, ry;
int trade, transfer;
if (parts[i].ctype == 1) //leaving in, just because
{
if (sim->pv[y/CELL][x/CELL] > -2.5 || parts[i].tmp)
{
parts[i].ctype = 0;
sim->part_change_type(i, x, y, PT_VIBR);
}
}
else if (!parts[i].life) //if not exploding
if (!parts[i].life) //if not exploding
{
//Heat absorption code
if (parts[i].temp > 274.65f)
@ -158,12 +150,12 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
sim->part_change_type(i,x,y,PT_BVBR);
sim->pv[y/CELL][x/CELL] -= 1;
}
else if (parts[i].life && ((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR) && !parts[r>>8].life)
else if (((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR) && parts[i].life && !parts[r>>8].life)
{
parts[r>>8].tmp += 10;
}
//Absorbs energy particles
if ((sim->elements[r&0xFF].Properties & TYPE_ENERGY) && !parts[i].life)
else if ((sim->elements[r&0xFF].Properties & TYPE_ENERGY) && !parts[i].life)
{
parts[i].tmp += 20;
sim->kill_part(r>>8);

View File

@ -48,19 +48,19 @@ Element_VINE::Element_VINE()
//#TPT-Directive ElementHeader Element_VINE static int update(UPDATE_FUNC_ARGS)
int Element_VINE::update(UPDATE_FUNC_ARGS)
{
{
int r, np, 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 (1>rand()%15)
if (!(rand()%15))
sim->part_change_type(i,x,y,PT_PLNT);
else if (!r)
{
np = sim->create_part(-1,x+rx,y+ry,PT_VINE);
if (np<0) return 0;
parts[np].temp = parts[i].temp;
parts[i].tmp = 1;
parts[i].tmp = 1;
sim->part_change_type(i,x,y,PT_PLNT);
}
}
@ -88,4 +88,4 @@ int Element_VINE::graphics(GRAPHICS_FUNC_ARGS)
}
Element_VINE::~Element_VINE() {}
Element_VINE::~Element_VINE() {}

View File

@ -54,7 +54,7 @@ int Element_WARP::update(UPDATE_FUNC_ARGS)
{
parts[i].temp = 10000;
sim->pv[y/CELL][x/CELL] += (parts[i].tmp2/5000) * CFDS;
if (2>rand()%100)
if (!(rand()%50))
sim->create_part(-3, x, y, PT_ELEC);
}
for ( trade = 0; trade<5; trade ++)

View File

@ -57,22 +57,22 @@ int Element_WATR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SALT && 1>(rand()%250))
if ((r&0xFF)==PT_SALT && !(rand()%250))
{
sim->part_change_type(i,x,y,PT_SLTW);
// on average, convert 3 WATR to SLTW before SALT turns into SLTW
if (rand()%3==0)
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
if (!(rand()%3))
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
}
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500))
else if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
parts[i].ctype = PT_WATR;
}
if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){
else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){
sim->kill_part(r>>8);
if(1>(rand()%150)){
if(!(rand()%150)){
sim->kill_part(i);
return 1;
}

View File

@ -48,46 +48,47 @@ Element_WIRE::Element_WIRE()
//#TPT-Directive ElementHeader Element_WIRE static int update(UPDATE_FUNC_ARGS)
int Element_WIRE::update(UPDATE_FUNC_ARGS)
{
int s,r,rx,ry,count;
/*
0: wire
1: spark head
2: spark tail
{
int s,r,rx,ry,count;
/*
0: wire
1: spark head
2: spark tail
tmp is previous state, ctype is current state
*/
//parts[i].tmp=parts[i].ctype;
parts[i].ctype=0;
if(parts[i].tmp==1)
tmp is previous state, ctype is current state
*/
//parts[i].tmp=parts[i].ctype;
parts[i].ctype=0;
if (parts[i].tmp==1)
{
parts[i].ctype=2;
}
if(parts[i].tmp==2)
else if (parts[i].tmp==2)
{
parts[i].ctype=0;
}
count=0;
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))
{
r = pmap[y+ry][x+rx];
count=0;
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))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if((r&0xFF)==PT_SPRK && parts[r>>8].life==3 && parts[r>>8].ctype==PT_PSCN)
if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3 && parts[r>>8].ctype==PT_PSCN)
{
parts[i].ctype=1;
return 0;
}
else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){sim->create_part(-1, x+rx, y+ry, PT_SPRK);}
else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;}
}
}
if(count==1 || count==2)
parts[i].ctype=1;
else if ((r&0xFF)==PT_NSCN && parts[i].tmp==1)
sim->create_part(-1, x+rx, y+ry, PT_SPRK);
else if ((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp)
count++;
}
}
if (count==1 || count==2)
parts[i].ctype=1;
return 0;
}
@ -124,4 +125,4 @@ int Element_WIRE::graphics(GRAPHICS_FUNC_ARGS)
}
Element_WIRE::~Element_WIRE() {}
Element_WIRE::~Element_WIRE() {}

View File

@ -57,7 +57,7 @@ int Element_WTRV::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500))
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && !(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
@ -70,4 +70,4 @@ int Element_WTRV::update(UPDATE_FUNC_ARGS)
}
Element_WTRV::~Element_WTRV() {}
Element_WTRV::~Element_WTRV() {}

View File

@ -57,7 +57,7 @@ int Element_YEST::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_DYST && 1>(rand()%30) && !sim->legacy_enable)
if ((r&0xFF)==PT_DYST && !(rand()%30) && !sim->legacy_enable)
{
sim->part_change_type(i,x,y,PT_DYST);
}
@ -69,4 +69,4 @@ int Element_YEST::update(UPDATE_FUNC_ARGS)
}
Element_YEST::~Element_YEST() {}
Element_YEST::~Element_YEST() {}