From a5a9882d9aa8d682d9196ca41e80a1b4129410e5 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 26 Mar 2023 12:45:48 +1100 Subject: [PATCH] - Duke: Add a myriad of pitch recentering CVARs. * Needs to be reworked into some kind of MP-safe flagging once we have demos/MP going. This will do for now. * Fixes #853. --- source/core/gamecvars.cpp | 10 +++++++++- source/core/gamecvars.h | 13 ++++++++++++- source/games/duke/src/duke3d.h | 2 +- source/games/duke/src/input.cpp | 15 --------------- source/games/duke/src/player.cpp | 2 +- source/games/duke/src/player_d.cpp | 2 +- source/games/duke/src/player_r.cpp | 2 +- source/games/duke/src/types.h | 5 ++++- wadsrc/static/menudef.txt | 8 +++++++- 9 files changed, 36 insertions(+), 23 deletions(-) diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 9681f3f95..62f1ae65b 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -91,8 +91,16 @@ CVARD(Bool, cl_bloodweapinterp, false, CVAR_ARCHIVE, "enable/disable Blood's wea CVARD(Bool, cl_bloodoldweapbalance, false, CVAR_ARCHIVE, "enable/disable legacy 1.0 weapon handling for Blood") CVARD(Bool, cl_loadingscreens, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable loading screens for games") CVARD(Bool, cl_clampedpitch, true, CVAR_ARCHIVE, "clamp the view pitch to original ranges") -CVARD(Bool, cl_dukelockpitchreturn, true, CVAR_ARCHIVE, "enable/disable Duke's pitch input when returning to centre") +CUSTOM_CVARD(Int, cl_dukepitchmode, 7, CVAR_ARCHIVE, "customise Duke's myriad of pitch options") +{ + if (self < 0) self = 0; + else if (self > 7) self = 7; +} + +CVARD(Flag, cl_dukepitchlockreturn, cl_dukepitchmode, 1, "enable/disable pitch input while returning to centre"); +CVARD(Flag, cl_dukepitchhardlanding, cl_dukepitchmode, 2, "enable/disable pitch adjustment from a high fall"); +CVARD(Flag, cl_dukepitchlandingrecenter, cl_dukepitchmode, 4, "enable/disable pitch recentreing after a high fall"); CUSTOM_CVARD(Int, cl_autoaim, 1, CVAR_ARCHIVE|CVAR_USERINFO, "enable/disable weapon autoaim") { diff --git a/source/core/gamecvars.h b/source/core/gamecvars.h index 99078798b..eb936a810 100644 --- a/source/core/gamecvars.h +++ b/source/core/gamecvars.h @@ -1,6 +1,13 @@ #pragma once #include "c_cvars.h" +enum +{ + kDukePitchLockReturn = 1, + kDukePitchHardLanding = 2, + kDukePitchLandingRecenter = 4, +}; + EXTERN_CVAR(Bool, cl_crosshair) EXTERN_CVAR(Bool, cl_automsg) EXTERN_CVAR(Int, cl_autoaim) @@ -36,7 +43,11 @@ EXTERN_CVAR(Bool, cl_bloodweapinterp) EXTERN_CVAR(Bool, cl_bloodoldweapbalance) EXTERN_CVAR(Bool, cl_loadingscreens) EXTERN_CVAR(Bool, cl_clampedpitch) -EXTERN_CVAR(Bool, cl_dukelockpitchreturn) + +EXTERN_CVAR(Int, cl_dukepitchmode) +EXTERN_CVAR(Flag, cl_dukepitchlockreturn) +EXTERN_CVAR(Flag, cl_dukepitchnohardlanding) +EXTERN_CVAR(Flag, cl_dukepitchnolandingcenter) EXTERN_CVAR(Bool, demorec_seeds_cvar) EXTERN_CVAR(Bool, demoplay_diffs) diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 9dca0d704..6f3716d78 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -39,7 +39,7 @@ struct GameInterface : public ::GameInterface void SerializeGameState(FSerializer& arc) override; void ExitFromMenu() override; void DrawPlayerSprite(const DVector2& origin, bool onteam) override; - void reapplyInputBits(InputPacket* const input) override; + void reapplyInputBits(InputPacket* const input) override { input->actions |= ps[myconnectindex].sync.actions & SB_CENTERVIEW; } void GetInput(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust) override; void UpdateSounds() override; void Startup() override; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index ac12c0f65..28d3e4a55 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -610,21 +610,6 @@ static void processVehicleInput(player_struct *p, HIDInput* const hidInput, Inpu } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void GameInterface::reapplyInputBits(InputPacket* const input) -{ - if ((ps[myconnectindex].sync.actions & SB_CENTERVIEW) && (cl_dukelockpitchreturn || !input->avel)) - { - input->actions |= SB_CENTERVIEW; - } -} - - //--------------------------------------------------------------------------- // // External entry point diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index a67f3f30d..b31fce45b 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -802,7 +802,7 @@ void player_struct::checkhardlanding() { if (hard_landing > 0) { - GetActor()->spr.Angles.Pitch += maphoriz(hard_landing << 4); + GetActor()->spr.Angles.Pitch += maphoriz(hard_landing << 4) * !!(cl_dukepitchmode & kDukePitchHardLanding); hard_landing--; } } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 2c6b56991..e485166a4 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2973,7 +2973,7 @@ HORIZONLY: } // center_view - if (actions & SB_CENTERVIEW || p->hard_landing) + if (actions & SB_CENTERVIEW || (p->hard_landing && (cl_dukepitchmode & kDukePitchLandingRecenter))) { playerCenterView(snum); } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 66ca79391..99d77df06 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3694,7 +3694,7 @@ HORIZONLY: return; } - if (actions & SB_CENTERVIEW || p->hard_landing) + if (actions & SB_CENTERVIEW || (p->hard_landing && (cl_dukepitchmode & kDukePitchLandingRecenter))) { playerCenterView(snum); } diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index e2f9fa98d..1479f5974 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -347,7 +347,10 @@ struct player_struct bool centeringView() { - return (sync.actions & SB_CENTERVIEW) && abs(GetActor()->spr.Angles.Pitch.Degrees()) > 2.2370; + const bool centering = sync.actions & SB_CENTERVIEW; + const bool lockedret = cl_dukepitchmode & kDukePitchLockReturn; + const bool rangetest = abs(GetActor()->spr.Angles.Pitch.Degrees()) > 2.2370; + return centering && lockedret && rangetest; } }; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 292622071..3d10c159f 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1024,12 +1024,18 @@ OptionMenu GameplayOptions protected { Option "$PLRMNU_FULLVIEWPITCH", "cl_clampedpitch", "OffOn" } + StaticText "" ifgame(Blood) { Option "$PLRMNU_BLDQAVINTERP", "cl_bloodqavinterp", "OnOff" Option "$PLRMNU_BLDWEAPINTERP", "cl_bloodweapinterp", "OnOff", "cl_bloodqavinterp" } - // StaticText "" + ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides) + { + Option "$PLRMNU_DUKEPITCHLOCKRET", "cl_dukepitchlockreturn", "OnOff" + Option "$PLRMNU_DUKEPITCHHARDLAND", "cl_dukepitchhardlanding", "OnOff" + Option "$PLRMNU_DUKEPITCHLANDRET", "cl_dukepitchlandingrecenter", "OnOff" + } // Option "Record Demo", "m_recstat", "OnOff" // Submenu "Cheats" "CheatsMenu }