mirror of
https://github.com/FWGS/hlsdk-xash3d
synced 2025-01-08 01:46:25 +01:00
Fix weapon reload bug. Use macros instead of magic numbers.
This commit is contained in:
parent
c28d86f748
commit
4ae58b4170
@ -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 )
|
||||
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 ) );
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -169,15 +169,15 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim )
|
||||
|
||||
void CGlock::Reload( void )
|
||||
{
|
||||
if( m_pPlayer->ammo_9mm <= 0 )
|
||||
return;
|
||||
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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
#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;
|
||||
}
|
||||
|
@ -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 )
|
||||
// don't bother with any of this if don't need to reload.
|
||||
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
|
||||
|
@ -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…
Reference in New Issue
Block a user