Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Implement RG_PM_LadderMove hook #254

Merged
merged 5 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

/**
Expand Down
6 changes: 6 additions & 0 deletions reapi/include/cssdk/dlls/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -654,6 +658,8 @@ class IReGameHookchains {
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 {
Expand Down
17 changes: 17 additions & 0 deletions reapi/src/hook_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions reapi/src/hook_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions reapi/src/hook_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ hook_t hooklist_gamedll[] = {
DLL(SpawnHeadGib),
DLL(SpawnRandomGibs),
DLL(CreateWeaponBox),
DLL(PM_LadderMove),
};

hook_t hooklist_animating[] = {
Expand Down
1 change: 1 addition & 0 deletions reapi/src/hook_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ enum GamedllFunc
RG_SpawnRandomGibs,

RG_CreateWeaponBox,
RG_PM_LadderMove,

// [...]
};
Expand Down
Loading