mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 01:11:44 +00:00
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:
parent
d26ae58627
commit
46ec5c4146
4 changed files with 87 additions and 78 deletions
|
@ -3322,6 +3322,17 @@ void P_CheckWeaponI(int32_t snum)
|
|||
}
|
||||
#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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
obj &= (MAXSPRITES-1);
|
||||
obj &= MAXSPRITES-1;
|
||||
|
||||
if (sprite[obj].picnum == CACTUS)
|
||||
{
|
||||
|
@ -3339,27 +3350,28 @@ static void P_CheckTouchDamage(DukePlayer_t *p, int32_t obj)
|
|||
|
||||
p->hurt_delay = 16;
|
||||
P_PalFrom(p, 32, 32,0,0);
|
||||
A_PlaySound(DUKE_LONGTERM_PAIN,p->i);
|
||||
A_PlaySound(DUKE_LONGTERM_PAIN, p->i);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((obj&49152) != 32768) return;
|
||||
if ((obj&49152) != 32768)
|
||||
return;
|
||||
|
||||
obj &= (MAXWALLS-1);
|
||||
|
||||
if (p->hurt_delay > 0) p->hurt_delay--;
|
||||
else if (wall[obj].cstat&85)
|
||||
if (p->hurt_delay > 0)
|
||||
{
|
||||
int32_t switchpicnum = wall[obj].overpicnum;
|
||||
if (switchpicnum>W_FORCEFIELD && switchpicnum<=W_FORCEFIELD+2)
|
||||
switchpicnum=W_FORCEFIELD;
|
||||
p->hurt_delay--;
|
||||
}
|
||||
else if (wall[obj].cstat & FORCEFIELD_CSTAT)
|
||||
{
|
||||
int32_t switchpicnum = G_GetForcefieldPicnum(obj);
|
||||
|
||||
switch (DYNAMICTILEMAP(switchpicnum))
|
||||
{
|
||||
case W_FORCEFIELD__STATIC:
|
||||
// case W_FORCEFIELD+1:
|
||||
// case W_FORCEFIELD+2:
|
||||
sprite[p->i].extra -= 5;
|
||||
|
||||
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);
|
||||
A_PlaySound(DUKE_LONGTERM_PAIN,p->i);
|
||||
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
DoWallTouchDamage(p, obj);
|
||||
break;
|
||||
|
||||
case BIGFORCE__STATIC:
|
||||
p->hurt_delay = GAMETICSPERSEC;
|
||||
{
|
||||
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);
|
||||
}
|
||||
DoWallTouchDamage(p, obj);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1239,11 +1239,7 @@ static inline void prelevel(char g)
|
|||
animwall[g_numAnimWalls].tag = 0;
|
||||
animwall[g_numAnimWalls].wallnum = 0;
|
||||
|
||||
switchpicnum = wal->overpicnum;
|
||||
if (wal->overpicnum > W_FORCEFIELD && wal->overpicnum <= W_FORCEFIELD+2)
|
||||
{
|
||||
switchpicnum = W_FORCEFIELD;
|
||||
}
|
||||
switchpicnum = G_GetForcefieldPicnum(i);
|
||||
|
||||
if (switchpicnum >= 0)
|
||||
{
|
||||
|
@ -1262,7 +1258,7 @@ static inline void prelevel(char g)
|
|||
tloadtile(W_FORCEFIELD+j, 0);
|
||||
if (wal->shade > 31)
|
||||
wal->cstat = 0;
|
||||
else wal->cstat |= 85+256;
|
||||
else wal->cstat |= FORCEFIELD_CSTAT|256;
|
||||
|
||||
|
||||
if (wal->lotag && wal->nextwall >= 0)
|
||||
|
|
|
@ -432,43 +432,41 @@ void G_AnimateWalls(void)
|
|||
|
||||
}
|
||||
|
||||
if (wall[i].cstat&16)
|
||||
if (wall[i].overpicnum >= W_FORCEFIELD && wall[i].overpicnum <= W_FORCEFIELD+2)
|
||||
if ((wall[i].cstat&16) && G_GetForcefieldPicnum(i)==W_FORCEFIELD)
|
||||
{
|
||||
t = animwall[p].tag;
|
||||
|
||||
if (wall[i].cstat&254)
|
||||
{
|
||||
t = animwall[p].tag;
|
||||
wall[i].xpanning -= t>>10; // sintable[(t+512)&2047]>>12;
|
||||
wall[i].ypanning -= t>>10; // sintable[t&2047]>>12;
|
||||
|
||||
if (wall[i].cstat&254)
|
||||
if (wall[i].extra == 1)
|
||||
{
|
||||
wall[i].xpanning -= t>>10; // sintable[(t+512)&2047]>>12;
|
||||
wall[i].ypanning -= t>>10; // sintable[t&2047]>>12;
|
||||
|
||||
if (wall[i].extra == 1)
|
||||
{
|
||||
wall[i].extra = 0;
|
||||
animwall[p].tag = 0;
|
||||
}
|
||||
else
|
||||
animwall[p].tag+=128;
|
||||
|
||||
if (animwall[p].tag < (128<<4))
|
||||
{
|
||||
if (animwall[p].tag&128)
|
||||
wall[i].overpicnum = W_FORCEFIELD;
|
||||
else wall[i].overpicnum = W_FORCEFIELD+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((krand()&255) < 32)
|
||||
animwall[p].tag = 128<<(krand()&3);
|
||||
else wall[i].overpicnum = W_FORCEFIELD+1;
|
||||
}
|
||||
wall[i].extra = 0;
|
||||
animwall[p].tag = 0;
|
||||
}
|
||||
else
|
||||
animwall[p].tag+=128;
|
||||
|
||||
if (animwall[p].tag < (128<<4))
|
||||
{
|
||||
if (animwall[p].tag&128)
|
||||
wall[i].overpicnum = W_FORCEFIELD;
|
||||
else wall[i].overpicnum = W_FORCEFIELD+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((krand()&255) < 32)
|
||||
animwall[p].tag = 128<<(krand()&3);
|
||||
else wall[i].overpicnum = W_FORCEFIELD+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t G_ActivateWarpElevators(int32_t s,int32_t d) //Parm = sectoreffectornum
|
||||
int32_t G_ActivateWarpElevators(int32_t s, int32_t d) //Parm = sectoreffectornum
|
||||
{
|
||||
int32_t i = headspritestat[STAT_EFFECTOR], sn = sprite[s].sectnum;
|
||||
|
||||
|
@ -1108,20 +1106,20 @@ void G_OperateForceFields(int32_t s, int32_t low)
|
|||
i = animwall[p].wallnum;
|
||||
|
||||
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))
|
||||
{
|
||||
animwall[p].tag = 0;
|
||||
|
||||
if (wall[i].cstat)
|
||||
{
|
||||
wall[i].cstat = 0;
|
||||
wall[i].cstat = 0;
|
||||
|
||||
if (s >= 0 && sprite[s].picnum == SECTOREFFECTOR && sprite[s].lotag == SE_30_TWO_WAY_TRAIN)
|
||||
wall[i].lotag = 0;
|
||||
}
|
||||
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;
|
||||
if (switchpicnum > W_FORCEFIELD && switchpicnum <= W_FORCEFIELD+2)
|
||||
switchpicnum = W_FORCEFIELD;
|
||||
|
||||
switch (DYNAMICTILEMAP(switchpicnum))
|
||||
{
|
||||
case W_FORCEFIELD__STATIC:
|
||||
//case W_FORCEFIELD+1:
|
||||
//case W_FORCEFIELD+2:
|
||||
wal->extra = 1; // tell the forces to animate
|
||||
/* fall-through */
|
||||
case BIGFORCE__STATIC:
|
||||
updatesector(pos->x,pos->y,&sn);
|
||||
if (sn < 0) return;
|
||||
updatesector(pos->x, pos->y, &sn);
|
||||
if (sn < 0)
|
||||
return;
|
||||
|
||||
if (atwith == -1)
|
||||
i = A_InsertSprite(sn,pos->x,pos->y,pos->z,FORCERIPPLE,-127,8,8,0,0,0,spr,5);
|
||||
else
|
||||
{
|
||||
if (atwith == CHAINGUN)
|
||||
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);
|
||||
else i = A_InsertSprite(sn,pos->x,pos->y,pos->z,FORCERIPPLE,-127,32,32,0,0,0,spr,5);
|
||||
int32_t xr=32, yr=32;
|
||||
|
||||
if (atwith == -1)
|
||||
xr = yr = 8;
|
||||
else if (atwith == CHAINGUN)
|
||||
{
|
||||
xr = 16+sprite[spr].xrepeat;
|
||||
yr = 16+sprite[spr].yrepeat;
|
||||
}
|
||||
|
||||
i = A_InsertSprite(sn, pos->x,pos->y,pos->z, FORCERIPPLE,
|
||||
-127, xr,yr, 0,0,0,spr,5);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
A_PlaySound(SOMETHINGHITFORCE,i);
|
||||
|
||||
return;
|
||||
|
||||
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;
|
||||
A_PlaySound(GLASS_BREAKING,i);
|
||||
return;
|
||||
|
||||
case STAINGLASS1__STATIC:
|
||||
updatesector(pos->x,pos->y,&sn);
|
||||
if (sn < 0) return;
|
||||
if (sn < 0)
|
||||
return;
|
||||
A_SpawnRandomGlass(spr,dawallnum,80);
|
||||
wal->cstat = 0;
|
||||
if (wal->nextwall >= 0)
|
||||
|
|
|
@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "gamevars.h"
|
||||
#include "actors.h" // actor_t
|
||||
#include "player.h" // playerspawn_t
|
||||
|
||||
#include "namesdyn.h" // for G_GetForcefieldPicnum()
|
||||
|
||||
#define MAXCYCLERS 1024
|
||||
#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 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"
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue