//----------------------------------------------------------------------------- // Purpose: Allows the weapon to choose proper weapon idle animation //----------------------------------------------------------------------------- void CBaseHL2MPCombatWeapon::WeaponIdle( void ) { //See if we should idle high or low if ( WeaponShouldBeLowered() ) { // Move to lowered position if we're not there yet if ( GetActivity() != ACT_VM_IDLE_LOWERED && GetActivity() != ACT_VM_IDLE_TO_LOWERED && GetActivity() != ACT_TRANSITION ) { SendWeaponAnim( ACT_VM_IDLE_LOWERED ); } else if ( HasWeaponIdleTimeElapsed() ) { // Keep idling low SendWeaponAnim( ACT_VM_IDLE_LOWERED ); } } else { // See if we need to raise immediately if ( m_flRaiseTime < gpGlobals->curtime && GetActivity() == ACT_VM_IDLE_LOWERED ) { SendWeaponAnim( ACT_VM_IDLE ); } else if ( HasWeaponIdleTimeElapsed() ) { SendWeaponAnim( ACT_VM_IDLE ); } } }
void CWeaponEgon::WeaponIdle( void ) { if ( !HasWeaponIdleTimeElapsed() ) return; if ( m_fireState != FIRE_OFF ) EndAttack(); int iAnim; float flRand = random->RandomFloat( 0,1 ); float flIdleTime; if ( flRand <= 0.5 ) { iAnim = ACT_VM_IDLE; flIdleTime = gpGlobals->curtime + random->RandomFloat( 10, 15 ); } else { iAnim = ACT_VM_FIDGET; flIdleTime = gpGlobals->curtime + 3.0; } SendWeaponAnim( iAnim ); SetWeaponIdleTime( flIdleTime ); }
void CWeaponGravityGun::WeaponIdle( void ) { if ( HasWeaponIdleTimeElapsed() ) { SendWeaponAnim( ACT_VM_IDLE ); if ( m_active ) { CBaseEntity *pObject = m_hObject; // pellet is touching object, so glue it if ( pObject && m_glueTouching ) { CGravityPellet *pPellet = m_activePellets[m_pelletAttract].pellet; if ( pPellet->MakeConstraint( pObject ) ) { WeaponSound( SPECIAL1 ); m_flNextPrimaryAttack = gpGlobals->curtime + 0.75; m_activePellets[m_pelletHeld].pellet->MakeInert(); } } EffectDestroy(); SoundDestroy(); } } }
//----------------------------------------------------------------------------- // Purpose: Idle updates the position of the build placement model //----------------------------------------------------------------------------- void CWeaponBuilder::WeaponIdle( void ) { CBaseTFPlayer *pOwner = ToBaseTFPlayer( GetOwner() ); if ( !pOwner ) return; // If we're in placement mode, update the placement model switch( m_iBuildState ) { case BS_PLACING: case BS_PLACING_INVALID: { if ( UpdatePlacement() ) { SetCurrentState( BS_PLACING ); } else { SetCurrentState( BS_PLACING_INVALID ); } } break; default: break; } if ( HasWeaponIdleTimeElapsed() ) { SendWeaponAnim( ACT_VM_IDLE ); } }
void CWeaponFlowerLauncher::ItemPostFrame( void ) { if ( m_bMustReload && HasWeaponIdleTimeElapsed() ) Reload(); BaseClass::ItemPostFrame(); }
void CWeaponSnark::WeaponIdle( void ) { CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( !pPlayer ) { return; } if ( !HasWeaponIdleTimeElapsed() ) return; if ( m_bJustThrown ) { m_bJustThrown = false; if ( pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) { if ( !pPlayer->SwitchToNextBestWeapon( pPlayer->GetActiveWeapon() ) ) Holster(); } else { SendWeaponAnim( ACT_VM_DRAW ); SetWeaponIdleTime( gpGlobals->curtime + random->RandomFloat( 10, 15 ) ); } } else { BaseClass::WeaponIdle(); } }
//----------------------------------------------------------------------------- // Purpose: Allows the weapon to choose proper weapon idle animation //----------------------------------------------------------------------------- void CBaseHLCombatWeapon::WeaponIdle( void ) { CBasePlayer *pPlayer = ToBasePlayer(GetOwner()); if ( pPlayer ) { if ( pPlayer->m_bIsRunning || !pPlayer->GetGroundEntity() || pPlayer->m_bShouldLowerWeapon ) return; } //See if we should idle high or low if ( WeaponShouldBeLowered() ) { #if !defined( CLIENT_DLL ) CHL2_Player *pPlayer = dynamic_cast<CHL2_Player*>(GetOwner()); if( pPlayer ) { pPlayer->Weapon_Lower(); } #endif // Move to lowered position if we're not there yet if ( GetActivity() != ACT_VM_IDLE_LOWERED && GetActivity() != ACT_VM_IDLE_TO_LOWERED && GetActivity() != ACT_TRANSITION ) { SendWeaponAnim( ACT_VM_IDLE_LOWERED ); } else if ( HasWeaponIdleTimeElapsed() ) { // Keep idling low SendWeaponAnim( ACT_VM_IDLE_LOWERED ); } } else { // See if we need to raise immediately if ( m_flRaiseTime < gpGlobals->curtime && GetActivity() == ACT_VM_IDLE_LOWERED ) { SendWeaponAnim( ACT_VM_IDLE ); } else if ( HasWeaponIdleTimeElapsed() ) { SendWeaponAnim( ACT_VM_IDLE ); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponCrossbow::ItemPostFrame() { // Allow zoom toggling CheckZoomToggle(); if ( m_bMustReload && HasWeaponIdleTimeElapsed() ) Reload(); BaseClass::ItemPostFrame(); }
//----------------------------------------------------------------------------- // Purpose: Idle updates the position of the build placement model //----------------------------------------------------------------------------- void CTFWeaponBuilder::WeaponIdle( void ) { CTFPlayer *pOwner = ToTFPlayer( GetOwner() ); if ( !pOwner ) return; if ( HasWeaponIdleTimeElapsed() ) { SendWeaponAnim( ACT_VM_IDLE ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponShock::ItemPostFrame( void ) { // Allow zoom toggling CheckZoomToggle(); if ( m_bMustReload && HasWeaponIdleTimeElapsed() ) { Reload(); } BaseClass::ItemPostFrame(); }
bool CWeaponShotgun::Reload( void ) { CBaseCombatCharacter *pOwner = GetOwner(); if ( pOwner == NULL ) return false; if ( pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) return false; if ( m_iClip1 >= GetMaxClip1() ) return false; // don't reload until recoil is done if ( m_flNextPrimaryAttack > gpGlobals->curtime ) return false; // check to see if we're ready to reload if ( m_fInSpecialReload == 0 ) { SendWeaponAnim( ACT_SHOTGUN_RELOAD_START ); m_fInSpecialReload = 1; pOwner->m_flNextAttack = gpGlobals->curtime + 0.6; SetWeaponIdleTime( gpGlobals->curtime + 0.6 ); m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; m_flNextSecondaryAttack = gpGlobals->curtime + 1.0; return true; } else if ( m_fInSpecialReload == 1 ) { if ( !HasWeaponIdleTimeElapsed() ) return false; // was waiting for gun to move to side m_fInSpecialReload = 2; // Play reload on different channel as otherwise steals channel away from fire sound WeaponSound( RELOAD ); SendWeaponAnim( ACT_VM_RELOAD ); SetWeaponIdleTime( gpGlobals->curtime + 0.5 ); } else { FillClip(); m_fInSpecialReload = 1; } return true; }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- void CWeapon_Tripwire::WeaponIdle( void ) { // Ready to switch animations? if ( HasWeaponIdleTimeElapsed() ) { if (m_bClearReload) { m_bNeedReload = false; m_bClearReload = false; } CBaseCombatCharacter *pOwner = GetOwner(); if (!pOwner) { return; } int iAnim = 0; if (m_bAttachTripwire) { TripwireAttach(); iAnim = ACT_SLAM_TRIPMINE_ATTACH2; } else if (m_bNeedReload) { // If owner had ammo draw the correct tripwire type if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) > 0) { iAnim = ACT_SLAM_TRIPMINE_DRAW; m_bClearReload = true; } else { pOwner->Weapon_Drop( this ); UTIL_Remove(this); } } else if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0) { pOwner->Weapon_Drop( this ); UTIL_Remove(this); } // If I don't need to reload just do the appropriate idle else { iAnim = ACT_SLAM_TRIPMINE_IDLE; } SendWeaponAnim( iAnim ); } }
//----------------------------------------------------------------------------- // Purpose: Idle tests to see if we're facing a valid target for the medikit // If so, move into the "heal-able" animation. // Otherwise, move into the "not-heal-able" animation. //----------------------------------------------------------------------------- void CWeaponMedigun::WeaponIdle( void ) { if ( HasWeaponIdleTimeElapsed() ) { // Loop the welding animation if ( m_bHealing ) { SendWeaponAnim( ACT_VM_PRIMARYATTACK ); return; } return BaseClass::WeaponIdle(); } }
void CGEWeaponGrenade::WeaponIdle( void ) { if ( HasWeaponIdleTimeElapsed() ) { if ( m_bDrawNext ) { m_bDrawNext = false; SendWeaponAnim( ACT_VM_DRAW ); m_flTimeWeaponIdle = gpGlobals->curtime + SequenceDuration(); } else SendWeaponAnim( ACT_VM_IDLE ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponMortar::WeaponIdle( void ) { if ( HasWeaponIdleTimeElapsed() ) { if ( m_bCarried ) { SendWeaponAnim( ACT_SLAM_TRIPMINE_IDLE ); } else { SendWeaponAnim( ACT_SLAM_DETONATOR_IDLE ); } SetWeaponIdleTime( gpGlobals->curtime + 1.0 ); } }
void CWeaponHgun::WeaponIdle( void ) { if ( !HasWeaponIdleTimeElapsed() ) return; int iAnim; float flRand = random->RandomFloat( 0, 1 ); if ( flRand <= 0.75 ) { iAnim = ACT_VM_IDLE; } else { iAnim = ACT_VM_FIDGET; } SendWeaponAnim( iAnim ); }
void CASW_Weapon_Chainsaw::WeaponIdle( void ) { if ( !HasWeaponIdleTimeElapsed() ) return; //Msg("%f CASW_Weapon_Chainsaw::WeaponIdle\n", gpGlobals->curtime); float flIdleTime; if ( m_fireState != FIRE_OFF ) { //Msg(" ending attack\n", gpGlobals->curtime); EndAttack(); flIdleTime = gpGlobals->curtime + 1.4f; } else { //Msg(" idle looping\n", gpGlobals->curtime); //EmitSound( "ASW_Chainsaw.IdleLoop" ); flIdleTime = gpGlobals->curtime + 1.7f; } //int iAnim; //float flRand = random->RandomFloat( 0,1 ); //if ( flRand <= 0.5 ) //{ //iAnim = ACT_VM_IDLE; //flIdleTime = gpGlobals->curtime + 1.4f; //} //else //{ //iAnim = ACT_VM_FIDGET; //flIdleTime = gpGlobals->curtime + 3.0; //} //SendWeaponAnim( iAnim ); SetWeaponIdleTime( flIdleTime ); }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- void CWeapon_SLAM::WeaponIdle( void ) { // Ready to switch animations? if ( HasWeaponIdleTimeElapsed() ) { // Don't allow throw to attach switch unless in idle m_flWallSwitchTime = gpGlobals->curtime + 50; if (m_bClearReload) { m_bNeedReload = false; m_bClearReload = false; } CBaseCombatCharacter *pOwner = GetOwner(); if (!pOwner) { return; } int iAnim = 0; if (m_bThrowSatchel) { SatchelThrow(); if (m_bDetonatorArmed && !m_bNeedDetonatorDraw) { iAnim = ACT_SLAM_THROW_THROW2; } else { iAnim = ACT_SLAM_THROW_THROW_ND2; } } else if (m_bAttachSatchel) { SatchelAttach(); if (m_bDetonatorArmed && !m_bNeedDetonatorDraw) { iAnim = ACT_SLAM_STICKWALL_ATTACH2; } else { iAnim = ACT_SLAM_STICKWALL_ND_ATTACH2; } } else if (m_bAttachTripmine) { TripmineAttach(); iAnim = ACT_SLAM_TRIPMINE_ATTACH2; } else if (m_bNeedReload) { // If owner had ammo draw the correct SLAM type if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) > 0) { switch( m_tSlamState) { case SLAM_TRIPMINE_READY: { iAnim = ACT_SLAM_TRIPMINE_DRAW; } break; case SLAM_SATCHEL_ATTACH: { if (m_bNeedDetonatorHolster) { iAnim = ACT_SLAM_STICKWALL_DETONATOR_HOLSTER; m_bNeedDetonatorHolster = false; } else if (m_bDetonatorArmed) { iAnim = m_bNeedDetonatorDraw ? ACT_SLAM_DETONATOR_STICKWALL_DRAW : ACT_SLAM_STICKWALL_DRAW; m_bNeedDetonatorDraw = false; } else { iAnim = ACT_SLAM_STICKWALL_ND_DRAW; } } break; case SLAM_SATCHEL_THROW: { if (m_bNeedDetonatorHolster) { iAnim = ACT_SLAM_THROW_DETONATOR_HOLSTER; m_bNeedDetonatorHolster = false; } else if (m_bDetonatorArmed) { iAnim = m_bNeedDetonatorDraw ? ACT_SLAM_DETONATOR_THROW_DRAW : ACT_SLAM_THROW_DRAW; m_bNeedDetonatorDraw = false; } else { iAnim = ACT_SLAM_THROW_ND_DRAW; } } break; } m_bClearReload = true; } // If no ammo and armed, idle with only the detonator else if (m_bDetonatorArmed) { iAnim = m_bNeedDetonatorDraw ? ACT_SLAM_DETONATOR_DRAW : ACT_SLAM_DETONATOR_IDLE; m_bNeedDetonatorDraw = false; } else { pOwner->Weapon_Drop( this ); UTIL_Remove(this); } } else if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0) { pOwner->Weapon_Drop( this ); UTIL_Remove(this); } // If I don't need to reload just do the appropriate idle else { switch( m_tSlamState) { case SLAM_TRIPMINE_READY: { iAnim = ACT_SLAM_TRIPMINE_IDLE; } break; case SLAM_SATCHEL_THROW: { if (m_bNeedDetonatorHolster) { iAnim = ACT_SLAM_THROW_DETONATOR_HOLSTER; m_bNeedDetonatorHolster = false; } else { iAnim = m_bDetonatorArmed ? ACT_SLAM_THROW_IDLE : ACT_SLAM_THROW_ND_IDLE; m_flWallSwitchTime = 0; } } break; case SLAM_SATCHEL_ATTACH: { if (m_bNeedDetonatorHolster) { iAnim = ACT_SLAM_STICKWALL_DETONATOR_HOLSTER; m_bNeedDetonatorHolster = false; } else { iAnim = m_bDetonatorArmed ? ACT_SLAM_STICKWALL_IDLE : ACT_SLAM_STICKWALL_ND_IDLE; m_flWallSwitchTime = 0; } } break; } } SendWeaponAnim( iAnim ); } }
void CWeaponShotgun::WeaponIdle( void ) { CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer == NULL ) return; pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); if ( m_flPumpTime && m_flPumpTime < gpGlobals->curtime ) { // play pumping sound WeaponSound( SPECIAL1 ); m_flPumpTime = 0; } if ( HasWeaponIdleTimeElapsed() ) { if ( m_iClip1 == 0 && m_fInSpecialReload == 0 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) > 0 ) { Reload(); } else if ( m_fInSpecialReload != 0 ) { if ( m_iClip1 != 8 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) > 0 ) { Reload( ); } else { // reload debounce has timed out SendWeaponAnim( ACT_SHOTGUN_PUMP ); // play cocking sound WeaponSound( SPECIAL1 ); m_fInSpecialReload = 0; SetWeaponIdleTime( gpGlobals->curtime + 1.5 ); } } else { int iAnim; float flRand = random->RandomFloat( 0, 1 ); if ( flRand <= 0.8 ) { iAnim = ACT_SHOTGUN_IDLE_DEEP; } else if ( flRand <= 0.95 ) { iAnim = ACT_VM_IDLE; } else { iAnim = ACT_SHOTGUN_IDLE4; } SendWeaponAnim( iAnim ); } } }
void CWeapon_Manhack::WeaponIdle( void ) { /*bool hasAmmo = false; CBaseCombatCharacter *pOwner = GetOwner(); if (pOwner==NULL) return false; if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) > 0) hasAmmo=true;*/ // Ready to switch animations? int iAnim; //TERO: lets set how many Manhacks we have online CBaseCombatCharacter *pOwner = GetOwner(); if (pOwner) { pOwner->SetAmmoCount( NumberOfManhacks(), m_iSecondaryAmmoType ); } if ( (HasNPCManhack() || !m_bHasAmmo) && !m_bSpawnSomeMore ) { iAnim=ACT_SLAM_DETONATOR_IDLE; m_bIsDoingController=true; UpdateControllerPanel(); //TERO: if (m_bIsDrawing) iAnim=ACT_SLAM_DETONATOR_DRAW; else if (m_bIsDoingShit) iAnim=ACT_SLAM_DETONATOR_DETONATE; else if (m_bIsDoingShitToo) iAnim=ACT_VM_HOLSTER; //ACT_SLAM_DETONATOR_THROW_DRAW if (HasWeaponIdleTimeElapsed() || m_bSkip) { SendWeaponAnim( iAnim ); m_bSkip=false; } } else { UpdateControllerPanel(); iAnim=ACT_VM_IDLE; m_bSkip =false; if (m_bIsDoingController) { m_bIsDoingShitToo=true; m_bRedraw=true; m_bSkip=true; m_bIsDoingController=false; } if ( HasWeaponIdleTimeElapsed() || m_bSkip ) { if (m_bIsDrawing) iAnim=ACT_VM_DRAW; else if (m_bIsDoingShit) iAnim=ACT_VM_THROW; else if (m_bIsDoingShitToo) iAnim=ACT_SLAM_DETONATOR_HOLSTER; SendWeaponAnim( iAnim ); } } }