Added fighters.

This commit is contained in:
savask 2011-08-29 23:47:22 +07:00 committed by Simon Robertshaw
parent f8d54e66db
commit 00d604820d
5 changed files with 727 additions and 552 deletions

View File

@ -210,7 +210,8 @@
#define PT_CLST 155 #define PT_CLST 155
#define PT_WIRE 156 #define PT_WIRE 156
#define PT_GBMB 157 #define PT_GBMB 157
#define PT_NUM 158 #define PT_FIGH 158
#define PT_NUM 159
#define R_TEMP 22 #define R_TEMP 22
#define MAX_TEMP 9999 #define MAX_TEMP 9999
@ -327,6 +328,7 @@ int update_CLST(UPDATE_FUNC_ARGS);
int update_DLAY(UPDATE_FUNC_ARGS); int update_DLAY(UPDATE_FUNC_ARGS);
int update_WIRE(UPDATE_FUNC_ARGS); int update_WIRE(UPDATE_FUNC_ARGS);
int update_GBMB(UPDATE_FUNC_ARGS); int update_GBMB(UPDATE_FUNC_ARGS);
int update_FIGH(UPDATE_FUNC_ARGS);
int update_CO2(UPDATE_FUNC_ARGS); int update_CO2(UPDATE_FUNC_ARGS);
int update_CBNW(UPDATE_FUNC_ARGS); int update_CBNW(UPDATE_FUNC_ARGS);
int update_STOR(UPDATE_FUNC_ARGS); int update_STOR(UPDATE_FUNC_ARGS);
@ -574,6 +576,7 @@ static const part_type ptypes[PT_NUM] =
{"CLST", PIXPACK(0xE4A4A4), 0.7f, 0.02f * CFDS, 0.94f, 0.95f, 0.0f, 0.2f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 1, 55, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Clay dust. Produces paste when mixed with water.", ST_SOLID, TYPE_PART, &update_CLST}, {"CLST", PIXPACK(0xE4A4A4), 0.7f, 0.02f * CFDS, 0.94f, 0.95f, 0.0f, 0.2f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 1, 55, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Clay dust. Produces paste when mixed with water.", ST_SOLID, TYPE_PART, &update_CLST},
{"WIRE", PIXPACK(0xFFCC00), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 250, "WireWorld wires.",ST_SOLID,TYPE_SOLID,&update_WIRE}, {"WIRE", PIXPACK(0xFFCC00), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 250, "WireWorld wires.",ST_SOLID,TYPE_SOLID,&update_WIRE},
{"GBMB", PIXPACK(0x1144BB), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Sticks to first object it touches then produces strong gravity push.", ST_NONE, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_GBMB}, {"GBMB", PIXPACK(0x1144BB), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Sticks to first object it touches then produces strong gravity push.", ST_NONE, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_GBMB},
{"FIGH", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Fighter. Tries to kill stickmans.", ST_NONE, 0, &update_FIGH},
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description
}; };
@ -747,6 +750,7 @@ static part_transition ptransitions[PT_NUM] =
/* CLST */ {IPL, NT, IPH, NT, ITL, NT, 1256.0f, PT_LAVA}, /* CLST */ {IPL, NT, IPH, NT, ITL, NT, 1256.0f, PT_LAVA},
/* WIRE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* WIRE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GBMB */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* GBMB */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* FIGH */ {IPL, NT, IPH, NT, ITL, NT, 620.0f, PT_FIRE},
}; };
#undef IPL #undef IPL
#undef IPH #undef IPH
@ -977,6 +981,9 @@ extern int gravwl_timeout;
extern float player[29]; extern float player[29];
extern float player2[29]; extern float player2[29];
extern float fighters[256][28];
extern unsigned char fighcount;
extern int gravityMode; extern int gravityMode;
extern int airMode; extern int airMode;

7
src/elements/figh.c Normal file
View File

@ -0,0 +1,7 @@
#include <element.h>
int update_FIGH(UPDATE_FUNC_ARGS)
{
run_stickman(fighters[(unsigned char)parts[i].tmp], UPDATE_FUNC_SUBCALL_ARGS);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1113,6 +1113,8 @@ void clear_sim(void)
memset(wireless, 0, sizeof(wireless)); memset(wireless, 0, sizeof(wireless));
memset(gol2, 0, sizeof(gol2)); memset(gol2, 0, sizeof(gol2));
memset(portalp, 0, sizeof(portalp)); memset(portalp, 0, sizeof(portalp));
memset(fighters, 0, sizeof(fighters));
fighcount = 0;
ISSPAWN1 = ISSPAWN2 = 0; ISSPAWN1 = ISSPAWN2 = 0;
player[27] = 0; player[27] = 0;
player2[27] = 0; player2[27] = 0;
@ -3115,7 +3117,7 @@ int main(int argc, char *argv[])
c = (b&1) ? sl : sr; //c is element to be spawned c = (b&1) ? sl : sr; //c is element to be spawned
su = c; su = c;
if (c!=WL_SIGN+100) if (c!=WL_SIGN+100 && c!=PT_FIGH)
{ {
if (!bq) if (!bq)
for (signi=0; signi<MAXSIGNS; signi++) for (signi=0; signi<MAXSIGNS; signi++)
@ -3144,6 +3146,12 @@ int main(int argc, char *argv[])
if (!bq) if (!bq)
add_sign_ui(vid_buf, x, y); add_sign_ui(vid_buf, x, y);
} }
if (c==PT_FIGH)
{
if (!bq)
create_part(-1, x, y, PT_FIGH);
}
//for the click functions, lx and ly, are the positions of where the FIRST click happened. x,y are current mouse position. //for the click functions, lx and ly, are the positions of where the FIRST click happened. x,y are current mouse position.
else if (lb)//lb means you are holding mouse down else if (lb)//lb means you are holding mouse down
{ {

View File

@ -16,6 +16,9 @@ int lighting_recreate = 0;
float player[29]; float player[29];
float player2[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 *parts;
particle *cb_parts; particle *cb_parts;
@ -110,6 +113,7 @@ void init_can_move()
//all stickman collisions are done in stickman update function //all stickman collisions are done in stickman update function
can_move[PT_STKM][t] = 2; can_move[PT_STKM][t] = 2;
can_move[PT_STKM2][t] = 2; can_move[PT_STKM2][t] = 2;
can_move[PT_FIGH][t] = 2;
} }
for (t=0;t<PT_NUM;t++) for (t=0;t<PT_NUM;t++)
{ {
@ -120,6 +124,7 @@ void init_can_move()
//all stickman collisions are done in stickman update function //all stickman collisions are done in stickman update function
can_move[t][PT_STKM] = 2; can_move[t][PT_STKM] = 2;
can_move[t][PT_STKM2] = 2; can_move[t][PT_STKM2] = 2;
can_move[PT_FIGH][t] = 2;
//INVIS behaviour varies with pressure //INVIS behaviour varies with pressure
can_move[t][PT_INVIS] = 3; can_move[t][PT_INVIS] = 3;
//stop CNCT being displaced by other particles //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; player2[27] = 0;
} }
if (parts[i].type == PT_FIGH)
{
fighters[(unsigned char)parts[i].tmp][27] = 0;
fighcount--;
}
parts[i].type=PT_NONE; parts[i].type=PT_NONE;
return 0; return 0;
} }
@ -323,6 +333,11 @@ int try_move(int i, int x, int y, int nx, int ny)
{ {
player2[27] = 0; player2[27] = 0;
} }
if (parts[i].type == PT_FIGH)
{
fighters[(unsigned char)parts[i].tmp][27] = 0;
fighcount--;
}
parts[i].type=PT_NONE; parts[i].type=PT_NONE;
if (!legacy_enable) if (!legacy_enable)
{ {
@ -592,6 +607,11 @@ void kill_part(int i)//kills particle number i
{ {
player2[27] = 0; player2[27] = 0;
} }
if (parts[i].type == PT_FIGH)
{
fighters[(unsigned char)parts[i].tmp][27] = 0;
fighcount--;
}
if (parts[i].type == PT_SPAWN) if (parts[i].type == PT_SPAWN)
{ {
ISSPAWN1 = 0; 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) if (parts[i].type == PT_STKM2)
player2[27] = 0; player2[27] = 0;
if (parts[i].type == PT_FIGH)
{
fighters[(unsigned char)parts[i].tmp][27] = 0;
fighcount--;
}
parts[i].type = t; parts[i].type = t;
if (t==PT_PHOT || t==PT_NEUT) 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 ((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; 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_CLNE&&t!=PT_PCLN&&
t!=PT_BCLN&&t!=PT_STKM&& t!=PT_BCLN&&t!=PT_STKM&&
t!=PT_STKM2&&t!=PT_PBCN&& t!=PT_STKM2&&t!=PT_PBCN&&
t!=PT_STOR) t!=PT_STOR&&t!=PT_FIGH)
) )
{ {
parts[pmap[y][x]>>8].ctype = t; 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[0] = 0.0f;
parts[i].pavg[1] = 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].x = (float)x;
parts[i].y = (float)y; 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); create_part(-1,x,y,PT_SPAWN2);
ISSPAWN2 = 1; 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) if (t==PT_BIZR||t==PT_BIZRG)
parts[i].ctype = 0x47FFFF; parts[i].ctype = 0x47FFFF;
//and finally set the pmap/photon maps to the newly created particle //and finally set the pmap/photon maps to the newly created particle
if (t==PT_PHOT||t==PT_NEUT) if (t==PT_PHOT||t==PT_NEUT)
photons[y][x] = t|(i<<8); 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); pmap[y][x] = t|(i<<8);
//Fancy dust effects for powder types //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_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_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_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); kill_part(i);
continue; continue;
@ -1736,7 +1786,7 @@ void update_particles_i(pixel *vid, int start, int inc)
pGravX -= gravxf[(y*XRES)+x]; pGravX -= gravxf[(y*XRES)+x];
pGravY -= gravyf[(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]; pGravX += gravxf[(y*XRES)+x];
pGravY += gravyf[(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 i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p;//n;
int wall = c - 100; int wall = c - 100;
if (c==SPC_WIND){ if (c==SPC_WIND || c==PT_FIGH)
return 0; return 0;
} }
if(c==SPC_PROP){ if(c==SPC_PROP){