diff --git a/gradle.properties b/gradle.properties index 6e26c9db..8b095261 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ majorVersion=5 -minorVersion=10 +minorVersion=11 maintenanceVersion=0 diff --git a/reapi/extra/amxmodx/scripting/include/reapi.inc b/reapi/extra/amxmodx/scripting/include/reapi.inc index 03b30149..9f2eb45e 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi.inc @@ -22,7 +22,8 @@ enum hooks_tables_e ht_gamerules, ht_rechecker, ht_grenade, - ht_weaponbox + ht_weaponbox, + ht_weapon }; enum members_tables_e @@ -136,7 +137,7 @@ enum HookChain * * @return Returns a hook handle. Use EnableHookChain/DisableHookChain to toggle the forward on or off */ -native HookChain:RegisterHookChain({EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc}:function_id, const callback[], post = 0); +native HookChain:RegisterHookChain({EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon}:function_id, const callback[], post = 0); /* * Stops a hook from triggering. diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index deb043a2..d0b65ceb 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -763,6 +763,40 @@ enum GamedllFunc_CBasePlayer RG_CBasePlayer_UseEmpty, }; +/** +* GamedllFunc CBasePlayer +*/ +enum GamedllFunc_CBasePlayerWeapon +{ + /* + * Description: - + * Return type: BOOL + * Params: (const this) + */ + RG_CBasePlayerWeapon_CanDeploy = BEGIN_FUNC_REGION(weapon), + + /* + * Description: - + * Return type: BOOL + * Params: (const this, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal) + */ + RG_CBasePlayerWeapon_DefaultDeploy, + + /* + * Description: - + * Return type: int + * Params: (const this, iClipSize, iAnim, Float:fDelay) + */ + RG_CBasePlayerWeapon_DefaultReload, + + /* + * Description: - + * Return type: bool + * Params: (const this, iAnim, iStartAnim, Float:fDelay, Float:fStartDelay, const pszReloadSound1[], const pszReloadSound2[]) + */ + RG_CBasePlayerWeapon_DefaultShotgunReload, +}; + /** * GamedllFunc CSGameRules */ diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index 20041468..e05bab42 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -38,7 +38,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 11 +#define REGAMEDLL_API_VERSION_MINOR 12 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn; @@ -444,6 +444,22 @@ typedef IHookChainRegistryClass IReGameHook_CBasePlayer_UseEmpty; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_UseEmpty; +// CBasePlayerWeapon::CanDeploy hook +typedef IHookChainClass IReGameHook_CBasePlayerWeapon_CanDeploy; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayerWeapon_CanDeploy; + +// CBasePlayerWeapon::DefaultDeploy hook +typedef IHookChainClass IReGameHook_CBasePlayerWeapon_DefaultDeploy; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayerWeapon_DefaultDeploy; + +// CBasePlayerWeapon::DefaultReload hook +typedef IHookChainClass IReGameHook_CBasePlayerWeapon_DefaultReload; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayerWeapon_DefaultReload; + +// CBasePlayerWeapon::DefaultShotgunReload hook +typedef IHookChainClass IReGameHook_CBasePlayerWeapon_DefaultShotgunReload; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -554,6 +570,10 @@ class IReGameHookchains { virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity() = 0; virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx() = 0; virtual IReGameHookRegistry_CBasePlayer_UseEmpty *CBasePlayer_UseEmpty() = 0; + virtual IReGameHookRegistry_CBasePlayerWeapon_CanDeploy *CBasePlayerWeapon_CanDeploy() = 0; + virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultDeploy *CBasePlayerWeapon_DefaultDeploy() = 0; + virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultReload *CBasePlayerWeapon_DefaultReload() = 0; + virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload *CBasePlayerWeapon_DefaultShotgunReload() = 0; }; struct ReGameFuncs_t { diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index cebef0b0..964200a9 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -562,6 +562,46 @@ void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceIn callVoidForward(RG_CBaseAnimating_ResetSequenceInfo, original, indexOfEdict(pthis->pev)); } +BOOL CBasePlayerWeapon_CanDeploy(IReGameHook_CBasePlayerWeapon_CanDeploy *chain, CBasePlayerWeapon *pthis) +{ + auto original = [chain](int _pthis) + { + return chain->callNext(getPrivate(_pthis)); + }; + + return callForward(RG_CBasePlayerWeapon_CanDeploy, original, indexOfEdict(pthis->pev)); +} + +BOOL CBasePlayerWeapon_DefaultDeploy(IReGameHook_CBasePlayerWeapon_DefaultDeploy *chain, CBasePlayerWeapon *pthis, char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal) +{ + auto original = [chain](int _pthis, char *_szViewModel, char *_szWeaponModel, int _iAnim, char *_szAnimExt, int _skiplocal) + { + return chain->callNext(getPrivate(_pthis), _szViewModel, _szWeaponModel, _iAnim, _szAnimExt, _skiplocal); + }; + + return callForward(RG_CBasePlayerWeapon_DefaultDeploy, original, indexOfEdict(pthis->pev), szViewModel, szWeaponModel, iAnim, szAnimExt, skiplocal); +} + +int CBasePlayerWeapon_DefaultReload(IReGameHook_CBasePlayerWeapon_DefaultReload *chain, CBasePlayerWeapon *pthis, int iClipSize, int iAnim, float fDelay) +{ + auto original = [chain](int _pthis, int _iClipSize, int _iAnim, float _fDelay) + { + return chain->callNext(getPrivate(_pthis), _iClipSize, _iAnim, _fDelay); + }; + + return callForward(RG_CBasePlayerWeapon_DefaultReload, original, indexOfEdict(pthis->pev), iClipSize, iAnim, fDelay); +} + +bool CBasePlayerWeapon_DefaultShotgunReload(IReGameHook_CBasePlayerWeapon_DefaultShotgunReload *chain, CBasePlayerWeapon *pthis, int iAnim, int iStartAnim, float fDelay, float fStartDelay, const char *pszReloadSound1, const char *pszReloadSound2) +{ + auto original = [chain](int _pthis, int _iAnim, int _iStartAnim, float _fDelay, float _fStartDelay, const char *_pszReloadSound1, const char *_pszReloadSound2) + { + return chain->callNext(getPrivate(_pthis), _iAnim, _iStartAnim, _fDelay, _fStartDelay, _pszReloadSound1, _pszReloadSound2); + }; + + return callForward(RG_CBasePlayerWeapon_DefaultShotgunReload, original, indexOfEdict(pthis->pev), iAnim, iStartAnim, fDelay, fStartDelay, pszReloadSound1, pszReloadSound2); +} + int GetForceCamera(IReGameHook_GetForceCamera *chain, CBasePlayer *pObserver) { auto original = [chain](int _pObserver) diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 2b98fd19..31d3df41 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -392,6 +392,11 @@ void CBasePlayer_UseEmpty(IReGameHook_CBasePlayer_UseEmpty *chain, CBasePlayer * void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis); +BOOL CBasePlayerWeapon_CanDeploy(IReGameHook_CBasePlayerWeapon_CanDeploy *chain, CBasePlayerWeapon *pthis); +BOOL CBasePlayerWeapon_DefaultDeploy(IReGameHook_CBasePlayerWeapon_DefaultDeploy *chain, CBasePlayerWeapon *pthis, char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal); +int CBasePlayerWeapon_DefaultReload(IReGameHook_CBasePlayerWeapon_DefaultReload *chain, CBasePlayerWeapon *pthis, int iClipSize, int iAnim, float fDelay); +bool CBasePlayerWeapon_DefaultShotgunReload(IReGameHook_CBasePlayerWeapon_DefaultShotgunReload *chain, CBasePlayerWeapon *pthis, int iAnim, int iStartAnim, float fDelay, float fStartDelay, const char *pszReloadSound1, const char *pszReloadSound2); + BOOL CSGameRules_FShouldSwitchWeapon(IReGameHook_CSGameRules_FShouldSwitchWeapon *chain, CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); BOOL CSGameRules_GetNextBestWeapon(IReGameHook_CSGameRules_GetNextBestWeapon *chain, CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon); float CSGameRules_FlPlayerFallDamage(IReGameHook_CSGameRules_FlPlayerFallDamage *chain, CBasePlayer *pPlayer); diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index b22586cf..f72ffba0 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -197,6 +197,13 @@ hook_t hooklist_weaponbox[] = { DLL(CWeaponBox_SetModel), }; +hook_t hooklist_weapon[] = { + DLL(CBasePlayerWeapon_CanDeploy), + DLL(CBasePlayerWeapon_DefaultDeploy), + DLL(CBasePlayerWeapon_DefaultReload), + DLL(CBasePlayerWeapon_DefaultShotgunReload), +}; + #define RCHECK(h,...) { {}, {}, #h, "ReChecker", [](){ return api_cfg.hasRechecker(); }, ((!(RC_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RC_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RecheckerHookchains->h()->registerHook(&h); }, [](){ g_RecheckerHookchains->h()->unregisterHook(&h); }} hook_t hooklist_rechecker[] = { RCHECK(FileConsistencyProcess, _AMXX), @@ -220,6 +227,7 @@ hook_t* hooklist_t::getHookSafe(size_t hook) CASE(rechecker) CASE(grenade) CASE(weaponbox) + CASE(weapon) } return nullptr; @@ -237,6 +245,7 @@ void hooklist_t::clear() FOREACH_CLEAR(rechecker); FOREACH_CLEAR(grenade); FOREACH_CLEAR(weaponbox); + FOREACH_CLEAR(weapon); } void hook_t::clear() diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index 7abcc695..b88f55a2 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -33,6 +33,7 @@ extern hook_t hooklist_gamerules[]; extern hook_t hooklist_rechecker[]; extern hook_t hooklist_grenade[]; extern hook_t hooklist_weaponbox[]; +extern hook_t hooklist_weapon[]; enum { @@ -57,6 +58,7 @@ struct hooklist_t CASE(rechecker) CASE(grenade) CASE(weaponbox) + CASE(weapon) } #undef CASE @@ -76,7 +78,8 @@ struct hooklist_t ht_gamerules, ht_rechecker, ht_grenade, - ht_weaponbox + ht_weaponbox, + ht_weapon }; }; @@ -200,6 +203,16 @@ enum GamedllFunc_CWeaponBox // [...] }; +enum GamedllFunc_CBasePlayerWeapon +{ + RG_CBasePlayerWeapon_CanDeploy = BEGIN_FUNC_REGION(weapon), + RG_CBasePlayerWeapon_DefaultDeploy, + RG_CBasePlayerWeapon_DefaultReload, + RG_CBasePlayerWeapon_DefaultShotgunReload, + + // [...] +}; + enum GamedllFunc_CSGameRules { // CSGameRules virtual