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

Implement RG_CreateWeaponBox hook (#275)

Interface was coded but never implemented. It needs tests
This commit is contained in:
Francisco Muñoz 2023-07-15 15:30:59 -04:00 committed by GitHub
parent e4783140ff
commit 3cbdc162a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 0 deletions

View File

@ -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,
};
/**

View File

@ -1329,6 +1329,18 @@ bool IsPenetrableEntity(IReGameHook_IsPenetrableEntity *chain, Vector &vecSrc, V
return callForward<bool>(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<CBasePlayerItem>(_pItem), getPrivate<CBasePlayer>(_pPlayerOwner), _modelName, vecOriginCopy, vecAnglesCopy, vecVelocityCopy, _lifeTime, _packAmmo));
};
return getPrivate<CWeaponBox>(callForward<size_t>(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)

View File

@ -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);

View File

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

View File

@ -144,6 +144,8 @@ enum GamedllFunc
RG_SpawnHeadGib,
RG_SpawnRandomGibs,
RG_CreateWeaponBox,
// [...]
};