Skip to content

Commit a7f630a

Browse files
committed
Implement player hooks
1 parent f57d28f commit a7f630a

6 files changed

Lines changed: 53 additions & 5 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
majorVersion=5
2-
minorVersion=20
2+
minorVersion=21
33
maintenanceVersion=0

regamedll/dlls/API/CAPI_Impl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ GAMEHOOK_REGISTRY(CBaseEntity_FireBullets);
186186
GAMEHOOK_REGISTRY(CBaseEntity_FireBuckshots);
187187
GAMEHOOK_REGISTRY(CBaseEntity_FireBullets3);
188188

189+
GAMEHOOK_REGISTRY(CBasePlayer_Pain);
190+
GAMEHOOK_REGISTRY(CBasePlayer_DeathSound);
191+
GAMEHOOK_REGISTRY(CBasePlayer_JoiningThink);
192+
189193
int CReGameApi::GetMajorVersion() {
190194
return REGAMEDLL_API_VERSION_MAJOR;
191195
}

regamedll/dlls/API/CAPI_Impl.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,18 @@ typedef IHookChainRegistryClassImpl<void, class CBaseEntity, ULONG, Vector &, Ve
615615
typedef IHookChainClassImpl<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> CReGameHook_CBaseEntity_FireBullets3;
616616
typedef IHookChainRegistryClassImpl<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> CReGameHookRegistry_CBaseEntity_FireBullets3;
617617

618+
// CBasePlayer::Pain hook
619+
typedef IHookChainClassImpl<void, CBasePlayer, int, bool> CReGameHook_CBasePlayer_Pain;
620+
typedef IHookChainRegistryClassImpl<void, CBasePlayer, int, bool> CReGameHookRegistry_CBasePlayer_Pain;
621+
622+
// CBasePlayer::DeathSound hook
623+
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_DeathSound;
624+
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_DeathSound;
625+
626+
// CBasePlayer::JoiningThink hook
627+
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_JoiningThink;
628+
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_JoiningThink;
629+
618630
class CReGameHookchains: public IReGameHookchains {
619631
public:
620632
// CBasePlayer virtual
@@ -740,6 +752,10 @@ class CReGameHookchains: public IReGameHookchains {
740752
CReGameHookRegistry_CBaseEntity_FireBullets m_CBaseEntity_FireBullets;
741753
CReGameHookRegistry_CBaseEntity_FireBuckshots m_CBaseEntity_FireBuckshots;
742754
CReGameHookRegistry_CBaseEntity_FireBullets3 m_CBaseEntity_FireBullets3;
755+
756+
CReGameHookRegistry_CBasePlayer_Pain m_CBasePlayer_Pain;
757+
CReGameHookRegistry_CBasePlayer_DeathSound m_CBasePlayer_DeathSound;
758+
CReGameHookRegistry_CBasePlayer_JoiningThink m_CBasePlayer_JoiningThink;
743759

744760
public:
745761
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
@@ -864,6 +880,10 @@ class CReGameHookchains: public IReGameHookchains {
864880
virtual IReGameHookRegistry_CBaseEntity_FireBullets *CBaseEntity_FireBullets();
865881
virtual IReGameHookRegistry_CBaseEntity_FireBuckshots *CBaseEntity_FireBuckshots();
866882
virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3();
883+
884+
virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain();
885+
virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound();
886+
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink();
867887
};
868888

869889
extern CReGameHookchains g_ReGameHookchains;

regamedll/dlls/player.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,9 @@ void CBasePlayer::SmartRadio()
461461
;
462462
}
463463

464-
void CBasePlayer::Pain(int iLastHitGroup, bool bHasArmour)
464+
LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, Pain, (int iLastHitGroup, bool bHasArmour), iLastHitGroup, bHasArmour)
465+
466+
void EXT_FUNC CBasePlayer::__API_HOOK(Pain)(int iLastHitGroup, bool bHasArmour)
465467
{
466468
int temp = RANDOM_LONG(0, 2);
467469

@@ -537,7 +539,9 @@ int TrainSpeed(int iSpeed, int iMax)
537539
return iRet;
538540
}
539541

540-
void CBasePlayer::DeathSound()
542+
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, DeathSound)
543+
544+
void EXT_FUNC CBasePlayer::__API_HOOK(DeathSound)()
541545
{
542546
// temporarily using pain sounds for death sounds
543547
switch (RANDOM_LONG(1, 4))
@@ -3538,7 +3542,9 @@ void EXT_FUNC CBasePlayer::__API_HOOK(MakeVIP)()
35383542
CSGameRules()->m_iConsecutiveVIP = 1;
35393543
}
35403544

3541-
void CBasePlayer::JoiningThink()
3545+
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, JoiningThink)
3546+
3547+
void EXT_FUNC CBasePlayer::__API_HOOK(JoiningThink)()
35423548
{
35433549
switch (m_iJoiningState)
35443550
{

regamedll/dlls/player.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ class CBasePlayer: public CBaseMonster {
430430
bool HintMessageEx_OrigFunc(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false);
431431
void UseEmpty_OrigFunc();
432432
void DropIdlePlayer_OrigFunc(const char *reason);
433+
void Pain_OrigFunc(int iLastHitGroup, bool bHasArmour);
434+
void DeathSound_OrigFunc();
435+
void JoiningThink_OrigFunc();
433436

434437
CCSPlayer *CSPlayer() const;
435438
#endif // REGAMEDLL_API

regamedll/public/regamedll/regamedll_api.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <API/CSInterfaces.h>
3939

4040
#define REGAMEDLL_API_VERSION_MAJOR 5
41-
#define REGAMEDLL_API_VERSION_MINOR 20
41+
#define REGAMEDLL_API_VERSION_MINOR 21
4242

4343
// CBasePlayer::Spawn hook
4444
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
@@ -500,6 +500,17 @@ typedef IHookChainRegistryClass<void, class CBaseEntity, ULONG, Vector &, Vector
500500
typedef IHookChainClass<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> IReGameHook_CBaseEntity_FireBullets3;
501501
typedef IHookChainRegistryClass<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> IReGameHookRegistry_CBaseEntity_FireBullets3;
502502

503+
// CBasePlayer::Pain hook
504+
typedef IHookChainClass<void, class CBasePlayer, int, bool> IReGameHook_CBasePlayer_Pain;
505+
typedef IHookChainRegistryClass<void, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Pain;
506+
507+
// CBasePlayer::DeathSound hook
508+
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_DeathSound;
509+
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_DeathSound;
510+
511+
// CBasePlayer::JoiningThink hook
512+
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_JoiningThink;
513+
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_JoiningThink;
503514

504515
class IReGameHookchains {
505516
public:
@@ -627,6 +638,10 @@ class IReGameHookchains {
627638
virtual IReGameHookRegistry_CBaseEntity_FireBullets *CBaseEntity_FireBullets() = 0;
628639
virtual IReGameHookRegistry_CBaseEntity_FireBuckshots *CBaseEntity_FireBuckshots() = 0;
629640
virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3() = 0;
641+
642+
virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain() = 0;
643+
virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound() = 0;
644+
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink() = 0;
630645
};
631646

632647
struct ReGameFuncs_t {

0 commit comments

Comments
 (0)