From 5bbba222189d2e8ed69e7aed3f446b08fac37568 Mon Sep 17 00:00:00 2001 From: s1lent Date: Thu, 2 Apr 2020 17:39:29 +0700 Subject: [PATCH] CreateWeaponBox: Remove constantly vector arguments --- regamedll/dlls/API/CAPI_Impl.h | 4 +-- regamedll/dlls/player.cpp | 35 +++++++++++++++++----- regamedll/dlls/player.h | 4 +-- regamedll/public/regamedll/regamedll_api.h | 4 +-- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h index fd6e23f01..af4876275 100644 --- a/regamedll/dlls/API/CAPI_Impl.h +++ b/regamedll/dlls/API/CAPI_Impl.h @@ -568,8 +568,8 @@ typedef IHookChainClassImpl CReGameHook_CBasePl typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropIdlePlayer; // CreateWeaponBox hook -typedef IHookChainImpl CReGameHook_CreateWeaponBox; -typedef IHookChainRegistryImpl CReGameHookRegistry_CreateWeaponBox; +typedef IHookChainImpl CReGameHook_CreateWeaponBox; +typedef IHookChainRegistryImpl CReGameHookRegistry_CreateWeaponBox; class CReGameHookchains: public IReGameHookchains { public: diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index a1fb5f3af..87cc3835c 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -1266,9 +1266,9 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva 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. 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); 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 CreateWeaponBox(pItem, pPlayer, modelName, - pPlayer->pev->origin, - pPlayer->pev->angles, - pPlayer->pev->velocity * 0.75f, + vecOrigin, + vecAngles, + vecVelocity, CGameRules::GetItemKillDelay(), packAmmo ); } @@ -1353,12 +1357,15 @@ void PackPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) vecAngles.x = 0.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. CreateWeaponBox(pItem, pPlayer, modelName, - pPlayer->pev->origin + dir, + vecOrigin, vecAngles, - pPlayer->pev->velocity * 0.75f, + vecVelocity, CGameRules::GetItemKillDelay(), packAmmo); } @@ -7852,7 +7859,19 @@ CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszIte } 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) { return nullptr; diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 4af1352ea..8f146c665 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -887,8 +887,8 @@ class CBasePlayer: public CBaseMonster { #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_OrigFunc(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, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo); class CWShield: public CBaseEntity { diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index c4ec98d9f..5ba789e00 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -465,8 +465,8 @@ typedef IHookChainClass IReGameHook_CBasePlayer typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropIdlePlayer; // CreateWeaponBox hook -typedef IHookChain IReGameHook_CreateWeaponBox; -typedef IHookChainRegistry IReGameHookRegistry_CreateWeaponBox; +typedef IHookChain IReGameHook_CreateWeaponBox; +typedef IHookChainRegistry IReGameHookRegistry_CreateWeaponBox; class IReGameHookchains { public: