summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-08-19 23:14:38 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-20 10:29:02 (GMT)
commita96afc863e814e0652e184614feda4d969ec2f94 (patch)
tree4183083f1cc8cbe6f7b3fba1680627b6ffef1410 /src/elements
parent7d283335d4e0a84c191314c299af70152eec9a77 (diff)
downloadpowder-a96afc863e814e0652e184614feda4d969ec2f94.zip
powder-a96afc863e814e0652e184614feda4d969ec2f94.tar.gz
Stickman go through portals
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/prto.c4
-rw-r--r--src/elements/stkm.c102
2 files changed, 74 insertions, 32 deletions
diff --git a/src/elements/prto.c b/src/elements/prto.c
index 4b6a576..38718a5 100644
--- a/src/elements/prto.c
+++ b/src/elements/prto.c
@@ -49,6 +49,10 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
}
else if (portalp[parts[i].tmp][randomness-1][nnx].type)
{
+ if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_STKM)
+ player[27] = 0;
+ if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_STKM2)
+ player2[27] = 0;
np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness-1][nnx].type);
if (np<0) continue;
parts[np] = portalp[parts[i].tmp][randomness-1][nnx];
diff --git a/src/elements/stkm.c b/src/elements/stkm.c
index 89bcd0e..4b43f57 100644
--- a/src/elements/stkm.c
+++ b/src/elements/stkm.c
@@ -215,6 +215,10 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
}
if (bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN)
playerp[2] = SPC_AIR;
+ if ((r&0xFF)==PT_PRTI)
+ STKM_interact(playerp, i, rx, ry);
+ if (!parts[i].type)//STKM_interact may kill STKM
+ return 1;
}
//Head position
@@ -352,48 +356,82 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
}
//If legs touch something
- r = pmap[(int)(playerp[8]+0.5)][(int)(playerp[7]+0.5)];
- if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
- {
- parts[i].life -= (int)(rand()/1000)+38;
- }
+ STKM_interact(playerp, i, (int)(playerp[7]+0.5), (int)(playerp[8]+0.5));
+ STKM_interact(playerp, i, (int)(playerp[15]+0.5), (int)(playerp[16]+0.5));
+ if (!parts[i].type)
+ return 1;
+
+ parts[i].ctype = playerp[2];
+ return 0;
+}
- if (r>0 && (r>>8)<NPART)
+void STKM_interact(float* playerp, int i, int x, int y)
+{
+ int r;
+ if (x<0 || y<0 || x>=XRES || y>=YRES || !parts[i].type)
+ return;
+ r = pmap[y][x];
+ if (r && (r>>8)<NPART)
{
- if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243) //If hot or cold
+ if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
{
- parts[i].life -= 2;
- playerp[26] -= 1;
+ parts[i].life -= (int)(rand()*20/RAND_MAX)+32;
}
- }
- if ((r&0xFF)==PT_ACID) //If on acid
- parts[i].life -= 5;
-
- if ((r&0xFF)==PT_PLUT) //If on plut
- parts[i].life -= 1;
-
- r = pmap[(int)(playerp[16]+0.5)][(int)(playerp[15]+0.5)];
- if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
- {
- parts[i].life -= (int)(rand()/1000)+38;
- }
-
- if (r>0 && (r>>8)<NPART) //If hot or cold
- {
- if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
+ if (ptypes[r&0xFF].hconduct && (parts[r>>8].temp>=323 || parts[r>>8].temp<=243))
{
parts[i].life -= 2;
playerp[22] -= 1;
}
- }
- if ((r&0xFF)==PT_ACID) //If on acid
- parts[i].life -= 5;
+ if ((r&0xFF)==PT_ACID) //If on acid
+ parts[i].life -= 5;
- if ((r&0xFF)==PT_PLUT) //If on plut
- parts[i].life -= 1;
+ if ((r&0xFF)==PT_PLUT) //If on plut
+ parts[i].life -= 1;
- parts[i].ctype = playerp[2];
- return 0;
+ if ((r&0xFF)==PT_PRTI && parts[i].type)
+ {
+ int nnx, count;
+ parts[r>>8].tmp = (int)((parts[r>>8].temp-73.15f)/100+1);
+ if (parts[r>>8].tmp>=CHANNELS) parts[r>>8].tmp = CHANNELS-1;
+ else if (parts[r>>8].tmp<0) parts[r>>8].tmp = 0;
+ for (count=1; count<=8; count++)
+ for (nnx=0; nnx<80; nnx++)
+ if (!portalp[parts[r>>8].tmp][count-1][nnx].type)
+ {
+ portalp[parts[r>>8].tmp][count-1][nnx] = parts[i];
+ kill_part(i);
+ playerp[27] = 1;//stop SPWN creating a new STKM while he is in portal
+ }
+ }
+ }
+}
+
+void STKM_init_legs(float* playerp, int i)
+{
+ int x, y;
+
+ x = (int)(parts[i].x+0.5f);
+ y = (int)(parts[i].y+0.5f);
+
+ player[3] = x-1;
+ player[4] = y+6;
+ player[5] = x-1;
+ player[6] = y+6;
+
+ player[7] = x-3;
+ player[8] = y+12;
+ player[9] = x-3;
+ player[10] = y+12;
+
+ player[11] = x+1;
+ player[12] = y+6;
+ player[13] = x+1;
+ player[14] = y+6;
+
+ player[15] = x+3;
+ player[16] = y+12;
+ player[17] = x+3;
+ player[18] = y+12;
}