Add camera distance
This commit is contained in:
@@ -8,7 +8,10 @@
|
||||
#include "Memory.hpp";
|
||||
#include "Maths.hpp";
|
||||
#include "ObfuscateString.h"
|
||||
#include "SDK/CoreUObject_classes.hpp"
|
||||
#include "SDK/Engine_classes.hpp"
|
||||
//#include "SDK/Engine_structs.hpp"
|
||||
//#include "SDK/Cronos_classes.hpp"
|
||||
|
||||
using namespace SDK;
|
||||
|
||||
@@ -34,7 +37,9 @@ static bool g_aspect_fix_enabled = false;
|
||||
static bool g_DOF_fix_enabled = false;
|
||||
static bool g_Vignetting_fix_enabled = false;
|
||||
static bool g_Fog_fix_enabled = false;
|
||||
static bool g_cam_distance_fix_enabled = false;
|
||||
static int g_AdditionalFOVValue = 0;
|
||||
static float g_cameraDistanceMultiplier = 0.f;
|
||||
|
||||
// Shared values
|
||||
static float g_FOV_In = 0;
|
||||
@@ -49,11 +54,14 @@ static uint8_t* Aspectaddress = nullptr;
|
||||
static uint8_t* DOFaddress = nullptr;
|
||||
static uint8_t* Vignettingaddress = nullptr;
|
||||
static uint8_t* Fogaddress = nullptr;
|
||||
static uint8_t* CameraDistanceaddress = nullptr;
|
||||
|
||||
// Hooking
|
||||
static SafetyHookMid FOVHook{};
|
||||
static SafetyHookMid AspectHook{};
|
||||
static SafetyHookMid FogHook{};
|
||||
static SafetyHookMid CameraDistanceHook{};
|
||||
//static SafetyHookMid PEHook{};
|
||||
|
||||
// Prototypes
|
||||
static void FOVFixEnabled(bool fix_enabled);
|
||||
@@ -61,7 +69,9 @@ static void AspectFixEnabled(bool fix_enabled);
|
||||
static void DOFFixEnabled(bool fix_enabled);
|
||||
static void VignettingFixEnabled(bool fix_enabled);
|
||||
static void FogFixEnabled(bool fix_enabled);
|
||||
static void CameraDistanceFixEnabled(bool fix_enabled);
|
||||
static void EnableConsole();
|
||||
//static void ProcessEvent();
|
||||
|
||||
uint8_t* basePtr = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr));
|
||||
|
||||
@@ -155,6 +165,18 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
}
|
||||
}
|
||||
|
||||
if (CameraDistanceaddress == nullptr) {
|
||||
constexpr auto CamDistanceStringObfuscated = make_obfuscated<0x4A>("E8 ?? ?? ?? ?? F2 0F ?? ?? ?? ?? 48 8D ?? ?? F3 0F ?? ?? ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 0F");
|
||||
CameraDistanceaddress = Memory::AOBScan(gameExecutable, CamDistanceStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
|
||||
if (!CameraDistanceaddress)
|
||||
logger->warn("Camera distance signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("Camera distance signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(CameraDistanceaddress));
|
||||
CameraDistanceaddress += 0x17;
|
||||
}
|
||||
}
|
||||
|
||||
if (FOVaddress && Aspectaddress && DOFaddress && Vignettingaddress && Fogaddress) {
|
||||
logger->info("All AOB signatures found. Ready to patch...");
|
||||
AOBScanDone = true;
|
||||
@@ -169,6 +191,8 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
if (DOFaddress) DOFFixEnabled(g_DOF_fix_enabled);
|
||||
if (Vignettingaddress) VignettingFixEnabled(g_Vignetting_fix_enabled);
|
||||
if (Fogaddress) FogFixEnabled(g_Fog_fix_enabled);
|
||||
if (CameraDistanceaddress) CameraDistanceFixEnabled(g_cameraDistanceMultiplier);
|
||||
//ProcessEvent();
|
||||
}
|
||||
else {
|
||||
if (FOVaddress) FOVFixEnabled(false);
|
||||
@@ -176,6 +200,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
if (DOFaddress) DOFFixEnabled(false);
|
||||
if (Vignettingaddress) VignettingFixEnabled(false);
|
||||
if (Fogaddress) FogFixEnabled(false);
|
||||
if (CameraDistanceaddress) CameraDistanceFixEnabled(false);
|
||||
logger->info("All fixes disabled");
|
||||
}
|
||||
}
|
||||
@@ -211,11 +236,22 @@ extern "C" __declspec(dllexport) void SetFogFixEnabled(bool enabled, bool init)
|
||||
if (!init) FogFixEnabled(g_Fog_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetCameraDistanceFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_cam_distance_fix_enabled = enabled;
|
||||
if (!init) CameraDistanceFixEnabled(g_cam_distance_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFOV(int fov)
|
||||
{
|
||||
g_AdditionalFOVValue = fov;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetCameraDistance(float cameraDistance)
|
||||
{
|
||||
g_cameraDistanceMultiplier = cameraDistance;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetConsole()
|
||||
{
|
||||
EnableConsole();
|
||||
@@ -312,6 +348,64 @@ static void FogFixEnabled(bool fix_enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
static void CameraDistanceFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && CameraDistanceaddress) {
|
||||
if (!CameraDistanceHook) { // Hook only once
|
||||
CameraDistanceHook = safetyhook::create_mid(CameraDistanceaddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
ctx.xmm1.f32[0] *= g_cameraDistanceMultiplier;
|
||||
});
|
||||
}
|
||||
else CameraDistanceHook.enable();
|
||||
|
||||
logger->info("Camera distance fix enabled");
|
||||
}
|
||||
if (!fix_enabled) {
|
||||
if (CameraDistanceHook) CameraDistanceHook.disable();
|
||||
logger->info("Camera distance fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// Debuggin function intended to find specific class or object
|
||||
// UE Process Event signature to search for : 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 4D ?? ?? 48 ?? ?? 4C ?? ?? 48 ?? ?? 0F 84
|
||||
//static void ProcessEvent() {
|
||||
// HMODULE gameHandle = nullptr;
|
||||
// static uint8_t* ProcessEventaddress = nullptr;
|
||||
//
|
||||
// while ((gameHandle = GetModuleHandleA("Cronos-Win64-Shipping.exe")) == nullptr)
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
//
|
||||
// uintptr_t base_module = (uintptr_t)GetModuleHandle(NULL);
|
||||
//
|
||||
// ProcessEventaddress = reinterpret_cast<uint8_t*>(base_module + static_cast<uintptr_t>(Offsets::ProcessEvent));
|
||||
//
|
||||
// if (!PEHook && ProcessEventaddress + 0x3c) { // Hook only once
|
||||
// PEHook = safetyhook::create_mid(ProcessEventaddress,
|
||||
// [](SafetyHookContext& ctx) {
|
||||
// UObject* object = (UObject*)ctx.rcx;
|
||||
// UFunction* func = (UFunction*)ctx.rdx;
|
||||
//
|
||||
// if (object && object->GetFullName().contains("SHPlayerCameraManagerPlay")) {
|
||||
// auto* camModifier = reinterpret_cast<UCameraModifier*>(object);
|
||||
// auto* camOwner = camModifier->CameraOwner;
|
||||
//
|
||||
// if (camModifier && camOwner) {
|
||||
// FTViewTarget viewTarget = camOwner->ViewTarget;
|
||||
// AActor* pawn = viewTarget.Target;
|
||||
// if (pawn) {
|
||||
// auto* springArm = reinterpret_cast<USpringArmComponent*>(pawn->GetComponentByClass(USHCharacterPlaySpringArmComponent::StaticClass()));
|
||||
//
|
||||
// if (springArm && springArm->GetOwner() == pawn && springArm->IsA(USHCharacterPlaySpringArmComponent::StaticClass())) {
|
||||
// logger->info("springarm trouve: {:p} = {} == {}", reinterpret_cast<void*>(&springArm->TargetArmLength), springArm->TargetArmLength, springArm->GetFullName());
|
||||
// springArm->TargetArmLength = 250.f;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//}
|
||||
|
||||
// UE Console creation
|
||||
static void EnableConsole()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user