Oops. You are right.
I'll bump it there a bit later today.
Thanks!
void CBasePlayerWeapon::ItemPostFrame()
{
if ((m_fInReload) && (m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase()))
{
// complete the reload.
int j = V_min(iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
// Add them to the clip
m_iClip += j;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j;
To better understand how this code works.
int j
= we are looking for how many bullets we need in our current clip to get a full clip (or the maximum ammo amounts available)V_min(a,b)
= "j" will be either the necessary amount to make a full clip OR the remaining ammo amount left. (You can't get a full Glock clip if you only have 3 bullets in your inventory)m_iClip += j;
)if
and else
statements.void CBasePlayerWeapon::ItemPostFrame()
{
if ((m_fInReload) && (m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase()))
{
// get j count
int j = V_min(iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
// Add a full clip and permanently remove the previous one if a full clip is available
// m_iClip = MaxClip(); could work as well.
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= iMaxClip())
{
m_iClip += j;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= iMaxClip();
}
// Add the only remaining clip (full or not) and permanently remove the previous one.
else
{
m_iClip = m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType];
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] = 0;
}
Now, the only thing to do is to ensure that none of your guns share the same type of ammo.