diff options
| author | jacksonmj <jacksonmj@jacksonmj.none> | 2011-01-08 00:07:10 (GMT) |
|---|---|---|
| committer | jacksonmj <jacksonmj@jacksonmj.none> | 2011-01-08 09:00:59 (GMT) |
| commit | d17758cc08080fcb3ab0b709ed74c5739d707894 (patch) | |
| tree | ffef6471b42f6eefeca052482f4660be8a85313e /src/elements | |
| parent | 9af0072b21409d71e04652330118a44e37c3f6c4 (diff) | |
| download | powder-d17758cc08080fcb3ab0b709ed74c5739d707894.zip powder-d17758cc08080fcb3ab0b709ed74c5739d707894.tar.gz | |
Yet more function pointers.
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/bcln.c | 10 | ||||
| -rw-r--r-- | src/elements/fwrk.c | 20 | ||||
| -rw-r--r-- | src/elements/goo.c | 15 | ||||
| -rw-r--r-- | src/elements/neut.c | 4 | ||||
| -rw-r--r-- | src/elements/phot.c | 1 | ||||
| -rw-r--r-- | src/elements/pyro.c | 99 | ||||
| -rw-r--r-- | src/elements/sprk.c | 1 |
7 files changed, 138 insertions, 12 deletions
diff --git a/src/elements/bcln.c b/src/elements/bcln.c index 41418cf..e27478d 100644 --- a/src/elements/bcln.c +++ b/src/elements/bcln.c @@ -1,6 +1,16 @@ #include <powder.h> int update_BCLN(UPDATE_FUNC_ARGS) { + if (!parts[i].life) + { + if (pv[y/CELL][x/CELL]>4.0f) + { + float advection = 0.1f; + parts[i].vx += advection*vx[y/CELL][x/CELL]; + parts[i].vy += advection*vy[y/CELL][x/CELL]; + parts[i].life = rand()%40+80; + } + } if (!parts[i].ctype) { for (nx=-1; nx<2; nx++) diff --git a/src/elements/fwrk.c b/src/elements/fwrk.c index 9a8b62f..30b5e0b 100644 --- a/src/elements/fwrk.c +++ b/src/elements/fwrk.c @@ -1,7 +1,7 @@ #include <powder.h> int update_FWRK(UPDATE_FUNC_ARGS) { - int r, a; + int r; if ((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST) { create_part(-1, x , y-1 , PT_FWRK); @@ -35,16 +35,16 @@ int update_FWRK(UPDATE_FUNC_ARGS) { { create_part(-1, x+nx, y+ny , PT_DUST); pv[y/CELL][x/CELL] += 2.00f*CFDS; - a= pmap[y+ny][x+nx]; - if (parts[a>>8].type==PT_DUST) + r = pmap[y+ny][x+nx]; + if (parts[r>>8].type==PT_DUST) { - parts[a>>8].vy = -(rand()%10-1); - parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ; - parts[a>>8].life= rand()%37+18; - parts[a>>8].tmp=q; - parts[a>>8].flags=w; - parts[a>>8].ctype=e; - parts[a>>8].temp= rand()%20+6000; + parts[r>>8].vy = -(rand()%10-1); + parts[r>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ; + parts[r>>8].life= rand()%37+18; + parts[r>>8].tmp=q; + parts[r>>8].flags=w; + parts[r>>8].ctype=e; + parts[r>>8].temp= rand()%20+6000; } } } diff --git a/src/elements/goo.c b/src/elements/goo.c new file mode 100644 index 0000000..7ae529b --- /dev/null +++ b/src/elements/goo.c @@ -0,0 +1,15 @@ +#include <powder.h> + +int update_GOO(UPDATE_FUNC_ARGS) { + if (!parts[i].life) + { + if (pv[y/CELL][x/CELL]>1.0f) + { + float advection = 0.1f; + parts[i].vx += advection*vx[y/CELL][x/CELL]; + parts[i].vy += advection*vy[y/CELL][x/CELL]; + parts[i].life = rand()%80+300; + } + } + return 0; +} diff --git a/src/elements/neut.c b/src/elements/neut.c index 94692aa..98b7eda 100644 --- a/src/elements/neut.c +++ b/src/elements/neut.c @@ -1,7 +1,7 @@ #include <powder.h> int update_NEUT(UPDATE_FUNC_ARGS) { - int r, fe; + int r; int rt = 3 + (int)pv[y/CELL][x/CELL]; for (nx=-1; nx<2; nx++) for (ny=-1; ny<2; ny++) @@ -34,7 +34,7 @@ int update_NEUT(UPDATE_FUNC_ARGS) { parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; } pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough - fe ++; + update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); } if ((r&0xFF)==PT_DEUT && (rt+1)>(rand()%1000)) { diff --git a/src/elements/phot.c b/src/elements/phot.c index cebff96..12f0b50 100644 --- a/src/elements/phot.c +++ b/src/elements/phot.c @@ -1,6 +1,7 @@ #include <powder.h> int update_PHOT(UPDATE_FUNC_ARGS) { + if (1>rand()%10) update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); // TODO return 0; diff --git a/src/elements/pyro.c b/src/elements/pyro.c new file mode 100644 index 0000000..f548928 --- /dev/null +++ b/src/elements/pyro.c @@ -0,0 +1,99 @@ +#include <powder.h> + +int update_PYRO(UPDATE_FUNC_ARGS) { + int r, rt, lpv, t = parts[i].type; + if (t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1) + { + parts[i].type = PT_NBLE; + parts[i].life = 0; + } + if (t==PT_FIRE && parts[i].life <=1 && parts[i].temp<625) + { + t = parts[i].type = PT_SMKE; + parts[i].life = rand()%20+250; + } + for (nx=-2; nx<3; nx++) + for (ny=-2; ny<3; ny++) + if (x+nx>=0 && y+ny>0 && + x+nx<XRES && y+ny<YRES && (nx || ny)) + { + r = pmap[y+ny][x+nx]; + if ((r>>8)>=NPART || !r) + continue; + if (bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/CELL]!=WL_STREAM) + continue; + rt = parts[r>>8].type; + if ((a || ptypes[rt].explosive) && (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH)) && + !(t==PT_PHOT && rt==PT_INSL) && + (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR && rt!=PT_QRTZ)) + && !(rt==PT_SPNG && parts[r>>8].life>0) && + ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000)) + { + parts[r>>8].type = PT_FIRE; + parts[r>>8].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2); + parts[r>>8].life = rand()%80+180; + if (ptypes[rt].explosive) + pv[y/CELL][x/CELL] += 0.25f * CFDS; + continue; + } + lpv = (int)pv[(y+ny)/CELL][(x+nx)/CELL]; + if (lpv < 1) lpv = 1; + if (legacy_enable) + { + if (t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) && + ptypes[rt].meltable*lpv>(rand()%1000)) + { + if (t!=PT_LAVA || parts[i].life>0) + { + parts[r>>8].ctype = (parts[r>>8].type==PT_BRMT)?PT_BMTL:parts[r>>8].type; + parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype; + parts[r>>8].type = PT_LAVA; + parts[r>>8].life = rand()%120+240; + } + else + { + parts[i].life = 0; + t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE; + parts[i].ctype = PT_NONE;//rt; + return 1; + } + } + if (t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW)) + { + parts[r>>8].type = PT_WATR; + if (t==PT_FIRE) + { + parts[i].x = lx; + parts[i].y = ly; + kill_part(i); + return 1; + } + if (t==PT_LAVA) + { + parts[i].life = 0; + t = parts[i].type = PT_STNE; + return 1; + } + } + if (t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW)) + { + kill_part(r>>8); + if (t==PT_FIRE) + { + parts[i].x = lx; + parts[i].y = ly; + kill_part(i); + return 1; + } + if (t==PT_LAVA) + { + parts[i].life = 0; + t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE; + parts[i].ctype = PT_NONE; + return 1; + } + } + } + } + return 0; +} diff --git a/src/elements/sprk.c b/src/elements/sprk.c index d6454ff..a4db735 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -1,6 +1,7 @@ #include <powder.h> int update_SPRK(UPDATE_FUNC_ARGS) { + update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); int r, rt, conduct_sprk, nearp, pavg, ct = parts[i].ctype; if (parts[i].life<=0) { |
