From d5d8d55186cc637c253a6098e7c37eaacb0f4dad Mon Sep 17 00:00:00 2001 From: gir489returns Date: Tue, 30 Jan 2024 11:08:05 -0500 Subject: [PATCH] Fixed infinite ammo. Refactored SpeedHack to not speed up the entire game if you are the host. Removed code from ResetStamina that causes a crash if the player doesn't have pals out. --- feature.cpp | 36 +++++++----------------------------- src/Menu.cpp | 5 +++-- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/feature.cpp b/feature.cpp index 2e11d07..ef3f00d 100644 --- a/feature.cpp +++ b/feature.cpp @@ -253,23 +253,19 @@ void SetFullbright(bool bIsSet) // void SpeedHack(float mSpeed) { - UWorld* pWorld = Config.gWorld; - if (!pWorld) + auto player_controller = Config.GetPalPlayerController(); + if (!player_controller) return; - ULevel* pLevel = pWorld->PersistentLevel; - if (!pLevel) + auto acknowledged_pawn = player_controller->AcknowledgedPawn; + + if (!acknowledged_pawn) return; - AWorldSettings* pWorldSettings = pLevel->WorldSettings; - if (!pWorldSettings) - return; - - pWorld->PersistentLevel->WorldSettings->TimeDilation = mSpeed; - - // pWorldSettings->TimeDilation = mSpeed; + acknowledged_pawn->CustomTimeDilation = mSpeed; } + // void SetDemiGodMode(bool bIsSet) { @@ -360,24 +356,6 @@ void ResetStamina() return; pParams->ResetSP(); - - - // Reset Pal Stamina ?? - TArray outPals; - Config.GetTAllPals(&outPals); - DWORD palsSize = outPals.Count(); - for (int i = 0; i < palsSize; i++) - { - APalCharacter* cPal = outPals[i]; - if (!cPal || cPal->IsA(APalMonsterCharacter::StaticClass())) - continue; - - UPalCharacterParameterComponent* pPalParams = pPalCharacter->CharacterParameterComponent; - if (!pPalParams) - return; - - pPalParams->ResetSP(); - } } // diff --git a/src/Menu.cpp b/src/Menu.cpp index 84e746a..ada3db6 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -72,8 +72,7 @@ namespace DX11_Base ImGui::Checkbox("InfStamina", &Config.IsInfStamina); - if (ImGui::Checkbox("InfAmmo", &Config.IsInfinAmmo)) - SetInfiniteAmmo(Config.IsInfinAmmo); + ImGui::Checkbox("InfAmmo", &Config.IsInfinAmmo); ImGui::Checkbox("Godmode", &Config.IsGodMode); @@ -789,5 +788,7 @@ namespace DX11_Base if (Config.IsGodMode) SetPlayerHealth(INT_MAX); + + SetInfiniteAmmo(Config.IsInfinAmmo); } } \ No newline at end of file