fixed bugs

This commit is contained in:
EricPlayZ
2024-05-12 02:00:35 +03:00
parent f50c883efc
commit 4043de504b
9 changed files with 78 additions and 26 deletions

View File

@ -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)

View File

@ -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 },

View File

@ -252,7 +252,7 @@ namespace GamePH {
if (Menu::Player::disableAirControl.GetValue())
*reinterpret_cast<bool*>(a1 + Offsets::Get_allowVelocityMod_offset()) = false;
if (Menu::Camera::disableHeadCorrection.GetValue())
if (Menu::Camera::disableHeadCorrection.GetValue() || Menu::Camera::goProMode.GetValue())
*reinterpret_cast<bool*>(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<LPVOID, void(*)(DWORD64, DWORD64, DWORD64, DWORD64)> 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<LPVOID, DWORD64(*)(float*, float*, float, DWORD64, DWORD64, DWORD64)> 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<LPVOID> SaveGameCRCBoolCheckHook{ "SaveGameCRCBoolCheck", &Offsets::Get_SaveGameCRCBoolCheck, SaveGameCRCBoolCheckBytes, sizeof(SaveGameCRCBoolCheckBytes), &Menu::Misc::disableSavegameCRCCheck }; // and bl, dil

View File

@ -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<float>("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<float>(FOV - baseFOV);
goProMode.SetPrevValue(false);
}
GamePH::PlayerVariables::ManagePlayerVarOption("SprintHeadCorrectionFactor", 0.0f, baseSprintHeadCorrectionFactor, &disableHeadCorrection, true);
if (goProMode.GetValue())
pCVideoSettings->extraFOV = static_cast<float>((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");
}
}
}

View File

@ -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 {

View File

@ -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.");
}
}
}

View File

@ -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;

View File

@ -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)

View File

@ -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 <typename GetTargetOffsetRetType, typename OrigType>
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 <typename GetTargetOffsetRetType, typename OrigType>
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;
};