diff options
| author | Cracker64 <cracker642@gmail.com> | 2011-03-28 22:58:27 (GMT) |
|---|---|---|
| committer | Simon <simon@hardwired.org.uk> | 2011-03-29 17:25:11 (GMT) |
| commit | 53bc3b817d712d56053d2210d1ff99fc8b44488b (patch) | |
| tree | 20111fdb23d2a5e736ae1eee5c209e9932ecb275 /src/elements | |
| parent | 83590424b07c788e7ebf09981a51a82ed53a0353 (diff) | |
| download | powder-53bc3b817d712d56053d2210d1ff99fc8b44488b.zip powder-53bc3b817d712d56053d2210d1ff99fc8b44488b.tar.gz | |
QRTZ grow changes, uses ctype.
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/qrtz.c | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/src/elements/qrtz.c b/src/elements/qrtz.c index e585361..431c46e 100644 --- a/src/elements/qrtz.c +++ b/src/elements/qrtz.c @@ -1,14 +1,18 @@ #include <element.h> int update_QRTZ(UPDATE_FUNC_ARGS) { - int r, tmp, trade, rx, ry, np; - parts[i].pavg[0] = parts[i].pavg[1]; - parts[i].pavg[1] = 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)) + int r, tmp, trade, rx, ry, np, t; + t = parts[i].type; + if(t == PT_QRTZ) { - part_change_type(i,x,y,PT_PQRT); + parts[i].pavg[0] = parts[i].pavg[1]; + parts[i].pavg[1] = 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)) + { + part_change_type(i,x,y,PT_PQRT); + } } - for (rx=-2; rx<3; rx++) + for (rx=-2; rx<3 && parts[i].ctype!=-1; rx++) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) { @@ -18,22 +22,39 @@ int update_QRTZ(UPDATE_FUNC_ARGS) { else if ((r&0xFF)==PT_SLTW && (1>rand()%2500)) { kill_part(r>>8); - parts[i].life ++; + parts[i].ctype ++; } } - if (parts[i].life>0) + if (parts[i].ctype>0) { - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) + 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>>8)>=NPART || r || parts[i].life==0) continue; - np = create_part(-1,x+rx,y+ry,PT_QRTZ); - if (np<0) continue; - parts[np].tmp = parts[i].tmp; - parts[i].life = 0; + if ((r>>8)<NPART && !r && parts[i].ctype!=0) + { + np = create_part(-1,x+rx,y+ry,PT_QRTZ); + if (np>0) + { + parts[np].tmp = parts[i].tmp; + parts[i].ctype = 0; + if(5>rand()%10) + { + parts[np].ctype=-1;//dead qrtz + } + else if(1>rand()%15) + { + parts[i].ctype=-1; + } + + break; + } + } } + } } for ( trade = 0; trade<9; trade ++) { @@ -44,19 +65,19 @@ int update_QRTZ(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if ((r>>8)>=NPART || !r) continue; - if ((r&0xFF)==PT_QRTZ&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion + if ((r&0xFF)==t && (parts[i].ctype>parts[r>>8].ctype) && parts[i].ctype>0 && parts[r>>8].ctype>=0 )//diffusion { - tmp = parts[i].life - parts[r>>8].life; + tmp = parts[i].ctype - parts[r>>8].ctype; if (tmp ==1) { - parts[r>>8].life ++; - parts[i].life --; + parts[r>>8].ctype ++; + parts[i].ctype --; trade = 9; } if (tmp>0) { - parts[r>>8].life += tmp/2; - parts[i].life -= tmp/2; + parts[r>>8].ctype += tmp/2; + parts[i].ctype -= tmp/2; trade = 9; } } |
