Browse Source

Fix weapon reload bug. Use macros instead of magic numbers.

halloween
Night Owl 8 years ago
parent
commit
4ae58b4170
  1. 4
      dlls/crossbow.cpp
  2. 2
      dlls/egon.cpp
  3. 6
      dlls/glock.cpp
  4. 4
      dlls/python.cpp
  5. 7
      dlls/rpg.cpp
  6. 2
      dlls/shotgun.cpp

4
dlls/crossbow.cpp

@ -481,7 +481,7 @@ void CCrossbow::SecondaryAttack() @@ -481,7 +481,7 @@ void CCrossbow::SecondaryAttack()
void CCrossbow::Reload( void )
{
if( m_pPlayer->ammo_bolts <= 0 )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CROSSBOW_MAX_CLIP )
return;
if( m_pPlayer->pev->fov != 0 )
@ -489,7 +489,7 @@ void CCrossbow::Reload( void ) @@ -489,7 +489,7 @@ void CCrossbow::Reload( void )
SecondaryAttack();
}
if( DefaultReload( 5, CROSSBOW_RELOAD, 4.5 ) )
if( DefaultReload( CROSSBOW_MAX_CLIP, CROSSBOW_RELOAD, 4.5 ) )
{
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) );
}

2
dlls/egon.cpp

@ -143,7 +143,7 @@ float CEgon::GetDischargeInterval( void ) @@ -143,7 +143,7 @@ float CEgon::GetDischargeInterval( void )
BOOL CEgon::HasAmmo( void )
{
if( m_pPlayer->ammo_uranium <= 0 )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
return FALSE;
return TRUE;

6
dlls/glock.cpp

@ -169,15 +169,15 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) @@ -169,15 +169,15 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim )
void CGlock::Reload( void )
{
if( m_pPlayer->ammo_9mm <= 0 )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == GLOCK_MAX_CLIP )
return;
int iResult;
if( m_iClip == 0 )
iResult = DefaultReload( 17, GLOCK_RELOAD, 1.5 );
iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD, 1.5 );
else
iResult = DefaultReload( 17, GLOCK_RELOAD_NOT_EMPTY, 1.5 );
iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD_NOT_EMPTY, 1.5 );
if( iResult )
{

4
dlls/python.cpp

@ -212,7 +212,7 @@ void CPython::PrimaryAttack() @@ -212,7 +212,7 @@ void CPython::PrimaryAttack()
void CPython::Reload( void )
{
if( m_pPlayer->ammo_357 <= 0 )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == PYTHON_MAX_CLIP )
return;
if( m_pPlayer->pev->fov != 0 )
@ -227,7 +227,7 @@ void CPython::Reload( void ) @@ -227,7 +227,7 @@ void CPython::Reload( void )
#else
bUseScope = g_pGameRules->IsMultiplayer();
#endif
if( DefaultReload( 6, PYTHON_RELOAD, 2.0, bUseScope ) )
if( DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.0, bUseScope ) )
{
m_flSoundDelay = 1.5;
}

7
dlls/rpg.cpp

@ -278,13 +278,8 @@ void CRpg::Reload( void ) @@ -278,13 +278,8 @@ void CRpg::Reload( void )
{
int iResult = 0;
if( m_iClip == 1 )
{
// don't bother with any of this if don't need to reload.
return;
}
if( m_pPlayer->ammo_rockets <= 0 )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == RPG_MAX_CLIP )
return;
// because the RPG waits to autoreload when no missiles are active while the LTD is on, the

2
dlls/shotgun.cpp

@ -320,7 +320,7 @@ void CShotgun::WeaponIdle( void ) @@ -320,7 +320,7 @@ void CShotgun::WeaponIdle( void )
}
else if( m_fInSpecialReload != 0 )
{
if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
if( m_iClip != SHOTGUN_MAX_CLIP && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
Reload();
}

Loading…
Cancel
Save