From 3a51834d4b407b0e3444234f2ffe86faa9befb76 Mon Sep 17 00:00:00 2001 From: EricPlayZ Date: Sat, 4 May 2024 00:58:15 +0300 Subject: [PATCH] - Added "Invisible to Enemies" (Player) - Changed Unlimited Immunity to use player variables instead of function hooking --- EGameTools/source/changelog.h | 1 + EGameTools/source/game/GamePH/game_hooks.cpp | 45 -------------------- EGameTools/source/menu/player.cpp | 9 +++- EGameTools/source/menu/player.h | 1 + EGameTools/source/offsets.h | 6 +-- 5 files changed, 12 insertions(+), 50 deletions(-) diff --git a/EGameTools/source/changelog.h b/EGameTools/source/changelog.h index 7c50afd..fe0bf34 100644 --- a/EGameTools/source/changelog.h +++ b/EGameTools/source/changelog.h @@ -54,6 +54,7 @@ Thank you everyone for the support <3)" }, R"(- Added compatibility with v1.16.1 hotfix update - Added "Player Immunity" slider (Player) - Added "Unlimited Immunity" (Player) +- Added "Invisible to Enemies" (Player) - Added "Increase Data PAKs Limit" (Misc; requires game restart to apply) - you can now add more than 8 data PAKs, e.g. data8.pak, data9.pak, data10.pak, etc, up to 200 PAKs in total - Added "Disable Data PAKs CRC Check" (Misc; requires game restart to apply) - stops the game from detecting data PAKs, which allows you to use data PAK mods in multiplayer as well - Added "Disable Savegame CRC Check" (Misc; requires game restart to apply) - stops the game from falsely saying your savegame is corrupt whenever you modify it diff --git a/EGameTools/source/game/GamePH/game_hooks.cpp b/EGameTools/source/game/GamePH/game_hooks.cpp index c555a93..e0ac738 100644 --- a/EGameTools/source/game/GamePH/game_hooks.cpp +++ b/EGameTools/source/game/GamePH/game_hooks.cpp @@ -223,51 +223,6 @@ namespace GamePH { } #pragma endregion -#pragma region CompareAndUpdateFloat - static bool funcHandlePlayerImmunityRunning = false; - - static float detourCompareAndUpdateFloat(float result, float a1, float a2); - static Utils::Hook::MHook CompareAndUpdateFloatHook{ "CompareAndUpdateFloat", &Offsets::Get_CompareAndUpdateFloat, &detourCompareAndUpdateFloat }; - - static float detourCompareAndUpdateFloat(float result, float a1, float a2) { - if (funcHandlePlayerImmunityRunning) { - LevelDI* iLevel = LevelDI::Get(); - if (!iLevel || !iLevel->IsLoaded()) - return CompareAndUpdateFloatHook.pOriginal(result, a1, a2); - GamePH::PlayerInfectionModule* playerInfectionModule = GamePH::PlayerInfectionModule::Get(); - if (!playerInfectionModule) - return CompareAndUpdateFloatHook.pOriginal(result, a1, a2); - - if (Menu::Player::unlimitedImmunity.GetValue()) - return playerInfectionModule->immunity; - } - - return CompareAndUpdateFloatHook.pOriginal(result, a1, a2); - } -#pragma endregion - -#pragma region HandlePlayerImmunity - static void detourHandlePlayerImmunity(LPVOID pInstance, float a2); - static Utils::Hook::MHook HandlePlayerImmunityHook{ "HandlePlayerImmunity", &Offsets::Get_HandlePlayerImmunity, &detourHandlePlayerImmunity }; - - static void detourHandlePlayerImmunity(LPVOID pInstance, float a2) { - funcHandlePlayerImmunityRunning = true; - HandlePlayerImmunityHook.pOriginal(pInstance, a2); - funcHandlePlayerImmunityRunning = false; - } -#pragma endregion - -#pragma region HandlePlayerImmunity2 - static void detourHandlePlayerImmunity2(LPVOID pInstance, DWORD64 a2, bool a3); - static Utils::Hook::MHook HandlePlayerImmunity2Hook{ "HandlePlayerImmunity2", &Offsets::Get_HandlePlayerImmunity2, &detourHandlePlayerImmunity2 }; - - static void detourHandlePlayerImmunity2(LPVOID pInstance, DWORD64 a2, bool a3) { - funcHandlePlayerImmunityRunning = true; - HandlePlayerImmunity2Hook.pOriginal(pInstance, a2, a3); - funcHandlePlayerImmunityRunning = false; - } -#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/player.cpp b/EGameTools/source/menu/player.cpp index 0e59454..b02c67d 100644 --- a/EGameTools/source/menu/player.cpp +++ b/EGameTools/source/menu/player.cpp @@ -6438,6 +6438,7 @@ namespace Menu { KeyBindOption godMode{ VK_F6 }; KeyBindOption unlimitedImmunity{ VK_NONE }; KeyBindOption freezePlayer{ VK_F7 }; + KeyBindOption invisibleToEnemies{ VK_NONE }; KeyBindOption disableOutOfBoundsTimer{ VK_NONE }; KeyBindOption nightrunnerMode{ VK_F9 }; KeyBindOption oneHandedMode{ VK_NONE }; @@ -6578,6 +6579,10 @@ namespace Menu { GamePH::PlayerVariables::ManagePlayerVarOption("NightRunnerFurySmashEnabled", nightrunnerMode.GetValue(), !nightrunnerMode.GetValue(), &nightrunnerMode); GamePH::PlayerVariables::ManagePlayerVarOption("NightRunnerFuryGroundPoundEnabled", nightrunnerMode.GetValue(), !nightrunnerMode.GetValue(), &nightrunnerMode); + GamePH::PlayerVariables::ManagePlayerVarOption("AntizinDrainBlocked", unlimitedImmunity.GetValue(), !unlimitedImmunity.GetValue(), &unlimitedImmunity); + + GamePH::PlayerVariables::ManagePlayerVarOption("InVisibleToEnemies", invisibleToEnemies.GetValue(), !invisibleToEnemies.GetValue(), &invisibleToEnemies); + GamePH::PlayerVariables::ManagePlayerVarOption("LeftHandDisabled", oneHandedMode.GetValue(), !oneHandedMode.GetValue(), &oneHandedMode); } static void UpdateDisabledOptions() { @@ -6887,8 +6892,7 @@ namespace Menu { ImGui::EndDisabled(); } GamePH::PlayerInfectionModule* playerInfectionModule = GamePH::PlayerInfectionModule::Get(); - ImGui::BeginDisabled(!playerInfectionModule); - { + ImGui::BeginDisabled(!playerInfectionModule); { if (ImGui::SliderFloat("Player Immunity", &playerImmunity, 0.0f, playerMaxImmunity, "%.2f") && playerInfectionModule) playerInfectionModule->immunity = playerImmunity / 100.0f; else if (playerInfectionModule) @@ -6903,6 +6907,7 @@ namespace Menu { ImGui::EndDisabled(); } ImGui::SameLine(); + ImGui::CheckboxHotkey("Invisible to Enemies", &invisibleToEnemies); ImGui::CheckboxHotkey("Disable Out of Bounds Timer", &disableOutOfBoundsTimer); ImGui::CheckboxHotkey("Nightrunner Mode", &nightrunnerMode); ImGui::SameLine(); diff --git a/EGameTools/source/menu/player.h b/EGameTools/source/menu/player.h index bb5a52c..e818d2e 100644 --- a/EGameTools/source/menu/player.h +++ b/EGameTools/source/menu/player.h @@ -11,6 +11,7 @@ namespace Menu { extern KeyBindOption godMode; extern KeyBindOption unlimitedImmunity; extern KeyBindOption freezePlayer; + extern KeyBindOption invisibleToEnemies; extern KeyBindOption disableOutOfBoundsTimer; extern KeyBindOption nightrunnerMode; extern KeyBindOption oneHandedMode; diff --git a/EGameTools/source/offsets.h b/EGameTools/source/offsets.h index 0bddeed..f81bb8f 100644 --- a/EGameTools/source/offsets.h +++ b/EGameTools/source/offsets.h @@ -70,9 +70,9 @@ struct Offsets { AddOffset(PlaySoundEvent, "gamedll_ph_x64_rwdi.dll", "4C 8B DC 49 89 5B ?? 49 89 73 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B 44 24 ?? 48 8B F9 48 8B DA", Utils::SigScan::PatternType::Address, LPVOID) AddOffset(CalculateFallHeight, "gamedll_ph_x64_rwdi.dll", "40 55 56 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 44 0F 29 9C 24", Utils::SigScan::PatternType::Address, LPVOID) AddOffset(PlayerHealthModuleKillPlayer, "gamedll_ph_x64_rwdi.dll", "40 53 48 83 EC ?? 48 8B 01 48 8B D9 FF 90 ?? ?? ?? ?? 84 C0 74 ?? 48 8B 4B ?? 48 81 C1 ?? ?? ?? ?? 48 8B 01 FF 50", 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) + //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) //AddOffset(HandleFallHeight, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 57 48 83 EC ?? 0F B6 FA 48 8B D9 0F B6 91", Utils::SigScan::PatternType::Address, LPVOID) //AddOffset(HandlePlayerFall, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 57 48 83 EC ?? 0F 29 74 24 ?? 48 8B FA 0F 28 F2", Utils::SigScan::PatternType::Address, LPVOID) //AddOffset(GetTimeWeatherSystem, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 33 D2 48 8B C8 E8 ?? ?? ?? ?? 49 8D 4F 38", PatternType::RelativePointer, LPVOID)