Add UI scaling and traveler health information. CPU overhead reduction. Ignore hits cheat restored.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "CommonHeaders.h"
|
||||
#include "UEngine.hpp";
|
||||
#include "UEngine.hpp"
|
||||
#include "UETools.hpp"
|
||||
#include "UEvars.hpp"
|
||||
#include "SDK/Basic.hpp"
|
||||
@@ -38,6 +38,7 @@ static bool g_IgnoreHits_fix_enabled = false;
|
||||
static bool g_Stealth_fix_enabled = false;
|
||||
static int g_AdditionalFOVValue = 0;
|
||||
static int g_HUDOffsets = 0;
|
||||
static int g_UIOffsets = 0;
|
||||
static float g_cameraDistanceMultiplier = 1.f;
|
||||
static float g_WorldTimeDilationValue = 1.f;
|
||||
static float g_AITimeDilationValue = 1.f;
|
||||
@@ -48,6 +49,7 @@ static float g_Compensated_FOV = 0;
|
||||
static float g_FOV_Out = 0;
|
||||
static float g_Camera_In = 180;
|
||||
static float g_Camera_Out = 180;
|
||||
static float g_PlayerHealth = 0;
|
||||
// AOB Scan pointers
|
||||
static uint8_t* FOVaddress = nullptr;
|
||||
static uint8_t* Aspectaddress = nullptr;
|
||||
@@ -73,7 +75,7 @@ static SafetyHookMid StealthHook{};
|
||||
// Prototypes
|
||||
static void FOVFixEnabled();
|
||||
static void UltrawideFixEnabled();
|
||||
static void HUDFixEnabled(UWidget* widget, bool writeLog, int depth = INT_MAX);
|
||||
static void HUDFixEnabled(UWidget* widget, int offset, bool writeLog, int depth = INT_MAX);
|
||||
static void DOFFixEnabled();
|
||||
static void VignettingFixEnabled();
|
||||
static void FogFixEnabled();
|
||||
@@ -124,7 +126,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
Memory::AOBScanBatch(signatures, logger);
|
||||
|
||||
if (FOVaddress && Aspectaddress && DOFaddress && Vignettingaddress && FogOpacityEngineaddress && CameraDistanceaddress &&
|
||||
WorldTimedilationaddress && GodModeaddress && StealthModeaddress)
|
||||
WorldTimedilationaddress && Timedilationaddress && GodModeaddress && StealthModeaddress)
|
||||
logger->info("All AOB signatures found. Ready to patch...");
|
||||
|
||||
// Unreal Engine Offsets updates (needed when the game reveives an update and to prevent the fix from crashing the game)
|
||||
@@ -154,10 +156,10 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
if (!init && FOVaddress) FOVFixEnabled();
|
||||
if (!init && Aspectaddress) UltrawideFixEnabled();
|
||||
if (!init) {
|
||||
HUDFixEnabled(g_HUDWidget, true);
|
||||
HUDFixEnabled(g_WorkbenchWidget, false, 1);
|
||||
HUDFixEnabled(g_SettingsWidget, false, 1);
|
||||
HUDFixEnabled(g_TutorialWidget, false, 1);
|
||||
HUDFixEnabled(g_HUDWidget, g_HUDOffsets, true);
|
||||
HUDFixEnabled(g_WorkbenchWidget, g_UIOffsets, false, 1);
|
||||
HUDFixEnabled(g_SettingsWidget, g_UIOffsets, false, 1);
|
||||
HUDFixEnabled(g_TutorialWidget, g_UIOffsets, false, 1);
|
||||
}
|
||||
if (!init && DOFaddress) DOFFixEnabled();
|
||||
if (!init && Vignettingaddress) VignettingFixEnabled();
|
||||
@@ -178,10 +180,10 @@ extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enable
|
||||
if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); }
|
||||
if (fix == GameFixes::UltraWide) { g_aspect_fix_enabled = enabled; UltrawideFixEnabled(); }
|
||||
if (fix == GameFixes::HUD) { g_HUD_fix_enabled = enabled;
|
||||
HUDFixEnabled(g_HUDWidget, true);
|
||||
HUDFixEnabled(g_WorkbenchWidget, false, 1);
|
||||
HUDFixEnabled(g_SettingsWidget, false, 1);
|
||||
HUDFixEnabled(g_TutorialWidget, false, 1); }
|
||||
HUDFixEnabled(g_HUDWidget, g_HUDOffsets, true);
|
||||
HUDFixEnabled(g_WorkbenchWidget, g_UIOffsets, false, 1);
|
||||
HUDFixEnabled(g_SettingsWidget, g_UIOffsets, false, 1);
|
||||
HUDFixEnabled(g_TutorialWidget, g_UIOffsets, false, 1); }
|
||||
if (fix == GameFixes::Camera) { g_cam_distance_fix_enabled = enabled; CameraDistanceFixEnabled(); }
|
||||
if (fix == GameFixes::DOF) { g_DOF_fix_enabled = enabled; DOFFixEnabled(); }
|
||||
if (fix == GameFixes::Vignetting) { g_Vignetting_fix_enabled = enabled; VignettingFixEnabled(); }
|
||||
@@ -202,10 +204,13 @@ extern "C" __declspec(dllexport) void SetValues(GameSetting setting, float value
|
||||
|
||||
if (setting == GameSetting::HUD) {
|
||||
g_HUDOffsets = ((int)value * screenWidth) / 100;
|
||||
HUDFixEnabled(g_HUDWidget, true);
|
||||
HUDFixEnabled(g_WorkbenchWidget, false, 1);
|
||||
HUDFixEnabled(g_SettingsWidget, false, 1);
|
||||
HUDFixEnabled(g_TutorialWidget, false, 1);
|
||||
HUDFixEnabled(g_HUDWidget, g_HUDOffsets, false);
|
||||
}
|
||||
if (setting == GameSetting::UI) {
|
||||
g_UIOffsets = ((int)value * screenWidth) / 100;
|
||||
HUDFixEnabled(g_WorkbenchWidget, g_UIOffsets, false, 1);
|
||||
HUDFixEnabled(g_SettingsWidget, g_UIOffsets, false, 1);
|
||||
HUDFixEnabled(g_TutorialWidget, g_UIOffsets, false, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +224,7 @@ extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
||||
infos->cameraIn = g_Camera_In;
|
||||
infos->cameraOut = g_Camera_Out;
|
||||
infos->consoleEnabled = g_Console_Enabled;
|
||||
infos->Health = g_PlayerHealth;
|
||||
}
|
||||
|
||||
static bool inContinue = false;
|
||||
@@ -231,64 +237,56 @@ static void ProcessEvent() {
|
||||
|
||||
if (object && func) {
|
||||
std::string funcName = func->GetName();
|
||||
std::string objectName = object->GetName();
|
||||
|
||||
if (objectName.contains("StartGameMenuWidget")) {
|
||||
if (object->IsA(UStartGameWidget::StaticClass())) {
|
||||
auto* widget = static_cast<UStartGameWidget*>(object);
|
||||
if (widget && widget->Class && widget->IsA(UStartGameWidget::StaticClass()) && funcName == "OnNext" && !inContinue) {
|
||||
if (widget && widget->Class && funcName == "OnNext" && !inContinue) {
|
||||
inContinue = true;
|
||||
if (g_SkipIntro_fix_enabled) widget->Continue();
|
||||
inContinue = false;
|
||||
}
|
||||
}
|
||||
if (funcName == "Construct" || funcName == "Destruct" || funcName.contains("Tick")) {
|
||||
else if (object->IsA(UUserWidget::StaticClass()) && (funcName == "Construct" || funcName == "Destruct" || funcName == "Tick")) {
|
||||
// UI scaling
|
||||
if (objectName.contains("StartGameMenuWidget")) {
|
||||
auto* widget = static_cast<UStartGameWidget*>(object);
|
||||
if (widget && widget->Class && widget->IsA(UStartGameWidget::StaticClass()) && funcName == "OnNext" && !inContinue) {
|
||||
inContinue = true;
|
||||
if (g_SkipIntro_fix_enabled) widget->Continue();
|
||||
inContinue = false;
|
||||
}
|
||||
}
|
||||
else if (objectName.contains("ExtendTutorial_Widget") && object->IsA(UUserWidget::StaticClass())) {
|
||||
if (object->IsA(UCronosExtendedTutorialWidget::StaticClass())) {
|
||||
auto* widget = static_cast<UUserWidget*>(object);
|
||||
if (funcName == "Construct" && widget->WidgetTree && widget->WidgetTree->RootWidget) {
|
||||
g_TutorialWidget = widget->WidgetTree->RootWidget;
|
||||
HUDFixEnabled(g_TutorialWidget, false, 1);
|
||||
HUDFixEnabled(g_TutorialWidget, g_UIOffsets, false, 1);
|
||||
}
|
||||
else if (funcName == "Destruct") g_TutorialWidget = nullptr;
|
||||
}
|
||||
else if (objectName.contains("SettingsWidget") && object->IsA(UUserWidget::StaticClass())) {
|
||||
else if (object->IsA(USettingsWidget::StaticClass())) {
|
||||
auto* settingsWidget = static_cast<USettingsWidget*>(object);
|
||||
if (funcName == "Construct") {
|
||||
if (settingsWidget && settingsWidget->Class && settingsWidget->Main_panel) {
|
||||
g_SettingsWidget = settingsWidget->Main_panel;
|
||||
HUDFixEnabled(g_SettingsWidget, false, 1);
|
||||
HUDFixEnabled(g_SettingsWidget, g_UIOffsets, false, 1);
|
||||
}
|
||||
}
|
||||
else if (funcName == "Destruct") g_SettingsWidget = nullptr;
|
||||
}
|
||||
else if (objectName.contains("WBP_UpgradeMenuWidget_C") && object->IsA(UUserWidget::StaticClass())) {
|
||||
else if (object->IsA(UBTUpgradeMenuWidget::StaticClass())) {
|
||||
auto* widget = static_cast<UUserWidget*>(object);
|
||||
if (funcName == "Construct") {
|
||||
if (widget && widget->WidgetTree && widget->WidgetTree->RootWidget) {
|
||||
g_WorkbenchWidget = widget->WidgetTree->RootWidget;
|
||||
if (g_WorkbenchWidget) HUDFixEnabled(g_WorkbenchWidget, false, 1);
|
||||
if (g_WorkbenchWidget) HUDFixEnabled(g_WorkbenchWidget, g_UIOffsets, false, 1);
|
||||
}
|
||||
}
|
||||
else if (funcName == "Destruct") g_WorkbenchWidget = nullptr;
|
||||
}
|
||||
// HUD scaling
|
||||
else if (objectName.contains("HudWidget") && object->IsA(USHGameplayHudWidget::StaticClass())) {
|
||||
else if (object->IsA(USHGameplayHudWidget::StaticClass())) {
|
||||
USHGameplayHudWidget* HUDWidget = static_cast<USHGameplayHudWidget*>(object);
|
||||
if (!HUDWidget) return;
|
||||
if (funcName == "Construct") {
|
||||
if (HUDWidget && HUDWidget->WidgetTree) {
|
||||
g_HUDWidget = HUDWidget->WidgetTree->RootWidget;
|
||||
if (g_HUDWidget) HUDFixEnabled(g_HUDWidget, false);
|
||||
if (g_HUDWidget) HUDFixEnabled(g_HUDWidget, g_HUDOffsets, false);
|
||||
}
|
||||
}
|
||||
else if (funcName.contains("Tick")) {
|
||||
else if (funcName == "Tick") {
|
||||
for (auto* collectWidget : HUDWidget->CollectItemsWidgets) {
|
||||
if (!collectWidget) continue;
|
||||
// Apply offset to collectible objects
|
||||
@@ -327,11 +325,11 @@ static void FOVFixEnabled() {
|
||||
}
|
||||
|
||||
// HUD fix hook UUserWidget -> AddToViewPort to log and know which HUD widget will be targeted
|
||||
static void HUDFixEnabled(UWidget* widget, bool writeLog, int depth) {
|
||||
static void HUDFixEnabled(UWidget* widget, int offset, bool writeLog, int depth) {
|
||||
if (writeLog) logger->info("HUD fix {}", g_fix_enabled && g_HUD_fix_enabled ? "enabled" : "disabled");
|
||||
if (!widget) return;
|
||||
|
||||
float targetOffset = g_fix_enabled && g_HUD_fix_enabled ? g_HUDOffsets : 0.f;
|
||||
float targetOffset = g_fix_enabled && g_HUD_fix_enabled ? offset : 0.f;
|
||||
if (widget->IsA(UCanvasPanel::StaticClass())) // Apply offsets To CanvasPanel
|
||||
ApplyOffsetsRecursive(widget, targetOffset, targetOffset, depth);
|
||||
else // Apply offsets to OvelaySlot
|
||||
@@ -393,6 +391,16 @@ static void EnableCheats(Cheat cheat) {
|
||||
enemy->CustomTimeDilation = g_TimeDilation_fix_enabled ? g_AITimeDilationValue : 1.f;
|
||||
}
|
||||
}
|
||||
else if (object->IsA(ASHCharacterPlay::StaticClass())) {
|
||||
auto* traveler = static_cast<ASHCharacterPlay*>(object);
|
||||
if (traveler && traveler->Class && traveler->Health) {
|
||||
g_PlayerHealth = traveler->Health->HealthValue;
|
||||
if (g_IgnoreHits_fix_enabled && traveler->bCanBeDamaged)
|
||||
traveler->bCanBeDamaged = false;
|
||||
if (!g_IgnoreHits_fix_enabled && !traveler->bCanBeDamaged)
|
||||
traveler->bCanBeDamaged = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (StealthModeaddress && !StealthHook) { // Hook function UAIPerceptionComponent -> GetPerceivedHostileActors
|
||||
@@ -450,7 +458,6 @@ static void VignettingFixEnabled() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void CameraDistanceFixEnabled() {
|
||||
if (g_fix_enabled && g_cam_distance_fix_enabled && CameraDistanceaddress) {
|
||||
if (!CameraDistanceHook) { // Hook only once
|
||||
|
||||
Reference in New Issue
Block a user