Skip to content
Open
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
1 change: 1 addition & 0 deletions src/game/client/swarm/c_asw_weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/game/server/swarm/asw_weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 1 addition & 7 deletions src/game/shared/swarm/asw_weapon_cryo_cannon_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
20 changes: 1 addition & 19 deletions src/game/shared/swarm/asw_weapon_flamer_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
Expand Down
21 changes: 1 addition & 20 deletions src/game/shared/swarm/asw_weapon_flechette2_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
21 changes: 1 addition & 20 deletions src/game/shared/swarm/asw_weapon_flechette_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
21 changes: 1 addition & 20 deletions src/game/shared/swarm/asw_weapon_minigun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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
{
Expand Down
21 changes: 2 additions & 19 deletions src/game/shared/swarm/asw_weapon_mining_laser_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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);
}

pMarine->OnWeaponFired(this, 1);
#endif
}
Expand Down Expand Up @@ -801,4 +784,4 @@ void CASW_Weapon_Mining_Laser::UpdateOnRemove()
#endif

BaseClass::UpdateOnRemove();
}
}
20 changes: 1 addition & 19 deletions src/game/shared/swarm/asw_weapon_pdw_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 1 addition & 19 deletions src/game/shared/swarm/asw_weapon_pistol_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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
{
Expand Down
15 changes: 2 additions & 13 deletions src/game/shared/swarm/asw_weapon_plasma_thrower_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 )
Expand Down
20 changes: 1 addition & 19 deletions src/game/shared/swarm/asw_weapon_railgun_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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
{
Expand Down
21 changes: 1 addition & 20 deletions src/game/shared/swarm/asw_weapon_ricochet_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
8 changes: 1 addition & 7 deletions src/game/shared/swarm/asw_weapon_rifle_burst_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
55 changes: 35 additions & 20 deletions src/game/shared/swarm/asw_weapon_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 // GAME_DLL
}

void CASW_Weapon::PrimaryAttack( void )
{
Expand Down Expand Up @@ -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
{
Expand Down
Loading
Loading