2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-03-13 05:50:16 +03:00

API: Implement RG_PM_LadderMove hook (#254)

This commit is contained in:
Adrian Cirstea 2023-07-15 22:40:32 +03:00 committed by GitHub
parent 3cbdc162a5
commit d9b72bf3a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 0 deletions

View File

@ -407,6 +407,12 @@ enum GamedllFunc
* Params: (const weaponent, const owner, modelName[], Float:origin[3], Float:angles[3], Float:velocity[3], Float:lifeTime, bool:packAmmo)
*/
RG_CreateWeaponBox,
/*
* Description: Called when a player is on a ladder.
* Params: (const playerIndex)
*/
RG_PM_LadderMove,
};
/**

View File

@ -237,6 +237,10 @@ typedef IHookChainRegistry<void, struct playermove_s *, int> IReGameHookRegistry
typedef IHookChain<void, int> IReGameHook_PM_AirMove;
typedef IHookChainRegistry<void, int> IReGameHookRegistry_PM_AirMove;
// PM_LadderMove hook
typedef IHookChain<void, struct physent_s *> IReGameHook_PM_LadderMove;
typedef IHookChainRegistry<void, struct physent_s *> IReGameHookRegistry_PM_LadderMove;
// HandleMenu_ChooseAppearance hook
typedef IHookChain<void, class CBasePlayer *, int> IReGameHook_HandleMenu_ChooseAppearance;
typedef IHookChainRegistry<void, class CBasePlayer *, int> IReGameHookRegistry_HandleMenu_ChooseAppearance;
@ -654,6 +658,8 @@ public:
virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain() = 0;
virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound() = 0;
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink() = 0;
virtual IReGameHookRegistry_PM_LadderMove *PM_LadderMove() = 0;
};
struct ReGameFuncs_t {

View File

@ -899,6 +899,23 @@ void PM_AirMove(IReGameHook_PM_AirMove *chain, int playerIndex)
callVoidForward(RG_PM_AirMove, original, playerIndex);
}
void PM_LadderMove_AMXX(Phys_T *data, int playerIndex)
{
auto original = [data](int _playerIndex)
{
data->m_chain->callNext(data->m_args.pLadder);
};
callVoidForward(RG_PM_LadderMove, original, playerIndex);
}
void PM_LadderMove(IReGameHook_PM_LadderMove *chain, physent_t *pLadder)
{
PM_LadderMove_args_t args(pLadder);
Phys_T data(chain, args);
PM_LadderMove_AMXX(&data, pLadder->player + 1);
}
BOOL CSGameRules_FShouldSwitchWeapon(IReGameHook_CSGameRules_FShouldSwitchWeapon *chain, CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
{
auto original = [chain](int _pPlayer, int _pWeapon)

View File

@ -402,6 +402,18 @@ void PM_Move_AMXX(Move_t *data, int playerIndex);
void PM_Move(IReGameHook_PM_Move *chain, playermove_t *ppmove, int server);
void PM_AirMove(IReGameHook_PM_AirMove *chain, int playerIndex);
struct PM_LadderMove_args_t
{
PM_LadderMove_args_t(physent_t *_ladder) : pLadder(_ladder) {}
physent_t *pLadder;
};
using Phys_T = hookdata_t<IReGameHook_PM_LadderMove *, PM_LadderMove_args_t &>;
void PM_LadderMove_AMXX(Phys_T *data);
void PM_LadderMove(IReGameHook_PM_LadderMove *chain, physent_t *pLadder);
void HandleMenu_ChooseAppearance(IReGameHook_HandleMenu_ChooseAppearance *chain, CBasePlayer *pPlayer, int slot);
BOOL HandleMenu_ChooseTeam(IReGameHook_HandleMenu_ChooseTeam *chain, CBasePlayer *pPlayer, int slot);
void ShowMenu(IReGameHook_ShowMenu *chain, CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText);

View File

@ -131,6 +131,7 @@ hook_t hooklist_gamedll[] = {
DLL(SpawnHeadGib),
DLL(SpawnRandomGibs),
DLL(CreateWeaponBox),
DLL(PM_LadderMove),
};
hook_t hooklist_animating[] = {

View File

@ -145,6 +145,7 @@ enum GamedllFunc
RG_SpawnRandomGibs,
RG_CreateWeaponBox,
RG_PM_LadderMove,
// [...]
};