diff --git a/src/game/client/swarm/c_asw_weapon.h b/src/game/client/swarm/c_asw_weapon.h index 84c1fc023..282f72540 100644 --- a/src/game/client/swarm/c_asw_weapon.h +++ b/src/game/client/swarm/c_asw_weapon.h @@ -105,6 +105,7 @@ class C_ASW_Weapon : public C_BaseCombatWeapon, public IASW_Client_Usable_Entity virtual void WeaponSound( WeaponSound_t sound_type, float soundtime = 0.0f ); virtual bool HasAmmo(); virtual bool PrimaryAmmoLoaded( void ); + virtual void NotifyIfNoneClip1Ammo( C_ASW_Marine *pMarine ); virtual float GetReloadTime(); virtual float GetReloadFailTime(); virtual bool Reload(); diff --git a/src/game/server/swarm/asw_weapon.h b/src/game/server/swarm/asw_weapon.h index 71355c08b..cee74687b 100644 --- a/src/game/server/swarm/asw_weapon.h +++ b/src/game/server/swarm/asw_weapon.h @@ -61,6 +61,7 @@ class CASW_Weapon : public CBaseCombatWeapon, public IASW_Server_Usable_Entity virtual float GetFireRate( void ); virtual bool HasAmmo(); virtual bool PrimaryAmmoLoaded( void ); + virtual void NotifyIfNoneClip1Ammo( CASW_Marine *pMarine ); virtual int LookupAttachment( const char *pAttachmentName ); virtual bool ShouldMarineMoveSlow(); // is the weapon in slow mode (when firing or reloading) diff --git a/src/game/shared/swarm/asw_weapon_cryo_cannon_shared.cpp b/src/game/shared/swarm/asw_weapon_cryo_cannon_shared.cpp index 1988910ab..bf4fb7340 100644 --- a/src/game/shared/swarm/asw_weapon_cryo_cannon_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_cryo_cannon_shared.cpp @@ -263,13 +263,7 @@ void CASW_Weapon_Cryo_Cannon::PrimaryAttack() { iShots = MIN( iShots, m_iClip1 ); m_iClip1 -= iShots; - -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_flamer_shared.cpp b/src/game/shared/swarm/asw_weapon_flamer_shared.cpp index 0c7716e7e..b75ab3d8f 100644 --- a/src/game/shared/swarm/asw_weapon_flamer_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_flamer_shared.cpp @@ -287,25 +287,7 @@ void CASW_Weapon_Flamer::PrimaryAttack( void ) // decrement ammo m_iClip1 -= 1; -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag* pAmmoBag = NULL; - CASW_Weapon* pWeapon = pMarine->GetASWWeapon(0); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - - if (!pAmmoBag) - { - pWeapon = pMarine->GetASWWeapon(1); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this) ) - pMarine->OnWeaponOutOfAmmo(true); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); /* if (!m_iClip1 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0) @@ -425,6 +407,7 @@ void CASW_Weapon_Flamer::SecondaryAttack( void ) { // decrement ammo m_iClip1 -= 2; + NotifyIfNoneClip1Ammo( pMarine ); } } if (!rd_flamer_infinite_extinguisher.GetBool() || m_iClip1 > 0) // only force the fire wait time if we have ammo for another shot diff --git a/src/game/shared/swarm/asw_weapon_flechette2_shared.cpp b/src/game/shared/swarm/asw_weapon_flechette2_shared.cpp index a7db8aa84..a3ceffd18 100644 --- a/src/game/shared/swarm/asw_weapon_flechette2_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_flechette2_shared.cpp @@ -133,26 +133,7 @@ void CASW_Weapon_Flechette2::PrimaryAttack() { iShots = MIN( iShots, m_iClip1 ); m_iClip1 -= iShots; - -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag *pAmmoBag = NULL; - CASW_Weapon *pWeapon = pMarine->GetASWWeapon( 0 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - - if ( !pAmmoBag ) - { - pWeapon = pMarine->GetASWWeapon( 1 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon( this ) ) - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_flechette_shared.cpp b/src/game/shared/swarm/asw_weapon_flechette_shared.cpp index 49074adbc..fbc548b85 100644 --- a/src/game/shared/swarm/asw_weapon_flechette_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_flechette_shared.cpp @@ -130,26 +130,7 @@ void CASW_Weapon_Flechette::PrimaryAttack() { iShots = MIN( iShots, m_iClip1 ); m_iClip1 -= iShots; - -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag *pAmmoBag = NULL; - CASW_Weapon *pWeapon = pMarine->GetASWWeapon( 0 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - - if ( !pAmmoBag ) - { - pWeapon = pMarine->GetASWWeapon( 1 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon( this ) ) - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_minigun.cpp b/src/game/shared/swarm/asw_weapon_minigun.cpp index e33267d4e..17607a178 100644 --- a/src/game/shared/swarm/asw_weapon_minigun.cpp +++ b/src/game/shared/swarm/asw_weapon_minigun.cpp @@ -229,26 +229,7 @@ void CASW_Weapon_Minigun::PrimaryAttack() iEffectiveClip -= info.m_iShots; m_iClip1 = ( iEffectiveClip + 1 ) / 2; m_bHalfShot = ( iEffectiveClip & 1 ) != 0; - -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag* pAmmoBag = NULL; - CASW_Weapon* pWeapon = pMarine->GetASWWeapon(0); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - - if (!pAmmoBag) - { - pWeapon = pMarine->GetASWWeapon(1); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this) ) - pMarine->OnWeaponOutOfAmmo(true); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_mining_laser_shared.cpp b/src/game/shared/swarm/asw_weapon_mining_laser_shared.cpp index 5ee90141a..29a5e322b 100644 --- a/src/game/shared/swarm/asw_weapon_mining_laser_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_mining_laser_shared.cpp @@ -550,25 +550,8 @@ bool CASW_Weapon_Mining_Laser::Fire( const Vector &vecOrigSrc, const Vector &vec // decrement ammo m_iClip1 -= 1; m_flAmmoUseTime = gpGlobals->curtime + 0.2; + NotifyIfNoneClip1Ammo( pMarine ); #ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag* pAmmoBag = NULL; - CASW_Weapon* pWeapon = pMarine->GetASWWeapon(0); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - - if (!pAmmoBag) - { - pWeapon = pMarine->GetASWWeapon(1); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this) ) - pMarine->OnWeaponOutOfAmmo(true); - } - pMarine->OnWeaponFired(this, 1); #endif } @@ -801,4 +784,4 @@ void CASW_Weapon_Mining_Laser::UpdateOnRemove() #endif BaseClass::UpdateOnRemove(); -} \ No newline at end of file +} diff --git a/src/game/shared/swarm/asw_weapon_pdw_shared.cpp b/src/game/shared/swarm/asw_weapon_pdw_shared.cpp index c72a92ed9..4fe10962a 100644 --- a/src/game/shared/swarm/asw_weapon_pdw_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_pdw_shared.cpp @@ -265,25 +265,7 @@ void CASW_Weapon_PDW::PrimaryAttack() for ( int k = 0; k < info.m_iShots; k++ ) { m_iClip1 -= 1; -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag *pAmmoBag = NULL; - CASW_Weapon *pWeapon = pMarine->GetASWWeapon( 0 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - - if ( !pAmmoBag ) - { - pWeapon = pMarine->GetASWWeapon( 1 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon( this ) ) - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } } else diff --git a/src/game/shared/swarm/asw_weapon_pistol_shared.cpp b/src/game/shared/swarm/asw_weapon_pistol_shared.cpp index 9eecb0a10..06bc2583b 100644 --- a/src/game/shared/swarm/asw_weapon_pistol_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_pistol_shared.cpp @@ -169,25 +169,7 @@ void CASW_Weapon_Pistol::PrimaryAttack( void ) { info.m_iShots = MIN( info.m_iShots, m_iClip1 ); m_iClip1 -= info.m_iShots; -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag* pAmmoBag = NULL; - CASW_Weapon* pWeapon = pMarine->GetASWWeapon(0); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - - if (!pAmmoBag) - { - pWeapon = pMarine->GetASWWeapon(1); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this) ) - pMarine->OnWeaponOutOfAmmo(true); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_plasma_thrower_shared.cpp b/src/game/shared/swarm/asw_weapon_plasma_thrower_shared.cpp index 39c656647..d6aeb722d 100644 --- a/src/game/shared/swarm/asw_weapon_plasma_thrower_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_plasma_thrower_shared.cpp @@ -324,13 +324,7 @@ void CASW_Weapon_Plasma_Thrower::PrimaryAttack() { info.m_iShots = MIN( info.m_iShots, m_iClip1 ); m_iClip1 -= info.m_iShots; - -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { @@ -491,12 +485,7 @@ void CASW_Weapon_Plasma_Thrower::SecondaryAttack() } m_iClip1 -= rd_plasma_thrower_airblast_ammo.GetInt(); -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); SendWeaponAnim( GetSecondaryAttackActivity() ); if ( pMarine ) diff --git a/src/game/shared/swarm/asw_weapon_railgun_shared.cpp b/src/game/shared/swarm/asw_weapon_railgun_shared.cpp index 03e77e2d7..93cf1b34d 100644 --- a/src/game/shared/swarm/asw_weapon_railgun_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_railgun_shared.cpp @@ -204,25 +204,7 @@ void CASW_Weapon_Railgun::PrimaryAttack() { info.m_iShots = MIN( info.m_iShots, m_iClip1 ); m_iClip1 -= info.m_iShots; -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag* pAmmoBag = NULL; - CASW_Weapon* pWeapon = pMarine->GetASWWeapon(0); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - - if (!pAmmoBag) - { - pWeapon = pMarine->GetASWWeapon(1); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this) ) - pMarine->OnWeaponOutOfAmmo(true); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_ricochet_shared.cpp b/src/game/shared/swarm/asw_weapon_ricochet_shared.cpp index d492f5c9c..573b6730f 100644 --- a/src/game/shared/swarm/asw_weapon_ricochet_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_ricochet_shared.cpp @@ -163,26 +163,7 @@ void CASW_Weapon_Ricochet::PrimaryAttack() { info.m_iShots = MIN( info.m_iShots, m_iClip1 ); m_iClip1 -= info.m_iShots; - -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag *pAmmoBag = NULL; - CASW_Weapon *pWeapon = pMarine->GetASWWeapon( 0 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - - if ( !pAmmoBag ) - { - pWeapon = pMarine->GetASWWeapon( 1 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon( this ) ) - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_rifle_burst_shared.cpp b/src/game/shared/swarm/asw_weapon_rifle_burst_shared.cpp index 8eb81f25e..ad6ccfb1a 100644 --- a/src/game/shared/swarm/asw_weapon_rifle_burst_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_rifle_burst_shared.cpp @@ -194,13 +194,7 @@ void CASW_Weapon_Rifle_Burst::DelayedAttack() { info.m_iShots = MIN( info.m_iShots, m_iClip1 ); m_iClip1 -= info.m_iShots; - -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_shared.cpp b/src/game/shared/swarm/asw_weapon_shared.cpp index 56d390e7c..a57b390fc 100644 --- a/src/game/shared/swarm/asw_weapon_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_shared.cpp @@ -655,6 +655,40 @@ bool CASW_Weapon::PrimaryAmmoLoaded( void ) return (m_iClip1 > 0); } +// if marine doesn't have ammo in an ammo bay +// call pMarine->OnWeaponOutOfAmmo( true ) +// +// `#ifdef GAME_DLL` in the body of this method +void CASW_Weapon::NotifyIfNoneClip1Ammo( CASW_Marine *pMarine ) +{ +#ifdef GAME_DLL + if ( m_iClip1 <= 0 && pMarine && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) + { + CASW_Weapon *pWeapon; + CASW_Weapon_Ammo_Bag *pAmmoBag = NULL; + + pWeapon = pMarine->GetASWWeapon(0); + if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) + { + pAmmoBag = assert_cast(pWeapon); + } + + if ( !pAmmoBag ) + { + pWeapon = pMarine->GetASWWeapon(1); + if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) + { + pAmmoBag = assert_cast(pWeapon); + } + } + + if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this) ) + { + pMarine->OnWeaponOutOfAmmo(true); + } + } +#endif // GAME_DLL +} void CASW_Weapon::PrimaryAttack( void ) { @@ -729,26 +763,7 @@ void CASW_Weapon::PrimaryAttack( void ) { info.m_iShots = MIN( info.m_iShots, m_iClip1 ); m_iClip1 -= info.m_iShots; - -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag *pAmmoBag = NULL; - CASW_Weapon *pWeapon = pMarine->GetASWWeapon( 0 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - - if ( !pAmmoBag ) - { - pWeapon = pMarine->GetASWWeapon( 1 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon( this ) ) - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_shotgun_shared.cpp b/src/game/shared/swarm/asw_weapon_shotgun_shared.cpp index f0a5d1e4f..b1c32a81c 100644 --- a/src/game/shared/swarm/asw_weapon_shotgun_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_shotgun_shared.cpp @@ -276,25 +276,7 @@ void CASW_Weapon_Shotgun::PrimaryAttack( void ) // decrement ammo m_iClip1 -= 1; -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine && pMarine->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag *pAmmoBag = NULL; - CASW_Weapon *pWeapon = pMarine->GetASWWeapon( 0 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - - if ( !pAmmoBag ) - { - pWeapon = pMarine->GetASWWeapon( 1 ); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast< CASW_Weapon_Ammo_Bag * >( pWeapon ); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon( this ) ) - pMarine->OnWeaponOutOfAmmo( true ); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } if ( m_iClip1 > 0 ) // only force the fire wait time if we have ammo for another shot diff --git a/src/game/shared/swarm/asw_weapon_sniper_rifle.cpp b/src/game/shared/swarm/asw_weapon_sniper_rifle.cpp index 31d103ea3..f2ba70c24 100644 --- a/src/game/shared/swarm/asw_weapon_sniper_rifle.cpp +++ b/src/game/shared/swarm/asw_weapon_sniper_rifle.cpp @@ -168,25 +168,7 @@ void CASW_Weapon_Sniper_Rifle::PrimaryAttack( void ) { info.m_iShots = MIN( info.m_iShots, m_iClip1 ); m_iClip1 -= info.m_iShots; -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag* pAmmoBag = NULL; - CASW_Weapon* pWeapon = pMarine->GetASWWeapon(0); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - - if (!pAmmoBag) - { - pWeapon = pMarine->GetASWWeapon(1); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this) ) - pMarine->OnWeaponOutOfAmmo(true); - } -#endif + NotifyIfNoneClip1Ammo( pMarine ); } else { diff --git a/src/game/shared/swarm/asw_weapon_tesla_gun_shared.cpp b/src/game/shared/swarm/asw_weapon_tesla_gun_shared.cpp index 463aaad9f..f37cdb98f 100644 --- a/src/game/shared/swarm/asw_weapon_tesla_gun_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_tesla_gun_shared.cpp @@ -200,6 +200,7 @@ void CASW_Weapon_Tesla_Gun::PrimaryAttack( void ) { m_iClip1 = MAX( 0, m_iClip1 - 1 ); m_flLastDischargeTime = gpGlobals->curtime; + NotifyIfNoneClip1Ammo( pMarine ); } m_flNextPrimaryAttack = gpGlobals->curtime; @@ -325,6 +326,7 @@ void CASW_Weapon_Tesla_Gun::ShockEntity() // decrement ammo m_iClip1 = MAX( 0, m_iClip1 - 1 ); + NotifyIfNoneClip1Ammo( pMarine ); CPASFilter filter( pShockBaseEntity->GetAbsOrigin() ); CBaseEntity::EmitSound( filter, SOUND_FROM_WORLD, "ASW_Tesla_Laser.Damage", &pShockBaseEntity->GetAbsOrigin() ); @@ -489,27 +491,6 @@ void CASW_Weapon_Tesla_Gun::Fire( const Vector &vecOrigSrc, const Vector &vecDir SetFiringState( ASW_TG_FIRE_DISCHARGE ); } - -#ifdef GAME_DLL - if ( m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) - { - // check he doesn't have ammo in an ammo bay - CASW_Weapon_Ammo_Bag* pAmmoBag = NULL; - CASW_Weapon* pWeapon = pMarine->GetASWWeapon(0); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - - if (!pAmmoBag) - { - pWeapon = pMarine->GetASWWeapon(1); - if ( pWeapon && pWeapon->Classify() == CLASS_ASW_AMMO_BAG ) - pAmmoBag = assert_cast(pWeapon); - } - if ( !pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this) ) - pMarine->OnWeaponOutOfAmmo(true); - } -#endif - if ( tr.DidHit() ) { vecDest = tr.endpos;