diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-14 12:38:52 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-14 12:38:52 (GMT) |
| commit | fa54c005b298befb065a8aa4134836b0460b75b7 (patch) | |
| tree | 56c4f3e002ad1be635f1cddbf121c983469102b0 /src | |
| parent | 73f2f9f57fd6efa4ed386a86f5a8d118d879a629 (diff) | |
| download | powder-fa54c005b298befb065a8aa4134836b0460b75b7.zip powder-fa54c005b298befb065a8aa4134836b0460b75b7.tar.gz | |
Use properties for life decrement/kill
Diffstat (limited to 'src')
| -rw-r--r-- | src/elements/hswc.c | 2 | ||||
| -rw-r--r-- | src/elements/lcry.c | 2 | ||||
| -rw-r--r-- | src/elements/pcln.c | 2 | ||||
| -rw-r--r-- | src/elements/pump.c | 2 | ||||
| -rw-r--r-- | src/elements/swch.c | 2 | ||||
| -rw-r--r-- | src/powder.c | 20 |
6 files changed, 23 insertions, 7 deletions
diff --git a/src/elements/hswc.c b/src/elements/hswc.c index 5470e2d..6e1b2df 100644 --- a/src/elements/hswc.c +++ b/src/elements/hswc.c @@ -2,6 +2,8 @@ int update_HSWC(UPDATE_FUNC_ARGS) { int r, rx, ry; + if (parts[i].life>0 && parts[i].life!=10) + parts[i].life--; if (parts[i].life==10) { for (rx=-2; rx<3; rx++) diff --git a/src/elements/lcry.c b/src/elements/lcry.c index a6d442f..7b1a64e 100644 --- a/src/elements/lcry.c +++ b/src/elements/lcry.c @@ -1,6 +1,8 @@ #include <element.h> int update_LCRY(UPDATE_FUNC_ARGS) { + if (parts[i].life>0 && parts[i].life!=10) + parts[i].life--; if (parts[i].life==10) { int r, rx, ry; diff --git a/src/elements/pcln.c b/src/elements/pcln.c index 5abe33f..8afa656 100644 --- a/src/elements/pcln.c +++ b/src/elements/pcln.c @@ -2,6 +2,8 @@ int update_PCLN(UPDATE_FUNC_ARGS) { int r, rx, ry; + if (parts[i].life>0 && parts[i].life!=10) + parts[i].life--; 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)) diff --git a/src/elements/pump.c b/src/elements/pump.c index 244ca8f..fa28b4c 100644 --- a/src/elements/pump.c +++ b/src/elements/pump.c @@ -2,6 +2,8 @@ int update_PUMP(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].temp>=256.0+273.15) diff --git a/src/elements/swch.c b/src/elements/swch.c index 0bd5e6d..5642419 100644 --- a/src/elements/swch.c +++ b/src/elements/swch.c @@ -2,6 +2,8 @@ int update_SWCH(UPDATE_FUNC_ARGS) { int r, rt, rx, ry; + if (parts[i].life>0 && parts[i].life!=10) + parts[i].life--; 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)) diff --git a/src/powder.c b/src/powder.c index 6aa43ce..63dcee0 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1367,21 +1367,27 @@ void update_particles_i(pixel *vid, int start, int inc) lx = parts[i].x; ly = parts[i].y; t = parts[i].type; + if (t>=PT_NUM) + continue; //printf("parts[%d].type: %d\n", i, parts[i].type); - //this if is whether or not life goes down automatically. - if (parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_STKM && t!=PT_STKM2 && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_SPNG && t!=PT_DEUT && t!=PT_PRTO && t!=PT_PRTI) + if (parts[i].life>0 && (ptypes[t].properties&PROP_LIFE_DEC)) { - //this if is for stopping life loss when at a certain life value - if (!(parts[i].life==10&&(t==PT_SWCH||t==PT_LCRY||t==PT_PCLN||t==PT_HSWC||t==PT_PUMP))) - parts[i].life--; - //this if is for stopping death when life hits 0 - if (parts[i].life<=0 && !(ptypes[t].properties&PROP_CONDUCTS) && t!=PT_SOAP && t!=PT_ARAY && t!=PT_FIRW && t!=PT_SWCH && t!=PT_PCLN && t!=PT_HSWC && t!=PT_PUMP && t!=PT_SPRK && t!=PT_LAVA && t!=PT_LCRY && t!=PT_QRTZ && t!=PT_GLOW && t!= PT_FOG && t!=PT_PIPE && t!=PT_FRZW &&!(t==PT_ICEI&&parts[i].ctype==PT_FRZW)&&t!=PT_INST && t!=PT_SHLD1&& t!=PT_SHLD2&& t!=PT_SHLD3&& t!=PT_SHLD4 && t!=PT_SING) + // automatically decrease life + parts[i].life--; + if (parts[i].life<=0 && (ptypes[t].properties&(PROP_LIFE_KILL_DEC|PROP_LIFE_KILL))) { + // kill on change to no life kill_part(i); continue; } } + else if (parts[i].life<=0 && (ptypes[t].properties&PROP_LIFE_KILL)) + { + // kill if no life + kill_part(i); + continue; + } x = (int)(parts[i].x+0.5f); y = (int)(parts[i].y+0.5f); |
