Commit 8bef6ebf authored by fant1kua's avatar fant1kua Committed by Dmitry Novikov

Implement RG_CBasePlayer_UseEmpty hook (#140)

* Implement RG_CBasePlayer_UseEmpty
parent 1b89757c
majorVersion=5
minorVersion=9
minorVersion=10
maintenanceVersion=0
......@@ -754,6 +754,13 @@ enum GamedllFunc_CBasePlayer
* Params: (const this, const message[], Float:duration, bool:bDisplayIfPlayerDead, bool:bOverride)
*/
RG_CBasePlayer_HintMessageEx,
/*
* Description: Called when a player press use and if a suitable candidate is not found.
* Return type: void
* Params: (const this)
*/
RG_CBasePlayer_UseEmpty,
};
/**
......
......@@ -80,7 +80,7 @@ public:
virtual void ResetSequenceInfo();
virtual void StartDeathCam();
virtual bool RemovePlayerItemEx(const char* pszItemName, bool bRemoveAmmo);
virtual void SetSpawnProtection(float flProtectionTime);
virtual void SetSpawnProtection(float flProtectionTime);
virtual void RemoveSpawnProtection();
virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false);
......
......@@ -38,7 +38,7 @@
#include <API/CSInterfaces.h>
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 9
#define REGAMEDLL_API_VERSION_MINOR 10
// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
......@@ -440,6 +440,10 @@ typedef IHookChainRegistry<bool, Vector &, Vector &, entvars_t *, edict_t *> IRe
typedef IHookChainClass<bool, class CBasePlayer, const char *, float, bool, bool> IReGameHook_CBasePlayer_HintMessageEx;
typedef IHookChainRegistryClass<bool, class CBasePlayer, const char *, float, bool, bool> IReGameHookRegistry_CBasePlayer_HintMessageEx;
// CBasePlayer::UseEmpty hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_UseEmpty;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_UseEmpty;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
......@@ -549,6 +553,7 @@ public:
virtual IReGameHookRegistry_CBasePlayer_SetSpawnProtection *CBasePlayer_SetSpawnProtection() = 0;
virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity() = 0;
virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx() = 0;
virtual IReGameHookRegistry_CBasePlayer_UseEmpty *CBasePlayer_UseEmpty() = 0;
};
struct ReGameFuncs_t {
......
......@@ -542,6 +542,16 @@ bool CBasePlayer_HintMessageEx(IReGameHook_CBasePlayer_HintMessageEx *chain, CBa
return callForward<bool>(RG_CBasePlayer_HintMessageEx, original, indexOfEdict(pthis->pev), pMessage, duration, bDisplayIfPlayerDead, bOverride);
}
void CBasePlayer_UseEmpty(IReGameHook_CBasePlayer_UseEmpty *chain, CBasePlayer *pthis)
{
auto original = [chain](int _pthis)
{
return chain->callNext(getPrivate<CBasePlayer>(_pthis));
};
callVoidForward(RG_CBasePlayer_UseEmpty, original, indexOfEdict(pthis->pev));
}
void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis)
{
auto original = [chain](int _pthis)
......
......@@ -376,6 +376,7 @@ CGrenade *CBasePlayer_ThrowGrenade(IReGameHook_CBasePlayer_ThrowGrenade *chain,
void CBasePlayer_SetSpawnProtection(IReGameHook_CBasePlayer_SetSpawnProtection *chain, CBasePlayer *pthis, float flProtectionTime);
void CBasePlayer_RemoveSpawnProtection(IReGameHook_CBasePlayer_RemoveSpawnProtection *chain, CBasePlayer *pthis);
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 CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis);
......
......@@ -154,6 +154,7 @@ hook_t hooklist_player[] = {
DLL(CBasePlayer_SetSpawnProtection),
DLL(CBasePlayer_RemoveSpawnProtection),
DLL(CBasePlayer_HintMessageEx),
DLL(CBasePlayer_UseEmpty),
};
hook_t hooklist_gamerules[] = {
......
......@@ -176,6 +176,7 @@ enum GamedllFunc_CBasePlayer
RG_CBasePlayer_SetSpawnProtection,
RG_CBasePlayer_RemoveSpawnProtection,
RG_CBasePlayer_HintMessageEx,
RG_CBasePlayer_UseEmpty,
// [...]
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment