Skip to content

Commit

Permalink
Merge pull request BSVino#48 from TomyLobo/drop-single-akimbo
Browse files Browse the repository at this point in the history
Drop akimbo weapons one by one
  • Loading branch information
TomyLobo committed Apr 3, 2016
2 parents 1002ec0 + f14e7d4 commit f06a498
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
48 changes: 25 additions & 23 deletions mp/src/game/server/sdk/sdk_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2250,9 +2250,23 @@ bool CSDKPlayer::ThrowWeapon( CWeaponSDKBase* pWeapon, bool bAutoSwitch )

float flDiameter = sqrt( CollisionProp()->OBBSize().x * CollisionProp()->OBBSize().x + CollisionProp()->OBBSize().y * CollisionProp()->OBBSize().y );

SDKWeaponID eFallbackId = pWeapon->GetFallbackWeaponID();
SDKThrowWeapon(pWeapon, vecForward, gunAngles, flDiameter);

if (bAutoSwitch) SwitchToNextBestWeapon( NULL );
if (!bAutoSwitch)
return true;

if (eFallbackId != WEAPON_NONE)
{
CWeaponSDKBase *pFallbackWeapon = FindWeapon(eFallbackId);
if (pFallbackWeapon)
{
Weapon_Switch(pFallbackWeapon);
return true;
}
}

SwitchToNextBestWeapon( NULL );
return true;
}

Expand Down Expand Up @@ -2496,33 +2510,21 @@ void CSDKPlayer::SDKThrowWeapon( CWeaponSDKBase *pWeapon, const Vector &vecForwa

if (pWeapon->IsAkimbo())
{
// This is an akimbo weapon. Toss two singles instead.

CAkimboBase *pAkimbos = (CAkimboBase*)pWeapon;
// This is an akimbo weapon. Toss a single instead.
CAkimboBase *pAkimbos = static_cast<CAkimboBase *>(pWeapon);
const char *pszSingle = pWeapon->GetSDKWpnData().m_szSingle;
char name[32];
int i;

Q_snprintf (name, sizeof (name), "weapon_%s", pszSingle);
for (i = 0; i < 2; i++)
{
CWeaponSDKBase *pThrow = (CWeaponSDKBase*)Weapon_Create(name);
pThrow->VPhysicsDestroyObject();
pThrow->VPhysicsInitShadow(true, true);
if (i == 0)
pThrow->m_iClip1 = pAkimbos->m_iRightClip;
else
pThrow->m_iClip1 = pAkimbos->m_iLeftClip;
Q_snprintf(name, sizeof(name), "weapon_%s", pszSingle);
CWeaponSDKBase *pThrow = static_cast<CWeaponSDKBase *>(Weapon_Create(name));
pThrow->VPhysicsDestroyObject();
pThrow->VPhysicsInitShadow(true, true);
// Take ammo from the left clip. The right clip stays with the single variant
pThrow->m_iClip1 = pAkimbos->m_iLeftClip;

SDKThrowWeaponInternal(pThrow, vecForward, vecAngles, flDiameter);
}
RemovePlayerItem (pAkimbos);
SDKThrowWeaponInternal(pThrow, vecForward, vecAngles, flDiameter);

// Remove the single version also.
CWeaponSDKBase *pSingle = pAkimbos->FindSingleWeapon();
AssertMsg (pSingle, "How do you have akimbos without a single?");
if (pSingle)
RemovePlayerItem (pSingle);
RemovePlayerItem(pAkimbos);

return;
}
Expand Down
8 changes: 4 additions & 4 deletions mp/src/game/shared/sdk/weapon_akimbobase.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ Each pistol has its own ammo counter, and when one becomes empty before the
other then only the one with ammo will be fired. The right pistol has its
ammo synched with the single pistol, and because of this akimbos should
always give the player an equivalent single pistol. When players throw
akimbos two unique single variants are created, each one has its ammo
set to the left/right counters of the akimbos. When in use, the combined
total of the left and right counters are packed into m_iClip1 for display
purposes.
akimbos, the right pistol is kept and the left pistol is dropped as a single
variant. When in use, the combined total of the left and right counters are
packed into m_iClip1 for display purposes.
The current implementation is not optimal and is implemented in several
different places. It would be better to have a single weapon that functions
Expand Down Expand Up @@ -66,6 +65,7 @@ class CAkimboBase : public CWeaponSDKBase
#endif
CAkimboBase();
virtual bool IsPredicted() const { return true; }
virtual SDKWeaponID GetFallbackWeaponID( void ) const { return AliasToWeaponID(GetSDKWpnData().m_szSingle); }
virtual Activity ActivityOverride(Activity baseAct, bool *pRequired);
virtual int GetTracerAttachment(void);
virtual Activity GetIdleActivity(void);
Expand Down
1 change: 1 addition & 0 deletions mp/src/game/shared/sdk/weapon_sdkbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CWeaponSDKBase : public CBaseCombatWeapon
// All predicted weapons need to implement and return true
virtual bool IsPredicted() const { return true; }
virtual SDKWeaponID GetWeaponID( void ) const { return WEAPON_NONE; }
virtual SDKWeaponID GetFallbackWeaponID( void ) const { return WEAPON_NONE; }
virtual void Precache( void );

// Get SDK weapon specific weapon data.
Expand Down

0 comments on commit f06a498

Please sign in to comment.