- SW: Fix player diving height issues.

* Fixes #822.
This commit is contained in:
Mitchell Richters 2022-12-29 13:52:01 +11:00
parent 6c7797a9f0
commit 09304ef298
3 changed files with 19 additions and 9 deletions

View file

@ -800,7 +800,13 @@ static void analyzesprites(tspriteArray& tsprites, const DVector3& viewpos, doub
pos.Z = tsp->pos.Z + pp->si.Z + pp->getViewHeightDiff();
if ((pp->Flags & PF_DEAD) && pos.Z > pp->actor->user.loz - pp->actor->user.floor_dist)
{
pos.Z = pp->actor->user.loz - pp->actor->user.floor_dist;
}
else if (pp->Flags & (PF_SWIMMING|PF_DIVING))
{
pos.Z -= PLAYER_DIVE_HEIGHTF - 10.;
}
tsp->pos = pos;
tsp->Angles.Yaw = pp->siang;

View file

@ -1483,11 +1483,15 @@ void DoPlayerSetWadeDepth(PLAYER* pp)
//
//---------------------------------------------------------------------------
void DoPlayerViewOffset(PLAYER* pp)
{
pp->actor->viewzoffset -= pp->getViewHeightDiff() * 0.375;
}
void DoPlayerHeight(PLAYER* pp)
{
constexpr double scale = 0.375;
pp->actor->viewzoffset -= pp->getViewHeightDiff() * scale;
pp->actor->spr.pos.Z -= (pp->actor->spr.pos.Z - pp->loz) * scale;
DoPlayerViewOffset(pp);
pp->actor->spr.pos.Z -= (pp->actor->spr.pos.Z - pp->loz) * 0.375;
}
void DoPlayerJumpHeight(PLAYER* pp)
@ -1855,8 +1859,7 @@ void UpdatePlayerSprite(PLAYER* pp)
}
else if (pp->DoPlayerAction == DoPlayerDive)
{
// bobbing and sprite position taken care of in DoPlayerDive
pp->height = 10;
pp->height = PLAYER_DIVE_HEIGHTF;
}
else if (pp->DoPlayerAction == DoPlayerClimb)
{
@ -2215,10 +2218,10 @@ void DoPlayerMove(PLAYER* pp)
else if (pp->Flags & (PF_SWIMMING|PF_DIVING))
{
if (pp->actor->getOffsetZ() > pp->loz)
pp->posZset(pp->loz - PLAYER_SWIM_HEIGHTF);
pp->posZset(pp->loz - PLAYER_DIVE_HEIGHTF);
if (pp->actor->getOffsetZ() < pp->hiz)
pp->posZset(pp->hiz + PLAYER_SWIM_HEIGHTF);
pp->posZset(pp->hiz + PLAYER_DIVE_HEIGHTF);
}
}
}
@ -4733,6 +4736,9 @@ void DoPlayerDive(PLAYER* pp)
move_sprite(bubble, DVector3(vec, 0), plActor->user.ceiling_dist, plActor->user.floor_dist, 0, synctics);
}
}
// Adjust view height moving up and down sectors
DoPlayerViewOffset(pp);
}
//---------------------------------------------------------------------------

View file

@ -35,8 +35,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
constexpr double PLAYER_HEIGHTF = 58;
#define PLAYER_CRAWL_HEIGHT Z(36)
constexpr double PLAYER_CRAWL_HEIGHTF = 36;
#define PLAYER_SWIM_HEIGHT Z(26)
constexpr double PLAYER_SWIM_HEIGHTF = 26;
#define PLAYER_DIVE_HEIGHT Z(26)
constexpr double PLAYER_DIVE_HEIGHTF = 26;
#define PLAYER_DIE_DOWN_HEIGHT Z(4)