summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-07 20:03:58 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-07 20:03:58 (GMT)
commitb69712bbdbaf32fef65e15141458cb27f9f7ec88 (patch)
tree622d2d413fe4edbe683c729d500206c447624b8d /src
parentfa1868314c1d48de9000c45dc8bcde36d92472cb (diff)
downloadpowder-b69712bbdbaf32fef65e15141458cb27f9f7ec88.zip
powder-b69712bbdbaf32fef65e15141458cb27f9f7ec88.tar.gz
Some more function pointers
Diffstat (limited to 'src')
-rw-r--r--src/elements/amtr.c32
-rw-r--r--src/elements/bcln.c23
-rw-r--r--src/elements/bomb.c64
-rw-r--r--src/elements/btry.c25
-rw-r--r--src/elements/c5.c24
-rw-r--r--src/elements/clne.c23
-rw-r--r--src/elements/firw.c67
-rw-r--r--src/elements/fwrk.c55
-rw-r--r--src/elements/isz.c17
-rw-r--r--src/elements/prti.c32
-rw-r--r--src/elements/prto.c53
-rw-r--r--src/elements/shld.c160
-rw-r--r--src/elements/sing.c59
-rw-r--r--src/elements/warp.c26
-rw-r--r--src/elements/wifi.c43
-rw-r--r--src/elements/yest.c22
-rw-r--r--src/powder.c683
17 files changed, 725 insertions, 683 deletions
diff --git a/src/elements/amtr.c b/src/elements/amtr.c
new file mode 100644
index 0000000..3f70daa
--- /dev/null
+++ b/src/elements/amtr.c
@@ -0,0 +1,32 @@
+#include <powder.h>
+
+int update_AMTR(UPDATE_FUNC_ARGS) {
+ int r, rt;
+ 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;
+ rt = parts[r>>8].type;
+ if ((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO)
+ {
+ parts[i].life++;
+ if (parts[i].life==3)
+ {
+ parts[i].type = PT_NONE;
+ kill_part(i);
+ return 1;
+ }
+ parts[r>>8].life = 0;
+ parts[r>>8].type = PT_NONE;
+ kill_part(r>>8);
+ if (2>(rand()/(RAND_MAX/100)))
+ create_part(-1, x+nx, y+ny, PT_PHOT);
+ pv[y/CELL][x/CELL] -= 5.0f;
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/bcln.c b/src/elements/bcln.c
new file mode 100644
index 0000000..41418cf
--- /dev/null
+++ b/src/elements/bcln.c
@@ -0,0 +1,23 @@
+#include <powder.h>
+
+int update_BCLN(UPDATE_FUNC_ARGS) {
+ if (!parts[i].ctype)
+ {
+ 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 &&
+ pmap[y+ny][x+nx] &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
+ (pmap[y+ny][x+nx]&0xFF)!=0xFF)
+ parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
+ }
+ else {
+ create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
+ }
+ return 0;
+}
diff --git a/src/elements/bomb.c b/src/elements/bomb.c
new file mode 100644
index 0000000..b80dfdf
--- /dev/null
+++ b/src/elements/bomb.c
@@ -0,0 +1,64 @@
+#include <powder.h>
+
+int update_BOMB(UPDATE_FUNC_ARGS) {
+ int r, nb;
+ if (parts[i].tmp==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 (parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB) {
+ parts[i].type = PT_NONE;
+ return 1;
+ }
+ }
+ } else if (parts[i].tmp==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)
+ {
+ r = pmap[y+ny][x+nx];
+ if ((r>>8)>=NPART || !r)
+ continue;
+ if (parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB && parts[r>>8].type!=PT_DMND && parts[r>>8].type!=PT_CLNE && parts[r>>8].type!=PT_PCLN && parts[r>>8].type!=PT_BCLN) {
+ int rad = 8;
+ int nxi;
+ int nxj;
+ pmap[y][x] = 0;
+ for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
+ for (nxi=-(rad+1); nxi<=(rad+1); nxi++)
+ if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1) {
+ nb = create_part(-1, x+nxi, y+nxj, PT_BOMB);
+ if (nb!=-1) {
+ parts[nb].tmp = 1;
+ parts[nb].life = 50;
+ parts[nb].temp = MAX_TEMP;
+ parts[nb].vx = rand()%20-10;
+ parts[nb].vy = rand()%20-10;
+ }
+ }
+ for (nxj=-rad; nxj<=rad; nxj++)
+ for (nxi=-rad; nxi<=rad; nxi++)
+ if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1)
+ if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) {
+ delete_part(x+nxi, y+nxj);
+ pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f;
+ nb = create_part(-1, x+nxi, y+nxj, PT_BOMB);
+ if (nb!=-1) {
+ parts[nb].tmp = 2;
+ parts[nb].life = 2;
+ parts[nb].temp = MAX_TEMP;
+ }
+ }
+ //create_parts(x, y, 9, 9, PT_BOMB);
+ //create_parts(x, y, 8, 8, PT_NONE);
+ parts[i].type = PT_NONE;
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/btry.c b/src/elements/btry.c
new file mode 100644
index 0000000..01ea48f
--- /dev/null
+++ b/src/elements/btry.c
@@ -0,0 +1,25 @@
+#include <powder.h>
+
+int update_BTRY(UPDATE_FUNC_ARGS) {
+ int r, rt;
+ 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;
+ rt = parts[r>>8].type;
+ if (parts_avg(i,r>>8,PT_INSL) != PT_INSL)
+ {
+ if ((ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(nx)+abs(ny) < 4)
+ {
+ parts[r>>8].life = 4;
+ parts[r>>8].ctype = rt;
+ parts[r>>8].type = PT_SPRK;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/c5.c b/src/elements/c5.c
new file mode 100644
index 0000000..afa7382
--- /dev/null
+++ b/src/elements/c5.c
@@ -0,0 +1,24 @@
+#include <powder.h>
+
+int update_C5(UPDATE_FUNC_ARGS) {
+ int r;
+ 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 ((parts[r>>8].temp<100 && parts[r>>8].type!=PT_C5)||parts[r>>8].type==PT_HFLM)
+ {
+ if (1>rand()%6)
+ {
+ parts[i].type = PT_HFLM;
+ parts[r>>8].temp = parts[i].temp = 0;
+ parts[i].life = rand()%150+50;
+ pv[y/CELL][x/CELL] += 1.5;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/clne.c b/src/elements/clne.c
new file mode 100644
index 0000000..d8e6879
--- /dev/null
+++ b/src/elements/clne.c
@@ -0,0 +1,23 @@
+#include <powder.h>
+
+int update_CLNE(UPDATE_FUNC_ARGS) {
+ if (!parts[i].ctype)
+ {
+ 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 &&
+ pmap[y+ny][x+nx] &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
+ (pmap[y+ny][x+nx]&0xFF)!=0xFF)
+ parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
+ }
+ else {
+ create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
+ }
+ return 0;
+}
diff --git a/src/elements/firw.c b/src/elements/firw.c
new file mode 100644
index 0000000..033e942
--- /dev/null
+++ b/src/elements/firw.c
@@ -0,0 +1,67 @@
+#include <powder.h>
+
+int update_FIRW(UPDATE_FUNC_ARGS) {
+ int r, rt;
+ if (parts[i].tmp==0) {
+ 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;
+ rt = parts[r>>8].type;
+ if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR)
+ {
+ parts[i].tmp = 1;
+ parts[i].life = rand()%50+60;
+ }
+ }
+ }
+ else if (parts[i].tmp==1) {
+ if (parts[i].life==0) {
+ parts[i].tmp=2;
+ } else {
+ float newVel = parts[i].life/25;
+ parts[i].flags = parts[i].flags&0xFFFFFFFE;
+ if ((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) {
+ parts[i].vy = -newVel;
+ // TODO
+ //ly-=newVel;
+ //iy-=newVel;
+ }
+ }
+ }
+ else if (parts[i].tmp==2) {
+ int col = rand()%200+4;
+ 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))
+ {
+ int tmul = rand()%7;
+ create_part(-1, x+nx, y+ny, PT_FIRW);
+ r = pmap[y+ny][x+nx];
+ if ((r>>8)>=NPART || !r)
+ continue;
+ if (parts[r>>8].type==PT_FIRW) {
+ parts[r>>8].vx = (rand()%3-1)*tmul;
+ parts[r>>8].vy = (rand()%3-1)*tmul;
+ parts[r>>8].tmp = col;
+ parts[r>>8].life = rand()%100+100;
+ parts[r>>8].temp = 6000.0f;
+ }
+ }
+ }
+ }
+ pv[y/CELL][x/CELL] += 20;
+ kill_part(i);
+ return 1;
+ } else if (parts[i].tmp>=3) {
+ if (parts[i].life<=0) {
+ kill_part(i);
+ return 1;
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/fwrk.c b/src/elements/fwrk.c
new file mode 100644
index 0000000..9a8b62f
--- /dev/null
+++ b/src/elements/fwrk.c
@@ -0,0 +1,55 @@
+#include <powder.h>
+
+int update_FWRK(UPDATE_FUNC_ARGS) {
+ int r, a;
+ 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);
+ r = pmap[y-1][x];
+ if ((r&0xFF)==PT_FWRK)
+ {
+ parts[r>>8].vy = rand()%8-22;
+ parts[r>>8].vx = rand()%20-rand()%20;
+ parts[r>>8].life=rand()%15+25;
+ parts[i].type=PT_NONE;
+ }
+ }
+ if (parts[i].life>1)
+ {
+ if (parts[i].life>=45&&parts[i].type==PT_FWRK)
+ parts[i].life=0;
+ }
+ if ((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0)
+ {
+ int q = (rand()%255+1);
+ int w = (rand()%255+1);
+ int e = (rand()%255+1);
+ for (nx=-1; nx<2; nx++)
+ for (ny=-2; ny<3; ny++)
+ if (x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES)
+ {
+ if (5>=rand()%8)
+ {
+ if (!pmap[y+ny][x+nx])
+ {
+ 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)
+ {
+ 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[i].type=PT_NONE;
+ }
+ return 0;
+}
diff --git a/src/elements/isz.c b/src/elements/isz.c
new file mode 100644
index 0000000..56bae10
--- /dev/null
+++ b/src/elements/isz.c
@@ -0,0 +1,17 @@
+#include <powder.h>
+
+int update_ISZ(UPDATE_FUNC_ARGS) {
+ float rr, rrr;
+ if (1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000))
+ {
+ parts[i].type = PT_PHOT;
+ rr = (rand()%228+128)/127.0f;
+ rrr = (rand()%360)*3.14159f/180.0f;
+ parts[i].life = 680;
+ parts[i].ctype = 0x3FFFFFFF;
+ parts[i].vx = rr*cosf(rrr);
+ parts[i].vy = rr*sinf(rrr);
+ create_part(i, x, y, PT_PHOT);
+ }
+ return 0;
+}
diff --git a/src/elements/prti.c b/src/elements/prti.c
new file mode 100644
index 0000000..33b449f
--- /dev/null
+++ b/src/elements/prti.c
@@ -0,0 +1,32 @@
+#include <powder.h>
+
+int update_PRTI(UPDATE_FUNC_ARGS) {
+ int r, temp, nnx, temprange = 100;
+ int count =0;
+ for ( temp = 0; temp < MAX_TEMP; temp += temprange)
+ if (parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
+ parts[i].tmp = temp/100;
+ for (ny=-1; ny<2; ny++)
+ for (nx=-1; nx<2; nx++)
+ if (x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ count ++;
+ r = pmap[y+ny][x+nx];
+ if ((r>>8)>=NPART || !r)
+ continue;
+ if (parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)))
+ for ( nnx=0; nnx<80; nnx++)
+ if (!portal[parts[i].tmp][count-1][nnx])
+ {
+ portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type;
+ portaltemp[parts[i].tmp][count-1][nnx] = parts[r>>8].temp;
+ if (parts[r>>8].type==PT_SPRK)
+ parts[r>>8].type = parts[r>>8].ctype;
+ else
+ parts[r>>8].type = PT_NONE;
+ break;
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/prto.c b/src/elements/prto.c
new file mode 100644
index 0000000..f7f97fc
--- /dev/null
+++ b/src/elements/prto.c
@@ -0,0 +1,53 @@
+#include <powder.h>
+
+int update_PRTO(UPDATE_FUNC_ARGS) {
+ int r, temp, nnx, temprange = 100;
+ int count = 0;
+ for ( temp = 0; temp < MAX_TEMP; temp += temprange)
+ if (parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
+ parts[i].tmp = temp/100;
+ for (ny=1; ny>-2; ny--)
+ for (nx=1; nx>-2; nx--)
+ if (x+nx>=0 && y+ny>0 &&
+ x+nx<XRES && y+ny<YRES && (nx || ny))
+ {
+ count ++;
+ r = pmap[y+ny][x+nx];
+ if ((r>>8)>=NPART || r)
+ continue;
+ if (!r)
+ {
+ for ( nnx =0 ; nnx<80; nnx++)
+ {
+ int randomness = count + rand()%3-1;
+ if (randomness<1)
+ randomness=1;
+ if (randomness>8)
+ randomness=8;
+ if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)//todo. make it look better
+ {
+ create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x+1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x,y-1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x,y+1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x-1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x-1,y,portal[parts[i].tmp][randomness-1][nnx]);
+ create_part(-1,x-1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
+ portal[parts[i].tmp][randomness-1][nnx] = 0;
+ portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
+ break;
+ }
+ else if (portal[parts[i].tmp][randomness-1][nnx])
+ {
+ create_part(-1,x+nx,y+ny,portal[parts[i].tmp][randomness-1][nnx]);
+ parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[parts[i].tmp][randomness-1][nnx];
+ portal[parts[i].tmp][randomness-1][nnx] = 0;
+ portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
+ break;
+ }
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/shld.c b/src/elements/shld.c
new file mode 100644
index 0000000..940fa08
--- /dev/null
+++ b/src/elements/shld.c
@@ -0,0 +1,160 @@
+#include <powder.h>
+
+int update_SHLD1(UPDATE_FUNC_ARGS) {
+ int r, nnx, nny;
+ 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;
+ else if (parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for ( nnx=-1; nnx<2; nnx++)
+ for ( nny=-1; nny<2; nny++)
+ {
+ if (7>rand()%200&&parts[i].life==0)
+ {
+ parts[i].type = PT_SHLD2;
+ parts[i].life = 7;
+ }
+ else if (!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ else if (parts[r>>8].type==PT_SHLD3&&4>rand()%10)
+ {
+ parts[i].type=PT_SHLD2;
+ parts[i].life = 7;
+ }
+ }
+ return 0;
+}
+
+int update_SHLD2(UPDATE_FUNC_ARGS) {
+ int r, nnx, nny;
+ 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)
+ continue;
+ if (!r && parts[i].life>0)
+ create_part(-1,x+nx,y+ny,PT_SHLD1);
+ if (!r)
+ continue;
+ else if (parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for ( nnx=-1; nnx<2; nnx++)
+ for ( nny=-1; nny<2; nny++)
+ {
+ if (3>rand()%200&&parts[i].life==0)
+ {
+ parts[i].type = PT_SHLD3;
+ parts[i].life = 7;
+ }
+ else if (!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ else if (parts[r>>8].type==PT_SHLD4&&4>rand()%10)
+ {
+ parts[i].type=PT_SHLD3;
+ parts[i].life = 7;
+ }
+ }
+ return 0;
+}
+
+int update_SHLD3(UPDATE_FUNC_ARGS) {
+ int r, nnx, nny;
+ 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)
+ continue;
+ if (!r)
+ {
+ if (1>rand()%2500)
+ {
+ create_part(-1,x+nx,y+ny,PT_SHLD1);
+ parts[pmap[y+ny][x+nx]>>8].life=7;
+ parts[i].type = PT_SHLD2;
+ }
+ else
+ continue;
+
+ }
+ if (parts[r>>8].type==PT_SHLD1 && parts[i].life>3)
+ {
+ parts[r>>8].type = PT_SHLD2;
+ parts[r>>8].life=7;
+ }
+ else if (parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for ( nnx=-1; nnx<2; nnx++)
+ for ( nny=-1; nny<2; nny++)
+ {
+ if (2>rand()%3000&&parts[i].life==0)
+ {
+ parts[i].type = PT_SHLD4;
+ parts[i].life = 7;
+ }
+ else if (!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ }
+ return 0;
+}
+
+int update_SHLD4(UPDATE_FUNC_ARGS) {
+ int r, nnx, nny;
+ 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)
+ continue;
+ if (!r)
+ {
+ if (1>rand()%5500)
+ {
+ create_part(-1,x+nx,y+ny,PT_SHLD1);
+ parts[pmap[y+ny][x+nx]>>8].life=7;
+ parts[i].type = PT_SHLD2;
+ }
+ else
+ continue;
+
+ }
+ if (parts[r>>8].type==PT_SHLD2 && parts[i].life>3)
+ {
+ parts[r>>8].type = PT_SHLD3;
+ parts[r>>8].life = 7;
+ }
+ else if (parts[r>>8].type==PT_SPRK&&parts[i].life==0)
+ for ( nnx=-1; nnx<2; nnx++)
+ for ( nny=-1; nny<2; nny++)
+ {
+ if (!pmap[y+ny+nny][x+nx+nnx])
+ {
+ create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/sing.c b/src/elements/sing.c
new file mode 100644
index 0000000..8f7c0a7
--- /dev/null
+++ b/src/elements/sing.c
@@ -0,0 +1,59 @@
+#include <powder.h>
+
+int update_SING(UPDATE_FUNC_ARGS) {
+ int r;
+ int singularity = -parts[i].life;
+
+ if (pv[y/CELL][x/CELL]<singularity)
+ pv[y/CELL][x/CELL] += 0.1f*(singularity-pv[y/CELL][x/CELL]);
+ if (y+CELL<YRES && pv[y/CELL+1][x/CELL]<singularity)
+ pv[y/CELL+1][x/CELL] += 0.1f*(singularity-pv[y/CELL+1][x/CELL]);
+ if (x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] += 0.1f*(singularity-pv[y/CELL][x/CELL+1]);
+ if (y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] += 0.1f*(singularity-pv[y/CELL+1][x/CELL+1]);
+ }
+ if (y+CELL>0 && pv[y/CELL-1][x/CELL]<singularity)
+ pv[y/CELL-1][x/CELL] += 0.1f*(singularity-pv[y/CELL-1][x/CELL]);
+ if (x+CELL>0)
+ {
+ pv[y/CELL][x/CELL-1] += 0.1f*(singularity-pv[y/CELL][x/CELL-1]);
+ if (y+CELL>0)
+ pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]);
+ }
+ 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_DMND&&33>=rand()/(RAND_MAX/100)+1)
+ {
+ if (parts[r>>8].type==PT_SING && parts[r>>8].life >10)
+ {
+ if (parts[i].life+parts[r>>8].life > 255)
+ continue;
+ parts[i].life += parts[r>>8].life;
+ }
+ else
+ {
+ if (parts[i].life+3 > 255)
+ {
+ if (parts[r>>8].type!=PT_SING && 1>rand()%100)
+ {
+ parts[r>>8].type = PT_SING;
+ parts[r>>8].life = rand()%50+60;
+ }
+ continue;
+ }
+ parts[i].life += 3;
+ }
+ parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP);
+ parts[r>>8].type=PT_NONE;
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/warp.c b/src/elements/warp.c
new file mode 100644
index 0000000..92881ed
--- /dev/null
+++ b/src/elements/warp.c
@@ -0,0 +1,26 @@
+#include <powder.h>
+
+int update_WARP(UPDATE_FUNC_ARGS) {
+ int trade, r;
+ for ( trade = 0; trade<5; trade ++)
+ {
+ nx = rand()%3-1;
+ ny = rand()%3-1;
+ 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_WARP&&parts[r>>8].type!=PT_STKM&&parts[r>>8].type!=PT_DMND&&parts[r>>8].type!=PT_CLNE&&parts[r>>8].type!=PT_BCLN&&parts[r>>8].type!=PT_PCLN&&(10>=rand()%200))
+ {
+ parts[i].x = parts[r>>8].x;
+ parts[i].y = parts[r>>8].y;
+ parts[r>>8].x = x;
+ parts[r>>8].y = y;
+ parts[i].life += 4;
+ trade = 5;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/wifi.c b/src/elements/wifi.c
new file mode 100644
index 0000000..85ede6c
--- /dev/null
+++ b/src/elements/wifi.c
@@ -0,0 +1,43 @@
+#include <powder.h>
+
+int update_WIFI(UPDATE_FUNC_ARGS) {
+ int r, temp, temprange = 100;
+ for ( temp = 0; temp < MAX_TEMP; temp += temprange)
+ if (parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
+ parts[i].tmp = temp/100;
+ for (ny=-1; ny<2; ny++)
+ for (nx=-1; nx<2; nx++)
+ 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_NSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].ctype = PT_NSCN;
+ parts[r>>8].life = 4;
+ }
+ else if (parts[r>>8].type==PT_PSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].ctype = PT_PSCN;
+ parts[r>>8].life = 4;
+ }
+ else if (parts[r>>8].type==PT_INWR&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
+ {
+ parts[r>>8].type = PT_SPRK;
+ parts[r>>8].ctype = PT_INWR;
+ parts[r>>8].life = 4;
+ }
+ else if (parts[r>>8].type==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3 && !wireless[parts[i].tmp][0])
+ {
+ //parts[r>>8].type = parts[r>>8].ctype;
+ wireless[parts[i].tmp][0] = 1;
+ wireless[parts[i].tmp][1] = 1;
+ ISWIRE = 1;
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/yest.c b/src/elements/yest.c
new file mode 100644
index 0000000..26bbbe9
--- /dev/null
+++ b/src/elements/yest.c
@@ -0,0 +1,22 @@
+#include <powder.h>
+
+int update_YEST(UPDATE_FUNC_ARGS) {
+ int r;
+ 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_DYST && 1>(rand()%30) && !legacy_enable)
+ {
+ parts[i].type = PT_DYST;
+ }
+ }
+ if (parts[i].temp>303&&parts[i].temp<317) {
+ create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST);
+ }
+ return 0;
+}
diff --git a/src/powder.c b/src/powder.c
index 999cd20..7d87108 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -1374,29 +1374,6 @@ void update_particles_i(pixel *vid, int start, int inc)
pv[y/CELL+1][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL+1][x/CELL+1]);
}
}
- else if (t==PT_SING)
- {
- int singularity = -parts[i].life;
-
- if (pv[y/CELL][x/CELL]<singularity)
- pv[y/CELL][x/CELL] += 0.1f*(singularity-pv[y/CELL][x/CELL]);
- if (y+CELL<YRES && pv[y/CELL+1][x/CELL]<singularity)
- pv[y/CELL+1][x/CELL] += 0.1f*(singularity-pv[y/CELL+1][x/CELL]);
- if (x+CELL<XRES)
- {
- pv[y/CELL][x/CELL+1] += 0.1f*(singularity-pv[y/CELL][x/CELL+1]);
- if (y+CELL<YRES)
- pv[y/CELL+1][x/CELL+1] += 0.1f*(singularity-pv[y/CELL+1][x/CELL+1]);
- }
- if (y+CELL>0 && pv[y/CELL-1][x/CELL]<singularity)
- pv[y/CELL-1][x/CELL] += 0.1f*(singularity-pv[y/CELL-1][x/CELL]);
- if (x+CELL>0)
- {
- pv[y/CELL][x/CELL-1] += 0.1f*(singularity-pv[y/CELL][x/CELL-1]);
- if (y+CELL>0)
- pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]);
- }
- }
else
{
pv[y/CELL][x/CELL] += ptypes[t].hotair;
@@ -1604,17 +1581,6 @@ void update_particles_i(pixel *vid, int start, int inc)
t = PT_NEUT;
create_part(i, x, y, t);
}
- if ((t==PT_ISOZ||t==PT_ISZS) && 1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000))
- {
- t = PT_PHOT;
- rr = (rand()%228+128)/127.0f;
- rrr = (rand()%360)*3.14159f/180.0f;
- parts[i].life = 680;
- parts[i].ctype = 0x3FFFFFFF;
- parts[i].vx = rr*cosf(rrr);
- parts[i].vy = rr*sinf(rrr);
- create_part(i, x, y, t);
- }
if (!legacy_enable)
{
@@ -1854,22 +1820,6 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if (t==PT_YEST)
- {
- 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_DYST && 1>(rand()%30) && !legacy_enable)
- {
- t = parts[i].type = PT_DYST;
- }
- }
- }
else if (t==PT_NEUT)
{
rt = 3 + (int)pv[y/CELL][x/CELL];
@@ -2033,165 +1983,6 @@ void update_particles_i(pixel *vid, int start, int inc)
ISLOLZ=1;
else if (t==PT_GRAV)
ISGRAV=1;
-
- else if (t==PT_WARP)
- {
- for ( trade = 0; trade<5; trade ++)
- {
- nx = rand()%3-1;
- ny = rand()%3-1;
- 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_WARP&&parts[r>>8].type!=PT_STKM&&parts[r>>8].type!=PT_DMND&&parts[r>>8].type!=PT_CLNE&&parts[r>>8].type!=PT_BCLN&&parts[r>>8].type!=PT_PCLN&&(10>=rand()%200))
- {
- parts[i].x = parts[r>>8].x;
- parts[i].y = parts[r>>8].y;
- parts[r>>8].x = x;
- parts[r>>8].y = y;
- parts[i].life += 4;
- trade = 5;
- }
- }
- }
- }
- else if (t==PT_C5)
- {
- 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 ((parts[r>>8].temp<100 && parts[r>>8].type!=PT_C5)||parts[r>>8].type==PT_HFLM)
- {
- if (1>rand()%6)
- {
- t = parts[i].type = PT_HFLM;
- parts[r>>8].temp = parts[i].temp = 0;
- parts[i].life = rand()%150+50;
- pv[y/CELL][x/CELL] += 1.5;
- }
- }
- }
- }
- else if (t==PT_BOMB)
- {
- int nb;
- if (parts[i].tmp==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 (parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB) {
- parts[i].type = PT_NONE;
- goto killed;
- }
- }
- } else if (parts[i].tmp==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)
- {
- r = pmap[y+ny][x+nx];
- if ((r>>8)>=NPART || !r)
- continue;
- if (parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB && parts[r>>8].type!=PT_DMND && parts[r>>8].type!=PT_CLNE && parts[r>>8].type!=PT_PCLN && parts[r>>8].type!=PT_BCLN) {
- int rad = 8;
- int nxi;
- int nxj;
- pmap[y][x] = 0;
- for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
- for (nxi=-(rad+1); nxi<=(rad+1); nxi++)
- if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1) {
- nb = create_part(-1, x+nxi, y+nxj, PT_BOMB);
- if (nb!=-1) {
- parts[nb].tmp = 1;
- parts[nb].life = 50;
- parts[nb].temp = MAX_TEMP;
- parts[nb].vx = rand()%20-10;
- parts[nb].vy = rand()%20-10;
- }
- }
- for (nxj=-rad; nxj<=rad; nxj++)
- for (nxi=-rad; nxi<=rad; nxi++)
- if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1)
- if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) {
- delete_part(x+nxi, y+nxj);
- pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f;
- nb = create_part(-1, x+nxi, y+nxj, PT_BOMB);
- if (nb!=-1) {
- parts[nb].tmp = 2;
- parts[nb].life = 2;
- parts[nb].temp = MAX_TEMP;
- }
- }
- //create_parts(x, y, 9, 9, PT_BOMB);
- //create_parts(x, y, 8, 8, PT_NONE);
- parts[i].type = PT_NONE;
- goto killed;
- }
- }
- }
- }
- else if (t==PT_FWRK)
- {
- 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);
- r = pmap[y-1][x];
- if ((r&0xFF)==PT_FWRK)
- {
- parts[r>>8].vy = rand()%8-22;
- parts[r>>8].vx = rand()%20-rand()%20;
- parts[r>>8].life=rand()%15+25;
- t=parts[i].type=PT_NONE;
- }
- }
- if (parts[i].life>1)
- {
- if (parts[i].life>=45&&parts[i].type==PT_FWRK)
- parts[i].life=0;
- }
- if ((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0)
- {
- int q = (rand()%255+1);
- int w = (rand()%255+1);
- int e = (rand()%255+1);
- for (nx=-1; nx<2; nx++)
- for (ny=-2; ny<3; ny++)
- if (x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES)
- {
- if (5>=rand()%8)
- {
- if (!pmap[y+ny][x+nx])
- {
- 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)
- {
- 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;
- }
- }
- }
- }
- t=parts[i].type=PT_NONE;
- }
- }
else if (t==PT_FRZW)
{
for (nx=-1; nx<2; nx++)
@@ -2241,430 +2032,6 @@ void update_particles_i(pixel *vid, int start, int inc)
}
}
}
- else if (t==PT_PRTI)
- {
- int temprange = 100;
- int count =0;
- for ( temp = 0; temp < MAX_TEMP; temp += temprange)
- if (parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
- parts[i].tmp = temp/100;
- for (ny=-1; ny<2; ny++)
- for (nx=-1; nx<2; nx++)
- if (x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- count ++;
- r = pmap[y+ny][x+nx];
- if ((r>>8)>=NPART || !r)
- continue;
- if (parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)))
- for ( nnx=0; nnx<80; nnx++)
- if (!portal[parts[i].tmp][count-1][nnx])
- {
- portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type;
- portaltemp[parts[i].tmp][count-1][nnx] = parts[r>>8].temp;
- if (parts[r>>8].type==PT_SPRK)
- parts[r>>8].type = parts[r>>8].ctype;
- else
- parts[r>>8].type = PT_NONE;
- break;
- }
- }
- }
- else if (t==PT_PRTO)
- {
- int temprange = 100;
- int count = 0;
- for ( temp = 0; temp < MAX_TEMP; temp += temprange)
- if (parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
- parts[i].tmp = temp/100;
- for (ny=1; ny>-2; ny--)
- for (nx=1; nx>-2; nx--)
- if (x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
- {
- count ++;
- r = pmap[y+ny][x+nx];
- if ((r>>8)>=NPART || r)
- continue;
- if (!r)
- {
- for ( nnx =0 ; nnx<80; nnx++)
- {
- int randomness = count + rand()%3-1;
- if (randomness<1)
- randomness=1;
- if (randomness>8)
- randomness=8;
- if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)//todo. make it look better
- {
- create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x+1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x,y-1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x,y+1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x-1,y+1,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x-1,y,portal[parts[i].tmp][randomness-1][nnx]);
- create_part(-1,x-1,y-1,portal[parts[i].tmp][randomness-1][nnx]);
- portal[parts[i].tmp][randomness-1][nnx] = 0;
- portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
- break;
- }
- else if (portal[parts[i].tmp][randomness-1][nnx])
- {
- create_part(-1,x+nx,y+ny,portal[parts[i].tmp][randomness-1][nnx]);
- parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[parts[i].tmp][randomness-1][nnx];
- portal[parts[i].tmp][randomness-1][nnx] = 0;
- portaltemp[parts[i].tmp][randomness-1][nnx] = 0;
- break;
- }
- }
- }
- }
- }
- else if (t==PT_WIFI)
- {
- int temprange = 100;
- for ( temp = 0; temp < MAX_TEMP; temp += temprange)
- if (parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
- parts[i].tmp = temp/100;
- for (ny=-1; ny<2; ny++)
- for (nx=-1; nx<2; nx++)
- 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_NSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].ctype = PT_NSCN;
- parts[r>>8].life = 4;
- }
- else if (parts[r>>8].type==PT_PSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].ctype = PT_PSCN;
- parts[r>>8].life = 4;
- }
- else if (parts[r>>8].type==PT_INWR&&parts[r>>8].life==0 && wireless[parts[i].tmp][0])
- {
- parts[r>>8].type = PT_SPRK;
- parts[r>>8].ctype = PT_INWR;
- parts[r>>8].life = 4;
- }
- else if (parts[r>>8].type==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3 && !wireless[parts[i].tmp][0])
- {
- //parts[r>>8].type = parts[r>>8].ctype;
- wireless[parts[i].tmp][0] = 1;
- wireless[parts[i].tmp][1] = 1;
- ISWIRE = 1;
- }
- }
- }
- else if (t==PT_SHLD1)
- {
- 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;
- else if (parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for ( nnx=-1; nnx<2; nnx++)
- for ( nny=-1; nny<2; nny++)
- {
- if (7>rand()%200&&parts[i].life==0)
- {
- t = parts[i].type = PT_SHLD2;
- parts[i].life = 7;
- }
- else if (!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- else if (parts[r>>8].type==PT_SHLD3&&4>rand()%10)
- {
- t = parts[i].type=PT_SHLD2;
- parts[i].life = 7;
- }
- }
- }
- else if (t==PT_SHLD2)
- {
- 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)
- continue;
- if (!r && parts[i].life>0)
- create_part(-1,x+nx,y+ny,PT_SHLD1);
- if (!r)
- continue;
- else if (parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for ( nnx=-1; nnx<2; nnx++)
- for ( nny=-1; nny<2; nny++)
- {
- if (3>rand()%200&&parts[i].life==0)
- {
- t = parts[i].type = PT_SHLD3;
- parts[i].life = 7;
- }
- else if (!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- else if (parts[r>>8].type==PT_SHLD4&&4>rand()%10)
- {
- t = parts[i].type=PT_SHLD3;
- parts[i].life = 7;
- }
- }
- }
- else if (t==PT_SHLD3)
- {
- 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)
- continue;
- if (!r)
- {
- if (1>rand()%2500)
- {
- create_part(-1,x+nx,y+ny,PT_SHLD1);
- parts[pmap[y+ny][x+nx]>>8].life=7;
- t = parts[i].type = PT_SHLD2;
- }
- else
- continue;
-
- }
- if (parts[r>>8].type==PT_SHLD1 && parts[i].life>3)
- {
- parts[r>>8].type = PT_SHLD2;
- parts[r>>8].life=7;
- }
- else if (parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for ( nnx=-1; nnx<2; nnx++)
- for ( nny=-1; nny<2; nny++)
- {
- if (2>rand()%3000&&parts[i].life==0)
- {
- t = parts[i].type = PT_SHLD4;
- parts[i].life = 7;
- }
- else if (!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- }
- }
- else if (t==PT_SHLD4)
- {
- 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)
- continue;
- if (!r)
- {
- if (1>rand()%5500)
- {
- create_part(-1,x+nx,y+ny,PT_SHLD1);
- parts[pmap[y+ny][x+nx]>>8].life=7;
- t = parts[i].type = PT_SHLD2;
- }
- else
- continue;
-
- }
- if (parts[r>>8].type==PT_SHLD2 && parts[i].life>3)
- {
- parts[r>>8].type = PT_SHLD3;
- parts[r>>8].life = 7;
- }
- else if (parts[r>>8].type==PT_SPRK&&parts[i].life==0)
- for ( nnx=-1; nnx<2; nnx++)
- for ( nny=-1; nny<2; nny++)
- {
- if (!pmap[y+ny+nny][x+nx+nnx])
- {
- create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1);
- parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
- }
- }
- }
- }
- else if (t==PT_AMTR)
- {
- 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;
- rt = parts[r>>8].type;
- if ((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO)
- {
- t = parts[i].life++;
- if (parts[i].life==3)
- {
- parts[i].type = PT_NONE;
- kill_part(i);
- goto killed;
- }
- parts[r>>8].life = 0;
- parts[r>>8].type = PT_NONE;
- kill_part(r>>8);
- if (2>(rand()/(RAND_MAX/100)))
- create_part(-1, x+nx, y+ny, PT_PHOT);
- pv[y/CELL][x/CELL] -= 5.0f;
- //goto killed;
- }
- }
- }
- else if (t==PT_SING)
- {
- 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_DMND&&33>=rand()/(RAND_MAX/100)+1)
- {
- if (parts[r>>8].type==PT_SING && parts[r>>8].life >10)
- {
- if (parts[i].life+parts[r>>8].life > 255)
- continue;
- parts[i].life += parts[r>>8].life;
- }
- else
- {
- if (parts[i].life+3 > 255)
- {
- if (parts[r>>8].type!=PT_SING && 1>rand()%100)
- {
- parts[r>>8].type = PT_SING;
- parts[r>>8].life = rand()%50+60;
- }
- continue;
- }
- parts[i].life += 3;
- }
- parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP);
- parts[r>>8].type=PT_NONE;
- }
- }
- }
- else if (t==PT_FIRW) {
- if (parts[i].tmp==0) {
- 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;
- rt = parts[r>>8].type;
- if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR)
- {
- parts[i].tmp = 1;
- parts[i].life = rand()%50+60;
- }
- }
- }
- else if (parts[i].tmp==1) {
- if (parts[i].life==0) {
- parts[i].tmp=2;
- } else {
- float newVel = parts[i].life/25;
- parts[i].flags = parts[i].flags&0xFFFFFFFE;
- if ((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) {
- parts[i].vy = -newVel;
- ly-=newVel;
- iy-=newVel;
- }
- }
- }
- else if (parts[i].tmp==2) {
- int col = rand()%200+4;
- 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))
- {
- int tmul = rand()%7;
- create_part(-1, x+nx, y+ny, PT_FIRW);
- r = pmap[y+ny][x+nx];
- if ((r>>8)>=NPART || !r)
- continue;
- if (parts[r>>8].type==PT_FIRW) {
- parts[r>>8].vx = (rand()%3-1)*tmul;
- parts[r>>8].vy = (rand()%3-1)*tmul;
- parts[r>>8].tmp = col;
- parts[r>>8].life = rand()%100+100;
- parts[r>>8].temp = 6000.0f;
- }
- }
- }
- }
- pv[y/CELL][x/CELL] += 20;
- kill_part(i);
- goto killed;
- } else if (parts[i].tmp>=3) {
- if (parts[i].life<=0) {
- kill_part(i);
- goto killed;
- }
- }
- }
- else if (t==PT_BTRY)
- {
- rt = 3 + (int)pv[y/CELL][x/CELL];
- 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;
- rt = parts[r>>8].type;
- if (parts_avg(i,r>>8,PT_INSL) != PT_INSL)
- {
- if ((ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(nx)+abs(ny) < 4)
- {
- parts[r>>8].life = 4;
- parts[r>>8].ctype = rt;
- parts[r>>8].type = PT_SPRK;
- }
- }
- }
- }
else if (t==PT_LCRY&&parts[i].life==10)
{
for (nx=-1; nx<2; nx++)
@@ -2978,56 +2345,6 @@ killed:
if (parts[i].type == PT_NONE)
continue;
}
- if (t==PT_CLNE)
- {
- if (!parts[i].ctype)
- {
- 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 &&
- pmap[y+ny][x+nx] &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
- (pmap[y+ny][x+nx]&0xFF)!=0xFF)
- parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
- }
- else {
- create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
- }
-
- }
- if (t==PT_BCLN)
- {
- if (!parts[i].ctype)
- {
- 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 &&
- pmap[y+ny][x+nx] &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
- (pmap[y+ny][x+nx]&0xFF)!=0xFF)
- parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
- }
- else {
- create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
- }
-
- }
- if (t==PT_YEST)
- {
- if (parts[i].temp>303&&parts[i].temp<317) {
- create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST);
- }
- }
if (t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1)
{
parts[i].type = PT_NBLE;