Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI combat location changes with fCombatLocationTargetRadiusMaxBase #45

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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