Added "Unlimited Immunity" (Player)

This commit is contained in:
EricPlayZ
2024-05-03 04:06:02 +03:00
parent 65e2dc3d44
commit f4699cdd30
8 changed files with 53 additions and 7 deletions

View File

@ -52,12 +52,14 @@ Thank you everyone for the support <3)" },
- Fetch game version using Windows' API instead of using the game's function)" },
{ "v1.1.4",
R"(- Added compatibility with v1.16.1 hotfix update
- Fixed "God Mode" (Player) staying enabled after toggling FreeCam off
- Fixed player variables saving and loading using old version of player_variables.scr (which made Max Health drop to negative infinite)
- Fixed long paths to mods inside UserModFiles causing a game crash or causing the mods to not load at all
- Added "Unlimited Immunity" (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
- Fixed "God Mode" (Player) staying enabled after toggling FreeCam off
- Fixed player variables saving and loading using old version of player_variables.scr (which made Max Health drop to negative infinite)
- Fixed long paths to mods inside UserModFiles causing a game crash or causing the mods to not load at all
- Fixed "God Mode" (Player) not working properly or at all in multiplayer
- Fixed volatiles still being able to kill you when they jump on top of you while "God Mode" (Player) is enabled
- Fixed "Disable Out of Bounds Timer" (Player) not working in missions

View File

@ -4343,6 +4343,7 @@ namespace Config {
{ "Menu", "HasSeenChangelog", false, &Menu::hasSeenChangelog, OPTION },
{ "Menu:Keybinds", "MenuToggleKey", std::string("VK_F5"), &Menu::menuToggle, String},
{ "Menu:Keybinds", "GodModeToggleKey", std::string("VK_F6"), &Menu::Player::godMode, String},
{ "Menu:Keybinds", "UnlimitedImmunityToggleKey", std::string("VK_NONE"), &Menu::Player::unlimitedImmunity, String},
{ "Menu:Keybinds", "FreezePlayerToggleKey", std::string("VK_F7"), &Menu::Player::freezePlayer, String},
{ "Menu:Keybinds", "DisableOutOfBoundsTimerToggleKey", std::string("VK_NONE"), &Menu::Player::disableOutOfBoundsTimer, String},
{ "Menu:Keybinds", "NightrunnerModeToggleKey", std::string("VK_F9"), &Menu::Player::nightrunnerMode, String},
@ -4358,6 +4359,7 @@ namespace Config {
{ "Menu:Keybinds", "FreezeTimeToggleKey", std::string("VK_NONE"), &Menu::World::freezeTime, String},
{ "Menu:Keybinds", "SlowMotionToggleKey", std::string("VK_4"), &Menu::World::slowMotion, String},
{ "Player:Misc", "GodMode", false, &Menu::Player::godMode, OPTION },
{ "Player:Misc", "UnlimitedImmunity", false, &Menu::Player::unlimitedImmunity, OPTION },
{ "Player:Misc", "DisableOutOfBoundsTimer", true, &Menu::Player::disableOutOfBoundsTimer, OPTION },
{ "Player:Misc", "NightrunnerMode", false, &Menu::Player::nightrunnerMode, OPTION },
{ "Player:Misc", "OneHandedMode", false, &Menu::Player::oneHandedMode, OPTION },

View File

@ -210,5 +210,39 @@ namespace GamePH {
return CalculateFallHeightHook.pOriginal(pInstance, height);
}
#pragma endregion
#pragma region CompareAndUpdateFloat
static bool funcHandlePlayerImmunityRunning = false;
static float detourCompareAndUpdateFloat(float result, float a1, float a2);
static Utils::Hook::MHook<LPVOID, float(*)(float, float, float)> CompareAndUpdateFloatHook{ "CompareAndUpdateFloat", &Offsets::Get_CompareAndUpdateFloat, &detourCompareAndUpdateFloat };
static float detourCompareAndUpdateFloat(float result, float a1, float a2) {
if (funcHandlePlayerImmunityRunning) {
static float immunityTimerBeforeFreeze = -1.0f;
if (Menu::Player::unlimitedImmunity.GetValue()) {
if (Utils::Values::are_samef(immunityTimerBeforeFreeze, -1.0f))
immunityTimerBeforeFreeze = result > a2 ? a2 : result;
return immunityTimerBeforeFreeze;
}
immunityTimerBeforeFreeze = -1.0f;
}
return CompareAndUpdateFloatHook.pOriginal(result, a1, a2);
}
#pragma endregion
#pragma region HandlePlayerImmunity
static void detourHandlePlayerImmunity(LPVOID pInstance, float a2);
static Utils::Hook::MHook<LPVOID, void(*)(LPVOID, float)> HandlePlayerImmunityHook{ "HandlePlayerImmunity", &Offsets::Get_HandlePlayerImmunity, &detourHandlePlayerImmunity };
static void detourHandlePlayerImmunity(LPVOID pInstance, float a2) {
funcHandlePlayerImmunityRunning = true;
HandlePlayerImmunityHook.pOriginal(pInstance, a2);
funcHandlePlayerImmunityRunning = false;
}
#pragma endregion
}
}

View File

@ -162,17 +162,19 @@ namespace Menu {
ImGui::CheckboxHotkey("Enabled##FreeCam", &freeCam);
ImGui::EndDisabled();
}
ImGui::SliderFloat("Speed##FreeCam", &freeCamSpeed, 0.1f, 200.0f, "%.2fx", ImGuiSliderFlags_AlwaysClamp);
ImGui::SameLine();
ImGui::BeginDisabled(teleportPlayerToCamera.GetChangesAreDisabled()); {
ImGui::CheckboxHotkey("Teleport Player to Camera", &teleportPlayerToCamera);
ImGui::EndDisabled();
}
ImGui::SliderFloat("Speed##FreeCam", &freeCamSpeed, 0.1f, 200.0f, "%.2fx", ImGuiSliderFlags_AlwaysClamp);
ImGui::SeparatorText("Third Person Camera");
ImGui::BeginDisabled(thirdPersonCamera.GetChangesAreDisabled()); {
ImGui::CheckboxHotkey("Enabled##ThirdPerson", &thirdPersonCamera);
ImGui::EndDisabled();
}
ImGui::SameLine();
ImGui::BeginDisabled(tpUseTPPModel.GetChangesAreDisabled()); {
ImGui::CheckboxHotkey("Use Third Person Player (TPP) Model", &tpUseTPPModel);
ImGui::EndDisabled();

View File

@ -6433,6 +6433,7 @@ namespace Menu {
float playerHealth = 80.0f;
float playerMaxHealth = 80.0f;
KeyBindOption godMode{ VK_F6 };
KeyBindOption unlimitedImmunity{ VK_NONE };
KeyBindOption freezePlayer{ VK_F7 };
KeyBindOption disableOutOfBoundsTimer{ VK_NONE };
KeyBindOption nightrunnerMode{ VK_F9 };
@ -6868,13 +6869,15 @@ namespace Menu {
}
ImGui::CheckboxHotkey("God Mode", &godMode);
ImGui::SameLine();
ImGui::CheckboxHotkey("Unlimited Immunity", &unlimitedImmunity);
ImGui::BeginDisabled(freezePlayer.GetChangesAreDisabled()); {
ImGui::CheckboxHotkey("Freeze Player", &freezePlayer);
ImGui::EndDisabled();
}
ImGui::SameLine();
ImGui::CheckboxHotkey("Disable Out of Bounds Timer", &disableOutOfBoundsTimer);
ImGui::CheckboxHotkey("Nightrunner Mode", &nightrunnerMode);
ImGui::SameLine();
ImGui::CheckboxHotkey("One-handed Mode", &oneHandedMode);
ImGui::SeparatorText("Player Jump Parameters");

View File

@ -7,6 +7,7 @@ namespace Menu {
extern float playerHealth;
extern float playerMaxHealth;
extern KeyBindOption godMode;
extern KeyBindOption unlimitedImmunity;
extern KeyBindOption freezePlayer;
extern KeyBindOption disableOutOfBoundsTimer;
extern KeyBindOption nightrunnerMode;

View File

@ -86,7 +86,7 @@ namespace Menu {
if (!menuToggle.GetValue()) {
time = dayNightCycle->time1 * 24.0f;
if (freezeTime.GetValue() && !Utils::Values::are_samef(time, timeBeforeFreeze, 0.009999f))
if (freezeTime.GetValue() && !Utils::Values::are_samef(time, timeBeforeFreeze, 0.0095f))
dayNightCycle->SetDaytime(timeBeforeFreeze);
if (!slowMotion.GetValue() && !slowMotion.HasChanged() && !Utils::Values::are_samef(gameSpeed, 1.0f))
@ -110,7 +110,7 @@ namespace Menu {
dayNightCycle->SetDaytime(time);
}
time = dayNightCycle->time1 * 24.0f;
if (freezeTime.GetValue() && !Utils::Values::are_samef(time, timeBeforeFreeze, 0.009999f))
if (freezeTime.GetValue() && !Utils::Values::are_samef(time, timeBeforeFreeze, 0.0095f))
dayNightCycle->SetDaytime(timeBeforeFreeze);
}

View File

@ -68,6 +68,8 @@ 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(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)