diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index 7eb6ffda..d5e91e97 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -170,6 +170,8 @@ namespace Components Dvar::Var Gamepad::gpad_button_rstick_deflect_max; Dvar::Var Gamepad::gpad_button_lstick_deflect_max; Dvar::Var Gamepad::gpad_use_hold_time; + Dvar::Var Gamepad::gpad_lockon_enabled; + Dvar::Var Gamepad::gpad_slowdown_enabled; Dvar::Var Gamepad::input_viewSensitivity; Dvar::Var Gamepad::input_invertPitch; Dvar::Var Gamepad::sv_allowAimAssist; @@ -416,6 +418,23 @@ namespace Components return AimAssist_GetBestTarget(aaGlob, range, regionWidth, regionHeight); } + bool Gamepad::AimAssist_IsLockonActive(const int gamePadIndex) + { + assert(gamePadIndex < Game::MAX_GAMEPADS); + auto& aaGlob = Game::aaGlobArray[gamePadIndex]; + + if (!aim_lockon_enabled.get() || !gpad_lockon_enabled.get()) + return false; + + if (AimAssist_IsPlayerUsingOffhand(&aaGlob.ps)) + return false; + + if (aaGlob.autoAimActive || aaGlob.autoMeleeState == Game::AIM_MELEE_STATE_UPDATING) + return false; + + return true; + } + void Gamepad::AimAssist_ApplyLockOn(const Game::AimInput* input, Game::AimOutput* output) { #ifdef AIM_ASSIST_ENABLED @@ -427,7 +446,7 @@ namespace Components const auto prevTargetEnt = aaGlob.lockOnTargetEnt; aaGlob.lockOnTargetEnt = Game::AIM_TARGET_INVALID; - if (!aim_lockon_enabled.get() || AimAssist_IsPlayerUsingOffhand(&aaGlob.ps) || aaGlob.autoAimActive || aaGlob.autoMeleeState == Game::AIM_MELEE_STATE_UPDATING) + if (!AimAssist_IsLockonActive(input->localClientNum)) return; const auto* weaponDef = Game::BG_GetWeaponDef(aaGlob.ps.weapIndex); @@ -510,7 +529,7 @@ namespace Components bool Gamepad::AimAssist_IsSlowdownActive(const Game::AimAssistPlayerState* ps) { - if (!aim_slowdown_enabled.get()) + if (!aim_slowdown_enabled.get() || !gpad_slowdown_enabled.get()) return false; if (!ps->weapIndex) @@ -1669,6 +1688,8 @@ namespace Components gpad_button_lstick_deflect_max = Dvar::Register("gpad_button_lstick_deflect_max", 1.0f, 0.0f, 1.0f, 0, "Game pad maximum pad stick pressed value"); gpad_button_rstick_deflect_max = Dvar::Register("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, 0, "Game pad maximum pad stick pressed value"); gpad_use_hold_time = Dvar::Register("gpad_use_hold_time", 250, 0, INT32_MAX, 0, "Time to hold the 'use' button on gamepads to activate use"); + gpad_lockon_enabled = Dvar::Register("gpad_lockon_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad lockon aim assist enabled"); + gpad_slowdown_enabled = Dvar::Register("gpad_slowdown_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad slowdown aim assist enabled"); input_viewSensitivity = Dvar::Register("input_viewSensitivity", 1.0f, 0.0001f, 5.0f, Game::DVAR_FLAG_SAVED, "View Sensitivity"); input_invertPitch = Dvar::Register("input_invertPitch", false, Game::DVAR_FLAG_SAVED, "Invert gamepad pitch"); diff --git a/src/Components/Modules/Gamepad.hpp b/src/Components/Modules/Gamepad.hpp index 51421410..21106886 100644 --- a/src/Components/Modules/Gamepad.hpp +++ b/src/Components/Modules/Gamepad.hpp @@ -299,6 +299,8 @@ namespace Components static Dvar::Var gpad_button_rstick_deflect_max; static Dvar::Var gpad_button_lstick_deflect_max; static Dvar::Var gpad_use_hold_time; + static Dvar::Var gpad_lockon_enabled; + static Dvar::Var gpad_slowdown_enabled; static Dvar::Var input_viewSensitivity; static Dvar::Var input_invertPitch; static Dvar::Var sv_allowAimAssist; @@ -338,6 +340,7 @@ namespace Components static const Game::AimScreenTarget* AimAssist_GetBestTarget(const Game::AimAssistGlobals* aaGlob, float range, float regionWidth, float regionHeight); static const Game::AimScreenTarget* AimAssist_GetTargetFromEntity(const Game::AimAssistGlobals* aaGlob, int entIndex); static const Game::AimScreenTarget* AimAssist_GetPrevOrBestTarget(const Game::AimAssistGlobals* aaGlob, float range, float regionWidth, float regionHeight, int prevTargetEnt); + static bool AimAssist_IsLockonActive(int gamePadIndex); static void AimAssist_ApplyLockOn(const Game::AimInput* input, Game::AimOutput* output); static void AimAssist_CalcAdjustedAxis(const Game::AimInput* input, float* pitchAxis, float* yawAxis); static bool AimAssist_IsSlowdownActive(const Game::AimAssistPlayerState* ps);