From fa47713e9a58b9f15a878b7a22656d373c21a9c6 Mon Sep 17 00:00:00 2001 From: carxt Date: Wed, 8 May 2024 01:37:15 +0200 Subject: [PATCH 1/4] AI stuff --- JG/JohnnyGuitarNVSE.h | 48 +++++++++++++++++++++++++++++++++++++++- nvse/nvse/GameSettings.h | 6 ++--- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/JG/JohnnyGuitarNVSE.h b/JG/JohnnyGuitarNVSE.h index e928cb5..546416d 100644 --- a/JG/JohnnyGuitarNVSE.h +++ b/JG/JohnnyGuitarNVSE.h @@ -68,6 +68,37 @@ 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 uintptr_t __cdecl hk_CLCHook(float m1, float m2) { + auto res = CdeclCall(hookCall, m1, m2); + return fmax(res, fCombatLocationTargetRadiusMaxBase.data.f); + } + hk_CombatLocationMaxCall() { + uintptr_t hk_hookPoint = hookCall; + hookCall = *(uintptr_t*)(hk_hookPoint + 1); + SafeWrite32((hk_hookPoint + 1), (uintptr_t)hk_CLCHook); + + } + + }; + void CombatLocationMaxRadiusBaseInitHook() { + hk_CombatLocationMaxCall<0x09A089F>(); + hk_CombatLocationMaxCall<0x09A0A0C>(); + ThisStdCall(func_AddGameSetting, &fCombatLocationTargetRadiusMaxBase, "fCombatLocationTargetRadiusMaxBase", 10.0f); + + } + + +} + template struct JGSetList { bool isWhiteList = false; @@ -1214,6 +1245,7 @@ void HandleFixes() { //CamShakeHook hk_CameraShakeHook::CreateHook(); + } void HandleIniOptions() { @@ -1270,6 +1302,19 @@ void HandleIniOptions() { } } + + + + + + + +void HandleGameSettingsJG(){ + + GMSTJG::CombatLocationMaxRadiusBaseInitHook(); + +} + void HandleFunctionPatches() { // WorldToScreen WriteRelJump(0xC5244A, (UInt32)NiCameraGetAltHook); @@ -1319,13 +1364,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, From f740ad02246c1301b5bc02bb6c079a2c11fcaa96 Mon Sep 17 00:00:00 2001 From: carxt Date: Wed, 8 May 2024 01:38:27 +0200 Subject: [PATCH 2/4] credit where it's due --- JG/JohnnyGuitarNVSE.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JG/JohnnyGuitarNVSE.h b/JG/JohnnyGuitarNVSE.h index 546416d..da00544 100644 --- a/JG/JohnnyGuitarNVSE.h +++ b/JG/JohnnyGuitarNVSE.h @@ -89,7 +89,7 @@ namespace GMSTJG { } }; - void CombatLocationMaxRadiusBaseInitHook() { + void CombatLocationMaxRadiusBaseInitHook() { //Thanks lStewieAl hk_CombatLocationMaxCall<0x09A089F>(); hk_CombatLocationMaxCall<0x09A0A0C>(); ThisStdCall(func_AddGameSetting, &fCombatLocationTargetRadiusMaxBase, "fCombatLocationTargetRadiusMaxBase", 10.0f); From b7d85c79da5e8451d8a6574e6cc5d890e7e45a41 Mon Sep 17 00:00:00 2001 From: carxt Date: Wed, 8 May 2024 01:39:05 +0200 Subject: [PATCH 3/4] fix hook lol --- JG/JohnnyGuitarNVSE.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JG/JohnnyGuitarNVSE.h b/JG/JohnnyGuitarNVSE.h index da00544..50fe665 100644 --- a/JG/JohnnyGuitarNVSE.h +++ b/JG/JohnnyGuitarNVSE.h @@ -77,7 +77,7 @@ namespace GMSTJG { private: static inline uintptr_t hookCall = a_addr; public: - static uintptr_t __cdecl hk_CLCHook(float m1, float m2) { + static float __cdecl hk_CLCHook(float m1, float m2) { auto res = CdeclCall(hookCall, m1, m2); return fmax(res, fCombatLocationTargetRadiusMaxBase.data.f); } From 25d5b43987e7a9d818f5c54e3c9d905d70277d2c Mon Sep 17 00:00:00 2001 From: carxt Date: Wed, 8 May 2024 02:08:51 +0200 Subject: [PATCH 4/4] shouldn't copypaste code at midnight --- JG/JohnnyGuitarNVSE.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/JG/JohnnyGuitarNVSE.h b/JG/JohnnyGuitarNVSE.h index 50fe665..1d2567b 100644 --- a/JG/JohnnyGuitarNVSE.h +++ b/JG/JohnnyGuitarNVSE.h @@ -77,17 +77,16 @@ namespace GMSTJG { private: static inline uintptr_t hookCall = a_addr; public: - static float __cdecl hk_CLCHook(float m1, float m2) { - auto res = CdeclCall(hookCall, m1, m2); + 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 = *(uintptr_t*)(hk_hookPoint + 1); - SafeWrite32((hk_hookPoint + 1), (uintptr_t)hk_CLCHook); - + hookCall = GetRelJumpAddr(hookCall); + WriteRelCall(hk_hookPoint, (uintptr_t)hk_CLCHook); } - }; void CombatLocationMaxRadiusBaseInitHook() { //Thanks lStewieAl hk_CombatLocationMaxCall<0x09A089F>();