Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop akimbo weapons one by one #48

Merged
merged 4 commits into from
Apr 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions mp/src/game/server/da/da_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2250,9 +2250,23 @@ bool CDAPlayer::ThrowWeapon( CWeaponDABase* pWeapon, bool bAutoSwitch )

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

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

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

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

SwitchToNextBestWeapon( NULL );
return true;
}

Expand Down Expand Up @@ -2496,33 +2510,21 @@ void CDAPlayer::SDKThrowWeapon( CWeaponDABase *pWeapon, const Vector &vecForward

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++)
{
CWeaponDABase *pThrow = (CWeaponDABase*)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);
CWeaponDABase *pThrow = static_cast<CWeaponDABase *>(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.
CWeaponDABase *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/da/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 CWeaponDABase
#endif
CAkimboBase();
virtual bool IsPredicted() const { return true; }
virtual DAWeaponID 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/da/weapon_dabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CWeaponDABase : public CBaseCombatWeapon
// All predicted weapons need to implement and return true
virtual bool IsPredicted() const { return true; }
virtual DAWeaponID GetWeaponID( void ) const { return WEAPON_NONE; }
virtual DAWeaponID GetFallbackWeaponID( void ) const { return WEAPON_NONE; }
virtual void Precache( void );

// Get SDK weapon specific weapon data.
Expand Down