summaryrefslogtreecommitdiff
path: root/src/powder.c
diff options
context:
space:
mode:
authorsavask <savask@yandex.ru>2011-08-29 16:47:22 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-26 14:31:55 (GMT)
commit00d604820d4900a422efd43dd3dd0a6f225e4adf (patch)
treec0c578eeffcfac21c440e9e00b09ce5ad1a88404 /src/powder.c
parentf8d54e66dba5d8448d30f61f84883b4e7e6e1087 (diff)
downloadpowder-00d604820d4900a422efd43dd3dd0a6f225e4adf.zip
powder-00d604820d4900a422efd43dd3dd0a6f225e4adf.tar.gz
Added fighters.
Diffstat (limited to 'src/powder.c')
-rw-r--r--src/powder.c64
1 files changed, 57 insertions, 7 deletions
diff --git a/src/powder.c b/src/powder.c
index bf31b18..e5680eb 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -16,6 +16,9 @@ int lighting_recreate = 0;
float player[29];
float player2[29];
+float fighters[256][28]; //255 is the maximum number of fighters
+unsigned char fighcount = 0; //Contains the number of fighters
+
particle *parts;
particle *cb_parts;
@@ -110,6 +113,7 @@ void init_can_move()
//all stickman collisions are done in stickman update function
can_move[PT_STKM][t] = 2;
can_move[PT_STKM2][t] = 2;
+ can_move[PT_FIGH][t] = 2;
}
for (t=0;t<PT_NUM;t++)
{
@@ -120,6 +124,7 @@ void init_can_move()
//all stickman collisions are done in stickman update function
can_move[t][PT_STKM] = 2;
can_move[t][PT_STKM2] = 2;
+ can_move[PT_FIGH][t] = 2;
//INVIS behaviour varies with pressure
can_move[t][PT_INVIS] = 3;
//stop CNCT being displaced by other particles
@@ -310,6 +315,11 @@ int try_move(int i, int x, int y, int nx, int ny)
{
player2[27] = 0;
}
+ if (parts[i].type == PT_FIGH)
+ {
+ fighters[(unsigned char)parts[i].tmp][27] = 0;
+ fighcount--;
+ }
parts[i].type=PT_NONE;
return 0;
}
@@ -323,6 +333,11 @@ int try_move(int i, int x, int y, int nx, int ny)
{
player2[27] = 0;
}
+ if (parts[i].type == PT_FIGH)
+ {
+ fighters[(unsigned char)parts[i].tmp][27] = 0;
+ fighcount--;
+ }
parts[i].type=PT_NONE;
if (!legacy_enable)
{
@@ -592,6 +607,11 @@ void kill_part(int i)//kills particle number i
{
player2[27] = 0;
}
+ if (parts[i].type == PT_FIGH)
+ {
+ fighters[(unsigned char)parts[i].tmp][27] = 0;
+ fighcount--;
+ }
if (parts[i].type == PT_SPAWN)
{
ISSPAWN1 = 0;
@@ -633,6 +653,12 @@ inline void part_change_type(int i, int x, int y, int t)//changes the type of pa
if (parts[i].type == PT_STKM2)
player2[27] = 0;
+ if (parts[i].type == PT_FIGH)
+ {
+ fighters[(unsigned char)parts[i].tmp][27] = 0;
+ fighcount--;
+ }
+
parts[i].type = t;
if (t==PT_PHOT || t==PT_NEUT)
{
@@ -761,7 +787,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{
if ((pmap[y][x]&0xFF)!=PT_SPAWN&&(pmap[y][x]&0xFF)!=PT_SPAWN2)
{
- if (t!=PT_STKM&&t!=PT_STKM2)
+ if (t!=PT_STKM&&t!=PT_STKM2&&t!=PT_FIGH)
{
return -1;
}
@@ -787,7 +813,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
t!=PT_CLNE&&t!=PT_PCLN&&
t!=PT_BCLN&&t!=PT_STKM&&
t!=PT_STKM2&&t!=PT_PBCN&&
- t!=PT_STOR)
+ t!=PT_STOR&&t!=PT_FIGH)
)
{
parts[pmap[y][x]>>8].ctype = t;
@@ -836,7 +862,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
parts[i].pavg[0] = 0.0f;
parts[i].pavg[1] = 0.0f;
}
- if (t!=PT_STKM&&t!=PT_STKM2)//set everything to default values first, except for stickman.
+ if (t!=PT_STKM&&t!=PT_STKM2&&t!=PT_FIGH)//set everything to default values first, except for stickman.
{
parts[i].x = (float)x;
parts[i].y = (float)y;
@@ -1003,12 +1029,36 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
create_part(-1,x,y,PT_SPAWN2);
ISSPAWN2 = 1;
}
+ if (t==PT_FIGH)
+ {
+ unsigned char cunt = 0;
+ while (cunt < 100 && cunt < (fighcount+1) && fighters[cunt][27]==1) cunt++;
+ if (cunt < 100 && fighters[cunt][27]==0)
+ {
+ parts[i].x = (float)x;
+ parts[i].y = (float)y;
+ parts[i].type = PT_FIGH;
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ parts[i].life = 100;
+ parts[i].ctype = 0;
+ parts[i].tmp = cunt;
+ parts[i].temp = ptypes[t].heat;
+ STKM_init_legs(fighters[cunt], i);
+ fighters[cunt][27] = 1;
+ fighters[cunt][2] = PT_DUST;
+ fighcount++;
+
+ return i;
+ }
+ return -1;
+ }
if (t==PT_BIZR||t==PT_BIZRG)
parts[i].ctype = 0x47FFFF;
//and finally set the pmap/photon maps to the newly created particle
if (t==PT_PHOT||t==PT_NEUT)
photons[y][x] = t|(i<<8);
- if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && t!=PT_NEUT)
+ if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_FIGH && t!=PT_PHOT && t!=PT_NEUT)
pmap[y][x] = t|(i<<8);
//Fancy dust effects for powder types
@@ -1674,7 +1724,7 @@ void update_particles_i(pixel *vid, int start, int inc)
(bmap[y/CELL][x/CELL]==WL_ALLOWGAS && !(ptypes[t].properties&TYPE_GAS)) || //&& ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_HFLM) ||
(bmap[y/CELL][x/CELL]==WL_ALLOWENERGY && !(ptypes[t].properties&TYPE_ENERGY)) ||
(bmap[y/CELL][x/CELL]==WL_DETECT && (t==PT_METL || t==PT_SPRK)) ||
- (bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM) && (t!=PT_STKM2)))
+ (bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM) && (t!=PT_STKM2) && (t!=PT_FIGH)))
{
kill_part(i);
continue;
@@ -1736,7 +1786,7 @@ void update_particles_i(pixel *vid, int start, int inc)
pGravX -= gravxf[(y*XRES)+x];
pGravY -= gravyf[(y*XRES)+x];
}
- else if(t!=PT_STKM && t!=PT_STKM2 && !(ptypes[t].properties & TYPE_SOLID))
+ else if(t!=PT_STKM && t!=PT_STKM2 && t!=PT_FIGH && !(ptypes[t].properties & TYPE_SOLID))
{
pGravX += gravxf[(y*XRES)+x];
pGravY += gravyf[(y*XRES)+x];
@@ -2838,7 +2888,7 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p;//n;
int wall = c - 100;
- if (c==SPC_WIND){
+ if (c==SPC_WIND || c==PT_FIGH)
return 0;
}
if(c==SPC_PROP){