Skip to content

Commit

Permalink
AI combat location changes with fCombatLocationTargetRadiusMaxBase (#45)
Browse files Browse the repository at this point in the history
* AI stuff

* credit where it's due

* fix hook lol

* shouldn't copypaste code at midnight

---------

Co-authored-by: carxt <[email protected]>
  • Loading branch information
c6-dev and carxt authored May 9, 2024
1 parent e3c9f44 commit 844258c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
47 changes: 46 additions & 1 deletion JG/JohnnyGuitarNVSE.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,36 @@ char g_workingDir[MAX_PATH];
std::unordered_set<DWORD> jg_gameRadioSet;
static float g_viewmodel_near = 0.f;


namespace GMSTJG {
static uintptr_t func_AddGameSetting = 0x040E0B0;
Setting fCombatLocationTargetRadiusMaxBase;
template <uintptr_t a_addr>
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<double>(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<void>(func_AddGameSetting, &fCombatLocationTargetRadiusMaxBase, "fCombatLocationTargetRadiusMaxBase", 10.0f);

}


}

template <class T>
struct JGSetList {
bool isWhiteList = false;
Expand Down Expand Up @@ -1214,6 +1244,7 @@ void HandleFixes() {
//CamShakeHook
hk_CameraShakeHook::CreateHook();


}

void HandleIniOptions() {
Expand Down Expand Up @@ -1270,6 +1301,19 @@ void HandleIniOptions() {
}
}








void HandleGameSettingsJG(){

GMSTJG::CombatLocationMaxRadiusBaseInitHook();

}

void HandleFunctionPatches() {
// WorldToScreen
WriteRelJump(0xC5244A, (UInt32)NiCameraGetAltHook);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions nvse/nvse/GameSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 844258c

Please sign in to comment.