From ecef52d1ac6b60a4171c72cf5043de16a100e97b Mon Sep 17 00:00:00 2001 From: techhex Date: Sun, 7 Jan 2024 11:58:12 -0400 Subject: [PATCH 1/3] API: PlayerDeathThink and Observer_Think --- reapi/include/cssdk/dlls/regamedll_api.h | 6 ++++++ reapi/src/hook_callback.cpp | 19 +++++++++++++++++++ reapi/src/hook_callback.h | 2 ++ reapi/src/hook_list.cpp | 3 +++ reapi/src/hook_list.h | 3 +++ 5 files changed, 33 insertions(+) diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index 762d06d6..dbf50875 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -622,6 +622,10 @@ typedef IHookChainRegistry IReGameHook_CBasePlayer_PlayerDeathThink; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_PlayerDeathThink; +// CBasePlayer::Observer_Think hook +typedef IHookChainClass IReGameHook_CBasePlayer_Observer_Think; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_Think; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -782,6 +786,8 @@ class IReGameHookchains { virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage() = 0; virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0; + virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0; + }; struct ReGameFuncs_t { diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 518a74e0..58c7bb72 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -1710,6 +1710,25 @@ void CBasePlayerWeapon_SendWeaponAnim(IReGameHook_CBasePlayerWeapon_SendWeaponAn callVoidForward(RG_CBasePlayerWeapon_SendWeaponAnim, original, indexOfEdict(pthis->pev), iAnim, skiplocal); } +void CBasePlayer_PlayerDeathThink(IReGameHook_CBasePlayer_PlayerDeathThink *chain, CBasePlayer *pthis) +{ + auto original = [chain](int _pthis) + { + chain->callNext(getPrivate(_pthis)); + }; + + callVoidForward(RG_CBasePlayer_PlayerDeathThink, original, indexOfEdict(pthis->pev)); +} + +void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_PlayerDeathThink *chain, CBasePlayer *pthis) +{ + auto original = [chain](int _pthis) + { + chain->callNext(getPrivate(_pthis)); + }; + + callVoidForward(RG_CBasePlayer_Observer_Think, original, indexOfEdict(pthis->pev)); +} /* * VTC functions diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index af39e6ad..ede4ad76 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -558,6 +558,8 @@ edict_t *CBasePlayer_EntSelectSpawnPoint(IReGameHook_CBasePlayer_EntSelectSpawnP void CBasePlayerWeapon_ItemPostFrame(IReGameHook_CBasePlayerWeapon_ItemPostFrame *chain, CBasePlayerWeapon *pthis); void CBasePlayerWeapon_KickBack(IReGameHook_CBasePlayerWeapon_KickBack *chain, CBasePlayerWeapon *pthis, float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change); void CBasePlayerWeapon_SendWeaponAnim(IReGameHook_CBasePlayerWeapon_SendWeaponAnim *chain, CBasePlayerWeapon *pthis, int iAnim, int skiplocal); +void CBasePlayer_PlayerDeathThink(IReGameHook_CBasePlayer_PlayerDeathThink *chain, CBasePlayer *pthis); +void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, CBasePlayer *pthis); /* * VTC functions diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index 870c95c1..8f5bf54a 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -212,6 +212,9 @@ hook_t hooklist_player[] = { DLL(CBasePlayer_CheckTimeBasedDamage), DLL(CBasePlayer_EntSelectSpawnPoint), + + DLL(CBasePlayer_PlayerDeathThink), + DLL(CBasePlayer_Observer_Think), }; hook_t hooklist_gamerules[] = { diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index 18483eb2..6e6d9da7 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -236,6 +236,9 @@ enum GamedllFunc_CBasePlayer RG_CBasePlayer_CheckTimeBasedDamage, RG_CBasePlayer_EntSelectSpawnPoint, + RG_CBasePlayer_PlayerDeathThink, + RG_CBasePlayer_Observer_Think, + // [...] }; From e4c3831f839458fa2b0763b23a8b29a7f466a35e Mon Sep 17 00:00:00 2001 From: techhex Date: Sun, 7 Jan 2024 12:18:12 -0400 Subject: [PATCH 2/3] FIX hook name (Observer_Think) --- reapi/src/hook_callback.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 58c7bb72..f2a41aba 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -1720,7 +1720,7 @@ void CBasePlayer_PlayerDeathThink(IReGameHook_CBasePlayer_PlayerDeathThink *chai callVoidForward(RG_CBasePlayer_PlayerDeathThink, original, indexOfEdict(pthis->pev)); } -void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_PlayerDeathThink *chain, CBasePlayer *pthis) +void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, CBasePlayer *pthis) { auto original = [chain](int _pthis) { From 768752c203717288d5c88046b65f4f7e86633138 Mon Sep 17 00:00:00 2001 From: techhex Date: Sun, 7 Jan 2024 12:22:02 -0400 Subject: [PATCH 3/3] Added hooks in reapi_gamedll_const.inc --- .../scripting/include/reapi_gamedll_const.inc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 5f2d6ae2..0b303097 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -914,6 +914,18 @@ enum GamedllFunc_CBasePlayer * Params: (const this) */ RG_CBasePlayer_EntSelectSpawnPoint, + + /* + * Description: - + * Params: (const this) + */ + RG_CBasePlayer_PlayerDeathThink, + + /* + * Description: - + * Params: (const this) + */ + RG_CBasePlayer_Observer_Think, }; /**