From d45be79c24c6d3f6fe8c66e24d381eb76bb7969a Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 26 Mar 2023 22:12:16 +1100 Subject: [PATCH] - Exhumed: Adjust yaw adjustment for Ramses to use the same formula as pitch. * Rather than just snapping the angle, the player's yaw and pitch move evenly towards Ramses. --- source/games/exhumed/src/player.cpp | 62 ++++++++++++++--------------- source/games/exhumed/src/ramses.cpp | 2 + 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index a4f72e7a4..ce34037d4 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1420,9 +1420,6 @@ static void doPlayerRamses(Player* const pPlayer) if (nTotalPlayers <= 1) { const auto pPlayerActor = pPlayer->pActor; - pPlayerActor->spr.Angles.Yaw = (pSpiritSprite->spr.pos.XY() - pPlayerActor->spr.pos.XY()).Angle(); - pPlayerActor->spr.Angles.Pitch = pPlayerActor->PrevAngles.Pitch; - pPlayerActor->backupang(); pPlayerActor->vel.Zero(); pPlayer->vel.Zero(); @@ -1463,6 +1460,31 @@ static void doPlayerGravity(DExhumedActor* const pPlayerActor) // //--------------------------------------------------------------------------- +static void doPlayerAngles(Player* const pPlayer) +{ + const auto pPlayerActor = pPlayer->pActor; + const auto pInput = &pPlayer->input; + const auto nDestVertPan = cl_slopetilting ? pPlayer->nDestVertPan : nullAngle; + const auto nVertPan = deltaangle(pPlayer->Angles.ViewAngles.Pitch, nDestVertPan).Tan() * 32.; + + if (SyncInput()) + { + pPlayerActor->spr.Angles.Yaw += DAngle::fromDeg(pInput->avel); + pPlayerActor->spr.Angles.Pitch += DAngle::fromDeg(pInput->horz); + } + + pPlayer->Angles.doYawKeys(pInput); + pPlayer->Angles.doViewYaw(pInput); + pPlayer->Angles.doPitchKeys(pInput); + pPlayer->Angles.ViewAngles.Pitch += maphoriz(abs(nVertPan) >= 4 ? Sgn(nVertPan) * 4. : nVertPan * 2.); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + static void updatePlayerFloorActor(Player* const pPlayer) { if (nTotalPlayers > 1) @@ -1650,6 +1672,9 @@ static void doPlayerMovingBlocks(Player* const pPlayer, const Collision& nMove, static bool doPlayerMovement(Player* const pPlayer) { + // update the player/actor's velocity before anything. + updatePlayerVelocity(pPlayer); + const auto pPlayerActor = pPlayer->pActor; const auto spr_vel = DVector3(pPlayerActor->vel.XY() * (pPlayer->bIsMummified ? 0.5 : 1.), pPlayerActor->vel.Z); const auto spr_pos = pPlayerActor->spr.pos; @@ -1699,6 +1724,9 @@ static bool doPlayerMovement(Player* const pPlayer) if ((pPlayerActor->sector()->Flag & 0x8000) && bTouchFloor) return false; + // update player angles here as per the original workflow. + doPlayerAngles(pPlayer); + if (nMove.type || nMove.exbits) { if (bTouchFloor) @@ -1867,31 +1895,6 @@ static void updatePlayerAction(Player* const pPlayer) // //--------------------------------------------------------------------------- -static void doPlayerAngles(Player* const pPlayer) -{ - const auto pPlayerActor = pPlayer->pActor; - const auto pInput = &pPlayer->input; - const auto nDestVertPan = cl_slopetilting ? pPlayer->nDestVertPan : nullAngle; - const auto nVertPan = deltaangle(pPlayer->Angles.ViewAngles.Pitch, nDestVertPan).Tan() * 32.; - - if (SyncInput()) - { - pPlayerActor->spr.Angles.Yaw += DAngle::fromDeg(pInput->avel); - pPlayerActor->spr.Angles.Pitch += DAngle::fromDeg(pInput->horz); - } - - pPlayer->Angles.doYawKeys(pInput); - pPlayer->Angles.doViewYaw(pInput); - pPlayer->Angles.doPitchKeys(pInput); - pPlayer->Angles.ViewAngles.Pitch += maphoriz(abs(nVertPan) >= 4 ? Sgn(nVertPan) * 4. : nVertPan * 2.); -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - static bool doPlayerDeathRestart(Player* const pPlayer) { if (!(pPlayer->input.actions & SB_OPEN) || pPlayer->nAction < 16) @@ -2043,9 +2046,6 @@ void AIPlayer::Tick(RunListEvent* ev) if (pPlayer->nHealth > 0) { - updatePlayerVelocity(pPlayer); - doPlayerAngles(pPlayer); - if (!doPlayerMovement(pPlayer)) { doPlayerRamses(pPlayer); diff --git a/source/games/exhumed/src/ramses.cpp b/source/games/exhumed/src/ramses.cpp index 9d60e2b18..fd30d6407 100644 --- a/source/games/exhumed/src/ramses.cpp +++ b/source/games/exhumed/src/ramses.cpp @@ -197,6 +197,8 @@ void DoSpiritHead() const auto pPlayer = &PlayerList[0]; const auto pPlayerActor = pPlayer->pActor; + const auto nSpiritAngle = (pSpiritSprite->spr.pos.XY() - pPlayerActor->spr.pos.XY()).Angle(); + pPlayerActor->spr.Angles.Yaw += deltaangle(pPlayerActor->spr.Angles.Yaw, nSpiritAngle) * 0.25; pPlayerActor->spr.Angles.Pitch += deltaangle(pPlayerActor->spr.Angles.Pitch, pPlayer->nDestVertPan) * 0.25; switch (nHeadStage)