diff --git a/mp/src/game/server/sdk/sdk_player.cpp b/mp/src/game/server/sdk/sdk_player.cpp index a61d79e5f..a199ddc49 100644 --- a/mp/src/game/server/sdk/sdk_player.cpp +++ b/mp/src/game/server/sdk/sdk_player.cpp @@ -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; } @@ -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(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(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; } diff --git a/mp/src/game/shared/sdk/weapon_akimbobase.h b/mp/src/game/shared/sdk/weapon_akimbobase.h index 02ddf0934..9d468af82 100644 --- a/mp/src/game/shared/sdk/weapon_akimbobase.h +++ b/mp/src/game/shared/sdk/weapon_akimbobase.h @@ -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 @@ -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); diff --git a/mp/src/game/shared/sdk/weapon_sdkbase.h b/mp/src/game/shared/sdk/weapon_sdkbase.h index 5334d073b..6a5bf5c56 100644 --- a/mp/src/game/shared/sdk/weapon_sdkbase.h +++ b/mp/src/game/shared/sdk/weapon_sdkbase.h @@ -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.