Implement RG_CBasePlayer_UseEmpty hook (#405)

* Implement to RG_CBasePlayer_UseEmpty
This commit is contained in:
fant1kua 2019-08-29 16:34:22 +03:00 committed by Dmitry Novikov
parent 371ac897bb
commit 77305688a9
7 changed files with 26 additions and 6 deletions

View File

@ -1,3 +1,3 @@
majorVersion=5 majorVersion=5
minorVersion=9 minorVersion=10
maintenanceVersion=0 maintenanceVersion=0

View File

@ -161,6 +161,7 @@ GAMEHOOK_REGISTRY(CBasePlayer_SetSpawnProtection);
GAMEHOOK_REGISTRY(CBasePlayer_RemoveSpawnProtection); GAMEHOOK_REGISTRY(CBasePlayer_RemoveSpawnProtection);
GAMEHOOK_REGISTRY(IsPenetrableEntity); GAMEHOOK_REGISTRY(IsPenetrableEntity);
GAMEHOOK_REGISTRY(CBasePlayer_HintMessageEx); GAMEHOOK_REGISTRY(CBasePlayer_HintMessageEx);
GAMEHOOK_REGISTRY(CBasePlayer_UseEmpty);
int CReGameApi::GetMajorVersion() { int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR; return REGAMEDLL_API_VERSION_MAJOR;

View File

@ -537,6 +537,10 @@ typedef IHookChainRegistryImpl<bool, Vector &, Vector &, entvars_t *, edict_t *>
typedef IHookChainClassImpl<bool, CBasePlayer, const char *, float, bool, bool> CReGameHook_CBasePlayer_HintMessageEx; typedef IHookChainClassImpl<bool, CBasePlayer, const char *, float, bool, bool> CReGameHook_CBasePlayer_HintMessageEx;
typedef IHookChainRegistryClassImpl<bool, CBasePlayer, const char *, float, bool, bool> CReGameHookRegistry_CBasePlayer_HintMessageEx; typedef IHookChainRegistryClassImpl<bool, CBasePlayer, const char *, float, bool, bool> CReGameHookRegistry_CBasePlayer_HintMessageEx;
// CBasePlayer::UseEmpty hook
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_UseEmpty;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_UseEmpty;
class CReGameHookchains: public IReGameHookchains { class CReGameHookchains: public IReGameHookchains {
public: public:
// CBasePlayer virtual // CBasePlayer virtual
@ -645,6 +649,7 @@ public:
CReGameHookRegistry_CBasePlayer_RemoveSpawnProtection m_CBasePlayer_RemoveSpawnProtection; CReGameHookRegistry_CBasePlayer_RemoveSpawnProtection m_CBasePlayer_RemoveSpawnProtection;
CReGameHookRegistry_IsPenetrableEntity m_IsPenetrableEntity; CReGameHookRegistry_IsPenetrableEntity m_IsPenetrableEntity;
CReGameHookRegistry_CBasePlayer_HintMessageEx m_CBasePlayer_HintMessageEx; CReGameHookRegistry_CBasePlayer_HintMessageEx m_CBasePlayer_HintMessageEx;
CReGameHookRegistry_CBasePlayer_UseEmpty m_CBasePlayer_UseEmpty;
public: public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn(); virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
@ -752,6 +757,7 @@ public:
virtual IReGameHookRegistry_CBasePlayer_RemoveSpawnProtection *CBasePlayer_RemoveSpawnProtection(); virtual IReGameHookRegistry_CBasePlayer_RemoveSpawnProtection *CBasePlayer_RemoveSpawnProtection();
virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity(); virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity();
virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx(); virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx();
virtual IReGameHookRegistry_CBasePlayer_UseEmpty *CBasePlayer_UseEmpty();
}; };
extern CReGameHookchains g_ReGameHookchains; extern CReGameHookchains g_ReGameHookchains;

View File

@ -3922,13 +3922,19 @@ void CBasePlayer::PlayerUse()
} }
} }
} }
else else if (m_afButtonPressed & IN_USE)
{ {
if (m_afButtonPressed & IN_USE) UseEmpty();
EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_denyselect.wav", 0.4, ATTN_NORM);
} }
} }
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, UseEmpty)
void EXT_FUNC CBasePlayer::__API_HOOK(UseEmpty)()
{
EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_denyselect.wav", 0.4, ATTN_NORM);
}
void CBasePlayer::HostageUsed() void CBasePlayer::HostageUsed()
{ {
if (m_flDisplayHistory & DHF_HOSTAGE_USED) if (m_flDisplayHistory & DHF_HOSTAGE_USED)

View File

@ -424,6 +424,7 @@ public:
void SetSpawnProtection_OrigFunc(float flProtectionTime); void SetSpawnProtection_OrigFunc(float flProtectionTime);
void RemoveSpawnProtection_OrigFunc(); void RemoveSpawnProtection_OrigFunc();
bool HintMessageEx_OrigFunc(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); bool HintMessageEx_OrigFunc(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false);
void UseEmpty_OrigFunc();
CCSPlayer *CSPlayer() const; CCSPlayer *CSPlayer() const;
#endif // REGAMEDLL_API #endif // REGAMEDLL_API
@ -619,6 +620,7 @@ public:
void SetSpawnProtection(float flProtectionTime); void SetSpawnProtection(float flProtectionTime);
void RemoveSpawnProtection(); void RemoveSpawnProtection();
void UseEmpty();
// templates // templates
template<typename T = CBasePlayerItem, typename Functor> template<typename T = CBasePlayerItem, typename Functor>

View File

@ -91,7 +91,7 @@ public:
virtual void ResetSequenceInfo(); virtual void ResetSequenceInfo();
virtual void StartDeathCam(); virtual void StartDeathCam();
virtual bool RemovePlayerItemEx(const char* pszItemName, bool bRemoveAmmo); virtual bool RemovePlayerItemEx(const char* pszItemName, bool bRemoveAmmo);
virtual void SetSpawnProtection(float flProtectionTime); virtual void SetSpawnProtection(float flProtectionTime);
virtual void RemoveSpawnProtection(); virtual void RemoveSpawnProtection();
virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false);

View File

@ -38,7 +38,7 @@
#include <API/CSInterfaces.h> #include <API/CSInterfaces.h>
#define REGAMEDLL_API_VERSION_MAJOR 5 #define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 9 #define REGAMEDLL_API_VERSION_MINOR 10
// CBasePlayer::Spawn hook // CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn; 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 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; 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 { class IReGameHookchains {
public: public:
virtual ~IReGameHookchains() {} virtual ~IReGameHookchains() {}
@ -549,6 +553,7 @@ public:
virtual IReGameHookRegistry_CBasePlayer_SetSpawnProtection *CBasePlayer_SetSpawnProtection() = 0; virtual IReGameHookRegistry_CBasePlayer_SetSpawnProtection *CBasePlayer_SetSpawnProtection() = 0;
virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity() = 0; virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity() = 0;
virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx() = 0; virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx() = 0;
virtual IReGameHookRegistry_CBasePlayer_UseEmpty *CBasePlayer_UseEmpty() = 0;
}; };
struct ReGameFuncs_t { struct ReGameFuncs_t {