Skip to content

Commit

Permalink
CreateWeaponBox: Remove constantly vector arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Apr 2, 2020
1 parent 73f5d6d commit 5bbba22
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
4 changes: 2 additions & 2 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ typedef IHookChainClassImpl<void, CBasePlayer, const char *> CReGameHook_CBasePl
typedef IHookChainRegistryClassImpl<void, CBasePlayer, const char *> CReGameHookRegistry_CBasePlayer_DropIdlePlayer;

// CreateWeaponBox hook
typedef IHookChainImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, const Vector &, const Vector &, const Vector &, float, bool> CReGameHook_CreateWeaponBox;
typedef IHookChainRegistryImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, const Vector &, const Vector &, const Vector &, float, bool> CReGameHookRegistry_CreateWeaponBox;
typedef IHookChainImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> CReGameHook_CreateWeaponBox;
typedef IHookChainRegistryImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> CReGameHookRegistry_CreateWeaponBox;

class CReGameHookchains: public IReGameHookchains {
public:
Expand Down
35 changes: 27 additions & 8 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions regamedll/public/regamedll/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ typedef IHookChainClass<void, CBasePlayer, const char *> IReGameHook_CBasePlayer
typedef IHookChainRegistryClass<void, CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropIdlePlayer;

// CreateWeaponBox hook
typedef IHookChain<class CWeaponBox *, class CBasePlayerItem *, class CBasePlayer *, const char *, const Vector &, const Vector &, const 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 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 *, Vector &, Vector &, Vector &, float, bool> IReGameHookRegistry_CreateWeaponBox;

class IReGameHookchains {
public:
Expand Down

0 comments on commit 5bbba22

Please sign in to comment.