2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-29 08:05:36 +03:00

Implement RG_CBasePlayer_Observer_SetMode hook (#208)

* Implement RG_CBasePlayer_Observer_SetMode hook

* fixes

Co-authored-by: Lopol2010 <evgeniy7@gmail.com>
Co-authored-by: Sergey Shorokhov <wopox1337@ya.ru>
This commit is contained in:
Lopol2010 2021-09-02 17:35:58 +03:00 committed by GitHub
parent 6063144a31
commit 2c415638ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#define RG_CBasePlayerWeapon_DefaultDeploy RG_CBaseWeapon_DefDeploy
#define RG_CBasePlayerWeapon_DefaultReload RG_CBaseWeapon_DefReload
#define RG_CBasePlayerWeapon_DefaultShotgunReload RG_CBaseWeapon_DefShotgunReload
#define RG_CBasePlayer_Observer_SetMode RG_CBasePlayer_Observer_SetMod
#endif
/**
@ -785,6 +786,12 @@ enum GamedllFunc_CBasePlayer
*/
RG_CBasePlayer_DropIdlePlayer,
/*
* Description: Called when a client attempt to change the observer mode.
* Params: (const this, iMode)
*/
RG_CBasePlayer_Observer_SetMode,
/*
* Description: Called when a client emits a "pain sound" after received damage.
* Return type: void

View File

@ -501,6 +501,10 @@ typedef IHookChainRegistryClass<void, class CBaseEntity, ULONG, Vector &, Vector
typedef IHookChainClass<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> IReGameHook_CBaseEntity_FireBullets3;
typedef IHookChainRegistryClass<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> IReGameHookRegistry_CBaseEntity_FireBullets3;
// CBasePlayer::Observer_SetMode hook
typedef IHookChainClass<void, class CBasePlayer, int> IReGameHook_CBasePlayer_Observer_SetMode;
typedef IHookChainRegistryClass<void, class CBasePlayer, int> IReGameHookRegistry_CBasePlayer_Observer_SetMode;
// CBasePlayer::Pain hook
typedef IHookChainClass<void, class CBasePlayer, int, bool> IReGameHook_CBasePlayer_Pain;
typedef IHookChainRegistryClass<void, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Pain;
@ -640,6 +644,8 @@ public:
virtual IReGameHookRegistry_CBaseEntity_FireBuckshots *CBaseEntity_FireBuckshots() = 0;
virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_SetMode *CBasePlayer_Observer_SetMode() = 0;
virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain() = 0;
virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound() = 0;
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink() = 0;

View File

@ -1237,6 +1237,16 @@ Vector &CBaseEntity_FireBullets3(IReGameHook_CBaseEntity_FireBullets3 *chain, CB
shared_rand);
}
void CBasePlayer_Observer_SetMode(IReGameHook_CBasePlayer_Observer_SetMode *chain, CBasePlayer *pthis, int iMode)
{
auto original = [chain](int _pthis, int _iMode)
{
chain->callNext(getPrivate<CBasePlayer>(_pthis), _iMode);
};
callVoidForward(RG_CBasePlayer_Observer_SetMode, original, indexOfEdict(pthis->pev), iMode);
}
int g_iClientStartSpeak, g_iClientStopSpeak;
void OnClientStartSpeak(size_t clientIndex)

View File

@ -428,6 +428,7 @@ void CBasePlayer_RemoveSpawnProtection(IReGameHook_CBasePlayer_RemoveSpawnProtec
bool CBasePlayer_HintMessageEx(IReGameHook_CBasePlayer_HintMessageEx *chain, CBasePlayer *pthis, const char *pMessage, float duration, bool bDisplayIfPlayerDead, bool bOverride);
void CBasePlayer_UseEmpty(IReGameHook_CBasePlayer_UseEmpty *chain, CBasePlayer *pthis);
void CBasePlayer_DropIdlePlayer(IReGameHook_CBasePlayer_DropIdlePlayer *chain, CBasePlayer *pthis, const char *reason);
void CBasePlayer_Observer_SetMode(IReGameHook_CBasePlayer_Observer_SetMode *chain, CBasePlayer *pthis, int iMode);
void CBasePlayer_Pain(IReGameHook_CBasePlayer_Pain *chain, CBasePlayer *pthis, int iLastHitGroup, bool bHasArmour);
void CBasePlayer_DeathSound(IReGameHook_CBasePlayer_DeathSound *chain, CBasePlayer *pthis);
void CBasePlayer_JoiningThink(IReGameHook_CBasePlayer_JoiningThink *chain, CBasePlayer *pthis);

View File

@ -167,6 +167,9 @@ hook_t hooklist_player[] = {
DLL(CBasePlayer_HintMessageEx),
DLL(CBasePlayer_UseEmpty),
DLL(CBasePlayer_DropIdlePlayer),
DLL(CBasePlayer_Observer_SetMode),
DLL(CBasePlayer_Pain),
DLL(CBasePlayer_DeathSound),
DLL(CBasePlayer_JoiningThink),

View File

@ -192,6 +192,9 @@ enum GamedllFunc_CBasePlayer
RG_CBasePlayer_HintMessageEx,
RG_CBasePlayer_UseEmpty,
RG_CBasePlayer_DropIdlePlayer,
RG_CBasePlayer_Observer_SetMode,
RG_CBasePlayer_Pain,
RG_CBasePlayer_DeathSound,
RG_CBasePlayer_JoiningThink,