CreateWeaponBox: Remove constantly vector arguments

This commit is contained in:
s1lent 2020-04-02 17:39:29 +07:00
parent 73f5d6d473
commit 5bbba22218
4 changed files with 33 additions and 14 deletions

View File

@ -568,8 +568,8 @@ typedef IHookChainClassImpl<void, CBasePlayer, const char *> CReGameHook_CBasePl
typedef IHookChainRegistryClassImpl<void, CBasePlayer, const char *> CReGameHookRegistry_CBasePlayer_DropIdlePlayer; typedef IHookChainRegistryClassImpl<void, CBasePlayer, const char *> CReGameHookRegistry_CBasePlayer_DropIdlePlayer;
// CreateWeaponBox hook // CreateWeaponBox hook
typedef IHookChainImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, const Vector &, const Vector &, const Vector &, float, bool> CReGameHook_CreateWeaponBox; typedef IHookChainImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> CReGameHook_CreateWeaponBox;
typedef IHookChainRegistryImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, const Vector &, const Vector &, const Vector &, float, bool> CReGameHookRegistry_CreateWeaponBox; typedef IHookChainRegistryImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> CReGameHookRegistry_CreateWeaponBox;
class CReGameHookchains: public IReGameHookchains { class CReGameHookchains: public IReGameHookchains {
public: public:

View File

@ -1266,9 +1266,9 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
return bTookDamage; return bTookDamage;
} }
LINK_HOOK_CHAIN(CWeaponBox *, CreateWeaponBox, (CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, const Vector &origin, const Vector &angles, const Vector &velocity, float lifeTime, bool packAmmo), pItem, pPlayerOwner, modelName, origin, angles, velocity, lifeTime, packAmmo) LINK_HOOK_CHAIN(CWeaponBox *, CreateWeaponBox, (CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo), pItem, pPlayerOwner, modelName, origin, angles, velocity, lifeTime, packAmmo)
CWeaponBox *EXT_FUNC __API_HOOK(CreateWeaponBox)(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, const Vector &origin, const Vector &angles, const Vector &velocity, float lifeTime, bool packAmmo) CWeaponBox *EXT_FUNC __API_HOOK(CreateWeaponBox)(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo)
{ {
// create a box to pack the stuff into. // create a box to pack the stuff into.
CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create("weaponbox", origin, angles, ENT(pPlayerOwner->pev)); CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create("weaponbox", origin, angles, ENT(pPlayerOwner->pev));
@ -1309,12 +1309,16 @@ void PackPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
const char *modelName = GetCSModelName(pItem->m_iId); const char *modelName = GetCSModelName(pItem->m_iId);
if (modelName) if (modelName)
{ {
Vector vecOrigin = pPlayer->pev->origin;
Vector vecAngles = pPlayer->pev->angles;
Vector vecVelocity = pPlayer->pev->velocity * 0.75f;
// create a box to pack the stuff into // create a box to pack the stuff into
CreateWeaponBox(pItem, pPlayer, CreateWeaponBox(pItem, pPlayer,
modelName, modelName,
pPlayer->pev->origin, vecOrigin,
pPlayer->pev->angles, vecAngles,
pPlayer->pev->velocity * 0.75f, vecVelocity,
CGameRules::GetItemKillDelay(), packAmmo CGameRules::GetItemKillDelay(), packAmmo
); );
} }
@ -1353,12 +1357,15 @@ void PackPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
vecAngles.x = 0.0f; vecAngles.x = 0.0f;
vecAngles.y += 45.0f; vecAngles.y += 45.0f;
Vector vecOrigin = pPlayer->pev->origin + dir;
Vector vecVelocity = pPlayer->pev->velocity * 0.75f;
// create a box to pack the stuff into. // create a box to pack the stuff into.
CreateWeaponBox(pItem, pPlayer, CreateWeaponBox(pItem, pPlayer,
modelName, modelName,
pPlayer->pev->origin + dir, vecOrigin,
vecAngles, vecAngles,
pPlayer->pev->velocity * 0.75f, vecVelocity,
CGameRules::GetItemKillDelay(), CGameRules::GetItemKillDelay(),
packAmmo); packAmmo);
} }
@ -7852,7 +7859,19 @@ CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszIte
} }
const char *modelname = GetCSModelName(pWeapon->m_iId); const char *modelname = GetCSModelName(pWeapon->m_iId);
CWeaponBox *pWeaponBox = CreateWeaponBox(pWeapon, this, modelname, pev->origin + gpGlobals->v_forward * 10, pev->angles, gpGlobals->v_forward * 300 + gpGlobals->v_forward * 100, CGameRules::GetItemKillDelay(), false);
Vector vecOrigin = pev->origin + gpGlobals->v_forward * 10;
Vector vecAngles = pev->angles;
Vector vecVelocity = gpGlobals->v_forward * 300 + gpGlobals->v_forward * 100;
CWeaponBox *pWeaponBox = CreateWeaponBox(pWeapon, this,
modelname,
vecOrigin,
vecAngles,
vecVelocity,
CGameRules::GetItemKillDelay(),
false);
if (!pWeaponBox) if (!pWeaponBox)
{ {
return nullptr; return nullptr;

View File

@ -887,8 +887,8 @@ public:
#endif #endif
}; };
CWeaponBox *CreateWeaponBox(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, const Vector &origin, const Vector &angles, const Vector &velocity, float lifeTime, bool packAmmo); CWeaponBox *CreateWeaponBox(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo);
CWeaponBox *CreateWeaponBox_OrigFunc(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, const Vector &origin, const Vector &angles, const Vector &velocity, float lifeTime, bool packAmmo); CWeaponBox *CreateWeaponBox_OrigFunc(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo);
class CWShield: public CBaseEntity class CWShield: public CBaseEntity
{ {

View File

@ -465,8 +465,8 @@ typedef IHookChainClass<void, CBasePlayer, const char *> IReGameHook_CBasePlayer
typedef IHookChainRegistryClass<void, CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropIdlePlayer; typedef IHookChainRegistryClass<void, CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropIdlePlayer;
// CreateWeaponBox hook // CreateWeaponBox hook
typedef IHookChain<class CWeaponBox *, class CBasePlayerItem *, class CBasePlayer *, const char *, const Vector &, const Vector &, const Vector &, float, bool> IReGameHook_CreateWeaponBox; typedef IHookChain<class CWeaponBox *, class CBasePlayerItem *, class CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> IReGameHook_CreateWeaponBox;
typedef IHookChainRegistry<class CWeaponBox *, class CBasePlayerItem *, class CBasePlayer *, const char *, const Vector &, const Vector &, const Vector &, float, bool> IReGameHookRegistry_CreateWeaponBox; typedef IHookChainRegistry<class CWeaponBox *, class CBasePlayerItem *, class CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> IReGameHookRegistry_CreateWeaponBox;
class IReGameHookchains { class IReGameHookchains {
public: public: