summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-07 23:05:26 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-07 23:05:26 (GMT)
commit9af0072b21409d71e04652330118a44e37c3f6c4 (patch)
treec7cd5205c4e63997cc212c7b2c9865aded61b001 /src/elements
parent685ede06433a7960f7c4aa90b03471942511e177 (diff)
downloadpowder-9af0072b21409d71e04652330118a44e37c3f6c4.zip
powder-9af0072b21409d71e04652330118a44e37c3f6c4.tar.gz
Further function pointers.
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/frzw.c35
-rw-r--r--src/elements/hswc.c25
-rw-r--r--src/elements/ice.c37
-rw-r--r--src/elements/lcry.c25
-rw-r--r--src/elements/neut.c98
-rw-r--r--src/elements/pcln.c20
-rw-r--r--src/elements/pump.c40
7 files changed, 280 insertions, 0 deletions
diff --git a/src/elements/frzw.c b/src/elements/frzw.c
new file mode 100644
index 0000000..fcdbda1
--- /dev/null
+++ b/src/elements/frzw.c
@@ -0,0 +1,35 @@
+#include <powder.h>
+
+int update_FRZW(UPDATE_FUNC_ARGS) {
+ int r;
+ for (nx=-1; nx<2; nx++)
+ for (ny=-1; ny<2; 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 (parts[r>>8].type==PT_WATR&&5>rand()%70)
+ {
+ parts[r>>8].type=PT_FRZW;
+ }
+ }
+ if (parts[i].life==0&&13>rand()%2500)
+ {
+ parts[i].type=PT_ICEI;
+ parts[i].ctype=PT_FRZW;
+ parts[i].temp -= 200.0f;
+ if (parts[i].temp<0)
+ parts[i].temp = 0;
+ }
+ else if ((100-(parts[i].life))>rand()%50000)
+ {
+ parts[i].type=PT_ICEI;
+ parts[i].ctype=PT_FRZW;
+ parts[i].temp -= 200.0f;
+ if (parts[i].temp<0)
+ parts[i].temp = 0;
+ }
+ return 0;
+}
diff --git a/src/elements/hswc.c b/src/elements/hswc.c
new file mode 100644
index 0000000..1b1dfaa
--- /dev/null
+++ b/src/elements/hswc.c
@@ -0,0 +1,25 @@
+#include <powder.h>
+
+int update_HSWC(UPDATE_FUNC_ARGS) {
+ int r;
+ if (parts[i].life==10)
+ {
+ 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 ((r&0xFF)==PT_PUMP)
+ {
+ if (parts[r>>8].life<10&&parts[r>>8].life>0)
+ parts[i].life = 9;
+ else if (parts[r>>8].life==0)
+ parts[r>>8].life = 10;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/ice.c b/src/elements/ice.c
new file mode 100644
index 0000000..11817e8
--- /dev/null
+++ b/src/elements/ice.c
@@ -0,0 +1,37 @@
+#include <powder.h>
+
+int update_ICEI(UPDATE_FUNC_ARGS) { //currently used for snow as well
+ int r;
+ if (parts[i].ctype==PT_FRZW)
+ {
+ parts[i].temp -= 1.0f;
+ if (parts[i].temp<0)
+ parts[i].temp = 0;
+
+ }
+ 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 (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && 1>(rand()%1000))
+ {
+ parts[i].type = PT_SLTW;
+ parts[r>>8].type = PT_SLTW;
+ }
+ if (legacy_enable)
+ {
+ if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
+ {
+ parts[i].type = PT_ICEI;
+ parts[r>>8].type = PT_ICEI;
+ }
+ if (parts[i].type==PT_SNOW && ((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000))
+ parts[i].type = PT_WATR;
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/lcry.c b/src/elements/lcry.c
new file mode 100644
index 0000000..0f87856
--- /dev/null
+++ b/src/elements/lcry.c
@@ -0,0 +1,25 @@
+#include <powder.h>
+
+int update_LCRY(UPDATE_FUNC_ARGS) {
+ int r;
+ if (parts[i].life==10)
+ {
+ for (nx=-1; nx<2; nx++)
+ for (ny=-1; ny<2; 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 ((r&0xFF)==PT_LCRY)
+ {
+ if (parts[r>>8].life<10&&parts[r>>8].life>0)
+ parts[i].life = 9;
+ else if (parts[r>>8].life==0)
+ parts[r>>8].life = 10;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/neut.c b/src/elements/neut.c
new file mode 100644
index 0000000..94692aa
--- /dev/null
+++ b/src/elements/neut.c
@@ -0,0 +1,98 @@
+#include <powder.h>
+
+int update_NEUT(UPDATE_FUNC_ARGS) {
+ int r, fe;
+ int rt = 3 + (int)pv[y/CELL][x/CELL];
+ for (nx=-1; nx<2; nx++)
+ for (ny=-1; ny<2; 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 ((r&0xFF)==PT_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW)
+ {
+ parts[i].vx *= 0.995;
+ parts[i].vy *= 0.995;
+ }
+ if ((r&0xFF)==PT_PLUT && rt>(rand()%1000))
+ {
+ if (33>rand()%100)
+ {
+ create_part(r>>8, x+nx, y+ny, rand()%3 ? PT_LAVA : PT_URAN);
+ parts[r>>8].temp = MAX_TEMP;
+ if (parts[r>>8].type==PT_LAVA) {
+ parts[r>>8].tmp = 100;
+ parts[r>>8].ctype = PT_PLUT;
+ }
+ }
+ else
+ {
+ create_part(r>>8, x+nx, y+ny, PT_NEUT);
+ parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
+ 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 ++;
+ }
+ if ((r&0xFF)==PT_DEUT && (rt+1)>(rand()%1000))
+ {
+#ifdef SDEUT
+ create_n_parts(parts[r>>8].life, x+nx, y+ny, parts[i].vx, parts[i].vy, PT_NEUT);
+#else
+ create_part(r>>8, x+nx, y+ny, PT_NEUT);
+ parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
+ parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
+ if (parts[r>>8].life>0)
+ {
+ parts[r>>8].life --;
+ parts[r>>8].temp += (parts[r>>8].life*17);
+ pv[y/CELL][x/CELL] += 6.0f * CFDS;
+
+ }
+ else
+ parts[r>>8].type = PT_NONE;
+#endif
+ }
+ if ((r&0xFF)==PT_GUNP && 15>(rand()%1000))
+ parts[r>>8].type = PT_DUST;
+ if ((r&0xFF)==PT_DYST && 15>(rand()%1000))
+ parts[r>>8].type = PT_YEST;
+ if ((r&0xFF)==PT_YEST) {
+ if (15>(rand()%100000)&&isplayer==0)
+ parts[r>>8].type = PT_STKM;
+ else
+ parts[r>>8].type = PT_DYST;
+ }
+
+ if ((r&0xFF)==PT_WATR && 15>(rand()%100))
+ parts[r>>8].type = PT_DSTW;
+ if ((r&0xFF)==PT_PLEX && 15>(rand()%1000))
+ parts[r>>8].type = PT_GOO;
+ if ((r&0xFF)==PT_NITR && 15>(rand()%1000))
+ parts[r>>8].type = PT_DESL;
+ if ((r&0xFF)==PT_PLNT && 5>(rand()%100))
+ parts[r>>8].type = PT_WOOD;
+ if ((r&0xFF)==PT_DESL && 15>(rand()%1000))
+ parts[r>>8].type = PT_GAS;
+ if ((r&0xFF)==PT_COAL && 5>(rand()%100))
+ parts[r>>8].type = PT_WOOD;
+ if ((r&0xFF)==PT_DUST && 5>(rand()%100))
+ parts[r>>8].type = PT_FWRK;
+ if ((r&0xFF)==PT_FWRK && 5>(rand()%100))
+ parts[r>>8].ctype = PT_DUST;
+ if ((r&0xFF)==PT_ACID && 5>(rand()%100))
+ {
+ parts[r>>8].type = PT_ISOZ;
+ parts[r>>8].life = 0;
+ }
+ /*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM &&
+ (ptypes[parts[r>>8].type-1].menusection==SC_LIQUID||
+ ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE||
+ ptypes[parts[r>>8].type-1].menusection==SC_GAS||
+ ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000))
+ parts[r>>8].type--;*/
+ }
+ return 0;
+}
diff --git a/src/elements/pcln.c b/src/elements/pcln.c
index 7b1df20..0ce469e 100644
--- a/src/elements/pcln.c
+++ b/src/elements/pcln.c
@@ -1,6 +1,26 @@
#include <powder.h>
int update_PCLN(UPDATE_FUNC_ARGS) {
+ int r;
+ if (parts[i].life==10)
+ {
+ 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 ((r&0xFF)==PT_PCLN)
+ {
+ if (parts[r>>8].life<10&&parts[r>>8].life>0)
+ parts[i].life = 9;
+ else if (parts[r>>8].life==0)
+ parts[r>>8].life = 10;
+ }
+ }
+ }
if (!parts[i].ctype)
for (nx=-1; nx<2; nx++)
for (ny=-1; ny<2; ny++)
diff --git a/src/elements/pump.c b/src/elements/pump.c
new file mode 100644
index 0000000..1de7a10
--- /dev/null
+++ b/src/elements/pump.c
@@ -0,0 +1,40 @@
+#include <powder.h>
+
+int update_PUMP(UPDATE_FUNC_ARGS) {
+ int r;
+ if (parts[i].life==10)
+ {
+ if (parts[i].temp>=256.0+273.15)
+ parts[i].temp=256.0+273.15;
+ if (parts[i].temp<= -256.0+273.15)
+ parts[i].temp = -256.0+273.15;
+
+ if (pv[y/CELL][x/CELL]<(parts[i].temp-273.15))
+ pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]);
+ if (y+CELL<YRES && pv[y/CELL+1][x/CELL]<(parts[i].temp-273.15))
+ pv[y/CELL+1][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL]);
+ if (x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL+1]);
+ if (y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL+1]);
+ }
+ 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 ((r&0xFF)==PT_PUMP)
+ {
+ if (parts[r>>8].life<10&&parts[r>>8].life>0)
+ parts[i].life = 9;
+ else if (parts[r>>8].life==0)
+ parts[r>>8].life = 10;
+ }
+ }
+ }
+ return 0;
+}