Add world time dilation
This commit is contained in:
@@ -34,8 +34,10 @@ static bool g_fov_fix_enabled = false;
|
|||||||
static bool g_CA_fix_enabled = false;
|
static bool g_CA_fix_enabled = false;
|
||||||
static bool g_Vignetting_fix_enabled = false;
|
static bool g_Vignetting_fix_enabled = false;
|
||||||
static bool g_Fog_fix_enabled = false;
|
static bool g_Fog_fix_enabled = false;
|
||||||
|
static bool g_WorldTimeDilation_fix_enabled = false;
|
||||||
static int g_AdditionalFOVValue = 0;
|
static int g_AdditionalFOVValue = 0;
|
||||||
static int g_CameraOffset = 0;
|
static int g_CameraOffset = 0;
|
||||||
|
static float g_WorldTimeDilationValue = 1.f;
|
||||||
static float g_TransitionCameraOffset = 0.f;
|
static float g_TransitionCameraOffset = 0.f;
|
||||||
static float g_NativeCameraDistance = 80.f;
|
static float g_NativeCameraDistance = 80.f;
|
||||||
static float g_LastCameraDeltaTime = 1.f / 60.f; // fallback
|
static float g_LastCameraDeltaTime = 1.f / 60.f; // fallback
|
||||||
@@ -69,12 +71,14 @@ static uint8_t* HUDaddress = nullptr;
|
|||||||
static uint8_t* CAaddress = nullptr;
|
static uint8_t* CAaddress = nullptr;
|
||||||
static uint8_t* Vignettingaddress = nullptr;
|
static uint8_t* Vignettingaddress = nullptr;
|
||||||
static uint8_t* Fogaddress = nullptr;
|
static uint8_t* Fogaddress = nullptr;
|
||||||
|
static uint8_t* WorldTimedilationaddress = nullptr;
|
||||||
|
|
||||||
// Hooking
|
// Hooking
|
||||||
static SafetyHookMid FOVHook{};
|
static SafetyHookMid FOVHook{};
|
||||||
static SafetyHookMid CameraHook{};
|
static SafetyHookMid CameraHook{};
|
||||||
static SafetyHookMid HUDHook{};
|
static SafetyHookMid HUDHook{};
|
||||||
static SafetyHookMid FogHook{};
|
static SafetyHookMid FogHook{};
|
||||||
|
static SafetyHookMid WorldTimeDilationHook{};
|
||||||
static SafetyHookMid PEHook{};
|
static SafetyHookMid PEHook{};
|
||||||
|
|
||||||
// Prototypes
|
// Prototypes
|
||||||
@@ -86,6 +90,7 @@ static void DOFFixEnabled();
|
|||||||
static void CAFixEnabled();
|
static void CAFixEnabled();
|
||||||
static void VignettingFixEnabled();
|
static void VignettingFixEnabled();
|
||||||
static void FogFixEnabled();
|
static void FogFixEnabled();
|
||||||
|
static void WorldTimeDilation();
|
||||||
static void EnableConsole();
|
static void EnableConsole();
|
||||||
|
|
||||||
// Unreal Engine camera struct
|
// Unreal Engine camera struct
|
||||||
@@ -95,7 +100,6 @@ struct BlueprintModifyCamera_Params
|
|||||||
FVector ViewLocation; // in
|
FVector ViewLocation; // in
|
||||||
FRotator ViewRotation; // in
|
FRotator ViewRotation; // in
|
||||||
float FOV; // in
|
float FOV; // in
|
||||||
|
|
||||||
// OUT parameters (Passed by refernce in Blueprint signature)
|
// OUT parameters (Passed by refernce in Blueprint signature)
|
||||||
FVector NewViewLocation; // out
|
FVector NewViewLocation; // out
|
||||||
FRotator NewViewRotation; // out
|
FRotator NewViewRotation; // out
|
||||||
@@ -107,7 +111,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
g_fix_enabled = enabled;
|
g_fix_enabled = enabled;
|
||||||
if (g_fix_enabled && !AOBScanDone) { // Unreal Engine 4.27.2
|
if (g_fix_enabled && !AOBScanDone) { // Unreal Engine 4.27.2
|
||||||
logger->info("--------------- AOB scan started ---------------");
|
logger->info("--------------- AOB scan started ---------------");
|
||||||
if (FOVaddress == nullptr) {
|
if (!FOVaddress) {
|
||||||
constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B");
|
constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B");
|
||||||
FOVaddress = Memory::AOBScan("", FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ, logger);
|
FOVaddress = Memory::AOBScan("", FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ, logger);
|
||||||
|
|
||||||
@@ -149,7 +153,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
logger->info("Chromatic aberrations signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(CAaddress));
|
logger->info("Chromatic aberrations signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(CAaddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Vignettingaddress == nullptr) {
|
if (!Vignettingaddress) {
|
||||||
constexpr auto VignettingStringObfuscated = make_obfuscated<0x4A>("8B ?? 83 ?? ?? 7D ?? 89 B3");
|
constexpr auto VignettingStringObfuscated = make_obfuscated<0x4A>("8B ?? 83 ?? ?? 7D ?? 89 B3");
|
||||||
Vignettingaddress = Memory::AOBScan("", VignettingStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
Vignettingaddress = Memory::AOBScan("", VignettingStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
|
|
||||||
@@ -159,7 +163,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
logger->info("Vignetting signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Vignettingaddress));
|
logger->info("Vignetting signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Vignettingaddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Fogaddress == nullptr) {
|
if (!Fogaddress) {
|
||||||
constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("83 ?? ?? ?? 75 ?? B3 ?? EB ?? 32 ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8");
|
constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("83 ?? ?? ?? 75 ?? B3 ?? EB ?? 32 ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8");
|
||||||
Fogaddress = Memory::AOBScan("", FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
Fogaddress = Memory::AOBScan("", FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
|
|
||||||
@@ -169,7 +173,17 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
logger->info("Fog signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Fogaddress));
|
logger->info("Fog signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Fogaddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FOVaddress && Cameraaddress && HUDaddress && CAaddress && Vignettingaddress && Fogaddress)
|
if (!WorldTimedilationaddress) {
|
||||||
|
constexpr auto WorldTimeDilationStringObfuscated = make_obfuscated<0x4A>("F3 0F 10 ?? ?? ?? ?? ?? F3 0F 10 ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? C3");
|
||||||
|
WorldTimedilationaddress = Memory::AOBScan("", WorldTimeDilationStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
|
|
||||||
|
if (!WorldTimedilationaddress)
|
||||||
|
logger->warn("World time dilation signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||||
|
else
|
||||||
|
logger->info("World time dilation signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(WorldTimedilationaddress));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FOVaddress && Cameraaddress && HUDaddress && CAaddress && Vignettingaddress && Fogaddress && WorldTimedilationaddress)
|
||||||
logger->info("All AOB signatures found. Ready to patch...");
|
logger->info("All AOB signatures found. Ready to patch...");
|
||||||
|
|
||||||
AOBScanDone = true;
|
AOBScanDone = true;
|
||||||
@@ -236,6 +250,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
if (!init && CAaddress) CAFixEnabled();
|
if (!init && CAaddress) CAFixEnabled();
|
||||||
if (!init && Vignettingaddress) VignettingFixEnabled();
|
if (!init && Vignettingaddress) VignettingFixEnabled();
|
||||||
if (!init && Fogaddress) FogFixEnabled();
|
if (!init && Fogaddress) FogFixEnabled();
|
||||||
|
if (!init && WorldTimedilationaddress) WorldTimeDilation();
|
||||||
if (!init && GObjectsaddress && AppendStringaddress && ProcessEventaddress) EnableConsole();
|
if (!init && GObjectsaddress && AppendStringaddress && ProcessEventaddress) EnableConsole();
|
||||||
if (ConstrainAspectaddress) UltraWideFixEnabled();
|
if (ConstrainAspectaddress) UltraWideFixEnabled();
|
||||||
}
|
}
|
||||||
@@ -249,6 +264,7 @@ extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enable
|
|||||||
if (fix == GameFixes::ChromaticAberrations) { g_CA_fix_enabled = enabled; CAFixEnabled(); }
|
if (fix == GameFixes::ChromaticAberrations) { g_CA_fix_enabled = enabled; CAFixEnabled(); }
|
||||||
if (fix == GameFixes::Vignetting) { g_Vignetting_fix_enabled = enabled; VignettingFixEnabled(); }
|
if (fix == GameFixes::Vignetting) { g_Vignetting_fix_enabled = enabled; VignettingFixEnabled(); }
|
||||||
if (fix == GameFixes::Fog) { g_Fog_fix_enabled = enabled; FogFixEnabled(); }
|
if (fix == GameFixes::Fog) { g_Fog_fix_enabled = enabled; FogFixEnabled(); }
|
||||||
|
if (fix == GameFixes::WorldTimeDilation) { g_WorldTimeDilation_fix_enabled = enabled; WorldTimeDilation(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) void SetFOV(int fov)
|
extern "C" __declspec(dllexport) void SetFOV(int fov)
|
||||||
@@ -266,6 +282,10 @@ extern "C" __declspec(dllexport) void SetHUDScale(int HUDScale) {
|
|||||||
g_HUDRight = 1.f - ((float)HUDScale / 100);
|
g_HUDRight = 1.f - ((float)HUDScale / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) void SetWorldTimeDilation(float timeDilation) {
|
||||||
|
g_WorldTimeDilationValue = timeDilation;
|
||||||
|
}
|
||||||
|
|
||||||
// Getters for Reshade addon call
|
// Getters for Reshade addon call
|
||||||
extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
||||||
if (!infos) return;
|
if (!infos) return;
|
||||||
@@ -364,12 +384,13 @@ static void CameraFixEnabled() {
|
|||||||
if (!pc) return;
|
if (!pc) return;
|
||||||
APawn* pawn = pc->AcknowledgedPawn;
|
APawn* pawn = pc->AcknowledgedPawn;
|
||||||
if (!pawn) return;
|
if (!pawn) return;
|
||||||
|
|
||||||
// Retrieve Character class
|
// Retrieve Character class
|
||||||
void* inventoryComp = *(void**)((uintptr_t)pawn + 0x6d8); // inventoryComp offset from SDK
|
void* inventoryComp = *(void**)((uintptr_t)pawn + 0x6d8); // inventoryComp offset from SDK
|
||||||
void* moveComp = *(void**)((uintptr_t)pawn + 0x908); // moveComp offset FROM SDK
|
void* moveComp = *(void**)((uintptr_t)pawn + 0x908); // moveComp offset FROM SDK
|
||||||
if (inventoryComp && moveComp) {
|
if (inventoryComp && moveComp) {
|
||||||
APhxCharacter* phxChar = static_cast<APhxCharacter*>(pawn);
|
APhxCharacter* phxChar = static_cast<APhxCharacter*>(pawn);
|
||||||
if (phxChar) bIsAiming = phxChar->GetIsAiming(); // Is player aiming
|
if (phxChar) bIsAiming = phxChar->bIsAiming; // Is player aiming ?
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Positions ---
|
// --- Positions ---
|
||||||
@@ -473,13 +494,13 @@ static void CameraFixEnabled() {
|
|||||||
[](SafetyHookContext& ctx) {
|
[](SafetyHookContext& ctx) {
|
||||||
if (bIsInCinematicMode) {
|
if (bIsInCinematicMode) {
|
||||||
double now = NowSeconds();
|
double now = NowSeconds();
|
||||||
if ((now - LastCineCallTime) > 1.0) // 1 seconde sans appel
|
if ((now - LastCineCallTime) > 1.0) // 1 second FOV is not changed -> cinematics = false
|
||||||
bIsInCinematicMode = false;
|
bIsInCinematicMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float dt = g_LastCameraDeltaTime;
|
float dt = g_LastCameraDeltaTime;
|
||||||
float fadeInSpeed = 3.5f; // vitesse quand on RAPPROCHE la caméra
|
float fadeInSpeed = 3.5f; // Camera speed when it's getting closer
|
||||||
float fadeOutSpeed = 3.5f; // vitesse quand on RECULE la caméra
|
float fadeOutSpeed = 3.5f; // Camera speed when it moves away
|
||||||
// sécurité
|
// sécurité
|
||||||
if (dt <= 0.f || dt > 0.1f) dt = 1.f / 60.f;
|
if (dt <= 0.f || dt > 0.1f) dt = 1.f / 60.f;
|
||||||
|
|
||||||
@@ -521,6 +542,23 @@ static void HUDFixEnabled() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void WorldTimeDilation() {
|
||||||
|
if (g_fix_enabled && g_WorldTimeDilation_fix_enabled) {
|
||||||
|
if (!WorldTimeDilationHook) {
|
||||||
|
WorldTimeDilationHook = safetyhook::create_mid(WorldTimedilationaddress + 0x20,
|
||||||
|
[](SafetyHookContext& ctx) {
|
||||||
|
ctx.xmm0.f32[0] = g_WorldTimeDilationValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else WorldTimeDilationHook.enable();
|
||||||
|
logger->info("World time dilation fix enabled");
|
||||||
|
}
|
||||||
|
if (!(g_fix_enabled && g_WorldTimeDilation_fix_enabled)) {
|
||||||
|
if (WorldTimeDilationHook) WorldTimeDilationHook.disable();
|
||||||
|
logger->info("World time dilation fix disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Memory patch fixes
|
// Memory patch fixes
|
||||||
static void UltraWideFixEnabled() {
|
static void UltraWideFixEnabled() {
|
||||||
if (ConstrainAspectaddress)
|
if (ConstrainAspectaddress)
|
||||||
@@ -549,7 +587,6 @@ static void VignettingFixEnabled() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void FogFixEnabled() {
|
static void FogFixEnabled() {
|
||||||
if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) {
|
if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) {
|
||||||
if (!FogHook) {
|
if (!FogHook) {
|
||||||
|
|||||||
3
external/includes/GameFixes.h
vendored
3
external/includes/GameFixes.h
vendored
@@ -16,5 +16,6 @@ enum class GameFixes : int {
|
|||||||
Fog,
|
Fog,
|
||||||
VolumetricFog,
|
VolumetricFog,
|
||||||
Sharpening,
|
Sharpening,
|
||||||
FilmGrain
|
FilmGrain,
|
||||||
|
WorldTimeDilation
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user