diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 38270e5..abc4bc9 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -400,6 +400,13 @@ enum GamedllFunc * Params: (pevVictim, cGibs, human) */ RG_SpawnRandomGibs, + + /* + * Description: Called when a player drops a weapon (usually manual drop or death) + * Return type: CWeaponBox * (Entity index of weaponbox) + * Params: (const weaponent, const owner, modelName[], Float:origin[3], Float:angles[3], Float:velocity[3], Float:lifeTime, bool:packAmmo) + */ + RG_CreateWeaponBox, }; /** diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 46f662c..4cca12d 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -1329,6 +1329,18 @@ bool IsPenetrableEntity(IReGameHook_IsPenetrableEntity *chain, Vector &vecSrc, V return callForward(RG_IsPenetrableEntity, original, getAmxVector(vecSrcCopy), getAmxVector(vecEndCopy), indexOfEdict(pevAttacker), indexOfEdict(pHit)); } +CWeaponBox *CreateWeaponBox(IReGameHook_CreateWeaponBox *chain, CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo) +{ + Vector vecOriginCopy(origin), vecAnglesCopy(angles), vecVelocityCopy(velocity); + + auto original = [chain, &vecOriginCopy, &vecAnglesCopy, &vecVelocityCopy](int _pItem, int _pPlayerOwner, const char *_modelName, cell _origin, cell _angles, cell _velocity, float _lifeTime, bool _packAmmo) + { + return indexOfPDataAmx(chain->callNext(getPrivate(_pItem), getPrivate(_pPlayerOwner), _modelName, vecOriginCopy, vecAnglesCopy, vecVelocityCopy, _lifeTime, _packAmmo)); + }; + + return getPrivate(callForward(RG_CreateWeaponBox, original, indexOfEdictAmx(pItem->pev), indexOfEdictAmx(pPlayerOwner->pev), modelName, getAmxVector(vecOriginCopy), getAmxVector(vecAnglesCopy), getAmxVector(vecVelocityCopy), lifeTime, packAmmo)); +} + CGib *SpawnHeadGib(IReGameHook_SpawnHeadGib *chain, entvars_t *pevVictim) { auto original = [chain](int _pevVictim) diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 0816bf5..0dc0df1 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -413,6 +413,7 @@ CGrenade *ThrowFlashbang(IReGameHook_ThrowFlashbang *chain, entvars_t *pevOwner, CGrenade *ThrowSmokeGrenade(IReGameHook_ThrowSmokeGrenade *chain, entvars_t *pevOwner, Vector &vecStart, Vector &vecVelocity, float time, unsigned short usEvent); CGrenade *PlantBomb(IReGameHook_PlantBomb *chain, entvars_t *pevOwner, Vector &vecStart, Vector &vecVelocity); bool IsPenetrableEntity(IReGameHook_IsPenetrableEntity *chain, Vector &vecSrc, Vector &vecEnd, entvars_t *pevAttacker, edict_t *pHit); +CWeaponBox *CreateWeaponBox(IReGameHook_CreateWeaponBox *chain, CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo); CGib *SpawnHeadGib(IReGameHook_SpawnHeadGib *chain, entvars_t *pevVictim); void SpawnRandomGibs(IReGameHook_SpawnRandomGibs *chain, entvars_t *pevVictim, int cGibs, int human); diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index 5699ecf..312ef37 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -130,6 +130,7 @@ hook_t hooklist_gamedll[] = { DLL(IsPenetrableEntity), DLL(SpawnHeadGib), DLL(SpawnRandomGibs), + DLL(CreateWeaponBox), }; hook_t hooklist_animating[] = { diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index 9112582..14b45b2 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -144,6 +144,8 @@ enum GamedllFunc RG_SpawnHeadGib, RG_SpawnRandomGibs, + RG_CreateWeaponBox, + // [...] };