diff --git a/HaloCEVR/Game.cpp b/HaloCEVR/Game.cpp index 01ed133..837ce2b 100644 --- a/HaloCEVR/Game.cpp +++ b/HaloCEVR/Game.cpp @@ -859,6 +859,11 @@ bool Game::GetCalculatedHandPositions(Matrix4& controllerTransform, Vector3& dom return inputHandler.GetCalculatedHandPositions(controllerTransform, dominantHandPos, offHand); } +bool Game::ShouldBlockAutoReloadStart() const +{ + return inputHandler.ShouldBlockAutoReloadStart(); +} + void Game::ReloadStart(HaloID param1, short param2, bool param3) { VR_PROFILE_SCOPE(Game_ReloadStart); @@ -1092,6 +1097,8 @@ void Game::SetupConfigs() c_LeftShoulderHolsterOffset = config.RegisterVector3("LeftShoulderHolsterOffset", "The (foward, left, up) Offset of the left shoulder holster relative to the headset's location", Vector3(-0.15f, 0.25f, -0.25f)); c_RightShoulderHolsterActivationDistance = config.RegisterFloat("RightShoulderHolsterDistance", "The 'size' of the right shoulder holster. This is the distance that the dominant hand needs to be from the holster to change weapons (<0 to disable)", 0.3f); c_RightShoulderHolsterOffset = config.RegisterVector3("RightShoulderHolsterOffset", "The (foward, left, up) Offset of the right shoulder holster relative to the headset's location", Vector3(-0.15f, -0.25f, -0.25f)); + // Manual reload settings + c_DisableEmptyMagazineAutoReload = config.RegisterBool("DisableEmptyMagazineAutoReload", "When enabled, the game will not automatically reload when the magazine is empty. Press Reload to reload manually", false); // Misc settings c_ShowRoomCentre = config.RegisterBool("ShowRoomCentre", "Draw an indicator at your feet to show where the player character is actually positioned", true); c_d3d9Path = config.RegisterString("CustomD3D9Path", "If set first try to load d3d9.dll from the specified path instead of from system32", ""); diff --git a/HaloCEVR/Game.h b/HaloCEVR/Game.h index d52d093..42de920 100644 --- a/HaloCEVR/Game.h +++ b/HaloCEVR/Game.h @@ -61,6 +61,7 @@ class Game bool GetCalculatedHandPositions(Matrix4& controllerTransform, Vector3& dominantHandPos, Vector3& offHand); void ReloadStart(HaloID param1, short param2, bool param3); void ReloadEnd(short param1, HaloID param2); + bool ShouldBlockAutoReloadStart() const; void UpdateInputs(); void CalculateSmoothedInput(); @@ -237,6 +238,7 @@ class Game FloatProperty* c_LeftHandMeleeSwingSpeed = nullptr; FloatProperty* c_RightHandMeleeSwingSpeed = nullptr; FloatProperty* c_CrouchHeight = nullptr; + BoolProperty* c_DisableEmptyMagazineAutoReload = nullptr; BoolProperty* c_ShowRoomCentre = nullptr; BoolProperty* c_ToggleGrip = nullptr; FloatProperty* c_TwoHandDistance = nullptr; diff --git a/HaloCEVR/Hooking/Hooks.cpp b/HaloCEVR/Hooking/Hooks.cpp index 8634f82..ba6158d 100644 --- a/HaloCEVR/Hooking/Hooks.cpp +++ b/HaloCEVR/Hooking/Hooks.cpp @@ -900,6 +900,12 @@ void Hooks::H_ReloadStart(HaloID param1, short param2, bool param3) { VR_PROFILE_SCOPE(Hooks_ReloadStart); + // Block auto-reload from starting. + if (Game::instance.ShouldBlockAutoReloadStart()) + { + return; + } + ReloadStart.Original(param1, param2, param3); Game::instance.ReloadStart(param1, param2, param3); diff --git a/HaloCEVR/InputHandler.cpp b/HaloCEVR/InputHandler.cpp index 71ead9c..b6bf153 100644 --- a/HaloCEVR/InputHandler.cpp +++ b/HaloCEVR/InputHandler.cpp @@ -11,6 +11,17 @@ #define ApplyBoolInput(x) controls.##x = vr->GetBoolInput(x) ? 127 : 0; #define ApplyImpulseBoolInput(x) controls.##x = vr->GetBoolInput(x, bHasChanged) && bHasChanged ? 127 : 0; +bool InputHandler::ShouldBlockAutoReloadStart() const +{ + if (!Game::instance.c_DisableEmptyMagazineAutoReload->Value()) + { + return false; + } + + IVR* vr = Game::instance.GetVR(); + return !vr->GetBoolInput(Reload); +} + void InputHandler::RegisterInputs() { IVR* vr = Game::instance.GetVR(); diff --git a/HaloCEVR/InputHandler.h b/HaloCEVR/InputHandler.h index 49c7fcd..cd560cf 100644 --- a/HaloCEVR/InputHandler.h +++ b/HaloCEVR/InputHandler.h @@ -15,6 +15,8 @@ class InputHandler bool GetCalculatedHandPositions(Matrix4& controllerTransform, Vector3& dominantHandPos, Vector3& offHand); void CalculateSmoothedInput(); + bool ShouldBlockAutoReloadStart() const; + Vector3 smoothedPosition = Vector3(0.0f, 0.0f, 0.0f); // Track previous yaw offset to detect snap turns for weapon position smoothing