- moveplayer

This commit is contained in:
Christoph Oelckers 2020-05-06 21:11:36 +02:00
parent 4b235c0771
commit 8d42055dd7
7 changed files with 280 additions and 241 deletions

View file

@ -1216,5 +1216,251 @@ int ifhitbyweapon(int sn)
return -1;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void movecyclers(void)
{
short q, j, x, t, s, * c;
walltype* wal;
char cshade;
for (q = numcyclers - 1; q >= 0; q--)
{
c = &cyclers[q][0];
s = c[0];
t = c[3];
j = t + (sintable[c[1] & 2047] >> 10);
cshade = c[2];
if (j < cshade) j = cshade;
else if (j > t) j = t;
c[1] += sector[s].extra;
if (c[5])
{
wal = &wall[sector[s].wallptr];
for (x = sector[s].wallnum; x > 0; x--, wal++)
if (wal->hitag != 1)
{
wal->shade = j;
if ((wal->cstat & 2) && wal->nextwall >= 0)
wall[wal->nextwall].shade = j;
}
sector[s].floorshade = sector[s].ceilingshade = j;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void movedummyplayers(void)
{
short i, p, nexti;
i = headspritestat[STAT_DUMMYPLAYER];
while (i >= 0)
{
nexti = nextspritestat[i];
p = sprite[sprite[i].owner].yvel;
if ((!isRR() && ps[p].on_crane >= 0) || sector[ps[p].cursectnum].lotag != 1 || sprite[ps[p].i].extra <= 0)
{
ps[p].dummyplayersprite = -1;
deletesprite(i);
i = nexti;
continue;
}
else
{
if (ps[p].on_ground && ps[p].on_warping_sector == 1 && sector[ps[p].cursectnum].lotag == 1)
{
sprite[i].cstat = 257;
sprite[i].z = sector[sprite[i].sectnum].ceilingz + (27 << 8);
sprite[i].ang = ps[p].q16ang >> FRACBITS;
if (hittype[i].temp_data[0] == 8)
hittype[i].temp_data[0] = 0;
else hittype[i].temp_data[0]++;
}
else
{
if (sector[sprite[i].sectnum].lotag != 2) sprite[i].z = sector[sprite[i].sectnum].floorz;
sprite[i].cstat = (short)32768;
}
}
sprite[i].x += (ps[p].posx - ps[p].oposx);
sprite[i].y += (ps[p].posy - ps[p].oposy);
setsprite(i, sprite[i].x, sprite[i].y, sprite[i].z);
i = nexti;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int otherp;
void moveplayers(void) //Players
{
short i, nexti;
int otherx;
spritetype* s;
struct player_struct* p;
i = headspritestat[STAT_PLAYER];
while (i >= 0)
{
nexti = nextspritestat[i];
s = &sprite[i];
p = &ps[s->yvel];
if (s->owner >= 0)
{
if (p->newowner >= 0) //Looking thru the camera
{
s->x = p->oposx;
s->y = p->oposy;
hittype[i].bposz = s->z = p->oposz + PHEIGHT;
s->ang = p->oq16ang >> FRACBITS;
setsprite(i, s->x, s->y, s->z);
}
else
{
if (ud.multimode > 1)
otherp = findotherplayer(s->yvel, &otherx);
else
{
otherp = s->yvel;
otherx = 0;
}
execute(i, s->yvel, otherx);
if (ud.multimode > 1)
if (sprite[ps[otherp].i].extra > 0)
{
if (s->yrepeat > 32 && sprite[ps[otherp].i].yrepeat < 32)
{
if (otherx < 1400 && p->knee_incs == 0)
{
p->knee_incs = 1;
p->weapon_pos = -1;
p->actorsqu = ps[otherp].i;
}
}
}
if (ud.god)
{
s->extra = p->max_player_health;
s->cstat = 257;
if (!isWW2GI() && !isRR())
p->jetpack_amount = 1599;
}
if (s->extra > 0)
{
// currently alive...
hittype[i].owner = i;
if (ud.god == 0)
if (ceilingspace(s->sectnum) || floorspace(s->sectnum))
quickkill(p);
}
else
{
p->posx = s->x;
p->posy = s->y;
p->posz = s->z - (20 << 8);
p->newowner = -1;
if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS)
{
int ang = p->q16ang >> FRACBITS;
ang += getincangle(ang, getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1;
ang &= 2047;
p->q16ang = ang << FRACBITS;
}
}
s->ang = p->q16ang >> FRACBITS;
}
}
else
{
if (p->holoduke_on == -1)
{
deletesprite(i);
i = nexti;
continue;
}
hittype[i].bposx = s->x;
hittype[i].bposy = s->y;
hittype[i].bposz = s->z;
s->cstat = 0;
if (s->xrepeat < 42)
{
s->xrepeat += 4;
s->cstat |= 2;
}
else s->xrepeat = 42;
if (s->yrepeat < 36)
s->yrepeat += 4;
else
{
s->yrepeat = 36;
if (sector[s->sectnum].lotag != ST_2_UNDERWATER)
makeitfall(i);
if (s->zvel == 0 && sector[s->sectnum].lotag == ST_1_ABOVE_WATER)
s->z += (32 << 8);
}
if (s->extra < 8)
{
s->xvel = 128;
s->ang = p->q16ang >> FRACBITS;
s->extra++;
//IFMOVING; // JBF 20040825: is really "if (ssp(i,CLIPMASK0)) ;" which is probably
ssp(i, CLIPMASK0); // not the safest of ideas because a zealous optimiser probably sees
// it as redundant, so I'll call the "ssp(i,CLIPMASK0)" explicitly.
}
else
{
s->ang = 2047 - (p->q16ang >> FRACBITS);
setsprite(i, s->x, s->y, s->z);
}
}
if (sector[s->sectnum].ceilingstat & 1)
s->shade += (sector[s->sectnum].ceilingshade - s->shade) >> 1;
else
s->shade += (sector[s->sectnum].floorshade - s->shade) >> 1;
i = nexti;
}
}
END_DUKE_NS

View file

@ -132,7 +132,11 @@ typedef struct
int32_t t_data[10]; // 40b sometimes used to hold offsets to con code
int32_t flags; // 4b
vec3_t bpos; // 12b
union
{
vec3_t bpos; // 12b
struct { int bposx, bposy, bposz; };
};
int32_t floorz, ceilingz; // 8b
vec2_t lastv; // 8b
int16_t picnum, ang, extra, owner; // 8b
@ -265,8 +269,8 @@ void A_AddToDeleteQueue(int spriteNum);
void A_DeleteSprite(int spriteNum);
void A_DoGuts(int spriteNum, int tileNum, int spawnCnt);
void A_DoGutsDir(int spriteNum, int tileNum, int spawnCnt);
void A_MoveCyclers(void);
void A_MoveDummyPlayers(void);
void movecyclers(void);
void movedummyplayers(void);
void A_MoveSector(int spriteNum);
void A_PlayAlertSound(int spriteNum);
inline void check_fta_sounds(int s)

View file

@ -36,8 +36,6 @@ BEGIN_DUKE_NS
#define DELETE_SPRITE_AND_CONTINUE(KX) do { A_DeleteSprite(KX); goto next_sprite; } while (0)
int32_t otherp;
void G_ClearCameraView(DukePlayer_t *ps)
{
ps->newowner = -1;
@ -371,80 +369,6 @@ int A_IncurDamage(int const spriteNum)
return ifhitbyweapon(spriteNum);
}
void A_MoveCyclers(void)
{
for (bssize_t i=g_cyclerCnt-1; i>=0; i--)
{
int16_t *const pCycler = g_cyclers[i];
int const sectNum = pCycler[0];
int spriteShade = pCycler[2];
int const floorShade = pCycler[3];
int sectorShade = clamp(floorShade + (sintable[pCycler[1] & 2047] >> 10), spriteShade, floorShade);
pCycler[1] += sector[sectNum].extra;
if (pCycler[5]) // angle 1536...
{
walltype *pWall = &wall[sector[sectNum].wallptr];
for (bssize_t wallsLeft = sector[sectNum].wallnum; wallsLeft > 0; wallsLeft--, pWall++)
{
if (pWall->hitag != 1)
{
pWall->shade = sectorShade;
if ((pWall->cstat&2) && pWall->nextwall >= 0)
wall[pWall->nextwall].shade = sectorShade;
}
}
sector[sectNum].floorshade = sector[sectNum].ceilingshade = sectorShade;
}
}
}
void A_MoveDummyPlayers(void)
{
int spriteNum = headspritestat[STAT_DUMMYPLAYER];
while (spriteNum >= 0)
{
int const playerNum = P_Get(OW(spriteNum));
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
int const nextSprite = nextspritestat[spriteNum];
int const playerSectnum = pPlayer->cursectnum;
if ((!RR && pPlayer->on_crane >= 0) || (playerSectnum >= 0 && sector[playerSectnum].lotag != ST_1_ABOVE_WATER) || sprite[pPlayer->i].extra <= 0)
{
pPlayer->dummyplayersprite = -1;
DELETE_SPRITE_AND_CONTINUE(spriteNum);
}
else
{
if (pPlayer->on_ground && pPlayer->on_warping_sector == 1 && playerSectnum >= 0 && sector[playerSectnum].lotag == ST_1_ABOVE_WATER)
{
CS(spriteNum) = 257;
SZ(spriteNum) = sector[SECT(spriteNum)].ceilingz+(27<<8);
SA(spriteNum) = fix16_to_int(pPlayer->q16ang);
if (T1(spriteNum) == 8)
T1(spriteNum) = 0;
else T1(spriteNum)++;
}
else
{
if (sector[SECT(spriteNum)].lotag != ST_2_UNDERWATER) SZ(spriteNum) = sector[SECT(spriteNum)].floorz;
CS(spriteNum) = 32768;
}
}
SX(spriteNum) += (pPlayer->pos.x-pPlayer->opos.x);
SY(spriteNum) += (pPlayer->pos.y-pPlayer->opos.y);
setsprite(spriteNum, (vec3_t *)&sprite[spriteNum]);
next_sprite:
spriteNum = nextSprite;
}
}
static int P_Submerge(int, int, DukePlayer_t *, int, int);
@ -468,165 +392,7 @@ static fix16_t P_GetQ16AngleDeltaForTic(DukePlayer_t const *pPlayer)
return fix16_sub(newAngle, oldAngle);
}
ACTOR_STATIC void G_MovePlayers(void)
{
int spriteNum = headspritestat[STAT_PLAYER];
while (spriteNum >= 0)
{
int const nextSprite = nextspritestat[spriteNum];
spritetype *const pSprite = &sprite[spriteNum];
DukePlayer_t *const pPlayer = g_player[P_GetP(pSprite)].ps;
if (pSprite->owner >= 0)
{
if (pPlayer->newowner >= 0) //Looking thru the camera
{
pSprite->x = pPlayer->opos.x;
pSprite->y = pPlayer->opos.y;
pSprite->z = pPlayer->opos.z + PHEIGHT;
actor[spriteNum].bpos.z = pSprite->z;
pSprite->ang = fix16_to_int(pPlayer->oq16ang);
setsprite(spriteNum, (vec3_t *)pSprite);
}
else
{
int32_t otherPlayerDist;
#ifdef YAX_ENABLE
// TROR water submerge/emerge
int const playerSectnum = pSprite->sectnum;
int const sectorLotag = sector[playerSectnum].lotag;
int32_t otherSector;
if (A_CheckNoSE7Water((uspritetype const *)pSprite, playerSectnum, sectorLotag, &otherSector))
{
// NOTE: Compare with G_MoveTransports().
pPlayer->on_warping_sector = 1;
if ((sectorLotag == ST_1_ABOVE_WATER ?
P_Submerge(spriteNum, P_GetP(pSprite), pPlayer, playerSectnum, otherSector) :
P_Emerge(spriteNum, P_GetP(pSprite), pPlayer, playerSectnum, otherSector)) == 1)
P_FinishWaterChange(spriteNum, pPlayer, sectorLotag, -1, otherSector);
}
#endif
if (g_netServer || ud.multimode > 1)
otherp = P_FindOtherPlayer(P_GetP(pSprite), &otherPlayerDist);
else
{
otherp = P_GetP(pSprite);
otherPlayerDist = 0;
}
if (G_HaveActor(sprite[spriteNum].picnum))
A_Execute(spriteNum, P_GetP(pSprite), otherPlayerDist);
pPlayer->q16angvel = P_GetQ16AngleDeltaForTic(pPlayer);
pPlayer->oq16ang = pPlayer->q16ang;
pPlayer->oq16horiz = pPlayer->q16horiz;
pPlayer->oq16horizoff = pPlayer->q16horizoff;
if (g_netServer || ud.multimode > 1)
{
if (sprite[g_player[otherp].ps->i].extra > 0)
{
if (pSprite->yrepeat > 32 && sprite[g_player[otherp].ps->i].yrepeat < 32)
{
if (otherPlayerDist < 1400 && pPlayer->knee_incs == 0)
{
pPlayer->knee_incs = 1;
pPlayer->weapon_pos = -1;
pPlayer->actorsqu = g_player[otherp].ps->i;
}
}
}
}
if (ud.god)
{
pSprite->extra = pPlayer->max_player_health;
pSprite->cstat = 257;
if (!RR && !WW2GI)
pPlayer->inv_amount[GET_JETPACK] = 1599;
}
if (pSprite->extra > 0)
{
actor[spriteNum].owner = spriteNum;
if (ud.god == 0)
if (G_CheckForSpaceCeiling(pSprite->sectnum) || G_CheckForSpaceFloor(pSprite->sectnum))
P_QuickKill(pPlayer);
}
else
{
pPlayer->pos.x = pSprite->x;
pPlayer->pos.y = pSprite->y;
pPlayer->pos.z = pSprite->z-(20<<8);
pPlayer->newowner = -1;
if (pPlayer->wackedbyactor >= 0 && sprite[pPlayer->wackedbyactor].statnum < MAXSTATUS)
{
pPlayer->q16ang += fix16_to_int(G_GetAngleDelta(pPlayer->q16ang,
getangle(sprite[pPlayer->wackedbyactor].x - pPlayer->pos.x,
sprite[pPlayer->wackedbyactor].y - pPlayer->pos.y))
>> 1);
pPlayer->q16ang &= 0x7FFFFFF;
}
}
pSprite->ang = fix16_to_int(pPlayer->q16ang);
}
}
else
{
if (pPlayer->holoduke_on == -1)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
Bmemcpy(&actor[spriteNum].bpos, pSprite, sizeof(vec3_t));
pSprite->cstat = 0;
if (pSprite->xrepeat < 42)
{
pSprite->xrepeat += 4;
pSprite->cstat |= 2;
}
else pSprite->xrepeat = 42;
if (pSprite->yrepeat < 36)
pSprite->yrepeat += 4;
else
{
pSprite->yrepeat = 36;
if (sector[pSprite->sectnum].lotag != ST_2_UNDERWATER)
A_Fall(spriteNum);
if (pSprite->zvel == 0 && sector[pSprite->sectnum].lotag == ST_1_ABOVE_WATER)
pSprite->z += ZOFFSET5;
}
if (pSprite->extra < 8)
{
pSprite->xvel = 128;
pSprite->ang = fix16_to_int(pPlayer->q16ang);
pSprite->extra++;
A_SetSprite(spriteNum,CLIPMASK0);
}
else
{
pSprite->ang = 2047-fix16_to_int(pPlayer->q16ang);
setsprite(spriteNum,(vec3_t *)pSprite);
}
}
pSprite->shade =
logapproach(pSprite->shade, (sector[pSprite->sectnum].ceilingstat & 1) ? sector[pSprite->sectnum].ceilingshade
: sector[pSprite->sectnum].floorshade);
next_sprite:
spriteNum = nextSprite;
}
}
void moveplayers();
ACTOR_STATIC void G_MoveFX(void)
{
@ -9061,7 +8827,7 @@ void G_MoveWorld(void)
G_MoveTransports(); //ST 9
}
G_MovePlayers(); //ST 10
moveplayers(); //ST 10
G_MoveFallers(); //ST 12
if (!DEER)
G_MoveMisc(); //ST 5
@ -9102,4 +8868,5 @@ void G_MoveWorld(void)
g_moveWorldTime = (1-0.033)*g_moveWorldTime + 0.033*(timerGetHiTicks()-worldTime);
}
END_DUKE_NS

View file

@ -7514,7 +7514,7 @@ int G_DoMoveThings(void)
if (ud.pause_on == 0)
{
g_globalRandom = krand2();
A_MoveDummyPlayers();//ST 13
movedummyplayers();//ST 13
}
for (bssize_t TRAVERSE_CONNECT(i))
@ -7562,7 +7562,7 @@ int G_DoMoveThings(void)
else
{
G_AnimateWalls();
A_MoveCyclers();
movecyclers();
}
//if (g_netServer && (everyothertime % 10) == 0)

View file

@ -75,10 +75,22 @@ extern uint32_t g_actorCalls[MAXTILES];
extern double g_actorTotalMs[MAXTILES], g_actorMinMs[MAXTILES], g_actorMaxMs[MAXTILES];
void A_Execute(int spriteNum, int playerNum, int playerDist);
inline void execute(int s, int p, int d)
{
A_Execute(s, p, d);
}
void A_Fall(int spriteNum);
inline void makeitfall(int s)
{
A_Fall(s);
}
int32_t A_GetFurthestAngle(int spriteNum, int angDiv);
void A_GetZLimits(int spriteNum);
int32_t __fastcall G_GetAngleDelta(int32_t currAngle, int32_t newAngle);
inline int getincangle(int c, int n)
{
return G_GetAngleDelta(c, n);
}
//void G_RestoreMapState();
//void G_SaveMapState();

View file

@ -110,6 +110,7 @@ G_EXTERN int32_t g_cloudCnt;
G_EXTERN int32_t g_curViewscreen;
G_EXTERN int32_t g_frameRate;
G_EXTERN int32_t g_cyclerCnt;
#define numcyclers g_cyclerCnt
G_EXTERN int32_t g_damageCameras;
G_EXTERN int32_t g_defaultLabelCnt;
G_EXTERN int32_t g_doQuickSave;
@ -143,6 +144,7 @@ G_EXTERN ClockTicks g_cloudClock;
G_EXTERN int16_t SpriteDeletionQueue[1024];
G_EXTERN int16_t g_cyclers[MAXCYCLERS][6];
#define cyclers g_cyclers
G_EXTERN int16_t g_mirrorSector[64];
G_EXTERN int16_t g_mirrorWall[64];
G_EXTERN int32_t *labelcode;

View file

@ -365,6 +365,10 @@ void P_DisplayScuba(void);
void P_DisplayWeapon(void);
void P_DropWeapon(int playerNum);
int P_FindOtherPlayer(int playerNum, int32_t *pDist);
inline int findotherplayer(int p, int* d)
{
return P_FindOtherPlayer(p, d);
}
void P_FragPlayer(int playerNum);
#ifdef YAX_ENABLE
void getzsofslope_player(int sectNum, int playerX, int playerY, int32_t *pCeilZ, int32_t *pFloorZ);
@ -373,6 +377,10 @@ void P_UpdatePosWhenViewingCam(DukePlayer_t *pPlayer);
void P_ProcessInput(int playerNum);
void P_DHProcessInput(int playerNum);
void P_QuickKill(DukePlayer_t *pPlayer);
inline void quickkill(DukePlayer_t* pPlayer)
{
P_QuickKill(pPlayer);
}
void P_SelectNextInvItem(DukePlayer_t *pPlayer);
void P_UpdateScreenPal(DukePlayer_t *pPlayer);
inline void setpal(DukePlayer_t* pPlayer)