From 1d48ac537ae5b4aa5a2e1cace7c7b55365b3d66a Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 18 Feb 2021 22:14:32 +1100 Subject: [PATCH] - Exhumed: Replace original chasecam code with `calcChaseCamPos()` within game. --- source/games/exhumed/src/exhumed.h | 3 ++ source/games/exhumed/src/osdcmds.cpp | 3 ++ source/games/exhumed/src/view.cpp | 64 +++++++++++++--------------- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index 803e21f08..93fc394a1 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -254,6 +254,9 @@ struct GameInterface : ::GameInterface int playerKeyMove() override { return 6; } void WarpToCoords(int x, int y, int z, int a, int h) override; void ToggleThirdPerson() override; + int chaseCamX(binangle ang) { return -ang.bcos() / 12; } + int chaseCamY(binangle ang) { return -ang.bsin() / 12; } + int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() / 384; } ::GameStats getStats() override; }; diff --git a/source/games/exhumed/src/osdcmds.cpp b/source/games/exhumed/src/osdcmds.cpp index 2c2bfbcd7..81efd81e8 100644 --- a/source/games/exhumed/src/osdcmds.cpp +++ b/source/games/exhumed/src/osdcmds.cpp @@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "input.h" #include "cheathandler.h" #include "gamestate.h" +#include "gamefuncs.h" #include "mmulti.h" BEGIN_PS_NS @@ -108,6 +109,8 @@ void GameInterface::ToggleThirdPerson() if (bCamera) { GrabPalette(); + cameradist = 0; + cameraclock = INT_MIN; } } } diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index dc0562edd..bd17491b4 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" #include "compat.h" #include "engine.h" +#include "gamefuncs.h" #include "names.h" #include "view.h" #include "status.h" @@ -247,11 +248,13 @@ void DrawView(double smoothRatio, bool sceneonly) if (!SyncInput()) { + pan = PlayerList[nLocalPlayer].horizon.sum(); nAngle = PlayerList[nLocalPlayer].angle.sum(); rotscrnang = PlayerList[nLocalPlayer].angle.rotscrnang; } else { + pan = PlayerList[nLocalPlayer].horizon.interpolatedsum(smoothRatio); nAngle = PlayerList[nLocalPlayer].angle.interpolatedsum(smoothRatio); rotscrnang = PlayerList[nLocalPlayer].angle.interpolatedrotscrn(smoothRatio); } @@ -261,51 +264,44 @@ void DrawView(double smoothRatio, bool sceneonly) sprite[nPlayerSprite].cstat |= CSTAT_SPRITE_INVISIBLE; sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE; } + else + { + sprite[nPlayerSprite].cstat |= CSTAT_SPRITE_TRANSLUCENT; + sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE; + } renderSetRollAngle(rotscrnang.asbuildf()); + + pan = q16horiz(clamp(pan.asq16(), gi->playerHorizMin(), gi->playerHorizMax())); } nCameraa = nAngle; - if (!bCamera || nFreeze || sceneonly) + if (nSnakeCam >= 0 && !sceneonly) { - if (nSnakeCam >= 0 && !sceneonly) - { - pan = q16horiz(0); - viewz = playerZ; - } - else - { - viewz = playerZ + nQuake[nLocalPlayer]; - int floorZ = sector[sprite[nPlayerSprite].sectnum].floorz; - - if (!SyncInput()) - { - pan = PlayerList[nLocalPlayer].horizon.sum(); - } - else - { - pan = PlayerList[nLocalPlayer].horizon.interpolatedsum(smoothRatio); - } - - if (viewz > floorZ) - viewz = floorZ; - - nCameraa += buildang((nQuake[nLocalPlayer] >> 7) % 31); - } - } - else - { - clipmove_old((int32_t*)&playerX, (int32_t*)&playerY, (int32_t*)&playerZ, &nSector, - -2000 * nAngle.bcos(), - -2000 * nAngle.bsin(), - 4, 0, 0, CLIPMASK1); - pan = q16horiz(0); viewz = playerZ; } + else + { + viewz = playerZ + nQuake[nLocalPlayer]; + int floorZ = sector[sprite[nPlayerSprite].sectnum].floorz; - pan = q16horiz(clamp(pan.asq16(), gi->playerHorizMin(), gi->playerHorizMax())); + if (viewz > floorZ) + viewz = floorZ; + + nCameraa += buildang((nQuake[nLocalPlayer] >> 7) % 31); + + if (bCamera) + { + viewz -= 2560; + if (!calcChaseCamPos(&playerX, &playerY, &viewz, &sprite[nPlayerSprite], &nSector, nAngle, pan, smoothRatio)) + { + viewz += 2560; + calcChaseCamPos(&playerX, &playerY, &viewz, &sprite[nPlayerSprite], &nSector, nAngle, pan, smoothRatio); + } + } + } nCamerax = playerX; nCameray = playerY;