You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When player rans out of ammo except AR grenades MP5 won't allow to use that grenades because autoswitch. If Secondary Attack held, MP5 fires grenades but it's really a hassle. Also MP5 can be still selected in HUD because there's still AR grenades present.
This happens because BOOL CBasePlayerWeapon::IsUseable() only check the magazine (or clip) if there is one and the primary ammo reserve (9mm in the case of the 9mmAR) if there is one. It does not perform any check for the secondary ammo reserve (ARgrenades) as shown here.
Adding the secondary ammo check should be easy and could be implemented like this:
BOOL CBasePlayerWeapon :: IsUseable( void )
{
if ( m_iClip <= 0 )
{
if ( m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] <= 0 && iMaxAmmo1() != -1 )
{
if ( m_pPlayer->m_rgAmmo[ SecondaryAmmoIndex() ] <= 0 && iMaxAmmo2() != -1 )
{
// clip is empty (or nonexistant) and the player has no more ammo of these types.returnFALSE;
}
}
}
returnTRUE;
}
This part of the code here might require an update as well to check for m_flNextSecondaryAttack in addition to the existing checks for m_flNextPrimaryAttack. Looking at CMP5::SecondaryAttack()'s code, m_flNextPrimaryAttack and m_flNextSecondaryAttack are updated together with the same value so theorically speaking, that update shouldn't be needed for vanilla Half-Life 1 (but worth mentioning for mod makers/programmers).
@JoelTroch your fix assumes that SecondaryAmmoIndex returns a valid index. By default it returns -1, only if the weapon overrides the method to return m_iSecondaryAmmoType will it return anything else, and then only if the secondary ammo type information is filled in in GetItemInfo.
When player rans out of ammo except AR grenades MP5 won't allow to use that grenades because autoswitch. If Secondary Attack held, MP5 fires grenades but it's really a hassle. Also MP5 can be still selected in HUD because there's still AR grenades present.
Issue can be seen here:
https://streamable.com/8h8wsi
The text was updated successfully, but these errors were encountered: