Skip to content

Commit

Permalink
Fix mp5 autoswitching when primary ammo is depleted, even if player s…
Browse files Browse the repository at this point in the history
…till has secondary ammo

halflife issue #3001
  • Loading branch information
Solokiller committed Jan 31, 2021
1 parent c7f0146 commit a9b1d9c
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,16 +947,38 @@ BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax )
//=========================================================
BOOL CBasePlayerWeapon :: IsUseable( void )
{
if ( m_iClip <= 0 )
if (m_iClip > 0)
{
return TRUE;
}

//Player has unlimited ammo for this weapon or does not use magazines
if (iMaxAmmo1() == WEAPON_NOCLIP)
{
if ( m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] <= 0 && iMaxAmmo1() != -1 )
return TRUE;
}

if (m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0)
{
return TRUE;
}

if (pszAmmo2())
{
//Player has unlimited ammo for this weapon or does not use magazines
if (iMaxAmmo2() == WEAPON_NOCLIP)
{
// clip is empty (or nonexistant) and the player has no more ammo of this type.
return FALSE;
return TRUE;
}

if (m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] > 0)
{
return TRUE;
}
}

return TRUE;
// clip is empty (or nonexistant) and the player has no more ammo of this type.
return FALSE;
}

BOOL CBasePlayerWeapon :: CanDeploy( void )
Expand Down

0 comments on commit a9b1d9c

Please sign in to comment.