Implement player Pain, DeathSound and JoiningThink hooks (#607)

This commit is contained in:
fl0werD 2021-08-29 08:12:25 +04:00 committed by GitHub
parent fbbd6bd083
commit 38dda25a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 5 deletions

View File

@ -186,6 +186,10 @@ GAMEHOOK_REGISTRY(CBaseEntity_FireBullets);
GAMEHOOK_REGISTRY(CBaseEntity_FireBuckshots);
GAMEHOOK_REGISTRY(CBaseEntity_FireBullets3);
GAMEHOOK_REGISTRY(CBasePlayer_Pain);
GAMEHOOK_REGISTRY(CBasePlayer_DeathSound);
GAMEHOOK_REGISTRY(CBasePlayer_JoiningThink);
int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
}

View File

@ -621,6 +621,18 @@ typedef IHookChainRegistryClassImpl<void, class CBaseEntity, ULONG, Vector &, Ve
typedef IHookChainClassImpl<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> CReGameHook_CBaseEntity_FireBullets3;
typedef IHookChainRegistryClassImpl<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> CReGameHookRegistry_CBaseEntity_FireBullets3;
// CBasePlayer::Pain hook
typedef IHookChainClassImpl<void, CBasePlayer, int, bool> CReGameHook_CBasePlayer_Pain;
typedef IHookChainRegistryClassImpl<void, CBasePlayer, int, bool> CReGameHookRegistry_CBasePlayer_Pain;
// CBasePlayer::DeathSound hook
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_DeathSound;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_DeathSound;
// CBasePlayer::JoiningThink hook
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_JoiningThink;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_JoiningThink;
class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
@ -746,6 +758,10 @@ public:
CReGameHookRegistry_CBaseEntity_FireBullets m_CBaseEntity_FireBullets;
CReGameHookRegistry_CBaseEntity_FireBuckshots m_CBaseEntity_FireBuckshots;
CReGameHookRegistry_CBaseEntity_FireBullets3 m_CBaseEntity_FireBullets3;
CReGameHookRegistry_CBasePlayer_Pain m_CBasePlayer_Pain;
CReGameHookRegistry_CBasePlayer_DeathSound m_CBasePlayer_DeathSound;
CReGameHookRegistry_CBasePlayer_JoiningThink m_CBasePlayer_JoiningThink;
public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
@ -870,6 +886,10 @@ public:
virtual IReGameHookRegistry_CBaseEntity_FireBullets *CBaseEntity_FireBullets();
virtual IReGameHookRegistry_CBaseEntity_FireBuckshots *CBaseEntity_FireBuckshots();
virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3();
virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain();
virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound();
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink();
};
extern CReGameHookchains g_ReGameHookchains;

View File

@ -461,7 +461,9 @@ void CBasePlayer::SmartRadio()
;
}
void CBasePlayer::Pain(int iLastHitGroup, bool bHasArmour)
LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, Pain, (int iLastHitGroup, bool bHasArmour), iLastHitGroup, bHasArmour)
void EXT_FUNC CBasePlayer::__API_HOOK(Pain)(int iLastHitGroup, bool bHasArmour)
{
int temp = RANDOM_LONG(0, 2);
@ -537,7 +539,9 @@ int TrainSpeed(int iSpeed, int iMax)
return iRet;
}
void CBasePlayer::DeathSound()
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, DeathSound)
void EXT_FUNC CBasePlayer::__API_HOOK(DeathSound)()
{
// temporarily using pain sounds for death sounds
switch (RANDOM_LONG(1, 4))
@ -3538,7 +3542,9 @@ void EXT_FUNC CBasePlayer::__API_HOOK(MakeVIP)()
CSGameRules()->m_iConsecutiveVIP = 1;
}
void CBasePlayer::JoiningThink()
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, JoiningThink)
void EXT_FUNC CBasePlayer::__API_HOOK(JoiningThink)()
{
switch (m_iJoiningState)
{

View File

@ -439,6 +439,9 @@ public:
bool HintMessageEx_OrigFunc(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false);
void UseEmpty_OrigFunc();
void DropIdlePlayer_OrigFunc(const char *reason);
void Pain_OrigFunc(int iLastHitGroup, bool bHasArmour);
void DeathSound_OrigFunc();
void JoiningThink_OrigFunc();
CCSPlayer *CSPlayer() const;
#endif // REGAMEDLL_API

View File

@ -38,7 +38,7 @@
#include <API/CSInterfaces.h>
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 20
#define REGAMEDLL_API_VERSION_MINOR 21
// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
@ -500,6 +500,17 @@ 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::Pain hook
typedef IHookChainClass<void, class CBasePlayer, int, bool> IReGameHook_CBasePlayer_Pain;
typedef IHookChainRegistryClass<void, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Pain;
// CBasePlayer::DeathSound hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_DeathSound;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_DeathSound;
// CBasePlayer::JoiningThink hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_JoiningThink;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_JoiningThink;
class IReGameHookchains {
public:
@ -627,6 +638,10 @@ public:
virtual IReGameHookRegistry_CBaseEntity_FireBullets *CBaseEntity_FireBullets() = 0;
virtual IReGameHookRegistry_CBaseEntity_FireBuckshots *CBaseEntity_FireBuckshots() = 0;
virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3() = 0;
virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain() = 0;
virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound() = 0;
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink() = 0;
};
struct ReGameFuncs_t {

View File

@ -6,5 +6,5 @@
#pragma once
#define VERSION_MAJOR 5
#define VERSION_MINOR 20
#define VERSION_MINOR 21
#define VERSION_MAINTENANCE 0