Clean up code related to forcefield player damage etc.

git-svn-id: https://svn.eduke32.com/eduke32@4221 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-12-26 19:45:14 +00:00
parent d26ae58627
commit 46ec5c4146
4 changed files with 87 additions and 78 deletions

View file

@ -3322,6 +3322,17 @@ void P_CheckWeaponI(int32_t snum)
} }
#endif #endif
static void DoWallTouchDamage(const DukePlayer_t *p, int32_t obj)
{
vec3_t davect;
davect.x = p->pos.x + (sintable[(p->ang+512)&2047]>>9);
davect.y = p->pos.y + (sintable[p->ang&2047]>>9);
davect.z = p->pos.z;
A_DamageWall(p->i, obj, &davect, -1);
}
static void P_CheckTouchDamage(DukePlayer_t *p, int32_t obj) static void P_CheckTouchDamage(DukePlayer_t *p, int32_t obj)
{ {
if ((obj = VM_OnEvent(EVENT_CHECKTOUCHDAMAGE, p->i, sprite[p->i].yvel, -1, obj)) == -1) if ((obj = VM_OnEvent(EVENT_CHECKTOUCHDAMAGE, p->i, sprite[p->i].yvel, -1, obj)) == -1)
@ -3329,7 +3340,7 @@ static void P_CheckTouchDamage(DukePlayer_t *p, int32_t obj)
if ((obj&49152) == 49152) if ((obj&49152) == 49152)
{ {
obj &= (MAXSPRITES-1); obj &= MAXSPRITES-1;
if (sprite[obj].picnum == CACTUS) if (sprite[obj].picnum == CACTUS)
{ {
@ -3345,21 +3356,22 @@ static void P_CheckTouchDamage(DukePlayer_t *p, int32_t obj)
return; return;
} }
if ((obj&49152) != 32768) return; if ((obj&49152) != 32768)
return;
obj &= (MAXWALLS-1); obj &= (MAXWALLS-1);
if (p->hurt_delay > 0) p->hurt_delay--; if (p->hurt_delay > 0)
else if (wall[obj].cstat&85)
{ {
int32_t switchpicnum = wall[obj].overpicnum; p->hurt_delay--;
if (switchpicnum>W_FORCEFIELD && switchpicnum<=W_FORCEFIELD+2) }
switchpicnum=W_FORCEFIELD; else if (wall[obj].cstat & FORCEFIELD_CSTAT)
{
int32_t switchpicnum = G_GetForcefieldPicnum(obj);
switch (DYNAMICTILEMAP(switchpicnum)) switch (DYNAMICTILEMAP(switchpicnum))
{ {
case W_FORCEFIELD__STATIC: case W_FORCEFIELD__STATIC:
// case W_FORCEFIELD+1:
// case W_FORCEFIELD+2:
sprite[p->i].extra -= 5; sprite[p->i].extra -= 5;
p->hurt_delay = 16; p->hurt_delay = 16;
@ -3369,29 +3381,13 @@ static void P_CheckTouchDamage(DukePlayer_t *p, int32_t obj)
p->vel.y = -(sintable[(p->ang)&2047]<<8); p->vel.y = -(sintable[(p->ang)&2047]<<8);
A_PlaySound(DUKE_LONGTERM_PAIN,p->i); A_PlaySound(DUKE_LONGTERM_PAIN,p->i);
{ DoWallTouchDamage(p, obj);
vec3_t davect;
davect.x = p->pos.x+(sintable[(p->ang+512)&2047]>>9);
davect.y = p->pos.y+(sintable[p->ang&2047]>>9);
davect.z = p->pos.z;
A_DamageWall(p->i,obj,&davect,-1);
}
break; break;
case BIGFORCE__STATIC: case BIGFORCE__STATIC:
p->hurt_delay = GAMETICSPERSEC; p->hurt_delay = GAMETICSPERSEC;
{ DoWallTouchDamage(p, obj);
vec3_t davect;
davect.x = p->pos.x+(sintable[(p->ang+512)&2047]>>9);
davect.y = p->pos.y+(sintable[p->ang&2047]>>9);
davect.z = p->pos.z;
A_DamageWall(p->i,obj,&davect,-1);
}
break; break;
} }
} }
} }

View file

@ -1239,11 +1239,7 @@ static inline void prelevel(char g)
animwall[g_numAnimWalls].tag = 0; animwall[g_numAnimWalls].tag = 0;
animwall[g_numAnimWalls].wallnum = 0; animwall[g_numAnimWalls].wallnum = 0;
switchpicnum = wal->overpicnum; switchpicnum = G_GetForcefieldPicnum(i);
if (wal->overpicnum > W_FORCEFIELD && wal->overpicnum <= W_FORCEFIELD+2)
{
switchpicnum = W_FORCEFIELD;
}
if (switchpicnum >= 0) if (switchpicnum >= 0)
{ {
@ -1262,7 +1258,7 @@ static inline void prelevel(char g)
tloadtile(W_FORCEFIELD+j, 0); tloadtile(W_FORCEFIELD+j, 0);
if (wal->shade > 31) if (wal->shade > 31)
wal->cstat = 0; wal->cstat = 0;
else wal->cstat |= 85+256; else wal->cstat |= FORCEFIELD_CSTAT|256;
if (wal->lotag && wal->nextwall >= 0) if (wal->lotag && wal->nextwall >= 0)

View file

@ -432,8 +432,7 @@ void G_AnimateWalls(void)
} }
if (wall[i].cstat&16) if ((wall[i].cstat&16) && G_GetForcefieldPicnum(i)==W_FORCEFIELD)
if (wall[i].overpicnum >= W_FORCEFIELD && wall[i].overpicnum <= W_FORCEFIELD+2)
{ {
t = animwall[p].tag; t = animwall[p].tag;
@ -463,7 +462,6 @@ void G_AnimateWalls(void)
else wall[i].overpicnum = W_FORCEFIELD+1; else wall[i].overpicnum = W_FORCEFIELD+1;
} }
} }
} }
} }
} }
@ -1108,7 +1106,7 @@ void G_OperateForceFields(int32_t s, int32_t low)
i = animwall[p].wallnum; i = animwall[p].wallnum;
if (low == wall[i].lotag || low == -1) if (low == wall[i].lotag || low == -1)
if (((wall[i].overpicnum >= W_FORCEFIELD) && (wall[i].overpicnum <= W_FORCEFIELD+2)) if (G_GetForcefieldPicnum(i) == W_FORCEFIELD
|| (wall[i].overpicnum == BIGFORCE)) || (wall[i].overpicnum == BIGFORCE))
{ {
animwall[p].tag = 0; animwall[p].tag = 0;
@ -1121,7 +1119,7 @@ void G_OperateForceFields(int32_t s, int32_t low)
wall[i].lotag = 0; wall[i].lotag = 0;
} }
else else
wall[i].cstat = 85; wall[i].cstat = FORCEFIELD_CSTAT;
} }
} }
} }
@ -1663,23 +1661,30 @@ void A_DamageWall(int32_t spr,int32_t dawallnum,const vec3_t *pos,int32_t atwith
int32_t switchpicnum = wal->overpicnum; int32_t switchpicnum = wal->overpicnum;
if (switchpicnum > W_FORCEFIELD && switchpicnum <= W_FORCEFIELD+2) if (switchpicnum > W_FORCEFIELD && switchpicnum <= W_FORCEFIELD+2)
switchpicnum = W_FORCEFIELD; switchpicnum = W_FORCEFIELD;
switch (DYNAMICTILEMAP(switchpicnum)) switch (DYNAMICTILEMAP(switchpicnum))
{ {
case W_FORCEFIELD__STATIC: case W_FORCEFIELD__STATIC:
//case W_FORCEFIELD+1:
//case W_FORCEFIELD+2:
wal->extra = 1; // tell the forces to animate wal->extra = 1; // tell the forces to animate
/* fall-through */
case BIGFORCE__STATIC: case BIGFORCE__STATIC:
updatesector(pos->x, pos->y, &sn); updatesector(pos->x, pos->y, &sn);
if (sn < 0) return; if (sn < 0)
return;
{
int32_t xr=32, yr=32;
if (atwith == -1) if (atwith == -1)
i = A_InsertSprite(sn,pos->x,pos->y,pos->z,FORCERIPPLE,-127,8,8,0,0,0,spr,5); xr = yr = 8;
else else if (atwith == CHAINGUN)
{ {
if (atwith == CHAINGUN) xr = 16+sprite[spr].xrepeat;
i = A_InsertSprite(sn,pos->x,pos->y,pos->z,FORCERIPPLE,-127,16+sprite[spr].xrepeat,16+sprite[spr].yrepeat,0,0,0,spr,5); yr = 16+sprite[spr].yrepeat;
else i = A_InsertSprite(sn,pos->x,pos->y,pos->z,FORCERIPPLE,-127,32,32,0,0,0,spr,5); }
i = A_InsertSprite(sn, pos->x,pos->y,pos->z, FORCERIPPLE,
-127, xr,yr, 0,0,0,spr,5);
} }
CS |= 18+128; CS |= 18+128;
@ -1687,7 +1692,6 @@ void A_DamageWall(int32_t spr,int32_t dawallnum,const vec3_t *pos,int32_t atwith
wal->y-wall[wal->point2].y)-512; wal->y-wall[wal->point2].y)-512;
A_PlaySound(SOMETHINGHITFORCE,i); A_PlaySound(SOMETHINGHITFORCE,i);
return; return;
case FANSPRITE__STATIC: case FANSPRITE__STATIC:
@ -1718,9 +1722,11 @@ void A_DamageWall(int32_t spr,int32_t dawallnum,const vec3_t *pos,int32_t atwith
T3 = dawallnum; T3 = dawallnum;
A_PlaySound(GLASS_BREAKING,i); A_PlaySound(GLASS_BREAKING,i);
return; return;
case STAINGLASS1__STATIC: case STAINGLASS1__STATIC:
updatesector(pos->x,pos->y,&sn); updatesector(pos->x,pos->y,&sn);
if (sn < 0) return; if (sn < 0)
return;
A_SpawnRandomGlass(spr,dawallnum,80); A_SpawnRandomGlass(spr,dawallnum,80);
wal->cstat = 0; wal->cstat = 0;
if (wal->nextwall >= 0) if (wal->nextwall >= 0)

View file

@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "gamevars.h" #include "gamevars.h"
#include "actors.h" // actor_t #include "actors.h" // actor_t
#include "player.h" // playerspawn_t #include "player.h" // playerspawn_t
#include "namesdyn.h" // for G_GetForcefieldPicnum()
#define MAXCYCLERS 1024 #define MAXCYCLERS 1024
#define MAXANIMATES 256 #define MAXANIMATES 256
@ -131,6 +131,17 @@ void P_CheckSectors(int32_t snum);
int32_t Sect_DamageCeilingOrFloor(int32_t floorp, int32_t sn); int32_t Sect_DamageCeilingOrFloor(int32_t floorp, int32_t sn);
int32_t SetAnimation(int32_t animsect,int32_t *animptr,int32_t thegoal,int32_t thevel); int32_t SetAnimation(int32_t animsect,int32_t *animptr,int32_t thegoal,int32_t thevel);
#define FORCEFIELD_CSTAT (64+16+4+1)
// Returns W_FORCEFIELD if wall has a forcefield overpicnum, its overpicnum else.
static inline int32_t G_GetForcefieldPicnum(int32_t wallnum)
{
int32_t picnum = wall[wallnum].overpicnum;
if (picnum > W_FORCEFIELD && picnum <= W_FORCEFIELD+2)
picnum = W_FORCEFIELD;
return picnum;
}
#include "sector_inline.h" #include "sector_inline.h"
#endif #endif