diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 3016bc2fb..eba8a7cf8 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -54,12 +54,12 @@ GameInput gameInput{}; // //--------------------------------------------------------------------------- -static inline DAngle getscaledangle(const DAngle angle, const double scale, const DAngle push) +static inline DAngle getscaledangle(const DAngle angle, const double scale, const double push) { - return (angle.Normalized180() * getTicrateScale(scale)) + push; + return (angle.Normalized180() * getTicrateScale(scale)) + DAngle::fromDeg(push); } -static inline bool scaletozero(DAngle& angle, const double scale, const DAngle push = DAngle::fromDeg(32. / 465.)) +bool scaletozero(DAngle& angle, const double scale, const double push) { const auto sgn = angle.Sgn(); diff --git a/source/core/gameinput.h b/source/core/gameinput.h index ce1ce9df6..ec860dabc 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -16,7 +16,7 @@ class GameInput TURBOTURNBASE = 590, }; - static constexpr double YAW_TURNSPEEDS[3] = { 41.1987304, 156.555175, 272.24121 }; + static constexpr double YAW_TURNSPEEDS[3] = { 234.375 * (360. / 2048.), 890.625 * (360. / 2048.), 1548.75 * (360. / 2048.) }; static constexpr double YAW_PREAMBLESCALE = YAW_TURNSPEEDS[0] / YAW_TURNSPEEDS[1]; // Input received from the OS. @@ -154,13 +154,13 @@ private: static constexpr double YAW_LOOKRETURN = 7.5; static constexpr double YAW_SPINSTAND = 675.; static constexpr double YAW_SPINCROUCH = YAW_SPINSTAND * 0.5; - static constexpr double PITCH_LOOKSPEED = 222.83185; + static constexpr double PITCH_LOOKSPEED = (269426662. / 1209103.); static constexpr double PITCH_AIMSPEED = PITCH_LOOKSPEED * 0.5; static constexpr double PITCH_CENTERSPEED = 10.7375; static constexpr double PITCH_HORIZOFFSPEED = 4.375; static constexpr DAngle PITCH_CNTRSINEOFFSET = DAngle90 / 8.; static constexpr DAngle PITCH_HORIZOFFCLIMB = DAngle::fromDeg(-38.); - static constexpr DAngle PITCH_HORIZOFFPUSH = DAngle::fromDeg(0.4476); + static constexpr double PITCH_HORIZOFFPUSH = (14115687. / 31535389.); }; extern GameInput gameInput; @@ -168,3 +168,4 @@ extern GameInput gameInput; class FSerializer; FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, PlayerAngles* def); void processCrouchToggle(bool& toggle, ESyncBits& actions, const bool crouchable, const bool disabletoggle); +bool scaletozero(DAngle& angle, const double scale, const double push = (7646143. / 110386328.)); diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 2cf09c94a..f75d3e5dc 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -36,6 +36,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include +CUSTOM_CVAR(Int, cl_exviewtilting, 0, CVAR_ARCHIVE) +{ + if (self < 0) self = 0; + else if (self > 2) self = 2; +} +CVAR(Float, cl_extiltscale, 1.f, CVAR_ARCHIVE); + BEGIN_PS_NS static constexpr actionSeq PlayerSeq[] = { @@ -1519,7 +1526,7 @@ static void doPlayerGravity(DExhumedActor* const pPlayerActor) // //--------------------------------------------------------------------------- -static void doPlayerPitch(Player* const pPlayer, const double nDestVertPan) +static void doPlayerPitch(Player* const pPlayer) { const auto pInput = &pPlayer->input; @@ -1528,7 +1535,6 @@ static void doPlayerPitch(Player* const pPlayer, const double nDestVertPan) pPlayer->pActor->spr.Angles.Pitch += DAngle::fromDeg(pInput->horz); } - doPlayerVertPanning(pPlayer, nDestVertPan * cl_slopetilting); pPlayer->Angles.doPitchKeys(pInput); } @@ -1557,6 +1563,41 @@ static void doPlayerYaw(Player* const pPlayer) // //--------------------------------------------------------------------------- +static void doPlayerCameraEffects(Player* const pPlayer, const double nDestVertPan) +{ + const auto pPlayerActor = pPlayer->pActor; + const auto pInput = &pPlayer->input; + static double rollreturnrate; + + // Pitch tilting when player's Z changes (stairs, jumping, etc). + doPlayerVertPanning(pPlayer, nDestVertPan * cl_slopetilting); + + // Roll tilting effect, either console or Quake-style. + if (cl_exviewtilting == 1) + { + // Console-like yaw rolling. Adjustment == (90/32) for keyboard turning. Clamp is 1.5x this value. + const auto adjustment = DAngle::fromDeg(pInput->avel * (48779.f / 150000.f) * cl_extiltscale); + const auto adjmaximum = DAngle::fromDeg((11553170. / 1347146.) * cl_extiltscale); + pPlayerActor->spr.Angles.Roll = clamp(pPlayerActor->spr.Angles.Roll + adjustment, -adjmaximum, adjmaximum); + rollreturnrate = GameTicRate * 0.5; + } + else if (cl_exviewtilting == 2) + { + // Quake-like strafe rolling. Adjustment == (90/48) for running keyboard strafe. + pPlayerActor->spr.Angles.Roll += DAngle::fromDeg(pInput->svel * (1563154.f / 4358097.f) * cl_extiltscale); + rollreturnrate = GameTicRate * 0.25; + } + + // Always scale roll back to zero in case the functionality is disabled mid-roll. + scaletozero(pPlayerActor->spr.Angles.Roll, rollreturnrate); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + static void updatePlayerFloorActor(Player* const pPlayer) { if (nTotalPlayers > 1) @@ -1787,6 +1828,7 @@ static bool doPlayerInput(Player* const pPlayer) // update player yaw here as per the original workflow. doPlayerYaw(pPlayer); + doPlayerPitch(pPlayer); if (nMove.type || nMove.exbits) { @@ -1801,8 +1843,9 @@ static bool doPlayerInput(Player* const pPlayer) pPlayer->ototalvel = pPlayer->totalvel; pPlayer->totalvel = int(posdelta.XY().Length() * worldtoint); + // Effects such as slope tilting, view bobbing, etc. // This should amplified 8x, not 2x, but it feels very heavy. Add a CVAR? - doPlayerPitch(pPlayer, -posdelta.Z * 2.); + doPlayerCameraEffects(pPlayer, -posdelta.Z * 2.); // Most-move updates. Input bit funcs are here because // updatePlayerAction() needs access to bUnderwater.