Skip to content

Commit

Permalink
WeaponsPrecache hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeperezz16 committed Jan 3, 2024
1 parent ef5d41d commit d746c30
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
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 @@ -479,6 +479,12 @@ enum GamedllFunc
* Params: (const pPlayer, iSlot)
*/
RG_BuyItem,

/*
* Description: Called inside CWorld::Spawn to store ItemInfo and AmmoInfo
* Params: ()
*/
RG_WeaponsPrecache,
};

/**
Expand Down
5 changes: 5 additions & 0 deletions reapi/include/cssdk/dlls/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,10 @@ typedef IHookChainRegistry<void, entvars_t *, entvars_t *> IReGameHookRegistry_A
typedef IHookChain<void, CBasePlayer *, int> IReGameHook_BuyItem;
typedef IHookChainRegistry<void, CBasePlayer *, int> IReGameHookRegistry_BuyItem;

// WeaponsPrecache hook
typedef IHookChain<void> IReGameHook_WeaponsPrecache;
typedef IHookChainRegistry<void> IReGameHookRegistry_WeaponsPrecache;

// CHalfLifeMultiplay::Think hook
typedef IHookChain<void> IReGameHook_CSGameRules_Think;
typedef IHookChainRegistry<void> IReGameHookRegistry_CSGameRules_Think;
Expand Down Expand Up @@ -769,6 +773,7 @@ class IReGameHookchains {
virtual IReGameHookRegistry_AddMultiDamage *AddMultiDamage() = 0;
virtual IReGameHookRegistry_ApplyMultiDamage *ApplyMultiDamage() = 0;
virtual IReGameHookRegistry_BuyItem *BuyItem() = 0;
virtual IReGameHookRegistry_WeaponsPrecache *WeaponsPrecache() = 0;
virtual IReGameHookRegistry_CSGameRules_Think *CSGameRules_Think() = 0;
virtual IReGameHookRegistry_CSGameRules_TeamFull *CSGameRules_TeamFull() = 0;
virtual IReGameHookRegistry_CSGameRules_TeamStacked *CSGameRules_TeamStacked() = 0;
Expand Down
10 changes: 10 additions & 0 deletions reapi/src/hook_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,16 @@ void BuyItem(IReGameHook_BuyItem *chain, CBasePlayer *pPlayer, int iSlot)
callVoidForward(RG_AddMultiDamage, original, indexOfEdict(pPlayer->pev), iSlot);
}

void WeaponsPrecache(IReGameHook_WeaponsPrecache *chain)
{
auto original = [chain]()
{
chain->callNext();
};

callVoidForward(RG_WeaponsPrecache, original);
}

void CSGameRules_Think(IReGameHook_CSGameRules_Think *chain)
{
auto original = [chain]()
Expand Down
1 change: 1 addition & 0 deletions reapi/src/hook_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ void ClearMultiDamage(IReGameHook_ClearMultiDamage *chain);
void AddMultiDamage(IReGameHook_AddMultiDamage *chain, entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
void ApplyMultiDamage(IReGameHook_ApplyMultiDamage *chain, entvars_t *pevInflictor, entvars_t *pevAttacker);
void BuyItem(IReGameHook_BuyItem *chain, CBasePlayer *pPlayer, int iSlot);
void WeaponsPrecache(IReGameHook_WeaponsPrecache *chain);
void CSGameRules_Think(IReGameHook_CSGameRules_Think *chain);
BOOL CSGameRules_TeamFull(IReGameHook_CSGameRules_TeamFull *chain, int team_id);
BOOL CSGameRules_TeamStacked(IReGameHook_CSGameRules_TeamStacked *chain, int newTeam_id, int curTeam_id);
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 @@ -145,6 +145,7 @@ hook_t hooklist_gamedll[] = {
DLL(AddMultiDamage),
DLL(ApplyMultiDamage),
DLL(BuyItem),
DLL(WeaponsPrecache),
};

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 @@ -160,6 +160,7 @@ enum GamedllFunc
RG_AddMultiDamage,
RG_ApplyMultiDamage,
RG_BuyItem,
RG_WeaponsPrecache,

// [...]
};
Expand Down

0 comments on commit d746c30

Please sign in to comment.