From 4043de504bda17d819d84621154455004d8a12a8 Mon Sep 17 00:00:00 2001 From: EricPlayZ Date: Sun, 12 May 2024 02:00:35 +0300 Subject: [PATCH] fixed bugs --- EGameTools/source/changelog.h | 1 + EGameTools/source/config/config.cpp | 2 + EGameTools/source/game/GamePH/game_hooks.cpp | 34 ++++++++++++++++- EGameTools/source/menu/camera.cpp | 40 +++++++++++++++----- EGameTools/source/menu/camera.h | 3 +- EGameTools/source/menu/player.cpp | 2 +- EGameTools/source/menu/teleport.cpp | 8 +--- EGameTools/source/offsets.h | 2 + EGameTools/source/utils/hook.h | 12 +++--- 9 files changed, 78 insertions(+), 26 deletions(-) diff --git a/EGameTools/source/changelog.h b/EGameTools/source/changelog.h index 8c8de50..682907a 100644 --- a/EGameTools/source/changelog.h +++ b/EGameTools/source/changelog.h @@ -70,6 +70,7 @@ Thank you everyone for the support <3)" }, - Added "No Recoil" (Weapon) - Added "Instant Reload" (Weapon) - Added "Lens Distortion" slider (Camera) +- Added "GoPro Mode" (Camera) - this is best used with Head Bob Reduction set to 0 and Player FOV Correction set to 0 in game options; thank you to @c.r.e.x on Discord for the idea of adding this feature! - Added "Disable Head Correction" (Camera) - disables centering of the player's hands to the center of the camera - Added "Teleport to Coords" with X, Y, Z inputs (Teleport), with a "Get Player Coords" button which will automatically fill the X, Y and Z inputs - Added "Teleport to Waypoint" (Teleport) diff --git a/EGameTools/source/config/config.cpp b/EGameTools/source/config/config.cpp index 0605a04..7f91c36 100644 --- a/EGameTools/source/config/config.cpp +++ b/EGameTools/source/config/config.cpp @@ -4364,6 +4364,7 @@ namespace Config { { "Menu:Keybinds", "TeleportPlayerToCameraToggleKey", std::string("VK_F4"), &Menu::Camera::teleportPlayerToCamera, String}, { "Menu:Keybinds", "ThirdPersonToggleKey", std::string("VK_F1"), &Menu::Camera::thirdPersonCamera, String}, { "Menu:Keybinds", "UseTPPModelToggleKey", std::string("VK_F2"), &Menu::Camera::tpUseTPPModel, String}, + { "Menu:Keybinds", "GoProMode", std::string("VK_NONE"), &Menu::Camera::goProMode, String }, { "Menu:Keybinds", "DisableSafezoneFOVReduction", std::string("VK_NONE"), &Menu::Camera::disableSafezoneFOVReduction, String }, { "Menu:Keybinds", "DisablePhotoModeLimits", std::string("VK_NONE"), &Menu::Camera::disablePhotoModeLimits, String}, { "Menu:Keybinds", "DisableHeadCorrectionToggleKey", std::string("VK_NONE"), &Menu::Camera::disableHeadCorrection, String }, @@ -4400,6 +4401,7 @@ namespace Config { { "Camera:ThirdPerson", "HeightAbovePlayer", 1.35f, &Menu::Camera::tpHeightAbovePlayer, Float }, { "Camera:ThirdPerson", "HorizontalDistanceFromPlayer", 0.0f, &Menu::Camera::tpHorizontalDistanceFromPlayer, Float }, { "Camera:Misc", "LensDistortion", 20.0f, &Menu::Camera::lensDistortion, Float }, + { "Camera:Misc", "GoProMode", false, &Menu::Camera::goProMode, OPTION }, { "Camera:Misc", "DisableSafezoneFOVReduction", true, &Menu::Camera::disableSafezoneFOVReduction, OPTION }, { "Camera:Misc", "DisablePhotoModeLimits", true, &Menu::Camera::disablePhotoModeLimits, OPTION }, { "Camera:Misc", "DisableHeadCorrection", false, &Menu::Camera::disableHeadCorrection, OPTION }, diff --git a/EGameTools/source/game/GamePH/game_hooks.cpp b/EGameTools/source/game/GamePH/game_hooks.cpp index d67c5ae..d09804b 100644 --- a/EGameTools/source/game/GamePH/game_hooks.cpp +++ b/EGameTools/source/game/GamePH/game_hooks.cpp @@ -252,7 +252,7 @@ namespace GamePH { if (Menu::Player::disableAirControl.GetValue()) *reinterpret_cast(a1 + Offsets::Get_allowVelocityMod_offset()) = false; - if (Menu::Camera::disableHeadCorrection.GetValue()) + if (Menu::Camera::disableHeadCorrection.GetValue() || Menu::Camera::goProMode.GetValue()) *reinterpret_cast(a1 + Offsets::Get_disableHeadCorrection_offset()) = true; return result; @@ -289,6 +289,38 @@ namespace GamePH { } #pragma endregion +/*#pragma region HandleHeadBob + static bool isHandleHeadBobRunning = false; + + static void detourHandleHeadBob(DWORD64 a1, DWORD64 a2, DWORD64 a3, DWORD64 a4); + static Utils::Hook::MHook HandleHeadBobHook{ "HandleHeadBob", &Offsets::Get_HandleHeadBob, &detourHandleHeadBob }; + + static void detourHandleHeadBob(DWORD64 a1, DWORD64 a2, DWORD64 a3, DWORD64 a4) { + isHandleHeadBobRunning = true; + HandleHeadBobHook.pOriginal(a1, a2, a3, a4); + isHandleHeadBobRunning = false; + } +#pragma endregion + +#pragma region SomeFloatCalcFunc + static DWORD64 detourSomeFloatCalcFunc(float* a1, float* a2, float a3, DWORD64 a4, DWORD64 a5, DWORD64 a6); + static Utils::Hook::MHook SomeFloatCalcFuncHook{ "SomeFloatCalcFunc", &Offsets::Get_SomeFloatCalcFunc, &detourSomeFloatCalcFunc }; + + static DWORD64 detourSomeFloatCalcFunc(float* a1, float* a2, float a3, DWORD64 a4, DWORD64 a5, DWORD64 a6) { + if (isHandleHeadBobRunning) { + static int i = 1; + if (*a1 < 0.002f && i >= 2 && i <= 3) { + *a1 *= 2.0f; + a3 *= 2.0f; + } + i++; + if (i > 3) + i = 1; + } + return SomeFloatCalcFuncHook.pOriginal(a1, a2, a3, a4, a5, a6); + } +#pragma endregion*/ + #pragma region ByteHooks static unsigned char SaveGameCRCBoolCheckBytes[3] = { 0xB3, 0x01, 0x90 }; // mov bl, 01 Utils::Hook::ByteHook SaveGameCRCBoolCheckHook{ "SaveGameCRCBoolCheck", &Offsets::Get_SaveGameCRCBoolCheck, SaveGameCRCBoolCheckBytes, sizeof(SaveGameCRCBoolCheckBytes), &Menu::Misc::disableSavegameCRCCheck }; // and bl, dil diff --git a/EGameTools/source/menu/camera.cpp b/EGameTools/source/menu/camera.cpp index 9615219..545a45e 100644 --- a/EGameTools/source/menu/camera.cpp +++ b/EGameTools/source/menu/camera.cpp @@ -29,8 +29,9 @@ namespace Menu { float tpHorizontalDistanceFromPlayer = 0.0f; float lensDistortion = 20.0f; - KeyBindOption disablePhotoModeLimits{ VK_NONE }; + KeyBindOption goProMode{ VK_NONE }; KeyBindOption disableSafezoneFOVReduction{ VK_NONE }; + KeyBindOption disablePhotoModeLimits{ VK_NONE }; KeyBindOption disableHeadCorrection{ VK_NONE }; static constexpr int baseFOV = 57; @@ -141,17 +142,27 @@ namespace Menu { if (!GamePH::PlayerVariables::gotPlayerVars) return; - static bool gotDefaultVal = false; - if (!gotDefaultVal) { - lensDistortion = GamePH::PlayerVariables::GetPlayerVar("FOVCorrection") * 100.0f; - gotDefaultVal = true; - } - GamePH::PlayerVariables::ManagePlayerVarOption("CameraDefaultFOVReduction", 0.0f, baseSafezoneFOVReduction, &disableSafezoneFOVReduction, true); - GamePH::PlayerVariables::ChangePlayerVar("FOVCorrection", lensDistortion / 100.0f); + Engine::CVideoSettings* pCVideoSettings = Engine::CVideoSettings::Get(); + if (pCVideoSettings) { + static int previousFOV = FOV; + if (goProMode.HasChangedTo(true)) { + previousFOV = FOV; + goProMode.SetPrevValue(true); + } else if (goProMode.HasChangedTo(false)) { + FOV = previousFOV; + pCVideoSettings->extraFOV = static_cast(FOV - baseFOV); + goProMode.SetPrevValue(false); + } - GamePH::PlayerVariables::ManagePlayerVarOption("SprintHeadCorrectionFactor", 0.0f, baseSprintHeadCorrectionFactor, &disableHeadCorrection, true); + if (goProMode.GetValue()) + pCVideoSettings->extraFOV = static_cast((goProMode.GetValue() ? 110 : FOV) - baseFOV); + } + GamePH::PlayerVariables::ChangePlayerVar("FOVCorrection", goProMode.GetValue() ? 1.0f : lensDistortion / 100.0f); + GamePH::PlayerVariables::ManagePlayerVarOption("HeadBobFactor", 1.25f, 1.0f, &goProMode, true); + + GamePH::PlayerVariables::ManagePlayerVarOption("SprintHeadCorrectionFactor", 0.0f, baseSprintHeadCorrectionFactor, goProMode.GetValue() ? &goProMode : &disableHeadCorrection, true); } static void UpdateDisabledOptions() { GamePH::LevelDI* iLevel = GamePH::LevelDI::Get(); @@ -161,6 +172,10 @@ namespace Menu { tpUseTPPModel.SetChangesAreDisabled(freeCam.GetValue() || photoMode.GetValue()); } static void HandleToggles() { + if (goProMode.HasChanged()) { + goProMode.SetPrevValue(goProMode.GetValue()); + GamePH::ReloadJumps(); + } if (disableHeadCorrection.HasChanged()) { disableHeadCorrection.SetPrevValue(disableHeadCorrection.GetValue()); GamePH::ReloadJumps(); @@ -213,10 +228,15 @@ namespace Menu { ImGui::EndDisabled(); } ImGui::SliderFloat("Lens Distortion", "Default game value is 20%", &lensDistortion, 0.0f, 100.0f, "%.1f%%"); - ImGui::CheckboxHotkey("Disable Safezone FOV Reduction", &disableSafezoneFOVReduction, "Disables the FOV reduction that happens while you're in a safezone"); + ImGui::CheckboxHotkey("GoPro Mode *", &goProMode, "Makes the camera behave similar to a GoPro mounted on the chest"); ImGui::SameLine(); + ImGui::CheckboxHotkey("Disable Safezone FOV Reduction", &disableSafezoneFOVReduction, "Disables the FOV reduction that happens while you're in a safezone"); ImGui::CheckboxHotkey("Disable Photo Mode Limits", &disablePhotoModeLimits, "Disables the invisible box while in Photo Mode"); + ImGui::SameLine(); ImGui::CheckboxHotkey("Disable Head Correction", &disableHeadCorrection, "Disables centering of the player's hands to the center of the camera"); + + ImGui::Separator(); + ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(IM_COL32(200, 0, 0, 255)), "* GoPro Mode is best used with Head Bob Reduction set to 0 and Player FOV\nCorrection set to 0 in game options"); } } } \ No newline at end of file diff --git a/EGameTools/source/menu/camera.h b/EGameTools/source/menu/camera.h index 8ef502d..630d6a5 100644 --- a/EGameTools/source/menu/camera.h +++ b/EGameTools/source/menu/camera.h @@ -19,8 +19,9 @@ namespace Menu { extern float tpHorizontalDistanceFromPlayer; extern float lensDistortion; - extern KeyBindOption disablePhotoModeLimits; + extern KeyBindOption goProMode; extern KeyBindOption disableSafezoneFOVReduction; + extern KeyBindOption disablePhotoModeLimits; extern KeyBindOption disableHeadCorrection; class Tab : MenuTab { diff --git a/EGameTools/source/menu/player.cpp b/EGameTools/source/menu/player.cpp index e655a0a..ba6fe6d 100644 --- a/EGameTools/source/menu/player.cpp +++ b/EGameTools/source/menu/player.cpp @@ -6544,7 +6544,7 @@ namespace Menu { } } catch (std::exception& e) { UNREFERENCED_PARAMETER(e); - spdlog::error("PlayerVarsUpdate() threw an exception! If this error message appears, please open a bug report."); + spdlog::error("PlayerVarsUpdate() threw an exception! Restart the game to fix this error. If the error still happens, please open a bug report."); } } } diff --git a/EGameTools/source/menu/teleport.cpp b/EGameTools/source/menu/teleport.cpp index a0fa97b..db2e82e 100644 --- a/EGameTools/source/menu/teleport.cpp +++ b/EGameTools/source/menu/teleport.cpp @@ -138,20 +138,14 @@ namespace Menu { if (pos.isDefault()) return false; - Engine::CBulletPhysicsCharacter* playerCharacter = Engine::CBulletPhysicsCharacter::Get(); - if (Camera::freeCam.GetValue()) { GamePH::FreeCamera* freeCam = GamePH::FreeCamera::Get(); if (!freeCam) return false; freeCam->SetPosition(&pos); - if (playerCharacter) { - if (Player::freezePlayer.GetValue()) - playerCharacter->posBeforeFreeze = pos; - playerCharacter->MoveCharacter(pos); - } } else { + Engine::CBulletPhysicsCharacter* playerCharacter = Engine::CBulletPhysicsCharacter::Get(); if (!playerCharacter) return false; diff --git a/EGameTools/source/offsets.h b/EGameTools/source/offsets.h index f60f3e1..6e5159e 100644 --- a/EGameTools/source/offsets.h +++ b/EGameTools/source/offsets.h @@ -102,6 +102,8 @@ struct Offsets { AddOffset(HandleInventoryItemsAmount, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC ?? 8B 29", Utils::SigScan::PatternType::Address, LPVOID) AddOffset(SetNewWaypointLocation, "gamedll_ph_x64_rwdi.dll", "85 D2 78 ?? 48 89 74 24 ?? 57 48 83 EC ?? 49 8B F8", Utils::SigScan::PatternType::Address, LPVOID) AddOffset(SetNewWaypointLocationWaypointIsSetBoolInstr, "gamedll_ph_x64_rwdi.dll", "C6 84 33 [?? ?? ?? ?? 01 48 8B 5C 24", Utils::SigScan::PatternType::Address, DWORD*) + AddOffset(HandleHeadBob, "gamedll_ph_x64_rwdi.dll", "40 53 48 83 EC ?? 0F 29 74 24 ?? 48 8D 51 ?? 0F 29 7C 24 ?? 0F 28 F3 0F 28 FA F3 0F 11 74 24 ?? F3 0F 10 51 ?? 0F 28 D9 44 0F 29 44 24 ?? 48 8B D9 F3 0F 11 7C 24 ?? 44 0F 28 C1 E8 ?? ?? ?? ?? F3 0F 10 53 ?? 48 8D 53 ?? F3 0F 11 74 24 ?? 48 8D 4B ?? 41 0F 28 D8 F3 0F 11 7C 24 ?? E8 ?? ?? ?? ?? F3 0F 10 53 ?? 48 8D 53 ?? F3 0F 11 74 24 ?? 48 8D 4B ?? 41 0F 28 D8 F3 0F 11 7C 24 ?? E8 ?? ?? ?? ?? F3 0F 10 53", Utils::SigScan::PatternType::Address, LPVOID) + AddOffset(SomeFloatCalcFunc, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? F3 0F 10 0D", Utils::SigScan::PatternType::Address, LPVOID) //AddOffset(CompareAndUpdateFloat, "gamedll_ph_x64_rwdi.dll", "0F 2F C1 73 ?? 0F 28 C1 C3", Utils::SigScan::PatternType::Address, LPVOID) //AddOffset(HandlePlayerImmunity, "gamedll_ph_x64_rwdi.dll", "48 8B C4 53 56 57 41 56 41 57", Utils::SigScan::PatternType::Address, LPVOID) //AddOffset(HandlePlayerImmunity2, "gamedll_ph_x64_rwdi.dll", "40 55 56 41 56 41 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 48 8B F1 45 0F B6 F0", Utils::SigScan::PatternType::Address, LPVOID) diff --git a/EGameTools/source/utils/hook.h b/EGameTools/source/utils/hook.h index 6816a97..af4154a 100644 --- a/EGameTools/source/utils/hook.h +++ b/EGameTools/source/utils/hook.h @@ -40,7 +40,7 @@ namespace Utils { bool HookLoop() override { if (hooked || (optionRef && !optionRef->GetValue())) return true; - timeSpentHooking = Utils::Time::Timer(60000); + timeSpentHooking = Utils::Time::Timer(180000); while (true) { if (timeSpentHooking.DidTimePass()) { @@ -111,7 +111,7 @@ namespace Utils { bool hooked = false; - Utils::Time::Timer timeSpentHooking{ 60000 }; + Utils::Time::Timer timeSpentHooking{ 180000 }; }; template class MHook : HookBase { @@ -121,7 +121,7 @@ namespace Utils { bool HookLoop() override { if (pOriginal) return true; - timeSpentHooking = Utils::Time::Timer(60000); + timeSpentHooking = Utils::Time::Timer(180000); while (true) { if (timeSpentHooking.DidTimePass()) { @@ -146,7 +146,7 @@ namespace Utils { GetTargetOffsetRetType(*pGetOffsetFunc)() = nullptr; OrigType pDetour = nullptr; - Utils::Time::Timer timeSpentHooking{ 60000 }; + Utils::Time::Timer timeSpentHooking{ 180000 }; }; template class VTHook : HookBase { @@ -156,7 +156,7 @@ namespace Utils { bool HookLoop() override { if (pOriginal) return true; - timeSpentHooking = Utils::Time::Timer(60000); + timeSpentHooking = Utils::Time::Timer(180000); while (true) { if (timeSpentHooking.DidTimePass()) { @@ -181,7 +181,7 @@ namespace Utils { LPVOID pInstance = nullptr; OrigType pDetour = nullptr; - Utils::Time::Timer timeSpentHooking{ 60000 }; + Utils::Time::Timer timeSpentHooking{ 180000 }; DWORD offset = 0x0; };