- hitradius.

This one was really messy...
This commit is contained in:
Christoph Oelckers 2020-05-06 00:08:08 +02:00
parent 51d4853375
commit b29351f3bc
10 changed files with 360 additions and 10 deletions

View file

@ -329,6 +329,297 @@ void checkavailweapon(struct player_struct* p)
else p->weapon_pos = -1;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void clearcamera(player_struct* ps)
{
ps->newowner = -1;
ps->posx = ps->oposx;
ps->posy = ps->oposy;
ps->posz = ps->oposz;
ps->q16ang = ps->oq16ang;
updatesector(ps->posx, ps->posy, &ps->cursectnum);
setpal(ps);
int k = headspritestat[1];
while (k >= 0)
{
if (sprite[k].picnum == CAMERA1)
sprite[k].yvel = 0;
k = nextspritestat[k];
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4)
{
spritetype* s, * sj;
walltype* wal;
int d, q, x1, y1;
int sectcnt, sectend, dasect, startwall, endwall, nextsect;
short j, p, x, nextj, sect;
static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC };
short tempshort[MAXSECTORS]; // originally hijacked a global buffer which is bad. Q: How many do we really need? RedNukem says 64.
s = &sprite[i];
if (s->xrepeat < 11)
{
if (!(g_gameType & GAMEFLAG_RRALL))
{
if (s->picnum == RPG) goto SKIPWALLCHECK;
}
else
{
if (s->picnum == RR_CROSSBOW || ((g_gameType & GAMEFLAG_RRRA) && s->picnum == RR_CHIKENCROSSBOW)) goto SKIPWALLCHECK;
}
}
if ((g_gameType & GAMEFLAG_RRALL) || s->picnum != SHRINKSPARK)
{
tempshort[0] = s->sectnum;
dasect = s->sectnum;
sectcnt = 0; sectend = 1;
do
{
dasect = tempshort[sectcnt++];
if (((sector[dasect].ceilingz - s->z) >> 8) < r)
{
d = abs(wall[sector[dasect].wallptr].x - s->x) + abs(wall[sector[dasect].wallptr].y - s->y);
if (d < r)
checkhitceiling(dasect);
else
{
// ouch...
d = abs(wall[wall[wall[sector[dasect].wallptr].point2].point2].x - s->x) + abs(wall[wall[wall[sector[dasect].wallptr].point2].point2].y - s->y);
if (d < r)
checkhitceiling(dasect);
}
}
startwall = sector[dasect].wallptr;
endwall = startwall + sector[dasect].wallnum;
for (x = startwall, wal = &wall[startwall]; x < endwall; x++, wal++)
if ((abs(wal->x - s->x) + abs(wal->y - s->y)) < r)
{
nextsect = wal->nextsector;
if (nextsect >= 0)
{
for (dasect = sectend - 1; dasect >= 0; dasect--)
if (tempshort[dasect] == nextsect) break;
if (dasect < 0) tempshort[sectend++] = nextsect;
}
x1 = (((wal->x + wall[wal->point2].x) >> 1) + s->x) >> 1;
y1 = (((wal->y + wall[wal->point2].y) >> 1) + s->y) >> 1;
updatesector(x1, y1, &sect);
if (sect >= 0 && cansee(x1, y1, s->z, sect, s->x, s->y, s->z, s->sectnum))
checkhitwall(i, x, wal->x, wal->y, s->z, s->picnum);
}
} while (sectcnt < sectend);
}
SKIPWALLCHECK:
int val = (g_gameType & GAMEFLAG_RRALL) ? 24 : 16;
q = -(val << 8) + (krand() & ((32 << 8) - 1));
for (x = 0; x < 7; x++)
{
j = headspritestat[statlist[x]];
while (j >= 0)
{
nextj = nextspritestat[j];
sj = &sprite[j];
if (x == 0 || x >= 5 || AFLAMABLE(sj->picnum))
{
if ((!(g_gameType & GAMEFLAG_RRALL) && s->picnum != SHRINKSPARK) || (sj->cstat & 257))
if (dist(s, sj) < r)
{
if (badguy(sj) && !cansee(sj->x, sj->y, sj->z + q, sj->sectnum, s->x, s->y, s->z + q, s->sectnum))
goto BOLT;
checkhitsprite(j, i);
}
}
else if (!(g_gameType & GAMEFLAG_RRALL))
{
if (sj->extra >= 0 && sj != s && (sj->picnum == TRIPBOMB || badguy(sj) || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL || (sj->cstat & 257) || sj->picnum == DUKELYINGDEAD))
{
if (s->picnum == SHRINKSPARK && sj->picnum != SHARK && (j == s->owner || sj->xrepeat < 24))
{
j = nextj;
continue;
}
if (s->picnum == MORTER && j == s->owner)
{
j = nextj;
continue;
}
if (sj->picnum == APLAYER) sj->z -= PHEIGHT;
d = dist(s, sj);
if (sj->picnum == APLAYER) sj->z += PHEIGHT;
if (d < r && cansee(sj->x, sj->y, sj->z - (8 << 8), sj->sectnum, s->x, s->y, s->z - (12 << 8), s->sectnum))
{
hittype[j].ang = getangle(sj->x - s->x, sj->y - s->y);
if (s->picnum == RPG && sj->extra > 0)
hittype[j].picnum = RPG;
else
{
if (s->picnum == SHRINKSPARK)
hittype[j].picnum = SHRINKSPARK;
else hittype[j].picnum = RADIUSEXPLOSION;
}
if (s->picnum != SHRINKSPARK)
{
if (d < r / 3)
{
if (hp4 == hp3) hp4++;
hittype[j].extra = hp3 + (krand() % (hp4 - hp3));
}
else if (d < 2 * r / 3)
{
if (hp3 == hp2) hp3++;
hittype[j].extra = hp2 + (krand() % (hp3 - hp2));
}
else if (d < r)
{
if (hp2 == hp1) hp2++;
hittype[j].extra = hp1 + (krand() % (hp2 - hp1));
}
if (sprite[j].picnum != TANK && sprite[j].picnum != ROTATEGUN && sprite[j].picnum != RECON && sprite[j].picnum != BOSS1 && sprite[j].picnum != BOSS2 && sprite[j].picnum != BOSS3 && sprite[j].picnum != BOSS4)
{
if (sj->xvel < 0) sj->xvel = 0;
sj->xvel += (s->extra << 2);
}
if (sj->picnum == PODFEM1 || sj->picnum == FEM1 ||
sj->picnum == FEM2 || sj->picnum == FEM3 ||
sj->picnum == FEM4 || sj->picnum == FEM5 ||
sj->picnum == FEM6 || sj->picnum == FEM7 ||
sj->picnum == FEM8 || sj->picnum == FEM9 ||
sj->picnum == FEM10 || sj->picnum == STATUE ||
sj->picnum == STATUEFLASH || sj->picnum == SPACEMARINE || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL)
checkhitsprite(j, i);
}
else if (s->extra == 0) hittype[j].extra = 0;
if (sj->picnum != RADIUSEXPLOSION &&
s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS)
{
if (sj->picnum == APLAYER)
{
p = sj->yvel;
if (ps[p].newowner >= 0)
{
clearcamera(&ps[p]);
}
}
hittype[j].owner = s->owner;
}
}
}
}
else
{
if (sj->extra >= 0 && sj != s && (badguy(sj) || sj->picnum == RR_QUEBALL || sj->picnum == RR_3440 || sj->picnum == RR_STRIPEBALL || (sj->cstat & 257) || sj->picnum == RR_LNRDLYINGDEAD))
{
if (s->picnum == RR_MORTER && j == s->owner)
{
j = nextj;
continue;
}
if ((g_gameType & GAMEFLAG_RRRA) && s->picnum == RR_CHEERBOMB && j == s->owner)
{
j = nextj;
continue;
}
if (sj->picnum == APLAYER) sj->z -= PHEIGHT;
d = dist(s, sj);
if (sj->picnum == APLAYER) sj->z += PHEIGHT;
if (d < r && cansee(sj->x, sj->y, sj->z - (8 << 8), sj->sectnum, s->x, s->y, s->z - (12 << 8), s->sectnum))
{
if ((g_gameType & GAMEFLAG_RRRA) && sprite[j].picnum == RR_MINION && sprite[j].pal == 19)
{
j = nextj;
continue;
}
hittype[j].ang = getangle(sj->x - s->x, sj->y - s->y);
if (s->picnum == RR_CROSSBOW && sj->extra > 0)
hittype[j].picnum = RR_CROSSBOW;
else if ((g_gameType & GAMEFLAG_RRRA) && s->picnum == RR_CHIKENCROSSBOW && sj->extra > 0)
hittype[j].picnum = RR_CROSSBOW;
else
hittype[j].picnum = RR_RADIUSEXPLOSION;
if (d < r / 3)
{
if (hp4 == hp3) hp4++;
hittype[j].extra = hp3 + (krand() % (hp4 - hp3));
}
else if (d < 2 * r / 3)
{
if (hp3 == hp2) hp3++;
hittype[j].extra = hp2 + (krand() % (hp3 - hp2));
}
else if (d < r)
{
if (hp2 == hp1) hp2++;
hittype[j].extra = hp1 + (krand() % (hp2 - hp1));
}
int pic = sprite[j].picnum;
if ((g_gameType & GAMEFLAG_RRRA)?
(pic != RR_HULK && pic != RR_MAMAJACKOLOPE && pic != RR_GUITARBILLY && pic != RR_BANJOCOOTER && pic != RR_MAMACLOUD) :
(pic != RR_HULK && pic != RR_SBMOVE))
{
if (sprite[j].xvel < 0) sprite[j].xvel = 0;
sprite[j].xvel += (sprite[j].extra << 2);
}
if (sj->picnum == RR_STATUEFLASH || sj->picnum == RR_QUEBALL ||
sj->picnum == RR_STRIPEBALL || sj->picnum == RR_3440)
checkhitsprite(j, i);
if (sprite[j].picnum != RR_RADIUSEXPLOSION &&
s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS)
{
if (sprite[j].picnum == APLAYER)
{
p = sprite[j].yvel;
if (ps[p].newowner >= 0)
{
clearcamera(&ps[p]);
}
}
hittype[j].owner = s->owner;
}
}
}
}
BOLT:
j = nextj;
}
}
}
//---------------------------------------------------------------------------
//
@ -357,7 +648,7 @@ bool ifsquished(int i, int p)
if (squishme)
{
FTA(QUOTE_SQUISHED, ps[p]);
FTA(QUOTE_SQUISHED, &ps[p]);
if (badguy(&sprite[i]))
sprite[i].xvel = 0;

View file

@ -275,6 +275,7 @@ void A_ResetLanePics(void);
int G_SetInterpolation(int32_t *posptr);
void G_AddGameLight(int lightRadius, int spriteNum, int zOffset, int lightRange, int lightColor, int lightPrio);
void G_ClearCameraView(DukePlayer_t *ps);
void clearcamera(player_struct* ps);
void G_DoInterpolations(int smoothRatio);
void G_MoveWorld(void);
void G_RefreshLights(void);

View file

@ -313,9 +313,9 @@ inline int dointerpolations(int smoothratio)
// Hack struct to allow old code to access the EDuke-style player data without changing it.
struct psaccess
{
DukePlayer_t* operator[](int index)
DukePlayer_t& operator[](int index)
{
return g_player[index].ps;
return *g_player[index].ps;
}
};
extern psaccess ps;

View file

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define EDUKE32_MACROS_H_
#include "mmulti.h"
#include "names.h"
BEGIN_DUKE_NS
@ -61,7 +62,14 @@ static FORCE_INLINE int32_t krand2(void)
#define TEST_SYNC_KEY(bits, sync_num) (!!TEST((bits), BIT(sync_num)))
#define AFLAMABLE(X) (X==TILE_BOX||X==TILE_TREE1||X==TILE_TREE2||X==TILE_TIRE||X==TILE_CONE)
inline bool AFLAMABLE(int X)
{
if (!(g_gameType & GAMEFLAG_RRALL))
return (X == BOX || X == TREE1 || X == TREE2 || X == TIRE || X == CONE);
else
return (X == RR_AFLAM1191 || X == RR_AFLAM1193 || X == RR_TIRE || X == RR_AFLAM3062);
}
#define rnd(X) ((krand2()>>8)>=(255-(X)))
//

View file

@ -23,6 +23,9 @@ Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#pragma once
BEGIN_DUKE_NS
enum
{
@ -209,7 +212,7 @@ enum
PIPE1B = 617,
PIPE3 = 618,
PIPE1 = 619,
CAMERA1 = 621,
DUKE_CAMERA1 = 621,
BRICK = 626,
SPLINTERWOOD = 630,
PIPE2B = 633,
@ -410,7 +413,7 @@ enum
SCRATCH = 1393,
FEM7 = 1395,
APLAYERTOP = 1400,
APLAYER = 1405,
DUKE_APLAYER = 1405,
PLAYERONWATER = 1420,
DUKELYINGDEAD = 1518,
DUKETORSO = 1520,
@ -894,6 +897,8 @@ enum
RR_QUEBALL = 1184,
RR_STRIPEBALL = 1185,
RR_POCKET = 1186,
RR_AFLAM1191 = 1191,
RR_AFLAM1193 = 1193,
RR_NEON1 = 1200,
RR_NEON2 = 1201,
RR_BOUNCEMINE = 1204,
@ -1010,6 +1015,7 @@ enum
RR_TESLA = 2097,
RR_HURTRAIL = 2221,
RR_LOCKSWITCH1 = 2224,
RR_STATUEFLASH = 2231,
RR_REACTOR2 = 2239,
RR_REACTOR2SPARK = 2243,
RR_REACTOR2BURNT = 2247,
@ -1027,6 +1033,8 @@ enum
RR_BUSTAWIN4A = 2898,
RR_BUSTAWIN4B = 2899,
RR_FRAMEEFFECT1 = 2999,
RR_AFLAM3062 = 3062,
RR_LOAFTILE = 3120,
RR_NUGGETTILE = 3122,
@ -1054,6 +1062,8 @@ enum
RR_FIRELASER = 3420,
RR_BOWLINGBALL = 3430,
RR_BOWLINGBALLSPRITE = 3437,
RR_3440,
RR_CHEERBOMB = -3464,
RR_OWHIP = 3471,
RR_UWHIP = 3475,
RR_BACKGROUND = 3822,
@ -1164,6 +1174,11 @@ enum
RR_JACKOLOPE = 7280,
RR_BANJOCOOTER = 7030,
RR_GUITARBILLY = 7035,
RR_MAMACLOUD = 8663,
RR_MAMAJACKOLOPE = 8705,
};
extern int APLAYER;
extern int CAMERA1;
END_DUKE_NS

View file

@ -2920,12 +2920,17 @@ void freehashnames(void)
}
#endif
int APLAYER, CAMERA1;
// This is run after all CON define's have been processed to set up the
// dynamic->static tile mapping.
void G_InitDynamicTiles(void)
{
int32_t i;
APLAYER = (g_gameType & GAMEFLAG_RRALL) ? RR_APLAYER : DUKE_APLAYER;
CAMERA1 = (g_gameType & GAMEFLAG_RRALL) ? RR_CAMERA1 : DUKE_CAMERA1;
Bmemset(DynamicTileMap, 0, sizeof(DynamicTileMap));
if (RR)

View file

@ -3075,7 +3075,7 @@ void Net_ReceivePlayerIndex(uint8_t *pbuf, int32_t packbufleng)
void Net_SendClientInfo(void)
{
int32_t i,l;
int32_t l;
strncpy(g_player[myconnectindex].user_name, playername, 32);
@ -3118,7 +3118,7 @@ void Net_SendClientInfo(void)
void Net_ReceiveClientInfo(uint8_t *pbuf, int32_t packbufleng, int32_t fromserver)
{
uint32_t i, j;
uint32_t i;
int32_t other = pbuf[packbufleng];
for (i=1; pbuf[i]; i++)

View file

@ -135,7 +135,19 @@ typedef struct {
// TODO: rearrange this if the opportunity arises!
// KEEPINSYNC lunatic/_defs_game.lua
typedef struct player_struct {
vec3_t pos, opos, vel, npos;
union
{
vec3_t pos;
struct { int32_t posx, posy, posz; };
};
union
{
vec3_t opos;
struct { int32_t oposx, oposy, oposz; };
};
vec3_t vel;
vec3_t npos;
vec2_t bobpos, fric;
fix16_t q16horiz, q16horizoff, oq16horiz, oq16horizoff;
@ -359,6 +371,11 @@ void P_DHProcessInput(int playerNum);
void P_QuickKill(DukePlayer_t *pPlayer);
void P_SelectNextInvItem(DukePlayer_t *pPlayer);
void P_UpdateScreenPal(DukePlayer_t *pPlayer);
inline void setpal(DukePlayer_t* pPlayer)
{
P_UpdateScreenPal(pPlayer);
}
void P_EndLevel(void);
void P_CheckWeaponI(int playerNum);
int P_GetHudPal(const DukePlayer_t *pPlayer);

View file

@ -109,7 +109,16 @@ void A_CallSound2(int soundNum, int playerNum);
int A_CallSound(int sectNum,int spriteNum);
int A_CheckHitSprite(int spriteNum,int16_t *hitSprite);
void A_DamageObject(int spriteNum,int dmgSrc);
inline void checkhitsprite(int s, int d)
{
A_DamageObject(s, d);
}
void A_DamageWall(int spr,int dawallnum,const vec3_t *pos,int weaponNum);
inline void checkhitwall(int spr, int wal, int x, int y, int z, int w)
{
vec3_t vec{ x, y, z };
A_DamageWall(spr, wal, &vec, w);
}
int __fastcall A_FindPlayer(const spritetype *pSprite,int32_t *dist);
void G_AlignWarpElevators(void);
int CheckDoorTile(int tileNum);
@ -131,6 +140,7 @@ int isanunderoperator(int lotag);
int P_ActivateSwitch(int playerNum, int wallOrSprite, int nSwitchType);
void P_CheckSectors(int playerNum);
void Sect_DamageCeiling(int sectNum);
inline void checkhitceiling(int sec) { Sect_DamageCeiling(sec); }
int SetAnimation(int sectNum,int32_t *animPtr,int goalVal,int animVel);
void G_DoFurniture(int wallNum, int sectNum, int playerNum);
void G_DoTorch(void);

View file

@ -61,7 +61,10 @@ static FORCE_INLINE int32_t krand2(void)
#define TEST_SYNC_KEY(bits, sync_num) (!!TEST((bits), BIT(sync_num)))
#define AFLAMABLE(X) (X==BOX||X==TREE1||X==TREE2||X==TIRE||X==CONE)
inline bool AFLAMABLE(int X)
{
return (X == BOX || X == TREE1 || X == TREE2 || X == TIRE || X == CONE);
}
#define rnd(X) ((krand2()>>8)>=(255-(X)))
//