From 844258c8e5da57cd77cbe61f73366514cd9d62a1 Mon Sep 17 00:00:00 2001 From: c6 <31777460+c6-dev@users.noreply.github.com> Date: Thu, 9 May 2024 11:50:59 +0400 Subject: [PATCH] AI combat location changes with fCombatLocationTargetRadiusMaxBase (#45) * AI stuff * credit where it's due * fix hook lol * shouldn't copypaste code at midnight --------- Co-authored-by: carxt --- JG/JohnnyGuitarNVSE.h | 47 +++++++++++++++++++++++++++++++++++++++- nvse/nvse/GameSettings.h | 6 ++--- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/JG/JohnnyGuitarNVSE.h b/JG/JohnnyGuitarNVSE.h index e928cb5..1d2567b 100644 --- a/JG/JohnnyGuitarNVSE.h +++ b/JG/JohnnyGuitarNVSE.h @@ -68,6 +68,36 @@ char g_workingDir[MAX_PATH]; std::unordered_set jg_gameRadioSet; static float g_viewmodel_near = 0.f; + +namespace GMSTJG { + static uintptr_t func_AddGameSetting = 0x040E0B0; + Setting fCombatLocationTargetRadiusMaxBase; + template + class hk_CombatLocationMaxCall { + private: + static inline uintptr_t hookCall = a_addr; + public: + static double __cdecl hk_CLCHook(float m_a1, float m_a2) { + auto res = CdeclCall(hookCall, m_a1, m_a2); + return fmax(res, fCombatLocationTargetRadiusMaxBase.data.f); + } + + hk_CombatLocationMaxCall() { + uintptr_t hk_hookPoint = hookCall; + hookCall = GetRelJumpAddr(hookCall); + WriteRelCall(hk_hookPoint, (uintptr_t)hk_CLCHook); + } + }; + void CombatLocationMaxRadiusBaseInitHook() { //Thanks lStewieAl + hk_CombatLocationMaxCall<0x09A089F>(); + hk_CombatLocationMaxCall<0x09A0A0C>(); + ThisStdCall(func_AddGameSetting, &fCombatLocationTargetRadiusMaxBase, "fCombatLocationTargetRadiusMaxBase", 10.0f); + + } + + +} + template struct JGSetList { bool isWhiteList = false; @@ -1214,6 +1244,7 @@ void HandleFixes() { //CamShakeHook hk_CameraShakeHook::CreateHook(); + } void HandleIniOptions() { @@ -1270,6 +1301,19 @@ void HandleIniOptions() { } } + + + + + + + +void HandleGameSettingsJG(){ + + GMSTJG::CombatLocationMaxRadiusBaseInitHook(); + +} + void HandleFunctionPatches() { // WorldToScreen WriteRelJump(0xC5244A, (UInt32)NiCameraGetAltHook); @@ -1319,13 +1363,14 @@ void HandleFunctionPatches() { hk_BarterHook::CreateHook(); WriteRelCall(0x8752F2, UInt32(SetViewmodelFrustumHook)); + } float timer22 = 30.0; void HandleGameHooks() { HandleFixes(); HandleIniOptions(); HandleFunctionPatches(); - + HandleGameSettingsJG(); // wip shit for void // WriteRelCall(0x97E745, (UInt32)WantsToFleeHook); // WriteRelCall(0x999082, (UInt32)WantsToFleeHook); diff --git a/nvse/nvse/GameSettings.h b/nvse/nvse/GameSettings.h index 1dc7605..fa45acc 100644 --- a/nvse/nvse/GameSettings.h +++ b/nvse/nvse/GameSettings.h @@ -5,10 +5,10 @@ // 0C class Setting { public: - Setting(); - virtual ~Setting(); + Setting() {}; + virtual ~Setting() {}; - virtual void Unk_01(void); + virtual void Unk_01(void) {}; enum EType { kSetting_Bool = 0,