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()
void CCrossbow::Reload( void ) void CCrossbow::Reload( void )
{ {
if( m_pPlayer->ammo_bolts <= 0 ) if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CROSSBOW_MAX_CLIP )
return; return;
if( m_pPlayer->pev->fov != 0 ) if( m_pPlayer->pev->fov != 0 )
@ -489,7 +489,7 @@ void CCrossbow::Reload( void )
SecondaryAttack(); 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 ) ); 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 )
BOOL CEgon::HasAmmo( void ) BOOL CEgon::HasAmmo( void )
{ {
if( m_pPlayer->ammo_uranium <= 0 ) if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
return FALSE; return FALSE;
return TRUE; return TRUE;

6
dlls/glock.cpp

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

4
dlls/python.cpp

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

7
dlls/rpg.cpp

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

Loading…
Cancel
Save