2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-01-14 15:48:03 +03:00

Implement Check* Hooks

- CheckGameOver
- CheckTimeLimit
- CheckFragLimit
- CheckMaxRounds
- CheckWinLimit
This commit is contained in:
Szabó Erhard Pál 2024-05-25 17:11:37 +02:00
parent 06743d6eb9
commit 9eed7e0fc7
7 changed files with 134 additions and 0 deletions

View File

@ -1260,6 +1260,41 @@ enum GamedllFunc_CSGameRules
* Params: (const pKiller, const pVictim, const pAssister, const pevInflictor, const killerWeaponName[], const DeathMessageFlags:iDeathMessageFlags, const KillRarity:iRarityOfKill)
*/
RG_CSGameRules_SendDeathMessage,
/*
* Description: Called when the game over condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckGameOver,
/*
* Description: Called when the time limit condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckTimeLimit,
/*
* Description: Called when the frag limit condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckFragLimit,
/*
* Description: Called when the max rounds condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckMaxRounds,
/*
* Description: Called when the win limit condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckWinLimit,
};
/**

View File

@ -555,6 +555,13 @@ public:
virtual void SendDeathMessage(CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, entvars_t *pevInflictor, const char *killerWeaponName, int iDeathMessageFlags, int iRarityOfKill) = 0;
// Check various conditions to end the map.
virtual BOOL CheckGameOver() = 0;
virtual BOOL CheckTimeLimit() = 0;
virtual BOOL CheckFragLimit() = 0;
virtual BOOL CheckMaxRounds() = 0;
virtual BOOL CheckWinLimit() = 0;
public:
bool ShouldSkipShowMenu() const { return m_bSkipShowMenu; }
void MarkShowMenuSkipped() { m_bSkipShowMenu = false; }

View File

@ -630,6 +630,26 @@ typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBa
typedef IHookChainClass<void, class CBasePlayer, BOOL> IReGameHook_CBasePlayer_RemoveAllItems;
typedef IHookChainRegistryClass<void, class CBasePlayer, BOOL> IReGameHookRegistry_CBasePlayer_RemoveAllItems;
// CHalfLifeMultiplay::CheckGameOver hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckGameOver;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckGameOver;
// CHalfLifeMultiplay::CheckTimeLimit hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckTimeLimit;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckTimeLimit;
// CHalfLifeMultiplay::CheckFragLimit hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckFragLimit;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckFragLimit;
// CHalfLifeMultiplay::CheckMaxRounds hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckMaxRounds;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckMaxRounds;
// CHalfLifeMultiplay::CheckWinLimit hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckWinLimit;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckWinLimit;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
@ -792,6 +812,12 @@ public:
virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0;
virtual IReGameHookRegistry_CBasePlayer_RemoveAllItems *CBasePlayer_RemoveAllItems() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckGameOver *CSGameRules_CheckGameOver() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckTimeLimit *CSGameRules_CheckTimeLimit() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckFragLimit *CSGameRules_CheckFragLimit() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckMaxRounds *CSGameRules_CheckMaxRounds() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckWinLimit *CSGameRules_CheckWinLimit() = 0;
};
struct ReGameFuncs_t {

View File

@ -1766,6 +1766,56 @@ void CSGameRules_SendDeathMessage(IReGameHook_CSGameRules_SendDeathMessage *chai
callVoidForward(RG_CSGameRules_SendDeathMessage, original, indexOfPDataAmx(pKiller), indexOfEdict(pVictim->pev), indexOfPDataAmx(pAssister), indexOfEdictAmx(pevInflictor), killerWeaponName, iDeathMessageFlags, iRarityOfKill);
}
BOOL CSGameRules_CheckGameOver(IReGameHook_CSGameRules_CheckGameOver *chain)
{
auto original = [chain]()
{
return chain->callNext();
};
return callForward<BOOL>(RG_CSGameRules_CheckGameOver, original);
}
BOOL CSGameRules_CheckTimeLimit(IReGameHook_CSGameRules_CheckTimeLimit *chain)
{
auto original = [chain]()
{
return chain->callNext();
};
return callForward<BOOL>(RG_CSGameRules_CheckTimeLimit, original);
}
BOOL CSGameRules_CheckFragLimit(IReGameHook_CSGameRules_CheckFragLimit *chain)
{
auto original = [chain]()
{
return chain->callNext();
};
return callForward<BOOL>(RG_CSGameRules_CheckFragLimit, original);
}
BOOL CSGameRules_CheckMaxRounds(IReGameHook_CSGameRules_CheckMaxRounds *chain)
{
auto original = [chain]()
{
return chain->callNext();
};
return callForward<BOOL>(RG_CSGameRules_CheckMaxRounds, original);
}
BOOL CSGameRules_CheckWinLimit(IReGameHook_CSGameRules_CheckWinLimit *chain)
{
auto original = [chain]()
{
return chain->callNext();
};
return callForward<BOOL>(RG_CSGameRules_CheckWinLimit, original);
}
/*
* VTC functions
*/

View File

@ -567,6 +567,12 @@ void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, C
void CBasePlayer_RemoveAllItems(IReGameHook_CBasePlayer_RemoveAllItems *chain, CBasePlayer *pthis, BOOL removeSuit);
void CSGameRules_SendDeathMessage(IReGameHook_CSGameRules_SendDeathMessage *chain, CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, entvars_t *pevInflictor, const char *killerWeaponName, int iDeathMessageFlags, int iRarityOfKill);
BOOL CSGameRules_CheckGameOver(IReGameHook_CSGameRules_CheckGameOver *chain);
BOOL CSGameRules_CheckTimeLimit(IReGameHook_CSGameRules_CheckTimeLimit *chain);
BOOL CSGameRules_CheckFragLimit(IReGameHook_CSGameRules_CheckFragLimit *chain);
BOOL CSGameRules_CheckMaxRounds(IReGameHook_CSGameRules_CheckMaxRounds *chain);
BOOL CSGameRules_CheckWinLimit(IReGameHook_CSGameRules_CheckWinLimit *chain);
/*
* VTC functions
*/

View File

@ -248,6 +248,11 @@ hook_t hooklist_gamerules[] = {
DLL(CSGameRules_TeamStacked),
DLL(CSGameRules_PlayerGotWeapon),
DLL(CSGameRules_SendDeathMessage),
DLL(CSGameRules_CheckGameOver),
DLL(CSGameRules_CheckTimeLimit),
DLL(CSGameRules_CheckFragLimit),
DLL(CSGameRules_CheckMaxRounds),
DLL(CSGameRules_CheckWinLimit),
};
hook_t hooklist_grenade[] = {

View File

@ -308,6 +308,11 @@ enum GamedllFunc_CSGameRules
RG_CSGameRules_TeamStacked,
RG_CSGameRules_PlayerGotWeapon,
RG_CSGameRules_SendDeathMessage,
RG_CSGameRules_CheckGameOver,
RG_CSGameRules_CheckTimeLimit,
RG_CSGameRules_CheckFragLimit,
RG_CSGameRules_CheckMaxRounds,
RG_CSGameRules_CheckWinLimit,
// [...]
};