Add HUD safezone fix
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
#include "SDK/Basic.hpp"
|
#include "SDK/Basic.hpp"
|
||||||
#include "SDK/Engine_classes.hpp"
|
#include "SDK/Engine_classes.hpp"
|
||||||
#include "SDK/Charlie_classes.hpp"
|
#include "SDK/Charlie_classes.hpp"
|
||||||
|
#include "SDK/UMG_classes.hpp"
|
||||||
|
#include "HUD_PlayerStatus_SUMG_classes.hpp"
|
||||||
|
|
||||||
using namespace SDK;
|
using namespace SDK;
|
||||||
|
|
||||||
@@ -18,7 +20,8 @@ const std::string PLUGIN_NAME = "HellIsUs";
|
|||||||
const std::string PLUGIN_LOG = PLUGIN_NAME + ".log";
|
const std::string PLUGIN_LOG = PLUGIN_NAME + ".log";
|
||||||
const std::string gameExecutable = "HellIsUs-Win64-Shipping.exe";
|
const std::string gameExecutable = "HellIsUs-Win64-Shipping.exe";
|
||||||
const float baseAspect = 1.777777791;
|
const float baseAspect = 1.777777791;
|
||||||
const float WORLD_FOV = 70.f;
|
const float DEFAULT_WORLD_FOV = 70.f;
|
||||||
|
const float DEFAULT_CAMERA_HEIGHT = -15.f;
|
||||||
|
|
||||||
// Logger
|
// Logger
|
||||||
std::shared_ptr<spdlog::logger> logger;
|
std::shared_ptr<spdlog::logger> logger;
|
||||||
@@ -38,6 +41,7 @@ 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_Camera_fix_enabled = false;
|
static bool g_Camera_fix_enabled = false;
|
||||||
|
static bool g_HUD_fix_enabled = false;
|
||||||
static int g_AdditionalFOVValue = 0;
|
static int g_AdditionalFOVValue = 0;
|
||||||
static float g_cameraDistanceMultiplier = 1.f;
|
static float g_cameraDistanceMultiplier = 1.f;
|
||||||
static float g_cameraHeight = -15.f;
|
static float g_cameraHeight = -15.f;
|
||||||
@@ -62,12 +66,20 @@ 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* Cameraaddress = nullptr;
|
static uint8_t* Cameraaddress = nullptr;
|
||||||
|
//static uint8_t* UEConstructaddress = nullptr;
|
||||||
|
static uint8_t* SetAnchorsaddress = nullptr;
|
||||||
|
|
||||||
// Hooking
|
// Hooking
|
||||||
static SafetyHookMid FOVHook{};
|
static SafetyHookMid FOVHook{};
|
||||||
static SafetyHookMid AspectHook{};
|
static SafetyHookMid AspectHook{};
|
||||||
static SafetyHookMid FogHook{};
|
static SafetyHookMid FogHook{};
|
||||||
static SafetyHookMid CameraHook{};
|
static SafetyHookMid CameraHook{};
|
||||||
|
static SafetyHookMid HUDHook{};
|
||||||
|
|
||||||
|
// HUD anchors
|
||||||
|
static FAnchors HUDAnchors = {{ 0.f, 0.f }, { 0.f , 1.f }};
|
||||||
|
static FAnchors TradeListAnchors = { { 0.2f, 0.f }, { 0.2f , 1.f } };
|
||||||
|
static FAnchors defaultHUDAnchors = {{ 0.f, 0.f }, { 1.f, 1.f }}; // Will be displayed on all screen viewport
|
||||||
|
|
||||||
// Camera Mode
|
// Camera Mode
|
||||||
enum class ECharlieCameraMode : uint8_t
|
enum class ECharlieCameraMode : uint8_t
|
||||||
@@ -84,6 +96,7 @@ static void CAFixEnabled(bool fix_enabled);
|
|||||||
static void VignettingFixEnabled(bool fix_enabled);
|
static void VignettingFixEnabled(bool fix_enabled);
|
||||||
static void FogFixEnabled(bool fix_enabled);
|
static void FogFixEnabled(bool fix_enabled);
|
||||||
static void CameraFixEnabled(bool fix_enabled, ECharlieCameraMode Mode);
|
static void CameraFixEnabled(bool fix_enabled, ECharlieCameraMode Mode);
|
||||||
|
static void HUDFixEnabled(bool fix_enabled);
|
||||||
static void EnableConsole();
|
static void EnableConsole();
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
||||||
@@ -210,6 +223,20 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//4C ?? ?? 55 57 41 ?? 41 ?? 41 ?? 49 8D ?? ?? ?? ?? ?? 48 81 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 83 B9
|
||||||
|
// 0x20
|
||||||
|
//if (UEConstructaddress == nullptr) {
|
||||||
|
// constexpr auto UEConstructStringObfuscated = make_obfuscated<0x4A>("4C ?? ?? 55 56 57 48 81 ?? ?? ?? ?? ?? 33 ?? 48 C7 ?? ?? ?? ?? ?? 48 ?? ?? 48 ?? ?? 48 C7 ?? ?? ?? ?? ?? ?? 39 B1 ?? ?? ?? ?? 0F 8E ?? ?? ?? ?? 0F B6");
|
||||||
|
// UEConstructaddress = Memory::AOBScan(gameExecutable, UEConstructStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
|
|
||||||
|
// if (!UEConstructaddress)
|
||||||
|
// logger->warn("UEConstruct signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||||
|
// else {
|
||||||
|
// logger->info("UEConstruct signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(UEConstructaddress));
|
||||||
|
// //UEConstructaddress += 0x30;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
if (FOVaddress && Aspectaddress && DOFaddress && CAaddress && Vignettingaddress && Fogaddress && Cameraaddress) {
|
if (FOVaddress && Aspectaddress && DOFaddress && CAaddress && Vignettingaddress && Fogaddress && Cameraaddress) {
|
||||||
logger->info("All AOB signatures found. Ready to patch...");
|
logger->info("All AOB signatures found. Ready to patch...");
|
||||||
AOBScanDone = true;
|
AOBScanDone = true;
|
||||||
@@ -274,6 +301,8 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
|||||||
if (Vignettingaddress) VignettingFixEnabled(g_Vignetting_fix_enabled);
|
if (Vignettingaddress) VignettingFixEnabled(g_Vignetting_fix_enabled);
|
||||||
if (Fogaddress) FogFixEnabled(g_Fog_fix_enabled);
|
if (Fogaddress) FogFixEnabled(g_Fog_fix_enabled);
|
||||||
if (Cameraaddress) CameraFixEnabled(g_Camera_fix_enabled, ECharlieCameraMode::Camera);
|
if (Cameraaddress) CameraFixEnabled(g_Camera_fix_enabled, ECharlieCameraMode::Camera);
|
||||||
|
if (GObjectsaddress && GNamesaddress && AppendStringaddress && ProcessEventaddress)
|
||||||
|
HUDFixEnabled(g_HUD_fix_enabled);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (FOVaddress) CameraFixEnabled(false, ECharlieCameraMode::FOV);
|
if (FOVaddress) CameraFixEnabled(false, ECharlieCameraMode::FOV);
|
||||||
@@ -283,10 +312,13 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
|||||||
if (Vignettingaddress) VignettingFixEnabled(false);
|
if (Vignettingaddress) VignettingFixEnabled(false);
|
||||||
if (Fogaddress) FogFixEnabled(false);
|
if (Fogaddress) FogFixEnabled(false);
|
||||||
if (Cameraaddress) CameraFixEnabled(false, ECharlieCameraMode::Camera);
|
if (Cameraaddress) CameraFixEnabled(false, ECharlieCameraMode::Camera);
|
||||||
|
if (GObjectsaddress && GNamesaddress && AppendStringaddress && ProcessEventaddress)
|
||||||
|
HUDFixEnabled(false);
|
||||||
logger->info("All fixes disabled.");
|
logger->info("All fixes disabled.");
|
||||||
}
|
}
|
||||||
if (!g_Console_Enabled && GObjectsaddress && GNamesaddress && AppendStringaddress && ProcessEventaddress)
|
if (!g_Console_Enabled && GObjectsaddress && GNamesaddress && AppendStringaddress && ProcessEventaddress) {
|
||||||
EnableConsole();
|
EnableConsole();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setters for Reshade addon call
|
// Setters for Reshade addon call
|
||||||
@@ -332,6 +364,12 @@ extern "C" __declspec(dllexport) void SetCameraFixEnabled(bool enabled, bool ini
|
|||||||
if (!init) CameraFixEnabled(g_Camera_fix_enabled, ECharlieCameraMode::Camera);
|
if (!init) CameraFixEnabled(g_Camera_fix_enabled, ECharlieCameraMode::Camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) void SetHUDFixEnabled(bool enabled, bool init)
|
||||||
|
{
|
||||||
|
g_HUD_fix_enabled = enabled;
|
||||||
|
if (!init) HUDFixEnabled(g_HUD_fix_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) void SetFOV(int fov)
|
extern "C" __declspec(dllexport) void SetFOV(int fov)
|
||||||
{
|
{
|
||||||
g_AdditionalFOVValue = fov;
|
g_AdditionalFOVValue = fov;
|
||||||
@@ -347,6 +385,13 @@ extern "C" __declspec(dllexport) void SetCameraHeight(int cameraHeight)
|
|||||||
g_cameraHeight = (float)cameraHeight;
|
g_cameraHeight = (float)cameraHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) void SetHUD(int HUDValue)
|
||||||
|
{
|
||||||
|
float percentageLeft = (float)HUDValue / 100;
|
||||||
|
float percentageRight = 1 - (float)HUDValue / 100;
|
||||||
|
HUDAnchors = { { percentageLeft , 0.f }, { percentageRight , 1.f} };
|
||||||
|
}
|
||||||
|
|
||||||
// Getters for Reshade addon call
|
// Getters for Reshade addon call
|
||||||
extern "C" __declspec(dllexport) float GetFOVIn() {
|
extern "C" __declspec(dllexport) float GetFOVIn() {
|
||||||
return g_FOV_In;
|
return g_FOV_In;
|
||||||
@@ -404,6 +449,69 @@ static void AspectFixEnabled(bool fix_enabled) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CameraFixEnabled(bool fix_enabled, ECharlieCameraMode mode) {
|
||||||
|
if (g_fix_enabled && fix_enabled && Cameraaddress) {
|
||||||
|
if (!CameraHook) { // Hook only once +0x4e or start to test +0x13
|
||||||
|
CameraHook = safetyhook::create_mid(Cameraaddress + 0x4e,
|
||||||
|
[](SafetyHookContext& ctx) {
|
||||||
|
ctx.xmm0.f32[0] *= (g_Camera_fix_enabled ? g_cameraDistanceMultiplier : 1.f);
|
||||||
|
// Retrieve player camera object
|
||||||
|
auto* charlieCameraBaseConfig = reinterpret_cast<UCharlieCameraBaseConfig*>(ctx.rax);
|
||||||
|
if (charlieCameraBaseConfig && charlieCameraBaseConfig->IsA(UCharlieCameraBaseConfig::StaticClass())) {
|
||||||
|
// Camera height
|
||||||
|
charlieCameraBaseConfig->DefaultHeightFromPlayer = (g_Camera_fix_enabled ? g_cameraHeight : DEFAULT_CAMERA_HEIGHT);
|
||||||
|
// World FOV
|
||||||
|
charlieCameraBaseConfig->FieldOfView = (g_fov_fix_enabled ? DEFAULT_WORLD_FOV + g_AdditionalFOVValue : DEFAULT_WORLD_FOV);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mode == ECharlieCameraMode::Camera) {
|
||||||
|
if (g_Camera_fix_enabled) logger->info("Camera fix enabled");
|
||||||
|
else logger->info("Camera fix disabled");
|
||||||
|
}
|
||||||
|
if (mode == ECharlieCameraMode::FOV) {
|
||||||
|
if (g_fov_fix_enabled) logger->info("FOV fix enabled");
|
||||||
|
else logger->info("FOV fix disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void HUDFixEnabled(bool fix_enabled) {
|
||||||
|
if (g_fix_enabled && fix_enabled && ProcessEventaddress) {
|
||||||
|
if (!HUDHook) {
|
||||||
|
HUDHook = safetyhook::create_mid(ProcessEventaddress + 0xc,
|
||||||
|
[](SafetyHookContext& ctx) {
|
||||||
|
auto original_rdx = ctx.r8;
|
||||||
|
auto* object = reinterpret_cast<UObject*>(ctx.rcx);
|
||||||
|
auto* function = reinterpret_cast<UFunction*>(ctx.rdx);
|
||||||
|
// Filter object on Unreal User widgets
|
||||||
|
if (object && object->IsA(UUserWidget::StaticClass()) && function) {
|
||||||
|
std::string funcName = function->GetName();
|
||||||
|
std::string objectName = object->GetName();
|
||||||
|
// Filter by function construct
|
||||||
|
if (funcName == "Construct") {
|
||||||
|
auto* objectClass = object->Class;
|
||||||
|
std::string className = objectClass ? objectClass->GetName() : "Unknown";
|
||||||
|
auto* widget = static_cast<UUserWidget*>(object);
|
||||||
|
// Ensure the widget is of UCanvasPanelSlot & valid
|
||||||
|
if (widget && widget->Slot && widget->Slot->IsA(UCanvasPanelSlot::StaticClass())) {
|
||||||
|
auto* canvasSlot = static_cast<UCanvasPanelSlot*>(widget->Slot);
|
||||||
|
|
||||||
|
// Filter on class drawing HUD in game
|
||||||
|
if (canvasSlot && className.contains("CombatHud_SUMG_C")) {
|
||||||
|
if (g_HUD_fix_enabled)
|
||||||
|
canvasSlot->SetAnchors(HUDAnchors);
|
||||||
|
else
|
||||||
|
canvasSlot->SetAnchors(defaultHUDAnchors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Memory patch fixes
|
// Memory patch fixes
|
||||||
static void DOFFixEnabled(bool fix_enabled) {
|
static void DOFFixEnabled(bool fix_enabled) {
|
||||||
if (g_fix_enabled && fix_enabled && DOFaddress) {
|
if (g_fix_enabled && fix_enabled && DOFaddress) {
|
||||||
@@ -450,33 +558,6 @@ static void FogFixEnabled(bool fix_enabled) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CameraFixEnabled(bool fix_enabled, ECharlieCameraMode mode) {
|
|
||||||
if (g_fix_enabled && fix_enabled && Cameraaddress) {
|
|
||||||
if (!CameraHook) { // Hook only once +0x4e or start to test +0x13
|
|
||||||
CameraHook = safetyhook::create_mid(Cameraaddress + 0x4e,
|
|
||||||
[](SafetyHookContext& ctx) {
|
|
||||||
ctx.xmm0.f32[0] *= (g_Camera_fix_enabled ? g_cameraDistanceMultiplier : 1.f);
|
|
||||||
// Retrieve player camera object
|
|
||||||
auto* charlieCameraBaseConfig = reinterpret_cast<UCharlieCameraBaseConfig*>(ctx.rax);
|
|
||||||
if (charlieCameraBaseConfig && charlieCameraBaseConfig->IsA(UCharlieCameraBaseConfig::StaticClass())) {
|
|
||||||
// Camera height
|
|
||||||
charlieCameraBaseConfig->DefaultHeightFromPlayer = (g_Camera_fix_enabled ? g_cameraHeight : -15.f);
|
|
||||||
// World FOV
|
|
||||||
charlieCameraBaseConfig->FieldOfView = (g_fov_fix_enabled ? WORLD_FOV + g_AdditionalFOVValue : WORLD_FOV);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mode == ECharlieCameraMode::Camera) {
|
|
||||||
if (g_Camera_fix_enabled) logger->info("Camera fix enabled");
|
|
||||||
else logger->info("Camera fix disabled");
|
|
||||||
}
|
|
||||||
if (mode == ECharlieCameraMode::FOV) {
|
|
||||||
if (g_fov_fix_enabled) logger->info("FOV fix enabled");
|
|
||||||
else logger->info("FOV fix disabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// UE Console creation
|
// UE Console creation
|
||||||
static void EnableConsole()
|
static void EnableConsole()
|
||||||
{
|
{
|
||||||
@@ -539,6 +620,7 @@ static void InitializeLogger()
|
|||||||
if (std::filesystem::exists(log_path))
|
if (std::filesystem::exists(log_path))
|
||||||
std::filesystem::remove(log_path);
|
std::filesystem::remove(log_path);
|
||||||
logger = std::make_shared<spdlog::logger>("Hell Is Us", std::make_shared<spdlog::sinks::rotating_file_sink_st>(PLUGIN_LOG, 10 * 1024 * 1024, 1));
|
logger = std::make_shared<spdlog::logger>("Hell Is Us", std::make_shared<spdlog::sinks::rotating_file_sink_st>(PLUGIN_LOG, 10 * 1024 * 1024, 1));
|
||||||
|
logger->set_level(spdlog::level::debug);
|
||||||
logger->flush_on(spdlog::level::debug); // Flush automatically
|
logger->flush_on(spdlog::level::debug); // Flush automatically
|
||||||
}
|
}
|
||||||
catch (const spdlog::spdlog_ex& ex)
|
catch (const spdlog::spdlog_ex& ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user