Code involved:
Reload for M3:
Code:
void CM3::Reload()
{
if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] <= 0 || m_iClip == SHOTGUN_MAX_CLIP )
{
return;
}
if ( m_flNextPrimaryAttack > UTIL_WeaponTimeBase() )
{
return;
}
switch ( m_fInSpecialReload )
{
case 0 :
{
m_pPlayer->SetAnimation( PLAYER_RELOAD );
SendWeaponAnim( M3_START_RELOAD, UseDecrement() );
m_fInSpecialReload = 1;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.55;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.55;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.55;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.55;
}
case 1 :
{
if ( m_flTimeWeaponIdle > gpGlobals->time )
{
return;
}
m_fInSpecialReload = 2;
SendWeaponAnim( M3_INSERT, UseDecrement() );
m_flNextReload = UTIL_WeaponTimeBase() + 0.45;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.45;
}
default :
{
m_iClip += 1;
m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] -= 1;
m_fInSpecialReload = 1;
m_pPlayer->ammo_buckshot--;
}
}
}
Reload for weapons (I used ak47 as example, they mostly equal to each other):
Code:
void CAK47::Reload()
{
if ( m_pPlayer->ammo_762nato && DefaultReload( AK47_MAX_CLIP, AK47_RELOAD, 2.45 ) )
{
m_pPlayer->SetAnimation( PLAYER_RELOAD );
m_flAccuracy = 0.2;
m_iShotsFired = 0;
m_bDelayFire = 0;
}
}
DefaultReload which is being called from any weapon reload (except shotguns)
Code:
BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay, int body )
{
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
return FALSE;
int j = min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
if (j == 0)
return FALSE;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay;
//!!UNDONE -- reload sound goes here !!!
SendWeaponAnim( iAnim, UseDecrement(), body );
m_fInReload = TRUE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3;
return TRUE;
}
__________________