bool CWeaponShotgun::Reload() { CSDKPlayer *pPlayer = GetPlayerOwner(); if (pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 || m_iClip1 == GetMaxClip1()) return true; // don't reload until recoil is done if (m_flNextPrimaryAttack > GetCurrentTime()) return true; CBaseViewModel *vm = pPlayer->GetViewModel( m_nViewModelIndex ); float flSpeedMultiplier = GetSDKWpnData().m_flReloadTimeMultiplier; // check to see if we're ready to reload if (m_iInSpecialReload == 0) { pPlayer->SetAnimation( PLAYER_RELOAD ); float flStartTime = 0.5f * flSpeedMultiplier; pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD ); SendWeaponAnim( ACT_SHOTGUN_RELOAD_START ); m_iInSpecialReload = 1; /* this is the only part of the reload sequence that can't be interrupted, seems unnecessary pPlayer->m_flNextAttack = GetCurrentTime() + flStartTime; m_flNextPrimaryAttack = GetCurrentTime() + flStartTime; m_flNextSecondaryAttack = GetCurrentTime() + flStartTime; */ SetWeaponIdleTime( GetCurrentTime() + flStartTime ); if (vm) vm->SetPlaybackRate( 1/flSpeedMultiplier ); pPlayer->Instructor_LessonLearned("reload"); return true; } else if (m_iInSpecialReload == 1) { if (m_flTimeWeaponIdle > GetCurrentTime()) return true; // was waiting for gun to move to side m_iInSpecialReload = 2; float flReloadTime = 0.45 * flSpeedMultiplier; SendWeaponAnim( ACT_VM_RELOAD ); SetWeaponIdleTime( GetCurrentTime() + flReloadTime ); pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_LOOP ); if (vm) vm->SetPlaybackRate( 1/flSpeedMultiplier ); } else if ( m_iInSpecialReload == 2 ) // Sanity, make sure it's actually in the right state. { // Add them to the clip m_iClip1 += 1; #ifdef GAME_DLL // Send a message to any clients that have this entity to play the reload. CPASFilter filter( pPlayer->GetAbsOrigin() ); filter.RemoveRecipient( pPlayer ); UserMessageBegin( filter, "ReloadEffect" ); WRITE_SHORT( pPlayer->entindex() ); MessageEnd(); #endif if ( pPlayer ) { bool bConsume = true; if (pPlayer->IsStyleSkillActive(SKILL_MARKSMAN)) bConsume = false; if (bConsume) pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType ); } if ( pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 || m_iClip1 == GetMaxClip1() ) pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_END ); m_iInSpecialReload = 1; } return true; }