From d298ad0c226eb859eff03cc15e5d9aa9933a6c9f Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:12:15 +0200 Subject: [PATCH] Client: initial rebuild of the curve look function This function didn't decompile properly, so a bunch of manual assembly work had to be used to reconstruct the truncated bits. The code does work correct for the most part. The call to the subroutine 'sub_1405AD760' has been commented as the parameter appears incorrect; passes in the address of a bool but indexes 4 bytes outside the size of a bool. Most likely incorrect decompile/disasm. Currently being investigated. --- src/common/global.cpp | 8 + src/common/global.h | 4 + src/core/init.cpp | 4 + src/game/CMakeLists.txt | 1 + src/game/client/c_basecombatcharacter.h | 3 +- src/game/client/c_player.cpp | 314 ++++++++++++++++++++++++ src/game/client/c_player.h | 94 ++++++- src/game/client/gamepad.h | 48 ++++ src/game/client/input.h | 7 +- src/game/client/r1/c_weapon_x.h | 3 + 10 files changed, 481 insertions(+), 5 deletions(-) create mode 100644 src/game/client/c_player.cpp diff --git a/src/common/global.cpp b/src/common/global.cpp index 0323a17d..b374ca9c 100644 --- a/src/common/global.cpp +++ b/src/common/global.cpp @@ -116,6 +116,10 @@ ConVar* cl_threaded_bone_setup = nullptr; ConVar* origin_disconnectWhenOffline = nullptr; ConVar* discord_updatePresence = nullptr; + +ConVar* gamepad_custom_enabled = nullptr; +ConVar* gamepad_custom_assist_on = nullptr; +ConVar* gamepad_look_curve = nullptr; #endif // !DEDICATED //----------------------------------------------------------------------------- // FILESYSTEM | @@ -191,6 +195,10 @@ void ConVar_InitShipped(void) #ifndef DEDICATED origin_disconnectWhenOffline = g_pCVar->FindVar("origin_disconnectWhenOffline"); discord_updatePresence = g_pCVar->FindVar("discord_updatePresence"); + + gamepad_custom_enabled = g_pCVar->FindVar("gamepad_custom_enabled"); + gamepad_custom_assist_on = g_pCVar->FindVar("gamepad_custom_assist_on"); + gamepad_look_curve = g_pCVar->FindVar("gamepad_look_curve"); #endif // !DEDICATED mp_gamemode = g_pCVar->FindVar("mp_gamemode"); ip_cvar = g_pCVar->FindVar("ip"); diff --git a/src/common/global.h b/src/common/global.h index 5df2c062..84c4f663 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -101,6 +101,10 @@ extern ConVar* cl_threaded_bone_setup; extern ConVar* origin_disconnectWhenOffline; extern ConVar* discord_updatePresence; + +extern ConVar* gamepad_custom_enabled; +extern ConVar* gamepad_custom_assist_on; +extern ConVar* gamepad_look_curve; #endif // !DEDICATED //------------------------------------------------------------------------- // FILESYSTEM | diff --git a/src/core/init.cpp b/src/core/init.cpp index bff65e82..11138c1a 100644 --- a/src/core/init.cpp +++ b/src/core/init.cpp @@ -146,9 +146,11 @@ #ifndef DEDICATED #include "game/client/viewrender.h" #include "game/client/input.h" +#include "game/client/gamepad.h" #include "game/client/movehelper_client.h" #include "game/client/vscript_client.h" #include "game/client/cliententitylist.h" +#include "game/client/c_player.h" #endif // !DEDICATED #include "public/edict.h" #ifndef DEDICATED @@ -679,8 +681,10 @@ void DetourRegister() // Register detour classes to be searched and hooked. #ifndef DEDICATED REGISTER(V_ViewRender); REGISTER(VInput); + REGISTER(V_GamePad); REGISTER(VMoveHelperClient); REGISTER(VClientEntityList); + REGISTER(V_Player); #endif // !DEDICATED // Public diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index 372176f1..86b069b3 100644 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -213,6 +213,7 @@ add_sources( SOURCE_GROUP "Entity" ) add_sources( SOURCE_GROUP "Player" + "client/c_player.cpp" "client/c_player.h" "client/c_playerlocaldata.h" ) diff --git a/src/game/client/c_basecombatcharacter.h b/src/game/client/c_basecombatcharacter.h index 65703a7a..a9fb0756 100644 --- a/src/game/client/c_basecombatcharacter.h +++ b/src/game/client/c_basecombatcharacter.h @@ -19,6 +19,7 @@ struct WeaponInventory_Client class C_BaseCombatCharacter : public C_BaseAnimatingOverlay { +protected: float m_flNextAttack; float m_lastFiredTime; int m_lastFiredWeapon; @@ -41,7 +42,7 @@ class C_BaseCombatCharacter : public C_BaseAnimatingOverlay char m_selectedOffhandsPendingHybridAction[3]; char m_lastCycleSlot; char gap_171d[3]; - int m_latestMeleeWeapon; + EHANDLE m_latestMeleeWeapon; int m_weaponPermission; float m_weaponDelayEnableTime; bool m_weaponDisabledInScript; diff --git a/src/game/client/c_player.cpp b/src/game/client/c_player.cpp new file mode 100644 index 00000000..3de8e6ec --- /dev/null +++ b/src/game/client/c_player.cpp @@ -0,0 +1,314 @@ +#include "input.h" +#include "r1/c_weapon_x.h" +#include "c_player.h" +#include "cliententitylist.h" + +bool C_Player::CheckMeleeWeapon() +{ + const C_EntInfo* pInfo = g_clientEntityList->GetEntInfoPtr(m_latestMeleeWeapon); + const C_WeaponX* pWeapon = (C_WeaponX*)pInfo->m_pEntity; + + return (pInfo->m_SerialNumber == m_latestMeleeWeapon.GetSerialNumber()) + && (pWeapon != NULL) + && *(float*)&pWeapon->m_modVars[600] > (float)(m_currentFramePlayer__timeBase - m_melee.attackLastHitNonWorldEntity); +} + +void C_Player::CurveLook(C_Player* player, CInput::UserInput_t* input, float a3, float a4, float a5, int a6, float inputSampleFrametime, bool runAimAssist, JoyAngle_t* a9) +{ + float v11; // xmm7_4 + float v12; // xmm11_4 + float v13; // xmm14_4 + float v14; // xmm15_4 + bool useActiveWeapon; // si + C_WeaponX* activeWeapon; // rax + float v17; // xmm0_4 + float v18; // xmm0_4 + __int64 v19; // xmm1_8 + bool m_bAutoAim_UnknownBool1AC; // r13 + bool m_bAutoAim_UnknownBool1AD; // r15 + bool m_bAutoAim_UnknownBool1B1; // r14 + vec_t z; // eax + QAngle* v24; // rax + bool v25; // zf + QAngle v26; // xmm0_12 + QAngle* p_m_angUnknown1C8; // rax + __int64 v28; // xmm0_8 + vec_t v29; // eax + float inputSampleFrametime_c; // xmm13_4 + float v31; // xmm8_4 + int selectedGamePadLookCurve; // r12d + float v33; // xmm7_4 + int customAimSpeed; // eax + char v36; // r10 + int v37; // edx + float* v38; // rsi + char* v39; // rsi + float v40; // xmm6_4 + float m_flUnknownFloat1B4; // xmm6_4 + float v42; // xmm0_4 + float v43; // xmm0_4 + float v44; // xmm10_4 + float v45; // xmm2_4 + float v46; // xmm6_4 + float v47; // xmm0_4 + float v48; // xmm7_4 + float v49; // xmm9_4 + float v50; // xmm6_4 + bool bZooming; // al + bool v55; // cl + float v56; // xmm1_4 + float v57; // xmm2_4 + float v58; // xmm0_4 + float v59; // xmm8_4 + float v60; // xmm9_4 + C_WeaponX* v61; // r14 + float v62; // xmm10_4 + float v63; // xmm0_4 + float v64; // xmm6_4 + JoyAngle_t* v65; // rsi + float v66; // xmm7_4 + QAngle v68; // [rsp+68h] [rbp-A0h] BYREF + QAngle v69; // [rsp+78h] [rbp-90h] BYREF + Vector3D v70; // [rsp+88h] [rbp-80h] BYREF + QAngle v71; // [rsp+178h] [rbp+70h] BYREF + float m_flUnknownFloat1B8; // [rsp+188h] [rbp+80h] + float v73; // [rsp+190h] [rbp+88h] + + v73 = a4; + v11 = sub_1408A0600(player); + v12 = 1.0f - v11; + v13 = (float)(1.0f - v11) * a3; + v14 = (float)(1.0f - v11) * a4; + + if (player->m_bZooming) + { + activeWeapon = C_BaseCombatCharacter__GetActiveWeapon(player); + useActiveWeapon = !activeWeapon || activeWeapon->m_modVars[3100]; + } + else + { + useActiveWeapon = 0; + } + + v17 = fabs(v13); + if (v17 > 0.050000001 || (v18 = fabs(v14), v18 > 0.050000001)) + (*double_14D413928) = Plat_FloatTime(); + + if (!runAimAssist) + sub_1405B0E00(player, input); + + //TODO: + //sub_1405AD760(player, &runAimAssist); + + const bool gamePadCustomEnabled = gamepad_custom_enabled->GetBool(); + + if (gamePadCustomEnabled && !gamepad_custom_assist_on->GetBool() + || Plat_FloatTime() - (*double_14D4151B8) < 2.0 + || (*double_14D4151B8) > (*double_14D413928) + || runAimAssist + || (unsigned int)sub_14066D190(player) + || C_Player__IsInTimeShift(player) + || v11 > 0.050000001 + || !gamePadCustomEnabled && (unsigned int)C_Player__GetAimSpeed(player, useActiveWeapon) == 7 + || (v19 = *(_QWORD*)&player->pl.lastPlayerView_angle.x, v70.z = player->pl.lastPlayerView_angle.z, *(_QWORD*)&v70.x = v19, *(float*)&v19 < -50.0) + || sub_1405AD4E0(player) < 0.00000011920929) // FLT_EPSILON + { + m_bAutoAim_UnknownBool1AC = 0; + m_bAutoAim_UnknownBool1AD = 0; + runAimAssist = 0; + m_bAutoAim_UnknownBool1B1 = 0; + } + else + { + m_bAutoAim_UnknownBool1AC = input->m_bAutoAim_UnknownBool1AC; + m_bAutoAim_UnknownBool1AD = input->m_bAutoAim_UnknownBool1AD; + m_bAutoAim_UnknownBool1B1 = input->m_bAutoAim_UnknownBool1B1; + runAimAssist = input->m_bAutoAim_UnknownBool1B0; + } + + z = input->m_vecUnknown1BC.z; + m_flUnknownFloat1B8 = input->m_flUnknownFloat1B8; + *(_QWORD*)&v70.x = *(_QWORD*)&input->m_vecUnknown1BC.x; + v70.z = z; + v24 = sub_1406257E0(&v69, player); + v25 = !input->m_bUnknown1D4; + *(_QWORD*)&v26.x = *(_QWORD*)&v24->x; + v68.z = v24->z; + p_m_angUnknown1C8 = &input->m_angUnknown1C8; + *(_QWORD*)&v68.x = *(_QWORD*)&v26.x; + if (v25) + p_m_angUnknown1C8 = &v68; + + v28 = *(_QWORD*)&p_m_angUnknown1C8->x; + v29 = p_m_angUnknown1C8->z; + inputSampleFrametime_c = inputSampleFrametime; + *(_QWORD*)&v69.x = v28; + v69.z = v29; + if (m_bAutoAim_UnknownBool1AD && m_bAutoAim_UnknownBool1B1) + input->m_flUnknownFloat1B4 = 0.0; + else + input->m_flUnknownFloat1B4 = inputSampleFrametime + input->m_flUnknownFloat1B4; + + v71.Init(); + v31 = 0.0f; + sub_1405B03A0(input, player, &v71); + selectedGamePadLookCurve = 1; + v33 = sub_1405B0BC0(player, input, 0); + a5 = sub_1405B0BC0(player, input, 1); + customAimSpeed = C_Player__GetAimSpeed(player, useActiveWeapon); + v37 = *(_DWORD*)((unsigned int)(*dword_1423880E0) + *(_QWORD*)&player->gap_21a0[16]); + + bool v35 = m_bAutoAim_UnknownBool1B1; // r9 + + if (m_bAutoAim_UnknownBool1AC && m_bAutoAim_UnknownBool1AD) + { + v36 = true; + } + else + { + v36 = false; + + if (!m_bAutoAim_UnknownBool1AC) + { + v35 = false; + } + } + + if (gamePadCustomEnabled) + { + sub_1405AEA10(nullptr, useActiveWeapon, v37 == 1); + v38 = dword_16A2A1640; + } + else + { + if (v37 == 1) + { + if (useActiveWeapon) + v39 = (char*)g_lookSensitivity_TitanZoomed; + else + v39 = (char*)g_lookSensitivity_Titan; + } + else + { + v25 = !useActiveWeapon; + v39 = (char*)g_lookSensitivity_Zoomed; + if (v25) + v39 = (char*)g_lookSensitivity; + } + + v38 = (float*)&v39[276 * customAimSpeed]; + } + + if (v35) + { + v40 = 0.64999998f; + } + else + { + m_flUnknownFloat1B4 = input->m_flUnknownFloat1B4; + if (m_flUnknownFloat1B4 <= 0.2) + { + if (m_flUnknownFloat1B4 > 0.1) + v40 = (float)((float)((float)(m_flUnknownFloat1B4 - 0.1f) / 0.1f) * 0.35000002f) + 0.64999998f; + else + v40 = 0.64999998f; + } + else + { + v40 = 1.0f; + } + } + + v42 = m_flUnknownFloat1B8; + sub_1405AF810(player, input, (__int64)v38, m_bAutoAim_UnknownBool1AC, v36, &v70, &v69, &v68, m_flUnknownFloat1B8); + inputSampleFrametime = (float)((float)(v42 * (float)(1.0 - v40)) + v40) * (float)(1.0 - (float)(v33 * 0.94999999f)); + v43 = sqrtf((float)(a3 * a3) + (float)(v73 * v73)); + v44 = v43; + + const int gamePadLookCurve = gamepad_look_curve->GetInt(); + + if (gamePadLookCurve <= 4u) + selectedGamePadLookCurve = gamePadLookCurve; + + v45 = fabs((float)(v43 - 0.0f)); + if (v45 > 0.001f) + { + if (gamePadCustomEnabled) + v47 = GamePad_CalcOuterDeadzoneCustom(v43); + else + v47 = GamePad_CalcOuterDeadzone(g_aimCurveConfig[selectedGamePadLookCurve], v43); + + v46 = v47 / v44; + } + else + { + v46 = 0.0; + } + + v48 = v46 * v13; + v49 = 0.0f; + v50 = v46 * v14; + + if (v38[67] <= 0.0f + || v38[65] == 0.0f && v38[64] == 0.0 + || m_bAutoAim_UnknownBool1AC + || v44 < 0.99000001f + || (unsigned int)(player->m_contextAction - 2) <= 1 + || ((player->m_melee.scriptedState - 3) & 0xFFFFFFFA) == 0 + || sub_1409DC4E0(player) + || (player->m_latestMeleeWeapon.IsValid()) + && (player->CheckMeleeWeapon()) // TODO: verify assembly + //&& (v52 = (unsigned __int16)m_latestMeleeWeapon, cl_entitylist.m_EntPtrArray[v52].m_SerialNumber == player->m_latestMeleeWeapon.GetSerialNumber()) + //&& (pWeapon = (C_WeaponX*)cl_entitylist.m_EntPtrArray[v52].m_pEntity) != 0i64 + //&& *(float*)&pWeapon->m_modVars[600] >(float)(player->m_currentFramePlayer__timeBase - player->m_melee.attackLastHitNonWorldEntity) + || player->m_MoveType == MOVETYPE_TRAVERSE && !player->m_traversalType + || (bZooming = input->m_bZooming, v55 = player->m_bZooming, input->m_bZooming = v55, bZooming) && !v55) + { + input->m_flSomeInputSampleFrameTime = 0.0f; + } + else + { + v56 = inputSampleFrametime_c + input->m_flSomeInputSampleFrameTime; + input->m_flSomeInputSampleFrameTime = v56; + v57 = v38[66]; + if (v57 <= v56) + { + v58 = GamePad_CalcOuterDeadzone((AimCurveConfig_s*)(v38 + 2), fminf(v56 - v57, v38[67]) / v38[67]); + v31 = (float)(v58 * v48) * v38[65]; + v49 = (float)(v58 * v50) * v38[64]; + } + } + + v59 = v31 * v12; + v60 = v49 * v12; + v61 = C_BaseCombatCharacter__GetActiveWeapon(player); + if (v61 && C_Player__GetZoomFrac(player) >= 0.99000001 && v61->m_modVars[412]) + v62 = *v38; + else + v62 = v38[1]; + + v63 = sub_1405D4300(player); + v64 = (float)(v50 * inputSampleFrametime) * *v38; + v65 = a9; + v66 = (float)(v48 * inputSampleFrametime) * v62; + a9->unk1 = v71.y; + v65->unk2 = 0i64; + v65->pitch.z = v71.x; + v65->pitch.x = (float)((float)(v66 + v59) * v63) * inputSampleFrametime_c; + v65->pitch.y = (float)((float)((float)(v64 + v60) * v63) * inputSampleFrametime_c) * -1.0f; + if (m_bAutoAim_UnknownBool1AD && runAimAssist) + { + sub_1405AF1F0(input, player, (QAngle*)&v70, &v69, v14, v13, inputSampleFrametime_c, a5, (QAngle*)&a9); + + v65->unk2 = a9; + + //v67 = HIDWORD(a9); + //LODWORD(v65->unk2) = (_DWORD)a9; + //HIDWORD(v65->unk2) = v67; + } +} + +void V_Player::Detour(const bool bAttach) const +{ + //DetourSetup(&C_Player__CurveLook, C_Player::CurveLook, bAttach); +} diff --git a/src/game/client/c_player.h b/src/game/client/c_player.h index 6cd46206..f9f74619 100644 --- a/src/game/client/c_player.h +++ b/src/game/client/c_player.h @@ -1,5 +1,5 @@ -#ifndef C_BASEPLAYER_H -#define C_BASEPLAYER_H +#ifndef C_PLAYER_H +#define C_PLAYER_H #include "icliententity.h" #include "icliententitylist.h" @@ -11,17 +11,24 @@ #include "playerstate.h" #include "vscript/ivscript.h" +#include "input.h" +#include "gamepad.h" + #include "c_baseentity.h" #include "c_baseanimating.h" #include "c_baseanimatingoverlay.h" #include "c_basecombatcharacter.h" #include "c_playerlocaldata.h" +#include "r1/c_weapon_x.h" #include "game/shared/r1/grapple.h" #include "game/shared/status_effect.h" #include "game/shared/player_viewoffset.h" #include "game/shared/player_melee.h" +class CInput; +struct CInput::UserInput_t; + struct PlayerZiplineData_Client { @@ -50,8 +57,19 @@ class C_KnockBack float endTime; }; +struct JoyAngle_t +{ + QAngle pitch; + float unk1; + void* unk2; +}; + class C_Player : public C_BaseCombatCharacter { +public: + static void CurveLook(C_Player* player, CInput::UserInput_t* input, float a3, float a4, float a5, int a6, float inputSampleFrametime, bool runAimAssist, JoyAngle_t* a9); + bool CheckMeleeWeapon(); +private: bool unk; bool m_bZooming; char gap_1882[2]; @@ -327,4 +345,74 @@ class C_Player : public C_BaseCombatCharacter static_assert(sizeof(C_Player) == 0x41C0); -#endif // C_BASEPLAYER_H +// move to combatcharacter! +inline C_WeaponX* (*C_BaseCombatCharacter__GetActiveWeapon)(C_BaseCombatCharacter* thisptr); + +inline float (*sub_1408A0600)(C_Player* player); +inline void (*sub_1405B0E00)(C_Player* player, CInput::UserInput_t* input); +inline void (*sub_1405AD760)(C_Player* player, unsigned char* unknown); +inline int (*sub_14066D190)(C_Player* player); +inline float (*sub_1405AD4E0)(C_Player* player); +inline QAngle* (*sub_1406257E0)(QAngle* angle, C_Player* player); +inline void (*sub_1405B03A0)(CInput::UserInput_t* input, C_Player* player, QAngle* angle); +inline float (*sub_1405B0BC0)(C_Player* player, CInput::UserInput_t* input, int a3); +inline void (*sub_1405AEA10)(void* a1, char a2, char a3); +inline void (*sub_1405AF810)(C_Player* player, CInput::UserInput_t* input, __int64 a3, char a4, char a5, Vector3D* a6, QAngle* a7, QAngle* a8, float a9); +inline C_BaseEntity* (*sub_1409DC4E0)(C_Player* player); +inline float (*sub_1405D4300)(C_Player* player); +inline QAngle* (*sub_1405AF1F0)(CInput::UserInput_t* a1, C_Player* a2, QAngle* a3, QAngle* a4, float a5, float a6, float a7, float a8, QAngle* a9); + +inline float (*C_Player__GetZoomFrac)(C_Player* thisptr); +inline int (*C_Player__GetAimSpeed)(C_Player* thisptr, bool useActiveWeapon); +inline bool (*C_Player__IsInTimeShift)(C_Player* thisptr); + +inline void (*C_Player__CurveLook)(C_Player* player, CInput::UserInput_t* input, float a3, float a4, float a5, int a6, float inputSampleFrametime, bool runAimAssist, JoyAngle_t* outAngles); + + +inline double* double_14D413928; +inline double* double_14D4151B8; + +inline int* dword_1423880E0; +inline float* dword_16A2A1640; + +/////////////////////////////////////////////////////////////////////////////// +class V_Player : public IDetour +{ + virtual void GetAdr(void) const + { + } + virtual void GetFun(void) const + { + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 0F 2F 05 ?? ?? ?? ?? 76 ?? 0F 28 CF").FollowNearCallSelf().GetPtr(sub_1408A0600); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8D 95 ?? ?? ?? ?? 48 8B CB E8 ?? ?? ?? ?? 48 8B 05").FollowNearCallSelf().GetPtr(sub_1405B0E00); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 83 78 ?? ?? 74 ?? 48 8B 05").FollowNearCallSelf().GetPtr(sub_1405AD760); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? FF C8 83 F8").FollowNearCallSelf().GetPtr(sub_14066D190); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? F3 0F 10 35 ?? ?? ?? ?? 0F 28 E7").FollowNearCallSelf().GetPtr(sub_1405AD4E0); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? F3 44 0F 10 26").FollowNearCallSelf().GetPtr(sub_1406257E0); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 45 33 C0 48 8B D7 48 8B CB").FollowNearCallSelf().GetPtr(sub_1405B03A0); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? F3 0F 11 85").FollowNearCallSelf().GetPtr(sub_1405B0BC0); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8D 35 ?? ?? ?? ?? EB").FollowNearCallSelf().GetPtr(sub_1405AEA10); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? F3 0F 59 3D ?? ?? ?? ?? 41 0F 28 CA").FollowNearCallSelf().GetPtr(sub_1405AF810); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 85 C0 0F 85 ?? ?? ?? ?? 8B 8B").FollowNearCallSelf().GetPtr(sub_1409DC4E0); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? F3 0F 59 B5").FollowNearCallSelf().GetPtr(sub_1405D4300); + + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 0F 2F 87").FollowNearCallSelf().GetPtr(C_Player__GetZoomFrac); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 83 F8 ?? 74 ?? F2 0F 10 8B").FollowNearCallSelf().GetPtr(C_Player__GetAimSpeed); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 3A D8 75").FollowNearCallSelf().GetPtr(C_Player__IsInTimeShift); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? F3 0F 10 15 ?? ?? ?? ?? 48 8D 45").FollowNearCallSelf().GetPtr(C_Player__CurveLook); + + g_GameDll.FindPatternSIMD("48 83 EC ?? 48 8B 01 FF 90 ?? ?? ?? ?? 48 83 C0 ?? 4C 8D 40").GetPtr(C_BaseCombatCharacter__GetActiveWeapon); + } + virtual void GetVar(void) const + { + CMemory(C_Player__CurveLook).OffsetSelf(0xFC).FindPatternSelf("F2 0F").ResolveRelativeAddressSelf(4, 8).GetPtr(double_14D413928); + CMemory(C_Player__CurveLook).OffsetSelf(0x140).FindPatternSelf("F2 0F").ResolveRelativeAddressSelf(4, 8).GetPtr(double_14D4151B8); + CMemory(C_Player__CurveLook).OffsetSelf(0x350).FindPatternSelf("44 8B").ResolveRelativeAddressSelf(3, 7).GetPtr(dword_1423880E0); + CMemory(C_Player__CurveLook).OffsetSelf(0x380).FindPatternSelf("48 8D").ResolveRelativeAddressSelf(3, 7).GetPtr(dword_16A2A1640); + } + virtual void GetCon(void) const { } + virtual void Detour(const bool bAttach) const; +}; +/////////////////////////////////////////////////////////////////////////////// + +#endif // C_PLAYER_H diff --git a/src/game/client/gamepad.h b/src/game/client/gamepad.h index 2d57028a..f989042e 100644 --- a/src/game/client/gamepad.h +++ b/src/game/client/gamepad.h @@ -18,5 +18,53 @@ enum WeaponScopeZoomLevel_e // TODO: move to shared game scripts! extern bool GamePad_UseAdvancedAdsScalarsPerScope(); extern float GamePad_GetAdvancedAdsScalarForOptic(const WeaponScopeZoomLevel_e opticType); +inline void (*GamePad_LoadAimAssistScripts)(); + +struct AimCurveConfig_s // Move to gamepad! +{ + int field_0; + int field_4; + int field_8; + int field_C; + int field_10; + int field_14; + char unknown[224]; +}; + +inline float (*GamePad_CalcOuterDeadzoneCustom)(float a1); +inline float (*GamePad_CalcOuterDeadzone)(AimCurveConfig_s* curve, float a2); + +inline char* g_lookSensitivity_TitanZoomed; +inline char* g_lookSensitivity_Titan; +inline char* g_lookSensitivity_Zoomed; +inline char* g_lookSensitivity; + +inline AimCurveConfig_s** g_aimCurveConfig; + +/////////////////////////////////////////////////////////////////////////////// +class V_GamePad : public IDetour +{ + virtual void GetAdr(void) const + { + } + virtual void GetFun(void) const + { + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 8B 5C 24 ?? 48 83 C4 ?? 5E").FollowNearCallSelf().GetPtr(GamePad_LoadAimAssistScripts); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? EB ?? 49 63 C4").FollowNearCallSelf().GetPtr(GamePad_CalcOuterDeadzoneCustom); + g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 0F 28 F0 F3 41 0F 5E F2").FollowNearCallSelf().GetPtr(GamePad_CalcOuterDeadzone); + } + virtual void GetVar(void) const + { + CMemory(GamePad_LoadAimAssistScripts).FindPatternSelf("48 8D").ResolveRelativeAddressSelf(3, 7).GetPtr(g_aimCurveConfig); + + CMemory(GamePad_LoadAimAssistScripts).OffsetSelf(0x60).FindPatternSelf("48 8D").ResolveRelativeAddressSelf(3, 7).GetPtr(g_lookSensitivity); + CMemory(GamePad_LoadAimAssistScripts).OffsetSelf(0x77).FindPatternSelf("48 8D").ResolveRelativeAddressSelf(3, 7).GetPtr(g_lookSensitivity_Zoomed); + CMemory(GamePad_LoadAimAssistScripts).OffsetSelf(0x8A).FindPatternSelf("48 8D").ResolveRelativeAddressSelf(3, 7).GetPtr(g_lookSensitivity_Titan); + CMemory(GamePad_LoadAimAssistScripts).OffsetSelf(0x9D).FindPatternSelf("48 8D").ResolveRelativeAddressSelf(3, 7).GetPtr(g_lookSensitivity_TitanZoomed); + } + virtual void GetCon(void) const { } + virtual void Detour(const bool bAttach) const { }; +}; +/////////////////////////////////////////////////////////////////////////////// #endif // CLIENT_GAMEPAD_H diff --git a/src/game/client/input.h b/src/game/client/input.h index 6bb0d281..194ead12 100644 --- a/src/game/client/input.h +++ b/src/game/client/input.h @@ -29,6 +29,7 @@ public: class CInput : public IInput { + friend class C_Player; public: virtual void sub_140701C40() = 0; virtual void sub_140701D60() = 0; @@ -76,7 +77,10 @@ protected: unsigned int ControlMap; } joy_axis_t; -private: + // NOTE: this has to be public because we otherwise couldn't properly set + // the prototypes for functions we obtain from the engine through our sig + // scanner. +public: struct UserInput_t { float m_flAccumulatedMouseXMovement; @@ -166,6 +170,7 @@ private: _BYTE gap200_endsAt_E30[3120]; }; +private: // Has the mouse been initialized? bool m_fMouseInitialized; // Is the mosue active? diff --git a/src/game/client/r1/c_weapon_x.h b/src/game/client/r1/c_weapon_x.h index 57a57848..042510d7 100644 --- a/src/game/client/r1/c_weapon_x.h +++ b/src/game/client/r1/c_weapon_x.h @@ -44,6 +44,9 @@ class C_WeaponX : C_BaseAnimating char gap_1339[7]; SmartAmmo_WeaponData_Client m_smartAmmo; char unk_pad[560]; + + // TODO: reverse this properly and make this private !!! +public: char m_modVars[4432]; };