mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-07-18 17:37:53 +08:00
Updated the mod to work with the latest patch, I need to clean the code because spending several days just to make this work is not an option, especially after a break that lasted half a year and forgetting what all this damn code does xD
This commit is contained in:
@ -157,8 +157,9 @@
|
||||
<AdditionalLibraryDirectories>source\MinHook\lib;</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /Y "$(SolutionDir)Extra Files\Default Config\EGameTools.ini" "$(SolutionDir)$(PlatformShortName)\$(Configuration)\EGameTools.ini"</Command>
|
||||
<Message>Copying the default config file to the debug build directory</Message>
|
||||
<Command>copy /Y "$(SolutionDir)Extra Files\Default Config\EGameTools.ini" "$(SolutionDir)$(PlatformShortName)\$(Configuration)\EGameTools.ini"
|
||||
copy /Y "$(SolutionDir)x64\Debug\EGameTools.asi" "D:\Program Files (x86)\Steam\steamapps\common\Dying Light 2\ph\work\bin\x64\EGameTools.asi"</Command>
|
||||
<Message>Copying the default config file to the debug build directory and the compiled ASI into the game folder</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@ -167,19 +168,20 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;DL2GameOverhaulScript_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>source\ImGui;source\ImGuiFileDialog;source\MinHook\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalLibraryDirectories>source\MinHook\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libMinHook-x64-v141-mtd.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
9
DL2GameOverhaulScript/EGameTools.ini
Normal file
9
DL2GameOverhaulScript/EGameTools.ini
Normal file
@ -0,0 +1,9 @@
|
||||
[Camera]
|
||||
DisablePhotoModeLimits=1
|
||||
DisableSafezoneFOVReduction=1
|
||||
[Menu:Keybinds]
|
||||
ToggleKey=VK_F5
|
||||
[Player:PlayerVariables]
|
||||
LastLoadSCRFilePath=C:\Users\EricPlayZ\Desktop\player_variables.scr
|
||||
LastSaveSCRPath=C:\Users\EricPlayZ\Desktop
|
||||
UseBACKUPPlayerVars=1
|
9
DL2GameOverhaulScript/EGameTools.ini.bak
Normal file
9
DL2GameOverhaulScript/EGameTools.ini.bak
Normal file
@ -0,0 +1,9 @@
|
||||
[Camera]
|
||||
DisablePhotoModeLimits=1
|
||||
DisableSafezoneFOVReduction=1
|
||||
[Menu:Keybinds]
|
||||
ToggleKey=VK_F5
|
||||
[Player:PlayerVariables]
|
||||
LastLoadSCRFilePath=C:\Users\EricPlayZ\Desktop\player_variables.scr
|
||||
LastSaveSCRPath=C:\Users\EricPlayZ\Desktop
|
||||
UseBACKUPPlayerVars=0
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
namespace Config {
|
||||
extern const char playerVars[];
|
||||
|
||||
extern int menuToggleKey;
|
||||
|
||||
extern void SaveConfig();
|
||||
|
@ -103,7 +103,7 @@ namespace Core {
|
||||
if (!rendererAPI.empty())
|
||||
return oReadVideoSettings(instance, file, flag1);
|
||||
|
||||
DWORD renderer = *reinterpret_cast<PDWORD>(reinterpret_cast<DWORD64>(instance) + 0x78);
|
||||
DWORD renderer = *reinterpret_cast<PDWORD>(reinterpret_cast<DWORD64>(instance) + 0x7C);
|
||||
rendererAPI = !renderer ? "d3d11" : "d3d12";
|
||||
|
||||
return oReadVideoSettings(instance, file, flag1);
|
||||
@ -132,6 +132,8 @@ namespace Core {
|
||||
createdConfigThread = true;
|
||||
}
|
||||
|
||||
if (Menu::Player::useBACKUPPlayerVarsEnabled && GamePH::PlayerVariables::playerVars.empty())
|
||||
GamePH::PlayerVariables::RunHooksBACKUP();
|
||||
if (!GamePH::PlayerVariables::gotPlayerVars)
|
||||
GamePH::PlayerVariables::GetPlayerVars();
|
||||
|
||||
@ -150,10 +152,11 @@ namespace Core {
|
||||
|
||||
DWORD64 WINAPI MainThread(HMODULE hModule) {
|
||||
EnableConsole();
|
||||
|
||||
HookLdrpInitRoutine();
|
||||
|
||||
Config::InitConfig();
|
||||
|
||||
if (!Menu::Player::useBACKUPPlayerVarsEnabled)
|
||||
HookLdrpInitRoutine();
|
||||
|
||||
MH_Initialize();
|
||||
LoopHookReadVideoSettings();
|
||||
|
@ -1,12 +1,19 @@
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include "MinHook\include\MinHook.h"
|
||||
#include "sigscan\offsets.h"
|
||||
#include "menu\player.h"
|
||||
#include "menu\camera.h"
|
||||
#include "config\config.h"
|
||||
#include "game_classes.h"
|
||||
#include "memory.h"
|
||||
#include "print.h"
|
||||
#include "utils.h"
|
||||
//#define DEBUGPVARS
|
||||
#ifdef DEBUGPVARS
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
namespace Core {
|
||||
extern void OnPostUpdate();
|
||||
@ -52,7 +59,7 @@ namespace GamePH {
|
||||
if (!pGameDI_PH2)
|
||||
continue;
|
||||
|
||||
Hook::VTHook(pGameDI_PH2, &detourOnPostUpdate, reinterpret_cast<LPVOID*>(&oOnPostUpdate), 0x368);
|
||||
Hook::VTHook(pGameDI_PH2, &detourOnPostUpdate, reinterpret_cast<LPVOID*>(&oOnPostUpdate), 0x3a8);
|
||||
if (oOnPostUpdate)
|
||||
break;
|
||||
}
|
||||
@ -144,39 +151,77 @@ namespace GamePH {
|
||||
PDWORD64 PlayerVariables::FloatPlayerVariableVT;
|
||||
PDWORD64 PlayerVariables::BoolPlayerVariableVT;
|
||||
|
||||
std::vector <std::pair<std::string_view, std::pair<LPVOID, std::string_view>>> PlayerVariables::playerVars;
|
||||
std::vector <std::pair<std::string_view, std::pair<std::any, std::string_view>>> PlayerVariables::playerVarsDefault;
|
||||
std::vector <std::pair<std::string, std::pair<LPVOID, std::string>>> PlayerVariables::playerVars;
|
||||
std::vector <std::pair<std::string, std::pair<std::any, std::string>>> PlayerVariables::playerVarsDefault;
|
||||
std::vector <std::pair<std::string, std::pair<std::any, std::string>>> PlayerVariables::playerCustomVarsDefault;
|
||||
bool PlayerVariables::gotPlayerVars = false;
|
||||
|
||||
std::unique_ptr<Hook::BreakpointHook> PlayerVariables::loadPlayerFloatVarBpHook = nullptr;
|
||||
std::unique_ptr<Hook::BreakpointHook> PlayerVariables::loadPlayerBoolVarBpHook = nullptr;
|
||||
|
||||
bool PlayerVariables::hooked = false;
|
||||
bool PlayerVariables::hookedBACKUP = false;
|
||||
void PlayerVariables::RunHooks() {
|
||||
if (hooked)
|
||||
return;
|
||||
if (!Offsets::Get_LoadPlayerFloatVariableOffset())
|
||||
return;
|
||||
if (!Offsets::Get_LoadPlayerBoolVariableOffset())
|
||||
return;
|
||||
|
||||
loadPlayerFloatVarBpHook = std::make_unique<Hook::BreakpointHook>(Offsets::Get_LoadPlayerFloatVariableOffset(), [&](PEXCEPTION_POINTERS info) -> void {
|
||||
const char* tempName = reinterpret_cast<const char*>(info->ContextRecord->R8);
|
||||
const std::string_view name = tempName;
|
||||
const std::string name = tempName;
|
||||
|
||||
PlayerVariables::playerVars.emplace_back(name, std::make_pair(nullptr, "float"));
|
||||
PlayerVariables::playerVarsDefault.emplace_back(name, std::make_pair(0.0f, "float"));
|
||||
PlayerVariables::playerCustomVarsDefault.emplace_back(name, std::make_pair(0.0f, "float"));
|
||||
});
|
||||
loadPlayerBoolVarBpHook = std::make_unique<Hook::BreakpointHook>(Offsets::Get_LoadPlayerBoolVariableOffset(), [&](PEXCEPTION_POINTERS info) -> void {
|
||||
loadPlayerBoolVarBpHook = std::make_unique<Hook::BreakpointHook>(Offsets::Get_LoadPlayerFloatVariableOffset() - Offsets::Get_LoadPlayerVariableFuncSize(), [&](PEXCEPTION_POINTERS info) -> void {
|
||||
const char* tempName = reinterpret_cast<const char*>(info->ContextRecord->R8);
|
||||
const std::string_view name = tempName;
|
||||
const std::string name = tempName;
|
||||
|
||||
PlayerVariables::playerVars.emplace_back(name, std::make_pair(nullptr, "bool"));
|
||||
PlayerVariables::playerVarsDefault.emplace_back(name, std::make_pair(false, "bool"));
|
||||
PlayerVariables::playerCustomVarsDefault.emplace_back(name, std::make_pair(false, "bool"));
|
||||
});
|
||||
|
||||
hooked = true;
|
||||
}
|
||||
void PlayerVariables::RunHooksBACKUP() {
|
||||
if (hookedBACKUP)
|
||||
return;
|
||||
if (!playerVars.empty())
|
||||
return;
|
||||
if (!Offsets::Get_LoadPlayerFloatVariableOffset())
|
||||
return;
|
||||
|
||||
std::stringstream ss(Config::playerVars);
|
||||
|
||||
while (ss.good()) {
|
||||
std::string pVar{};
|
||||
getline(ss, pVar, ',');
|
||||
|
||||
std::stringstream ssPVar(pVar);
|
||||
|
||||
std::string varName{};
|
||||
std::string varType{};
|
||||
|
||||
while (ssPVar.good()) {
|
||||
std::string subStr{};
|
||||
getline(ssPVar, subStr, ':');
|
||||
|
||||
if (subStr != "float" && subStr != "bool")
|
||||
varName = subStr;
|
||||
else
|
||||
varType = subStr;
|
||||
}
|
||||
|
||||
PlayerVariables::playerVars.emplace_back(varName, std::make_pair(nullptr, varType));
|
||||
PlayerVariables::playerVarsDefault.emplace_back(varName, std::make_pair(varType == "float" ? 0.0f : false, varType));
|
||||
PlayerVariables::playerCustomVarsDefault.emplace_back(varName, std::make_pair(varType == "float" ? 0.0f : false, varType));
|
||||
}
|
||||
|
||||
hookedBACKUP = true;
|
||||
}
|
||||
|
||||
PDWORD64 PlayerVariables::GetFloatPlayerVariableVT() {
|
||||
if (FloatPlayerVariableVT)
|
||||
@ -212,6 +257,21 @@ namespace GamePH {
|
||||
if (!GetBoolPlayerVariableVT())
|
||||
return;
|
||||
|
||||
#ifdef DEBUGPVARS
|
||||
std::string pVars{};
|
||||
|
||||
for (auto const& [key, val] : GamePH::PlayerVariables::playerVars) {
|
||||
pVars.append(key);
|
||||
pVars.append(":");
|
||||
pVars.append(val.second);
|
||||
pVars.append(",");
|
||||
}
|
||||
pVars.pop_back();
|
||||
std::ofstream out("pvars.txt");
|
||||
out << pVars;
|
||||
out.close();
|
||||
#endif
|
||||
|
||||
PDWORD64* playerVarsMem = reinterpret_cast<PDWORD64*>(Get());
|
||||
bool isFloatPlayerVar = false;
|
||||
bool isBoolPlayerVar = false;
|
||||
@ -223,7 +283,7 @@ namespace GamePH {
|
||||
|
||||
if (isFloatPlayerVar || isBoolPlayerVar) {
|
||||
it->second.first = playerVarsMem + 1;
|
||||
const std::string_view varName = it->first;
|
||||
const std::string varName = it->first;
|
||||
|
||||
auto itDef = std::find_if(GamePH::PlayerVariables::playerVarsDefault.begin(), GamePH::PlayerVariables::playerVarsDefault.end(), [&varName](const auto& pair) {
|
||||
return pair.first == varName;
|
||||
@ -235,6 +295,16 @@ namespace GamePH {
|
||||
itDef->second.first = *reinterpret_cast<bool*>(it->second.first);
|
||||
}
|
||||
|
||||
auto itCustomDef = std::find_if(GamePH::PlayerVariables::playerCustomVarsDefault.begin(), GamePH::PlayerVariables::playerCustomVarsDefault.end(), [&varName](const auto& pair) {
|
||||
return pair.first == varName;
|
||||
});
|
||||
if (itCustomDef != GamePH::PlayerVariables::playerCustomVarsDefault.end()) {
|
||||
if (isFloatPlayerVar)
|
||||
itCustomDef->second.first = *reinterpret_cast<float*>(it->second.first);
|
||||
else
|
||||
itCustomDef->second.first = *reinterpret_cast<bool*>(it->second.first);
|
||||
}
|
||||
|
||||
playerVarsMem += isFloatPlayerVar ? 3 : 2;
|
||||
break;
|
||||
} else
|
||||
@ -243,8 +313,10 @@ namespace GamePH {
|
||||
}
|
||||
|
||||
gotPlayerVars = true;
|
||||
loadPlayerFloatVarBpHook->Disable();
|
||||
loadPlayerBoolVarBpHook->Disable();
|
||||
if (!Menu::Player::useBACKUPPlayerVarsEnabled) {
|
||||
loadPlayerFloatVarBpHook->Disable();
|
||||
loadPlayerBoolVarBpHook->Disable();
|
||||
}
|
||||
}
|
||||
|
||||
PlayerVariables* PlayerVariables::Get() {
|
||||
@ -318,10 +390,10 @@ namespace GamePH {
|
||||
|
||||
#pragma region FreeCamera
|
||||
Vector3* FreeCamera::GetPosition(Vector3* posIN) {
|
||||
return Memory::CallVT<198, Vector3*>(this, posIN);
|
||||
return Memory::CallVT<181, Vector3*>(this, posIN);
|
||||
}
|
||||
void FreeCamera::AllowCameraMovement(int mode) {
|
||||
Memory::CallVT<203>(this, mode);
|
||||
Memory::CallVT<187>(this, mode);
|
||||
}
|
||||
|
||||
FreeCamera* FreeCamera::Get() {
|
||||
@ -410,7 +482,7 @@ namespace GamePH {
|
||||
|
||||
#pragma region LevelDI
|
||||
float LevelDI::GetTimePlayed() {
|
||||
return Memory::CallVT<334, float>(this);
|
||||
return Memory::CallVT<317, float>(this);
|
||||
}
|
||||
LPVOID LevelDI::GetViewCamera() {
|
||||
if (!Offsets::Get_GetViewCameraOffset())
|
||||
@ -461,7 +533,7 @@ namespace GamePH {
|
||||
if (!pGameDI_PH)
|
||||
return nullptr;
|
||||
|
||||
GameDI_PH2* ptr = reinterpret_cast<GameDI_PH2*>(reinterpret_cast<DWORD64>(pGameDI_PH) + Offsets::Get_gameDI_PH2Offset());
|
||||
GameDI_PH2* ptr = reinterpret_cast<GameDI_PH2*>(reinterpret_cast<DWORD64>(pGameDI_PH) + Offsets::Get_gameDI_PH2_offset());
|
||||
|
||||
if (!Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
|
||||
return nullptr;
|
||||
@ -473,14 +545,11 @@ namespace GamePH {
|
||||
#pragma endregion
|
||||
|
||||
#pragma region GameDI_PH
|
||||
PDWORD64 GameDI_PH::GetLocalPlayerEntity() {
|
||||
return Memory::CallVT<135, PDWORD64>(this);
|
||||
}
|
||||
INT64 GameDI_PH::GetCurrentGameVersion() {
|
||||
return Memory::CallVT<218, INT64>(this);
|
||||
return Memory::CallVT<225, INT64>(this);
|
||||
}
|
||||
void GameDI_PH::TogglePhotoMode(bool doNothing, bool setAsOptionalCamera) {
|
||||
Memory::CallVT<249>(this, doNothing, setAsOptionalCamera);
|
||||
Memory::CallVT<258>(this, doNothing, setAsOptionalCamera);
|
||||
}
|
||||
|
||||
GameDI_PH* GameDI_PH::Get() {
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <Windows.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <any>
|
||||
#include "hook.h"
|
||||
@ -58,15 +58,18 @@ namespace GamePH {
|
||||
static PDWORD64 FloatPlayerVariableVT;
|
||||
static PDWORD64 BoolPlayerVariableVT;
|
||||
public:
|
||||
static std::vector<std::pair<std::string_view, std::pair<LPVOID, std::string_view>>> playerVars;
|
||||
static std::vector<std::pair<std::string_view, std::pair<std::any, std::string_view>>> playerVarsDefault;
|
||||
static std::vector<std::pair<std::string, std::pair<LPVOID, std::string>>> playerVars;
|
||||
static std::vector<std::pair<std::string, std::pair<std::any, std::string>>> playerVarsDefault;
|
||||
static std::vector<std::pair<std::string, std::pair<std::any, std::string>>> playerCustomVarsDefault;
|
||||
static bool gotPlayerVars;
|
||||
|
||||
static std::unique_ptr<Hook::BreakpointHook> loadPlayerFloatVarBpHook;
|
||||
static std::unique_ptr<Hook::BreakpointHook> loadPlayerBoolVarBpHook;
|
||||
|
||||
static bool hooked;
|
||||
static bool hookedBACKUP;
|
||||
static void RunHooks();
|
||||
static void RunHooksBACKUP();
|
||||
|
||||
static PDWORD64 GetFloatPlayerVariableVT();
|
||||
static PDWORD64 GetBoolPlayerVariableVT();
|
||||
@ -78,7 +81,7 @@ namespace GamePH {
|
||||
class PlayerState {
|
||||
public:
|
||||
union {
|
||||
DEFINE_MEMBER_N(PlayerVariables*, playerVars, 0x278);
|
||||
DEFINE_MEMBER_N(PlayerVariables*, playerVars, 0x290);
|
||||
};
|
||||
|
||||
static PlayerState* Get();
|
||||
@ -146,7 +149,6 @@ namespace GamePH {
|
||||
|
||||
class GameDI_PH {
|
||||
public:
|
||||
PDWORD64 GetLocalPlayerEntity();
|
||||
INT64 GetCurrentGameVersion();
|
||||
void TogglePhotoMode(bool doNothing = false, bool setAsOptionalCamera = false);
|
||||
|
||||
@ -156,7 +158,7 @@ namespace GamePH {
|
||||
class PlayerObjProperties {
|
||||
public:
|
||||
union {
|
||||
DEFINE_MEMBER_N(Engine::CoPhysicsProperty*, pCoPhysicsProperty, 0xE8);
|
||||
DEFINE_MEMBER_N(Engine::CoPhysicsProperty*, pCoPhysicsProperty, 0xF0);
|
||||
};
|
||||
|
||||
static PlayerObjProperties* Get();
|
||||
@ -167,7 +169,7 @@ namespace Engine {
|
||||
class CVideoSettings {
|
||||
public:
|
||||
union {
|
||||
DEFINE_MEMBER_N(float, ExtraFOV, 0x78);
|
||||
DEFINE_MEMBER_N(float, ExtraFOV, 0x7C);
|
||||
};
|
||||
|
||||
static CVideoSettings* Get();
|
||||
@ -187,7 +189,7 @@ namespace Engine {
|
||||
union {
|
||||
DEFINE_MEMBER_N(GamePH::GameDI_PH*, pGameDI_PH, 0x8);
|
||||
DEFINE_MEMBER_N(CVideoSettings*, pCVideoSettings, 0x28);
|
||||
DEFINE_MEMBER_N(CLevel*, pCLevel, 0x370);
|
||||
DEFINE_MEMBER_N(CLevel*, pCLevel, 0x380);
|
||||
};
|
||||
|
||||
static CGame* Get();
|
||||
@ -213,9 +215,9 @@ namespace Engine {
|
||||
class CBulletPhysicsCharacter {
|
||||
public:
|
||||
union {
|
||||
DEFINE_MEMBER_N(Vector3, playerPos2, 0x87C);
|
||||
DEFINE_MEMBER_N(Vector3, playerPos, 0x894);
|
||||
DEFINE_MEMBER_N(float, playerDownwardVelocity, 0xC28);
|
||||
DEFINE_MEMBER_N(Vector3, playerPos2, 0x8A0);
|
||||
DEFINE_MEMBER_N(Vector3, playerPos, 0x8B8);
|
||||
DEFINE_MEMBER_N(float, playerDownwardVelocity, 0xC38);
|
||||
};
|
||||
|
||||
static Vector3 posBeforeFreeze;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "hook.h"
|
||||
#include "sigscan\offsets.h"
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include "sigscan\offsets.h"
|
||||
#include "hook.h"
|
||||
|
||||
namespace Hook {
|
||||
// VTable hooking
|
||||
|
@ -156,7 +156,7 @@ namespace Menu {
|
||||
}
|
||||
|
||||
ImGui::BeginDisabled(!GamePH::PlayerVariables::gotPlayerVars); {
|
||||
ImGui::Checkbox("Disabled Safezone FOV Reduction", &disableSafezoneFOVReductionEnabled.value);
|
||||
ImGui::Checkbox("Disable Safezone FOV Reduction", &disableSafezoneFOVReductionEnabled.value);
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace Menu {
|
||||
static const ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize;
|
||||
static const ImVec2 minWndSize = ImVec2(0.0f, 0.0f);
|
||||
static const ImVec2 maxWndSize = ImVec2(700.0f, 675.0f);
|
||||
static const ImVec2 maxWndSize = ImVec2(900.0f, 675.0f);
|
||||
|
||||
bool isOpen = false;
|
||||
|
||||
|
@ -5684,16 +5684,22 @@ namespace Menu {
|
||||
0x75, 0x65, 0x6E, 0x63, 0x65, 0x22, 0x2C, 0x20, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x29, 0x3B, 0x0D,
|
||||
0x0A, 0x7D, 0x0D, 0x0A };
|
||||
#pragma endregion
|
||||
|
||||
static bool debugEnabled = false;
|
||||
|
||||
SMART_BOOL godModeEnabled{};
|
||||
SMART_BOOL freezePlayerEnabled{};
|
||||
|
||||
bool useBACKUPPlayerVarsEnabled = false;
|
||||
|
||||
std::string saveSCRPath{};
|
||||
std::string loadSCRFilePath{};
|
||||
|
||||
bool restoreVarsToSavedVarsEnabled = false;
|
||||
|
||||
static char playerVarsSearchFilter[64];
|
||||
|
||||
static std::string_view getParamName(const std::string_view str) {
|
||||
static std::string getParamName(const std::string str) {
|
||||
size_t firstQuotePos = str.find_first_of("\"");
|
||||
size_t lastQuotePos = firstQuotePos;
|
||||
if (firstQuotePos == std::string::npos)
|
||||
@ -5748,7 +5754,7 @@ namespace Menu {
|
||||
std::string line{};
|
||||
while (std::getline(iss, line)) {
|
||||
const std::string origLine = line;
|
||||
const std::string_view paramName = getParamName(line);
|
||||
const std::string paramName = getParamName(line);
|
||||
if (paramName.empty())
|
||||
continue;
|
||||
|
||||
@ -5791,7 +5797,7 @@ namespace Menu {
|
||||
|
||||
std::string line{};
|
||||
while (std::getline(file, line)) {
|
||||
const std::string_view paramName = getParamName(line);
|
||||
const std::string paramName = getParamName(line);
|
||||
if (paramName.empty())
|
||||
continue;
|
||||
const std::string paramValue = getParamValue(line);
|
||||
@ -5823,10 +5829,12 @@ namespace Menu {
|
||||
for (auto const& [key, val] : GamePH::PlayerVariables::playerVars) {
|
||||
if (!val.first)
|
||||
continue;
|
||||
auto itDef = std::find_if(GamePH::PlayerVariables::playerVarsDefault.begin(), GamePH::PlayerVariables::playerVarsDefault.end(), [&key](const auto& pair) {
|
||||
|
||||
auto& defVars = restoreVarsToSavedVarsEnabled ? GamePH::PlayerVariables::playerCustomVarsDefault : GamePH::PlayerVariables::playerVarsDefault;
|
||||
auto itDef = std::find_if(defVars.begin(), defVars.end(), [&key](const auto& pair) {
|
||||
return pair.first == key;
|
||||
});
|
||||
if (itDef == GamePH::PlayerVariables::playerVarsDefault.end())
|
||||
if (itDef == defVars.end())
|
||||
continue;
|
||||
|
||||
if (val.second == "float") {
|
||||
@ -5842,6 +5850,28 @@ namespace Menu {
|
||||
|
||||
ImGui::OpenPopup("Restored player variables!");
|
||||
}
|
||||
static void SaveVariablesAsDefault() {
|
||||
for (auto const& [key, val] : GamePH::PlayerVariables::playerVars) {
|
||||
if (!val.first)
|
||||
continue;
|
||||
|
||||
auto itCustomDef = std::find_if(GamePH::PlayerVariables::playerCustomVarsDefault.begin(), GamePH::PlayerVariables::playerCustomVarsDefault.end(), [&key](const auto& pair) {
|
||||
return pair.first == key;
|
||||
});
|
||||
if (itCustomDef == GamePH::PlayerVariables::playerCustomVarsDefault.end())
|
||||
continue;
|
||||
|
||||
if (val.second == "float") {
|
||||
float* varAddr = reinterpret_cast<float*>(val.first);
|
||||
itCustomDef->second.first = *varAddr;
|
||||
} else if (val.second == "bool") {
|
||||
bool* varAddr = reinterpret_cast<bool*>(val.first);
|
||||
itCustomDef->second.first = *varAddr;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::OpenPopup("Saved current player variables!");
|
||||
}
|
||||
static void RestoreVariableToDefault(LPVOID variable) {
|
||||
auto it = std::find_if(GamePH::PlayerVariables::playerVars.begin(), GamePH::PlayerVariables::playerVars.end(), [&variable](const auto& pair) {
|
||||
return pair.second.first == variable;
|
||||
@ -5849,10 +5879,11 @@ namespace Menu {
|
||||
if (it == GamePH::PlayerVariables::playerVars.end())
|
||||
return;
|
||||
|
||||
auto itDef = std::find_if(GamePH::PlayerVariables::playerVarsDefault.begin(), GamePH::PlayerVariables::playerVarsDefault.end(), [&it](const auto& pair) {
|
||||
auto& defVars = restoreVarsToSavedVarsEnabled ? GamePH::PlayerVariables::playerCustomVarsDefault : GamePH::PlayerVariables::playerVarsDefault;
|
||||
auto itDef = std::find_if(defVars.begin(), defVars.end(), [&it](const auto& pair) {
|
||||
return pair.first == it->first;
|
||||
});
|
||||
if (itDef == GamePH::PlayerVariables::playerVarsDefault.end())
|
||||
if (itDef == defVars.end())
|
||||
return;
|
||||
|
||||
if (it->second.second == "float") {
|
||||
@ -5894,6 +5925,30 @@ namespace Menu {
|
||||
playerCharacter->FreezeCharacter();
|
||||
}
|
||||
|
||||
void UpdatePlayerVars() {
|
||||
auto bgn = GamePH::PlayerVariables::playerVars.begin();
|
||||
for (auto it = bgn; it != GamePH::PlayerVariables::playerVars.end(); ++it) {
|
||||
if (!it->second.first)
|
||||
continue;
|
||||
|
||||
try {
|
||||
auto& valDef = GamePH::PlayerVariables::playerVarsDefault.at(it - bgn);
|
||||
|
||||
if (it->second.second == "float") {
|
||||
float* varAddr = reinterpret_cast<float*>(it->second.first);
|
||||
if (!Utils::are_same(*varAddr, *(varAddr + 1)) && !Utils::are_same(*(varAddr + 1), std::any_cast<float>(valDef.second.first)))
|
||||
*varAddr = *(varAddr + 1);
|
||||
} else if (it->second.second == "bool") {
|
||||
bool* varAddr = reinterpret_cast<bool*>(it->second.first);
|
||||
if (*varAddr != *(varAddr + 1) && *(varAddr + 1) != std::any_cast<bool>(valDef.second.first))
|
||||
*varAddr = *(varAddr + 1);
|
||||
}
|
||||
} catch (std::out_of_range& e) {
|
||||
UNREFERENCED_PARAMETER(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (Menu::Camera::freeCamEnabled.value)
|
||||
godModeEnabled.Change(true);
|
||||
@ -5906,9 +5961,12 @@ namespace Menu {
|
||||
freezePlayerEnabled.Restore();
|
||||
|
||||
PlayerPositionUpdate();
|
||||
UpdatePlayerVars();
|
||||
}
|
||||
|
||||
void Render() {
|
||||
ImGui::Checkbox("Debug", &debugEnabled);
|
||||
|
||||
ImGui::BeginDisabled(!GamePH::PlayerHealthModule::Get() || Menu::Camera::freeCamEnabled.value); {
|
||||
ImGui::Checkbox("God Mode", &godModeEnabled.value);
|
||||
ImGui::EndDisabled();
|
||||
@ -5918,6 +5976,9 @@ namespace Menu {
|
||||
ImGui::Checkbox("Freeze Player", &freezePlayerEnabled.value);
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Use BACKUP Player Vars (USE ONLY IF PLAYER VARIABLES IS DISABLED!)", &useBACKUPPlayerVarsEnabled);
|
||||
|
||||
ImGui::BeginDisabled(!GamePH::PlayerVariables::gotPlayerVars); {
|
||||
if (ImGui::CollapsingHeader("Player Variables", ImGuiTreeNodeFlags_None)) {
|
||||
ImGui::Indent();
|
||||
@ -5926,9 +5987,15 @@ namespace Menu {
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Load variables from file"))
|
||||
ImGuiFileDialog::Instance()->OpenDialog("ChooseSCRLoadPath", "Choose File", ".scr", loadSCRFilePath.empty() ? "." : loadSCRFilePath);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::Checkbox("Restore variables to saved variables", &restoreVarsToSavedVarsEnabled);
|
||||
|
||||
if (ImGui::Button("Restore variables to default"))
|
||||
RestoreVariablesToDefault();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Save current variables as default"))
|
||||
SaveVariablesAsDefault();
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::InputTextWithHint("##VarsSearch", "Search variables", playerVarsSearchFilter, 64);
|
||||
@ -5948,23 +6015,37 @@ namespace Menu {
|
||||
if (val.second == "float") {
|
||||
float* varAddr = reinterpret_cast<float*>(val.first);
|
||||
|
||||
ImGui::InputFloat(key.data(), &*varAddr);
|
||||
float newValue = *varAddr;
|
||||
|
||||
if (ImGui::InputFloat(key.data(), &newValue)) {
|
||||
*varAddr = newValue;
|
||||
*(varAddr + 1) = newValue;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
restoreBtnName = std::string("Restore##") + std::string(key);
|
||||
if (ImGui::Button(restoreBtnName.c_str()))
|
||||
RestoreVariableToDefault(val.first);
|
||||
|
||||
*(varAddr + 1) = *varAddr;
|
||||
if (debugEnabled) {
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("0x%p", varAddr);
|
||||
}
|
||||
} else if (val.second == "bool") {
|
||||
bool* varAddr = reinterpret_cast<bool*>(val.first);
|
||||
|
||||
ImGui::Checkbox(key.data(), &*varAddr);
|
||||
bool newValue = *varAddr;
|
||||
|
||||
if (ImGui::Checkbox(key.data(), &newValue)) {
|
||||
*varAddr = newValue;
|
||||
*(varAddr + 1) = newValue;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
restoreBtnName = std::string("Restore##") + std::string(key);
|
||||
if (ImGui::Button(restoreBtnName.c_str()))
|
||||
RestoreVariableToDefault(val.first);
|
||||
|
||||
*(varAddr + 1) = *varAddr;
|
||||
if (debugEnabled) {
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("0x%p", varAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::Unindent();
|
||||
@ -6019,6 +6100,12 @@ namespace Menu {
|
||||
ImGui::CloseCurrentPopup();
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
if (ImGui::BeginPopupModal("Saved current player variables!", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::Text("All current player variables have been stored as default! Now if you have \"Restore variables to saved variables\" enabled, restoring to default will restore player variables to the ones you have saved!");
|
||||
if (ImGui::Button("OK", ImVec2(120.0f, 0.0f)))
|
||||
ImGui::CloseCurrentPopup();
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,9 +7,13 @@ namespace Menu {
|
||||
extern SMART_BOOL godModeEnabled;
|
||||
extern SMART_BOOL freezePlayerEnabled;
|
||||
|
||||
extern bool useBACKUPPlayerVarsEnabled;
|
||||
|
||||
extern std::string saveSCRPath;
|
||||
extern std::string loadSCRFilePath;
|
||||
|
||||
extern bool restoreVarsToSavedVarsEnabled;
|
||||
|
||||
extern void Update();
|
||||
extern void Render();
|
||||
}
|
||||
|
@ -2,15 +2,12 @@
|
||||
#include "sigscan.h"
|
||||
#include "..\memory.h"
|
||||
|
||||
// macro for lazily adding signatures to this sig list
|
||||
#define AddOffset(name, moduleName, pattern, type, retType) \
|
||||
static retType Get_## name () {\
|
||||
static retType name = NULL;\
|
||||
if (Memory::IsValidPtr(name)) return name; \
|
||||
return name=reinterpret_cast<retType>(PatternScanner::FindPattern(moduleName, {pattern, type}));\
|
||||
}
|
||||
|
||||
// macro for lazily adding offsets to the sig list
|
||||
#define AddStaticOffset(name, off) \
|
||||
static DWORD64 Get_## name () {\
|
||||
static DWORD64 name = NULL;\
|
||||
@ -18,44 +15,44 @@ static DWORD64 Get_## name () {\
|
||||
return name=static_cast<DWORD64>(off);\
|
||||
}
|
||||
|
||||
// Static offsets go here
|
||||
// NEEDS REPLACING SIGNATURES FOR MOST!!!
|
||||
struct Offsets {
|
||||
// ntdll.dll
|
||||
AddOffset(LdrpCallInitRoutineOffset, "ntdll.dll", "[48 89 5C 24 08 44 89 44 24 18 48", PatternType::Address, PDWORD64)
|
||||
AddOffset(LdrpRunInitializeRoutinesOffset, "ntdll.dll", "[48 89 4C 24 08 53 56 57 41 54 41 55 41 56 41 57 48 81 EC 90", PatternType::Address, PDWORD64) // for win7
|
||||
|
||||
// Input related
|
||||
AddOffset(g_CInput, "engine_x64_rwdi.dll", "48 89 05 [?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B 86 ?? ?? ?? ??", PatternType::RelativePointer, PDWORD64*)
|
||||
AddOffset(g_CInput, "engine_x64_rwdi.dll", "48 8B 0D [?? ?? ?? ?? 48 85 C9 74 0F 48 8B 01 84 D2", PatternType::RelativePointer, PDWORD64*)
|
||||
|
||||
// Player vars related
|
||||
AddOffset(LoadPlayerFloatVariableOffset, "gamedll_ph_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 8D 55 80 48 8B 08", PatternType::RelativePointer, PDWORD64);
|
||||
AddOffset(LoadPlayerBoolVariableOffset, "gamedll_ph_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 8D 55 98 48 8B 08", PatternType::RelativePointer, PDWORD64);
|
||||
AddOffset(InitializePlayerVariablesOffset, "gamedll_ph_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 8B E8 48 8B CF 48 89 AF ?? ?? ?? ??", PatternType::RelativePointer, DWORD64)
|
||||
AddStaticOffset(initPlayerFloatVarsInstrOffset, 0xE);
|
||||
AddStaticOffset(initPlayerBoolVarsInstrOffset, 0x234);
|
||||
AddOffset(PlayerStateOffset, "gamedll_ph_x64_rwdi.dll", "48 8B 3D [?? ?? ?? ?? 4C 8B EA", PatternType::RelativePointer, LPVOID)
|
||||
AddStaticOffset(LoadPlayerVariableFuncSize, 0x14E)
|
||||
AddOffset(LoadPlayerFloatVariableOffset, "gamedll_ph_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 8B D0 48 8D 8C 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8D 94 24 ?? ?? ?? ?? 48 8B 8C 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8D 8C 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8D 8C 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B 84 24 ?? ?? ?? ??", PatternType::RelativePointer, PDWORD64);
|
||||
AddOffset(InitializePlayerVariablesOffset, "gamedll_ph_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 8B F0 48 8B CF", PatternType::RelativePointer, DWORD64)
|
||||
AddStaticOffset(initPlayerFloatVarsInstrOffset, 0x99);
|
||||
AddStaticOffset(initPlayerBoolVarsInstrOffset, 0x2E7);
|
||||
AddOffset(PlayerStateOffset, "gamedll_ph_x64_rwdi.dll", "4C 8B 35 [?? ?? ?? ?? 4C 8B E2", PatternType::RelativePointer, LPVOID)
|
||||
|
||||
// Game related
|
||||
AddStaticOffset(gameDI_PH2_offset, 0x28)
|
||||
AddOffset(CLobbySteamOffset, "engine_x64_rwdi.dll", "48 8B 05 [?? ?? ?? ?? 48 85 C0 74 05 48 83 C0 08 C3", PatternType::RelativePointer, LPVOID)
|
||||
AddStaticOffset(gameDI_PH2Offset, 0x18)
|
||||
AddOffset(g_PlayerObjProperties, "gamedll_ph_x64_rwdi.dll", "48 8B D9 48 89 0D [?? ?? ?? ??", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(g_DayNightCycle, "gamedll_ph_x64_rwdi.dll", "48 8B 0D [?? ?? ?? ?? 48 85 C9 74 10 E8 ?? ?? ?? ?? 84 C0 74 07 B0 01 48 83 C4 28 C3 32 C0", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(g_CameraFPPDI, "gamedll_ph_x64_rwdi.dll", "48 89 05 [?? ?? ?? ?? 40 84 FF", PatternType::RelativePointer, PDWORD64)
|
||||
AddOffset(g_FreeCamera, "gamedll_ph_x64_rwdi.dll", "48 89 05 [?? ?? ?? ?? 48 89 4C 24 ??", PatternType::RelativePointer, PDWORD64)
|
||||
|
||||
// Functions
|
||||
AddOffset(ReadVideoSettingsOffset, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 8D 4C 24 ?? FF 15 ?? ?? ?? ?? 8B 54 24 78", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(ReadVideoSettingsOffset, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 8D 4C 24 ?? FF 15 ?? ?? ?? ?? 48 C7 C2 ?? ?? ?? ??", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(CalculateFreeCamCollisionOffset, "gamedll_ph_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 8B 06 4C 8D 4C 24 ??", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(GetViewCameraOffset, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 85 C0 74 28 48 8B C8", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(MoveCharacterOffset, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 80 BB ?? ?? ?? ?? ?? 74 4E", PatternType::RelativePointer, LPVOID)
|
||||
// NOT USING FOR NOW
|
||||
//AddOffset(MoveCharacterOffset, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 80 BB ?? ?? ?? ?? ?? 74 4E", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(CreatePlayerHealthModuleOffset, "gamedll_ph_x64_rwdi.dll", "[48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 4C 8B F1 E8 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ??", PatternType::Address, LPVOID)
|
||||
AddOffset(LifeSetHealth, "gamedll_ph_x64_rwdi.dll", "E8 [?? ?? ?? ?? 49 8D 4C 24 ?? 49 03 CE", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(TogglePhotoMode, "gamedll_ph_x64_rwdi.dll", "48 83 EC 48 38 91 ?? ?? ?? ??", PatternType::Address, LPVOID)
|
||||
AddOffset(GetTimeWeatherSystemOffset, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 33 D2 48 8B C8 E8 ?? ?? ?? ?? 4C 8B C8", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(GetTimeWeatherSystemOffset, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 33 D2 48 8B C8 E8 ?? ?? ?? ?? 49 8D 4F 38", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(SetForcedWeatherOffset, "engine_x64_rwdi.dll", "89 51 68 C3 CC CC CC CC CC CC CC CC CC CC CC CC", PatternType::Address, LPVOID)
|
||||
AddOffset(GetCurrentWeatherOffset, "engine_x64_rwdi.dll", "48 8B 41 78 48 85 C0 75 0F", PatternType::Address, LPVOID)
|
||||
};
|
||||
|
||||
#undef AddFuncCall
|
||||
#undef AddOffset
|
||||
#undef AddStaticOffset
|
@ -3,6 +3,10 @@
|
||||
#include "utils.h"
|
||||
|
||||
namespace Utils {
|
||||
bool are_same(float a, float b) {
|
||||
return abs(a - b) < 0.0001f;
|
||||
}
|
||||
|
||||
bool str_replace(std::string& str, const std::string& from, const std::string& to) {
|
||||
const size_t start_pos = str.find(from);
|
||||
if (start_pos == std::string::npos)
|
||||
|
@ -8,6 +8,8 @@ enum class WindowsVersion {
|
||||
};
|
||||
|
||||
namespace Utils {
|
||||
extern bool are_same(float a, float b);
|
||||
|
||||
extern bool str_replace(std::string& str, const std::string& from, const std::string& to);
|
||||
|
||||
extern std::string_view GetDesktopDir();
|
||||
|
@ -6,3 +6,4 @@ ToggleKey=VK_F5
|
||||
[Player:PlayerVariables]
|
||||
LastLoadSCRFilePath=
|
||||
LastSaveSCRPath=
|
||||
UseBACKUPPlayerVars=0
|
||||
|
BIN
Extra Files/Images/Camera Tab.jpg
Normal file
BIN
Extra Files/Images/Camera Tab.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 262 KiB |
BIN
Extra Files/Images/CoverPhoto.png
Normal file
BIN
Extra Files/Images/CoverPhoto.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
Extra Files/Images/Player Tab.jpg
Normal file
BIN
Extra Files/Images/Player Tab.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 448 KiB |
BIN
Extra Files/Images/World Tab.jpg
Normal file
BIN
Extra Files/Images/World Tab.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 434 KiB |
Reference in New Issue
Block a user