//----------------------------------------------------------------------------- // Purpose: Switch to next best weapon // Input : // Output : //----------------------------------------------------------------------------- void CWeapon_SLAM::Weapon_Switch( void ) { // Note that we may pick the SLAM again, when we switch // weapons, in which case we have to save and restore the // detonator armed state. // The SLAMs may be about to blow up, but haven't done so yet // and the deploy function will find the undetonated charges // and we are armed bool saveState = m_bDetonatorArmed; CBaseCombatCharacter *pOwner = GetOwner(); pOwner->SwitchToNextBestWeapon( pOwner->GetActiveWeapon() ); if (pOwner->GetActiveWeapon() == this) { m_bDetonatorArmed = saveState; } #ifndef CLIENT_DLL // If not armed and have no ammo if (!m_bDetonatorArmed && pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0) { pOwner->ClearActiveWeapon(); } #endif }
//----------------------------------------------------------------------------- // Purpose: Put the rocket back on the end of the rocket launcher after we reload it. //----------------------------------------------------------------------------- void CGEWeaponRocketLauncher::OnReloadOffscreen(void) { BaseClass::OnReloadOffscreen(); CBaseCombatCharacter *pOwner = GetOwner(); if (!pOwner) return; if (pOwner->GetActiveWeapon() == this) SwitchBodygroup(1, 0); }
void CWeaponShotgun::OnReloadOffscreen(void) { BaseClass::OnReloadOffscreen(); CBaseCombatCharacter *pOwner = GetOwner(); if (!pOwner) return; if (pOwner->GetActiveWeapon() == this) CalculateShellVis(true); // Check shell count when we reload, but adjust for the amount of ammo we're about to take out of the clip. }
void CWeapon_Manhack::WeaponSwitch( void ) { CBaseCombatCharacter *pOwner = GetOwner(); if (pOwner==NULL) return; pOwner->SwitchToNextBestWeapon( pOwner->GetActiveWeapon() ); if (CPropVehicleManhack::GetManhackVehicle() == NULL && pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0) { pOwner->ClearActiveWeapon(); } }
bool CSDKPlayerAnimState::IsOuterGrenadePrimed() { CBaseCombatCharacter *pChar = m_pOuter->MyCombatCharacterPointer(); if ( pChar ) { CBaseSDKGrenade *pGren = dynamic_cast<CBaseSDKGrenade*>( pChar->GetActiveWeapon() ); return pGren && pGren->IsPinPulled(); } else { return false; } }