diff options
| author | chaos.powdertoy.co.uk <admin@powdertoy.co.uk> | 2012-03-15 02:14:17 (GMT) |
|---|---|---|
| committer | chaos.powdertoy.co.uk <admin@powdertoy.co.uk> | 2012-03-15 02:14:17 (GMT) |
| commit | 6254d4064dff390ce92c1803cdf9d9fb58a62e79 (patch) | |
| tree | c95626a1f5ea562d7a4dc5c58a02b0db3c902043 /src/elements | |
| parent | 4fc0f750221a33a9ac922022ee58ccda6bbe3440 (diff) | |
| parent | 7a454d4d729a5715a7c1e71dfbaf303471bf8d1f (diff) | |
| download | powder-6254d4064dff390ce92c1803cdf9d9fb58a62e79.zip powder-6254d4064dff390ce92c1803cdf9d9fb58a62e79.tar.gz | |
Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/aray.c | 5 | ||||
| -rw-r--r-- | src/elements/co2.c | 15 | ||||
| -rw-r--r-- | src/elements/elec.c | 2 | ||||
| -rw-r--r-- | src/elements/figh.c | 42 | ||||
| -rw-r--r-- | src/elements/h2.c | 56 | ||||
| -rw-r--r-- | src/elements/nble.c | 26 | ||||
| -rw-r--r-- | src/elements/newgraphics.c | 3 | ||||
| -rw-r--r-- | src/elements/prti.c | 7 | ||||
| -rw-r--r-- | src/elements/prto.c | 34 | ||||
| -rw-r--r-- | src/elements/pyro.c | 1 | ||||
| -rw-r--r-- | src/elements/sprk.c | 10 | ||||
| -rw-r--r-- | src/elements/stkm.c | 7 |
12 files changed, 160 insertions, 48 deletions
diff --git a/src/elements/aray.c b/src/elements/aray.c index c1a1bf4..32f1124 100644 --- a/src/elements/aray.c +++ b/src/elements/aray.c @@ -44,12 +44,11 @@ int update_ARAY(UPDATE_FUNC_ARGS) { } else if ((r&0xFF)==PT_FILT) {//get color if passed through FILT colored = parts[r>>8].ctype; //this if prevents BRAY from stopping on certain materials - } else if ((r&0xFF)!=PT_STOR && (r&0xFF)!=PT_INWR && (r&0xFF)!=PT_ARAY && (r&0xFF)!=PT_WIFI && !((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) { + } else if ((r&0xFF)!=PT_STOR && (r&0xFF)!=PT_INWR && ((r&0xFF)!=PT_SPRK || parts[r>>8].ctype!=PT_INWR) && (r&0xFF)!=PT_ARAY && (r&0xFF)!=PT_WIFI && !((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) { if (nyy!=0 || nxx!=0) { create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK); } - //if (!(nostop && (ptypes[r&0xFF].properties&PROP_CONDUCTS))) { - if (!(nostop && parts[r>>8].ctype >= 0 && parts[r>>8].ctype < PT_NUM && (ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))) { + if (!(nostop && parts[r>>8].type==PT_SPRK && parts[r>>8].ctype >= 0 && parts[r>>8].ctype < PT_NUM && (ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))) { docontinue = 0; } else { docontinue = 1; diff --git a/src/elements/co2.c b/src/elements/co2.c index f820425..3356397 100644 --- a/src/elements/co2.c +++ b/src/elements/co2.c @@ -27,5 +27,20 @@ int update_CO2(UPDATE_FUNC_ARGS) { kill_part(r>>8); } } + if (parts[i].temp > 9773.15 && pv[y/CELL][x/CELL] > 200.0f) + { + if (rand()%5 < 1) + { + int j; + kill_part(i); + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = 15000; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = 15000; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_O2); if (j != -1) parts[j].temp = 15000; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_SING); if (j != -1) { parts[j].temp = 15000; parts[i].life = rand()%100+450; } + + parts[i].temp += 15000; + pv[y/CELL][x/CELL] += 100; + } + } return 0; } diff --git a/src/elements/elec.c b/src/elements/elec.c index 6acbbab..a5c254f 100644 --- a/src/elements/elec.c +++ b/src/elements/elec.c @@ -79,7 +79,7 @@ int update_ELEC(UPDATE_FUNC_ARGS) { kill_part(i); return 1; } - if (ptypes[r&0xFF].properties & PROP_CONDUCTS) + if (ptypes[r&0xFF].properties & PROP_CONDUCTS && ((r&0xFF)!=PT_H2||parts[i].tmp!=1)) { create_part(-1, x+rx, y+ry, PT_SPRK); kill_part(i); diff --git a/src/elements/figh.c b/src/elements/figh.c index 284a56c..928923f 100644 --- a/src/elements/figh.c +++ b/src/elements/figh.c @@ -4,41 +4,41 @@ int update_FIGH(UPDATE_FUNC_ARGS) { playerst* figh = &fighters[(unsigned char)parts[i].tmp]; - float tarx, tary; + unsigned int tarx, tary; parts[i].tmp2 = 0; //0 - stay in place, 1 - seek a stick man //Set target cords - if (player.spwn) + if (player.spwn && player2.spwn) { - if (player2.spwn) if ((pow(player.legs[2]-x, 2) + pow(player.legs[3]-y, 2))<= (pow(player2.legs[2]-x, 2) + pow(player2.legs[3]-y, 2))) { - tarx = player.legs[2]; - tary = player.legs[3]; + tarx = (unsigned int)player.legs[2]; + tary = (unsigned int)player.legs[3]; } else { - tarx = player2.legs[2]; - tary = player2.legs[3]; + tarx = (unsigned int)player2.legs[2]; + tary = (unsigned int)player2.legs[3]; } - else - { - tarx = player.legs[2]; - tary = player.legs[3]; - } - - parts[i].tmp2 = 1; + parts[i].tmp2 = 1; } else + { + if (player.spwn) + { + tarx = (unsigned int)player.legs[2]; + tary = (unsigned int)player.legs[3]; + parts[i].tmp2 = 1; + } if (player2.spwn) { - tarx = player2.legs[2]; - tary = player2.legs[3]; - + tarx = (unsigned int)player2.legs[2]; + tary = (unsigned int)player2.legs[3]; parts[i].tmp2 = 1; } + } switch (parts[i].tmp2) { @@ -51,9 +51,10 @@ int update_FIGH(UPDATE_FUNC_ARGS) figh->comm = (int)figh->comm | 0x08; } else - if (tarx<x ) + if (tarx<x) { - if(!eval_move(PT_DUST, figh->legs[4]-10, figh->legs[5]+6, NULL)) + if(!(eval_move(PT_DUST, figh->legs[4]-10, figh->legs[5]+6, NULL) + && eval_move(PT_DUST, figh->legs[4]-10, figh->legs[5]+3, NULL))) figh->comm = 0x01; else figh->comm = 0x02; @@ -65,7 +66,8 @@ int update_FIGH(UPDATE_FUNC_ARGS) } else { - if (!eval_move(PT_DUST, figh->legs[12]+10, figh->legs[13]+6, NULL)) + if (!(eval_move(PT_DUST, figh->legs[12]+10, figh->legs[13]+6, NULL) + && eval_move(PT_DUST, figh->legs[12]+10, figh->legs[13]+3, NULL))) figh->comm = 0x02; else figh->comm = 0x01; diff --git a/src/elements/h2.c b/src/elements/h2.c index c601108..e80f04a 100644 --- a/src/elements/h2.c +++ b/src/elements/h2.c @@ -3,6 +3,8 @@ int update_H2(UPDATE_FUNC_ARGS) { int r,rx,ry,rt; + if (parts[i].temp > 2273.15 && pv[y/CELL][x/CELL] > 50.0f) + parts[i].tmp = 1; 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)) @@ -16,19 +18,51 @@ int update_H2(UPDATE_FUNC_ARGS) part_change_type(r>>8,x+rx,y+ry,PT_WATR); part_change_type(i,x,y,PT_OIL); } - if ((r&0xFF)==PT_FIRE) - { - parts[r>>8].temp=2473.15; - if(parts[r>>8].tmp&0x02) - parts[r>>8].temp=3473; - parts[r>>8].tmp |= 1; - } - if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA) + if (parts[r>>8].temp > 2273.15)// && pv[y/CELL][x/CELL] > 50.0f) + continue; + if (parts[i].tmp != 1) { - create_part(i,x,y,PT_FIRE); - parts[i].temp+=(rand()/(RAND_MAX/100)); - parts[i].tmp |= 1; + if (rt==PT_FIRE) + { + parts[r>>8].temp=2473.15; + if(parts[r>>8].tmp&0x02) + parts[r>>8].temp=3473; + parts[r>>8].tmp |= 1; + } + if (rt==PT_FIRE || rt==PT_PLSM || rt==PT_LAVA) + { + create_part(i,x,y,PT_FIRE); + parts[i].temp+=(rand()/(RAND_MAX/100)); + parts[i].tmp |= 1; + } } } + if (parts[i].temp > 2273.15 && pv[y/CELL][x/CELL] > 50.0f) + { + parts[i].tmp = 1; + if (rand()%5 < 1) + { + int j; + float temp = parts[i].temp; + part_change_type(i,x,y,PT_PLSM); + parts[i].life = rand()%150+50; + create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); + create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); + if (j != -1) { parts[j].ctype = 0xFFFF00; parts[j].temp = temp; } + + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NBLE); + if (j != -1) { parts[j].tmp = 1; parts[j].temp = temp; } + + if (rand()%2) + { + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NBLE); + if (j != -1) { parts[j].tmp = 1; parts[j].temp = temp; } + } + + parts[i].temp += 6000; + pv[y/CELL][x/CELL] += 30; + } + } return 0; } diff --git a/src/elements/nble.c b/src/elements/nble.c new file mode 100644 index 0000000..43264b4 --- /dev/null +++ b/src/elements/nble.c @@ -0,0 +1,26 @@ +#include <element.h> + +int update_NBLE(UPDATE_FUNC_ARGS) +{ + if (parts[i].temp > 5273.15 && pv[y/CELL][x/CELL] > 100.0f) + { + if (rand()%5 < 1) + { + int j; + float temp = parts[i].temp; + part_change_type(i,x,y,PT_PLSM); + parts[i].life = rand()%150+50; + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); + if (j != -1) { parts[j].ctype = 0xFF0000; parts[j].temp = temp; } + + j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_CO2); + if (j != -1) parts[j].temp = temp - 1000; + + parts[i].temp += 10000; + pv[y/CELL][x/CELL] += 30; + } + } + return 0; +} diff --git a/src/elements/newgraphics.c b/src/elements/newgraphics.c index 8957df9..4c9225c 100644 --- a/src/elements/newgraphics.c +++ b/src/elements/newgraphics.c @@ -164,6 +164,7 @@ int graphics_WIFI(GRAPHICS_FUNC_ARGS) *colr = sin(frequency*q + 0) * 127 + 128; *colg = sin(frequency*q + 2) * 127 + 128; *colb = sin(frequency*q + 4) * 127 + 128; + *pixel_mode |= EFFECT_LINES; return 0; } int graphics_PRTI(GRAPHICS_FUNC_ARGS) @@ -173,6 +174,7 @@ int graphics_PRTI(GRAPHICS_FUNC_ARGS) *fireg = 0; *fireb = 0; *pixel_mode |= EFFECT_GRAVIN; + *pixel_mode |= EFFECT_LINES; *pixel_mode &= ~PMODE; *pixel_mode |= PMODE_ADD; return 1; @@ -184,6 +186,7 @@ int graphics_PRTO(GRAPHICS_FUNC_ARGS) *fireg = 0; *fireb = 255; *pixel_mode |= EFFECT_GRAVOUT; + *pixel_mode |= EFFECT_LINES; *pixel_mode &= ~PMODE; *pixel_mode |= PMODE_ADD; return 1; diff --git a/src/elements/prti.c b/src/elements/prti.c index 57830ab..8b15598 100644 --- a/src/elements/prti.c +++ b/src/elements/prti.c @@ -31,6 +31,9 @@ int update_PRTI(UPDATE_FUNC_ARGS) { 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) detach(r>>8); @@ -52,8 +55,8 @@ int update_PRTI(UPDATE_FUNC_ARGS) { if (fe) { int orbd[4] = {0, 0, 0, 0}; //Orbital distances int orbl[4] = {0, 0, 0, 0}; //Orbital locations - if (!parts[i].life) parts[i].life = rand(); - if (!parts[i].ctype) parts[i].ctype = rand(); + if (!parts[i].life) parts[i].life = rand()*rand()*rand(); + if (!parts[i].ctype) parts[i].ctype = rand()*rand()*rand(); orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); for (r = 0; r < 4; r++) { if (orbd[r]>1) { diff --git a/src/elements/prto.c b/src/elements/prto.c index dcbc53c..1dd00d4 100644 --- a/src/elements/prto.c +++ b/src/elements/prto.c @@ -47,8 +47,31 @@ int update_PRTO(UPDATE_FUNC_ARGS) { player.spwn = 0; if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2) player2.spwn = 0; + if (portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH) + { + fighcount--; + fighters[(unsigned char)portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 0; + } np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness][nnx].type); - if (np<0) continue; + if (np<0) + { + if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM) + player.spwn = 1; + if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2) + player2.spwn = 1; + if (portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH) + { + fighcount++; + fighters[(unsigned char)portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1; + } + continue; + } + if (parts[np].type==PT_FIGH) + { + // Release the fighters[] element allocated by create_part, the one reserved when the fighter went into the portal will be used + fighters[(unsigned char)parts[np].tmp].spwn = 0; + fighters[(unsigned char)portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1; + } parts[np] = portalp[parts[i].tmp][randomness][nnx]; parts[np].x = x+rx; parts[np].y = y+ry; @@ -62,8 +85,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) { if (fe) { int orbd[4] = {0, 0, 0, 0}; //Orbital distances int orbl[4] = {0, 0, 0, 0}; //Orbital locations - if (!parts[i].life) parts[i].life = rand(); - if (!parts[i].ctype) parts[i].life = rand(); + if (!parts[i].life) parts[i].life = rand()*rand()*rand(); + if (!parts[i].ctype) parts[i].ctype = rand()*rand()*rand(); orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); for (r = 0; r < 4; r++) { if (orbd[r]<254) { @@ -71,9 +94,10 @@ int update_PRTO(UPDATE_FUNC_ARGS) { if (orbd[r]>254) { orbd[r] = 0; orbl[r] = rand()%255; + } else { + orbl[r] += 1; + orbl[r] = orbl[r]%255; } - //orbl[r] += 1; - //orbl[r] = orbl[r]%255; } else { orbd[r] = 0; orbl[r] = rand()%255; diff --git a/src/elements/pyro.c b/src/elements/pyro.c index dc51e76..003c8f8 100644 --- a/src/elements/pyro.c +++ b/src/elements/pyro.c @@ -46,6 +46,7 @@ int update_PYRO(UPDATE_FUNC_ARGS) { (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL)) && (t!=PT_PHOT || rt!=PT_INSL) && (rt!=PT_SPNG || parts[r>>8].life==0) && + (rt!=PT_H2 || (parts[r>>8].temp < 2273.15 && pv[y/CELL][x/CELL] < 50.0f)) && ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) { part_change_type(r>>8,x+rx,y+ry,PT_FIRE); diff --git a/src/elements/sprk.c b/src/elements/sprk.c index 67b8132..00279f5 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -44,7 +44,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { parts[nearp].ctype = PT_ETRD; } } - else if (ct==PT_NBLE&&parts[i].life<=1) + else if (ct==PT_NBLE&&parts[i].life<=1&&parts[i].tmp!=1) { parts[i].life = rand()%150+50; part_change_type(i,x,y,PT_PLSM); @@ -179,6 +179,8 @@ int update_SPRK(UPDATE_FUNC_ARGS) { conduct_sprk = 0; if (rt==PT_INST&&ct!=PT_PSCN) conduct_sprk = 0; + if (rt == PT_NBLE && parts[r>>8].tmp == 1) + conduct_sprk = 0; if (conduct_sprk) { if (rt==PT_WATR||rt==PT_SLTW) { @@ -221,9 +223,9 @@ int graphics_SPRK(GRAPHICS_FUNC_ARGS) { *firea = 80; - *firer = *colr = 170; - *fireg = *colg = 200; - *fireb = *colb = 220; + *firer = 170; + *fireg = 200; + *fireb = 220; //*pixel_mode |= FIRE_ADD; *pixel_mode |= FIRE_ADD; return 1; diff --git a/src/elements/stkm.c b/src/elements/stkm.c index 08cb1ba..7a67b65 100644 --- a/src/elements/stkm.c +++ b/src/elements/stkm.c @@ -257,7 +257,7 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { { int np = -1; if (playerp->elem == SPC_AIR) - create_parts(rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0); + create_parts(rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0, 1); else if (playerp->elem==PT_LIGH && playerp->frames<30)//limit lightning creation rate np = -1; else @@ -451,7 +451,10 @@ void STKM_interact(playerst* playerp, int i, int x, int y) { portalp[parts[r>>8].tmp][count][nnx] = parts[i]; kill_part(i); - playerp->spwn = 1;//stop SPWN creating a new STKM while he is in portal + //stop new STKM/fighters being created to replace the ones in the portal: + playerp->spwn = 1; + if (portalp[parts[r>>8].tmp][count][nnx].type==PT_FIGH) + fighcount++; break; } } |
