Going through again.

This commit is contained in:
cracker64 2013-02-28 12:37:16 -05:00
parent c65081d3ed
commit 5873d69586
15 changed files with 151 additions and 140 deletions

View File

@ -58,8 +58,7 @@ int Element_AMTR::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = r&0xFF;
//would a table lookup be faster than 11 checks? if (rt!=PT_AMTR && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_VOID && rt!=PT_BHOL && rt!=PT_NBHL && rt!=PT_PRTI && rt!=PT_PRTO)
if (rt!=PT_AMTR && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_NONE && rt!=PT_PHOT && rt!=PT_VOID && rt!=PT_BHOL && rt!=PT_NBHL && rt!=PT_PRTI && rt!=PT_PRTO)
{ {
parts[i].life++; parts[i].life++;
if (parts[i].life==4) if (parts[i].life==4)
@ -67,7 +66,7 @@ int Element_AMTR::update(UPDATE_FUNC_ARGS)
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;
} }
if (10>(rand()/(RAND_MAX/100))) if (!(rand()%10))
sim->create_part(r>>8, x+rx, y+ry, PT_PHOT); sim->create_part(r>>8, x+rx, y+ry, PT_PHOT);
else else
sim->kill_part(r>>8); sim->kill_part(r>>8);

View File

@ -60,15 +60,12 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_HFLM) if ((r&0xFF)==PT_HFLM && !(rand()%22))
{ {
if (1>rand()%22) sim->part_change_type(i,x,y,PT_HFLM);
{ parts[i].life = rand()%150+50;
sim->part_change_type(i,x,y,PT_HFLM); parts[r>>8].temp = parts[i].temp = 0;
parts[i].life = rand()%150+50; sim->pv[y/CELL][x/CELL] -= 0.5;
parts[r>>8].temp = parts[i].temp = 0;
sim->pv[y/CELL][x/CELL] -= 0.5;
}
} }
} }
return 0; return 0;

View File

@ -78,17 +78,20 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS)
parts[nr].temp = parts[i].temp; parts[nr].temp = parts[i].temp;
} }
} else if (!destroy) { } else if (!destroy) {
if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==0) {//if it hits another BRAY that isn't red if ((r&0xFF)==PT_BRAY) {
if (nyy!=0 || nxx!=0) { if (parts[r>>8].tmp==0){//if it hits another BRAY that isn't red
parts[r>>8].life = 1020;//makes it last a while if (nyy!=0 || nxx!=0) {
parts[r>>8].tmp = 1; parts[r>>8].life = 1020;//makes it last a while
if (!parts[r>>8].ctype)//and colors it if it isn't already parts[r>>8].tmp = 1;
parts[r>>8].ctype = colored; if (!parts[r>>8].ctype)//and colors it if it isn't already
parts[r>>8].ctype = colored;
}
docontinue = 0;//then stop it
}
else if (parts[r>>8].tmp==1) {//if it hits one that already was a long life, reset it
parts[r>>8].life = 1020;
//docontinue = 1;
} }
docontinue = 0;//then stop it
} else if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==1) {//if it hits one that already was a long life, reset it
parts[r>>8].life = 1020;
//docontinue = 1;
} else if ((r&0xFF)==PT_FILT) {//get color if passed through FILT } else if ((r&0xFF)==PT_FILT) {//get color if passed through FILT
colored = parts[r>>8].ctype; colored = parts[r>>8].ctype;
//this if prevents BRAY from stopping on certain materials //this if prevents BRAY from stopping on certain materials

View File

@ -65,15 +65,15 @@ int Element_BCOL::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM))
{ {
if (parts[i].life>100) { if (parts[i].life>100 && !(rand()%500)) {
parts[i].life = 99; parts[i].life = 99;
} }
} }
if ((r&0xFF)==PT_LAVA && 1>(rand()%500)) else if ((r&0xFF)==PT_LAVA)
{ {
if (parts[r>>8].ctype == PT_IRON) { if (parts[r>>8].ctype == PT_IRON && !(rand()%500)) {
parts[r>>8].ctype = PT_METL; parts[r>>8].ctype = PT_METL;
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;

View File

@ -82,7 +82,7 @@ int Element_BIZR::update(UPDATE_FUNC_ARGS)
} }
} }
} }
if(((r = sim->photons[y][x])&0xFF)==PT_PHOT) if(((r = sim->photons[y][x])&0xFF)==PT_PHOT)//this should be in movement checks?
{ {
sim->part_change_type(r>>8, x, y, PT_ELEC); sim->part_change_type(r>>8, x, y, PT_ELEC);
parts[r>>8].ctype = 0; parts[r>>8].ctype = 0;

View File

@ -60,14 +60,14 @@ int Element_BMTL::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if (((r&0xFF)==PT_METL || (r&0xFF)==PT_IRON) && 1>(rand()/(RAND_MAX/100))) if (((r&0xFF)==PT_METL || (r&0xFF)==PT_IRON) && !(rand()%100))
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_BMTL); sim->part_change_type(r>>8,x+rx,y+ry,PT_BMTL);
parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
} }
} }
} }
else if (parts[i].tmp==1 && 1>rand()%1000) else if (parts[i].tmp==1 && !(rand()%1000))
{ {
parts[i].tmp = 0; parts[i].tmp = 0;
sim->part_change_type(i,x,y,PT_BRMT); sim->part_change_type(i,x,y,PT_BRMT);

View File

@ -76,15 +76,19 @@ int Element_BOYL::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_WATR && 1>rand()%30) if ((r&0xFF)==PT_WATR)
{ {
sim->part_change_type(r>>8,x+rx,y+ry,PT_FOG); if (!(rand()%30))
sim->part_change_type(r>>8,x+rx,y+ry,PT_FOG);
} }
else if ((r&0xFF)==PT_O2 && 1>rand()%9) else if ((r&0xFF)==PT_O2)
{ {
sim->kill_part(r>>8); if (!(rand()%9))
sim->part_change_type(i,x,y,PT_WATR); {
sim->pv[y/CELL][x/CELL] += 4.0; sim->kill_part(r>>8);
sim->part_change_type(i,x,y,PT_WATR);
sim->pv[y/CELL][x/CELL] += 4.0;
}
} }
} }
return 0; return 0;

View File

@ -54,12 +54,12 @@ int Element_BREC::update(UPDATE_FUNC_ARGS)
{ {
if (sim->pv[y/CELL][x/CELL]>10.0f) if (sim->pv[y/CELL][x/CELL]>10.0f)
{ {
if (parts[i].temp>9000 && sim->pv[y/CELL][x/CELL]>30.0f && 1>rand()%200) if (parts[i].temp>9000 && sim->pv[y/CELL][x/CELL]>30.0f && !(rand()%200))
{ {
sim->part_change_type(i, x ,y ,PT_EXOT); sim->part_change_type(i, x ,y ,PT_EXOT);
parts[i].life = 1000; parts[i].life = 1000;
} }
parts[i].temp = parts[i].temp + (sim->pv[y/CELL][x/CELL])/8; parts[i].temp += (sim->pv[y/CELL][x/CELL])/8;
} }
} }

View File

@ -62,7 +62,7 @@ int Element_BRMT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_BREC && 1>(rand()%tempFactor)) if ((r&0xFF)==PT_BREC && !(rand()%tempFactor))
{ {
if(rand()%2) if(rand()%2)
{ {

View File

@ -59,7 +59,7 @@ int Element_C5::update(UPDATE_FUNC_ARGS)
continue; continue;
if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100 && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10)) || (r&0xFF)==PT_HFLM) if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100 && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10)) || (r&0xFF)==PT_HFLM)
{ {
if (1>rand()%6) if (!(rand()%6))
{ {
sim->part_change_type(i,x,y,PT_HFLM); sim->part_change_type(i,x,y,PT_HFLM);
parts[r>>8].temp = parts[i].temp = 0; parts[r>>8].temp = parts[i].temp = 0;

View File

@ -48,91 +48,93 @@ Element_CBNW::Element_CBNW()
//#TPT-Directive ElementHeader Element_CBNW static int update(UPDATE_FUNC_ARGS) //#TPT-Directive ElementHeader Element_CBNW static int update(UPDATE_FUNC_ARGS)
int Element_CBNW::update(UPDATE_FUNC_ARGS) int Element_CBNW::update(UPDATE_FUNC_ARGS)
{ {
int r, rx, ry; int r, rx, ry;
if (sim->pv[y/CELL][x/CELL]<=3) if (sim->pv[y/CELL][x/CELL]<=3)
{ {
if(sim->pv[y/CELL][x/CELL]<=-0.5) if(sim->pv[y/CELL][x/CELL]<=-0.5)
{ {
sim->part_change_type(i,x,y,PT_CO2); sim->part_change_type(i,x,y,PT_CO2);
parts[i].ctype = 5; parts[i].ctype = 5;
sim->pv[y/CELL][x/CELL] += 0.5f; sim->pv[y/CELL][x/CELL] += 0.5f;
} }
else if(1>(rand()%4000)) else if(!(rand()%4000))
{ {
sim->part_change_type(i,x,y,PT_CO2); sim->part_change_type(i,x,y,PT_CO2);
parts[i].ctype = 5; parts[i].ctype = 5;
sim->pv[y/CELL][x/CELL] += 0.5f; sim->pv[y/CELL][x/CELL] += 0.5f;
} }
} }
if (parts[i].tmp2!=20) { if (parts[i].tmp2!=20) {
parts[i].tmp2 -= (parts[i].tmp2>20)?1:-1; parts[i].tmp2 -= (parts[i].tmp2>20)?1:-1;
} }
else if(!(rand()%200)) else if(!(rand()%200))
{ {
parts[i].tmp2 = rand()%40; parts[i].tmp2 = rand()%40;
} }
if(parts[i].tmp>0) if(parts[i].tmp>0)
{ {
//Explode //Explode
if(parts[i].tmp==1 && rand()%4) if(parts[i].tmp==1 && rand()%4)
{ {
sim->part_change_type(i,x,y,PT_CO2); sim->part_change_type(i,x,y,PT_CO2);
parts[i].ctype = 5; parts[i].ctype = 5;
sim->pv[y/CELL][x/CELL] += 0.2f; sim->pv[y/CELL][x/CELL] += 0.2f;
} }
parts[i].tmp--; parts[i].tmp--;
} }
for (rx=-2; rx<3; rx++) for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++) for (ry=-2; ry<3; 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 && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((sim->elements[r&0xFF].Properties&TYPE_PART) && parts[i].tmp == 0 && 1>(rand()%250)) if ((sim->elements[r&0xFF].Properties&TYPE_PART) && parts[i].tmp == 0 && !(rand()%250))
{ {
//Start explode //Start explode
parts[i].tmp = rand()%25;//(rand()%100)+50; parts[i].tmp = rand()%25;//(rand()%100)+50;
} }
else if((r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && (sim->elements[r&0xFF].Properties&TYPE_SOLID) && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%40000)) else if((sim->elements[r&0xFF].Properties&TYPE_SOLID) && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%40000))
{ {
sim->part_change_type(i,x,y,PT_CO2); sim->part_change_type(i,x,y,PT_CO2);
parts[i].ctype = 5; parts[i].ctype = 5;
sim->pv[y/CELL][x/CELL] += 0.2f; sim->pv[y/CELL][x/CELL] += 0.2f;
}
} if ((r&0xFF)==PT_CBNW)
if ((r&0xFF)==PT_CBNW) {
{ if(!parts[i].tmp && parts[r>>8].tmp)
if(!parts[i].tmp && parts[r>>8].tmp) {
{ parts[i].tmp = parts[r>>8].tmp;
parts[i].tmp = parts[r>>8].tmp; if((r>>8)>i) //If the other particle hasn't been life updated
if((r>>8)>i) //If the other particle hasn't been life updated parts[i].tmp--;
parts[i].tmp--; }
} else if(parts[i].tmp && !parts[r>>8].tmp)
else if(parts[i].tmp && !parts[r>>8].tmp) {
{ parts[r>>8].tmp = parts[i].tmp;
parts[r>>8].tmp = parts[i].tmp; if((r>>8)>i) //If the other particle hasn't been life updated
if((r>>8)>i) //If the other particle hasn't been life updated parts[r>>8].tmp++;
parts[r>>8].tmp++; }
} }
} else if ((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD)
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500)) {
{ 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; sim->part_change_type(i,x,y,PT_FIRE);
parts[i].ctype = PT_WATR; 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)){ else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){
sim->kill_part(i); sim->kill_part(r>>8);
return 1; if(1>(rand()%150)){
} sim->kill_part(i);
} return 1;
} }
return 0; }
}
return 0;
} }

View File

@ -58,23 +58,26 @@ int Element_CLST::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_WATR && 1>(rand()%1500)) if ((r&0xFF)==PT_WATR)
{ {
sim->part_change_type(i,x,y,PT_PSTS); if (!(rand()%1500))
sim->kill_part(r>>8); {
sim->part_change_type(i,x,y,PT_PSTS);
sim->kill_part(r>>8);
}
} }
if ((r&0xFF)==PT_NITR) else if ((r&0xFF)==PT_NITR)
{ {
sim->create_part(i, x, y, PT_BANG); sim->create_part(i, x, y, PT_BANG);
sim->create_part(r>>8, x+rx, y+ry, PT_BANG); sim->create_part(r>>8, x+rx, y+ry, PT_BANG);
} }
if ((r&0xFF)==PT_CLST) else if ((r&0xFF)==PT_CLST)
{ {
if(parts[i].temp <195) if(parts[i].temp <195)
cxy = 0.05; cxy = 0.05;
else if(parts[i].temp >= 195 && parts[i].temp <295) else if(parts[i].temp <295)
cxy = 0.015; cxy = 0.015;
else if(parts[i].temp >= 295 && parts[i].temp <350) else if(parts[i].temp <350)
cxy = 0.01; cxy = 0.01;
else else
cxy = 0.005; cxy = 0.005;

View File

@ -64,11 +64,14 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
return 1; return 1;
} }
} }
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%250)) else if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%250))
{ {
sim->part_change_type(r>>8, x+rx, y+ry, PT_CBNW); sim->part_change_type(r>>8, x+rx, y+ry, PT_CBNW);
if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet
{
sim->create_part(i, x, y, PT_WATR); sim->create_part(i, x, y, PT_WATR);
return 0;
}
else else
{ {
sim->kill_part(i); sim->kill_part(i);

View File

@ -72,15 +72,15 @@ int Element_COAL::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM))
{ {
if (parts[i].life>100) { if (parts[i].life>100 && !(rand()%500)) {
parts[i].life = 99; parts[i].life = 99;
} }
} }
if ((r&0xFF)==PT_LAVA && 1>(rand()%500)) else if ((r&0xFF)==PT_LAVA)
{ {
if (parts[r>>8].ctype == PT_IRON) { if (parts[r>>8].ctype == PT_IRON && !(rand()%500)) {
parts[r>>8].ctype = PT_METL; parts[r>>8].ctype = PT_METL;
sim->kill_part(i); sim->kill_part(i);
return 1; return 1;

View File

@ -57,7 +57,7 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
{ {
if ( parts[i].life>0) if (parts[i].life>0)
sim->create_part(-1,x+rx,y+ry,PT_SHLD1); sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
continue; continue;
} }