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 > gpGlobals->curtime) return true; // check to see if we're ready to reload if (m_fInSpecialReload == 0) { pPlayer->SetAnimation( PLAYER_RELOAD ); SendWeaponAnim( ACT_SHOTGUN_RELOAD_START ); m_fInSpecialReload = 1; pPlayer->m_flNextAttack = gpGlobals->curtime + 0.5; m_flNextPrimaryAttack = gpGlobals->curtime + 0.5; m_flNextSecondaryAttack = gpGlobals->curtime + 0.5; SetWeaponIdleTime( gpGlobals->curtime + 0.5 ); return true; } else if (m_fInSpecialReload == 1) { if (m_flTimeWeaponIdle > gpGlobals->curtime) return true; // was waiting for gun to move to side m_fInSpecialReload = 2; SendWeaponAnim( ACT_VM_RELOAD ); SetWeaponIdleTime( gpGlobals->curtime + 0.45 ); } else { // Add them to the clip m_iClip1 += 1; #ifdef GAME_DLL SendReloadEvents(); #endif CSDKPlayer *pPlayer = GetPlayerOwner(); if ( pPlayer ) pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType ); m_fInSpecialReload = 1; } return true; }
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: //----------------------------------------------------------------------------- void CBaseSDKGrenade::SecondaryAttack() { if ( m_bRedraw ) return; CSDKPlayer *pPlayer = GetPlayerOwner(); if ( pPlayer == NULL ) return; //See if we're ducking //if ( pPlayer->GetFlags() & FL_DUCKING ) //{ // //Send the weapon animation // SendWeaponAnim( ACT_VM_SECONDARYATTACK ); //} //else { //Send the weapon animation SendWeaponAnim( ACT_VM_HAULBACK ); } // Don't let weapon idle interfere in the middle of a throw! SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() ); //Tony; updated; minimum grenade tossing time is 1 second delay! + sequence m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration() + 1.0; m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration() + 1.0; }
void CASW_Weapon_Chainsaw::EndAttack( void ) { if ( m_fireState != FIRE_OFF ) { StartAttackOffSound(); #ifdef CLIENT_DLL DispatchParticleEffect( "mining_laser_exhaust", PATTACH_POINT_FOLLOW, this, "eject1" ); #endif } StopChainsawSound(); SetWeaponIdleTime( gpGlobals->curtime + 2.0 ); m_flNextPrimaryAttack = gpGlobals->curtime + GetWeaponInfo()->m_flFireRate; m_flNextSecondaryAttack = gpGlobals->curtime + GetWeaponInfo()->m_flFireRate; SetFiringState(FIRE_OFF); ClearIsFiring(); DestroyEffect(); }
// ---------------------------------------------------------------------------- - // Purpose: //----------------------------------------------------------------------------- void CTFCompoundBow::FireArrow( void ) { // Get the player owning the weapon. CTFPlayer *pPlayer = GetTFPlayerOwner(); if ( !pPlayer ) return; CalcIsAttackCritical(); SendWeaponAnim( ACT_VM_PRIMARYATTACK ); pPlayer->SetAnimation( PLAYER_ATTACK1 ); pPlayer->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY ); pPlayer->m_Shared.RemoveCond( TF_COND_AIMING ); pPlayer->TeamFortress_SetSpeed(); FireProjectile( pPlayer ); #if !defined( CLIENT_DLL ) pPlayer->SpeakWeaponFire(); CTF_GameStats.Event_PlayerFiredWeapon( pPlayer, IsCurrentAttackACrit() ); #endif // Set next attack times. float flDelay = m_pWeaponInfo->GetWeaponData( m_iWeaponMode ).m_flTimeFireDelay; CALL_ATTRIB_HOOK_FLOAT( flDelay, mult_postfiredelay ); m_flNextPrimaryAttack = gpGlobals->curtime + flDelay; SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() ); m_flChargeBeginTime = 0.0f; }
//----------------------------------------------------------------------------- // Purpose: // // //----------------------------------------------------------------------------- void CHLSelectFireMachineGun::PrimaryAttack( void ) { if (m_bFireOnEmpty) { return; } switch( m_iFireMode ) { case FIREMODE_FULLAUTO: BaseClass::PrimaryAttack(); // Msg("%.3f\n", m_flNextPrimaryAttack.Get() ); SetWeaponIdleTime( gpGlobals->curtime + 3.0f ); break; case FIREMODE_3RNDBURST: m_iBurstSize = GetBurstSize(); // Call the think function directly so that the first round gets fired immediately. BurstThink(); SetThink( &CHLSelectFireMachineGun::BurstThink ); m_flNextPrimaryAttack = gpGlobals->curtime + GetBurstCycleRate(); m_flNextSecondaryAttack = gpGlobals->curtime + GetBurstCycleRate(); // Pick up the rest of the burst through the think function. SetNextThink( gpGlobals->curtime + GetFireRate() ); break; } CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner ) { m_iPrimaryAttacks++; gamestats->Event_WeaponFired( pOwner, true, GetClassname() ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseSDKGrenade::SecondaryAttack() { if ( m_bRedraw ) return; CSDKPlayer *pPlayer = GetPlayerOwner(); if ( pPlayer == NULL ) return; //See if we're ducking if ( pPlayer->GetFlags() & FL_DUCKING ) { //Send the weapon animation SendWeaponAnim( ACT_VM_SECONDARYATTACK ); } else { //Send the weapon animation SendWeaponAnim( ACT_VM_HAULBACK ); } // Don't let weapon idle interfere in the middle of a throw! SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() ); m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration(); }
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 CWeaponElite::WeaponIdle() { CCSPlayer *pPlayer = GetPlayerOwner(); if ( !pPlayer ) return; if (m_flTimeWeaponIdle > gpGlobals->curtime) return; if ( pPlayer->HasShield() ) { SetWeaponIdleTime( gpGlobals->curtime + 20 ); //MIKETODO: shields //if ( FBitSet(m_iWeaponState, WPNSTATE_SHIELD_DRAWN) ) // SendWeaponAnim( GLOCK18_SHIELD_IDLE, UseDecrement() ? 1:0 ); } else { // only idle if the slid isn't back if (m_iClip1 != 0) { if ( m_iClip1 == 1 ) SendWeaponAnim( ACT_VM_IDLE_EMPTY_LEFT ); else SendWeaponAnim( ACT_VM_IDLE ); } } }
//----------------------------------------------------------------------------- // Purpose: // Input : *pPlayer - //----------------------------------------------------------------------------- void CTFWeaponBaseMelee::Swing( CTFPlayer *pPlayer ) { CalcIsAttackCritical(); // Play the melee swing and miss (whoosh) always. SendPlayerAnimEvent( pPlayer ); DoViewModelAnimation(); // Set next attack times. m_flNextPrimaryAttack = gpGlobals->curtime + m_pWeaponInfo->GetWeaponData( m_iWeaponMode ).m_flTimeFireDelay; SetWeaponIdleTime( m_flNextPrimaryAttack + m_pWeaponInfo->GetWeaponData( m_iWeaponMode ).m_flTimeIdleEmpty ); if ( IsCurrentAttackACrit() ) { WeaponSound( BURST ); } else { WeaponSound( MELEE_MISS ); } m_flSmackTime = gpGlobals->curtime + m_pWeaponInfo->GetWeaponData( m_iWeaponMode ).m_flSmackDelay; }
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: //----------------------------------------------------------------------------- void CTFFlareGun::LaunchProjectile(void) { // Get the player owning the weapon. CTFPlayer *pPlayer = ToTFPlayer(GetPlayerOwner()); if (!pPlayer) return; CalcIsAttackCritical(); SendWeaponAnim(ACT_VM_PRIMARYATTACK); pPlayer->SetAnimation(PLAYER_ATTACK1); pPlayer->DoAnimationEvent(PLAYERANIMEVENT_ATTACK_PRIMARY); FireProjectile(pPlayer); #if !defined( CLIENT_DLL ) pPlayer->SpeakWeaponFire(); CTF_GameStats.Event_PlayerFiredWeapon(pPlayer, IsCurrentAttackACrit()); #endif // Set next attack times. m_flNextPrimaryAttack = gpGlobals->curtime + m_pWeaponInfo->GetWeaponData(m_iWeaponMode).m_flTimeFireDelay; SetWeaponIdleTime(gpGlobals->curtime + SequenceDuration()); // Check the reload mode and behave appropriately. if (m_bReloadsSingly) { m_iReloadMode.Set(TF_RELOAD_START); } }
void CWeaponFlowerLauncher::PrimaryAttack( void ) { FireBolt(); m_bMustReload = true; SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration( ACT_VM_PRIMARYATTACK ) ); }
void PrimaryAttack() { m_flNextPrimaryAttack = gpGlobals->curtime + FLT_MAX; SetWeaponIdleTime( FLT_MAX ); m_flBeamTime = gpGlobals->curtime + 0.2f; m_flDamageTime = gpGlobals->curtime + 0.2f; }
bool CTFWeaponInvis::Deploy( void ) { bool b = BaseClass::Deploy(); SetWeaponIdleTime( gpGlobals->curtime + 1.5 ); return b; }
bool CTFWeaponInvis::Holster( CBaseCombatWeapon *pSwitchingTo ) { bool bHolster = BaseClass::Holster( pSwitchingTo ); // far in the future SetWeaponIdleTime( gpGlobals->curtime + 10 ); return bHolster; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGrapple::PrimaryAttack(void) { // Can't have an active hook out if (m_hHook != NULL) return; FireHook(); SetWeaponIdleTime(gpGlobals->curtime + SequenceDuration(ACT_VM_PRIMARYATTACK)); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseSDKGrenade::ItemPostFrame() { CSDKPlayer *pPlayer = GetPlayerOwner(); if ( !pPlayer ) return; CBaseViewModel *vm = pPlayer->GetViewModel( m_nViewModelIndex ); if ( !vm ) return; // If they let go of the fire button, they want to throw the grenade. if ( m_bPinPulled && !(pPlayer->m_nButtons & IN_ATTACK) ) { pPlayer->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY ); // if (m_bSecondary) // DropGrenade(); // else ThrowGrenade(); DecrementAmmo( pPlayer ); m_bPinPulled = false; SendWeaponAnim( ACT_VM_THROW ); SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() ); m_bPinPulled = false; // m_bSecondary = false; } else if( m_bRedraw ) { // Has the throw animation finished playing if( m_flTimeWeaponIdle < gpGlobals->curtime ) { // if we're officially out of grenades, ditch this weapon if( pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) { #ifdef GAME_DLL pPlayer->Weapon_Drop( this, NULL, NULL ); UTIL_Remove(this); #endif pPlayer->SwitchToNextBestWeapon( NULL ); //Tony; now switch! cuz we rans outs! } else { m_bRedraw = false; m_flNextPrimaryAttack = gpGlobals->curtime + 1.2; m_flNextSecondaryAttack = gpGlobals->curtime + 1.2; SendWeaponAnim( GetDeployActivity() ); } return; //don't animate this grenade any more! } } else if( !m_bRedraw ) { BaseClass::ItemPostFrame(); } }
void CWeaponMP5::PrimaryAttack( void ) { const CSDKWeaponInfo &pWeaponInfo = GetSDKWpnData(); CSDKPlayer *pPlayer = GetPlayerOwner(); float flCycleTime = pWeaponInfo.m_flCycleTime; bool bPrimaryMode = true; float flSpread = 0.01f; // more spread when jumping if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) ) flSpread = 0.05f; pPlayer->m_iShotsFired++; // Out of ammo? if ( m_iClip1 <= 0 ) { if (m_bFireOnEmpty) { PlayEmptySound(); m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; } } SendWeaponAnim( ACT_VM_PRIMARYATTACK ); m_iClip1--; // player "shoot" animation pPlayer->SetAnimation( PLAYER_ATTACK1 ); FX_FireBullets( pPlayer->entindex(), pPlayer->Weapon_ShootPosition(), pPlayer->EyeAngles() + pPlayer->GetPunchAngle(), GetWeaponID(), bPrimaryMode?Primary_Mode:Secondary_Mode, CBaseEntity::GetPredictionRandomSeed() & 255, flSpread ); pPlayer->DoMuzzleFlash(); m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + flCycleTime; if (!m_iClip1 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0) { // HEV suit - indicate out of ammo condition pPlayer->SetSuitUpdate("!HEV_AMO0", false, 0); } // start idle animation in 5 seconds SetWeaponIdleTime( gpGlobals->curtime + 5.0 ); }
void CWeaponMP5::SecondaryAttack( void ) { // Only the player fires this way so we can cast CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if (!pPlayer) { return; } if ( pPlayer->GetAmmoCount( m_iSecondaryAmmoType ) <= 0 ) { DryFire( ); return; } WeaponSound(DOUBLE); pPlayer->m_fEffects |= EF_MUZZLEFLASH; Vector vecSrc = pPlayer->Weapon_ShootPosition(); Vector vecThrow = pPlayer->GetAutoaimVector( 0 ) * 800; QAngle angGrenAngle; VectorAngles( vecThrow, angGrenAngle ); CGrenadeMP5 * m_pMyGrenade = (CGrenadeMP5*)Create( "grenade_mp5", vecSrc, angGrenAngle, GetOwner() ); m_pMyGrenade->SetAbsVelocity( vecThrow ); m_pMyGrenade->SetLocalAngularVelocity( QAngle( random->RandomFloat( -100, -500 ), 0, 0 ) ); m_pMyGrenade->SetMoveType( MOVETYPE_FLYGRAVITY ); m_pMyGrenade->SetOwner( GetOwner() ); m_pMyGrenade->SetDamage( sk_plr_dmg_mp5_grenade.GetFloat() ); SendWeaponAnim( ACT_VM_SECONDARYATTACK ); pPlayer->SetAnimation( PLAYER_ATTACK1 ); pPlayer->ViewPunch( QAngle( -10, 0, 0 ) ); // Register a muzzleflash for the AI. pPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 0.5 ); CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 400, 0.2 ); // Decrease ammo pPlayer->RemoveAmmo( 1, m_iSecondaryAmmoType ); if ( pPlayer->GetAmmoCount( m_iSecondaryAmmoType ) <= 0 ) { // HEV suit - indicate out of ammo condition pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); } m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; m_flNextSecondaryAttack = gpGlobals->curtime + 1.0; SetWeaponIdleTime( gpGlobals->curtime + 5.0 ); }
bool CASW_Weapon_Chainsaw::Deploy( void ) { SetFiringState(FIRE_OFF); m_bPlayedIdleSound = true; EmitSound( "ASW_Chainsaw.Start" ); SetWeaponIdleTime( gpGlobals->curtime + 0.7f ); return BaseClass::Deploy(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSnark::PrimaryAttack( void ) { // Only the player fires this way so we can cast CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( !pPlayer ) { return; } if ( pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) return; Vector vecForward; pPlayer->EyeVectors( &vecForward ); // find place to toss monster // Does this need to consider a crouched player? Vector vecStart = pPlayer->WorldSpaceCenter() + (vecForward * 20); Vector vecEnd = vecStart + (vecForward * 44); trace_t tr; UTIL_TraceLine( vecStart, vecEnd, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); if ( tr.allsolid || tr.startsolid || tr.fraction <= 0.25 ) return; // player "shoot" animation SendWeaponAnim( ACT_VM_PRIMARYATTACK ); pPlayer->SetAnimation( PLAYER_ATTACK1 ); CSnark *pSnark = (CSnark*)Create( "monster_snark", tr.endpos, pPlayer->EyeAngles(), GetOwner() ); if ( pSnark ) { pSnark->SetAbsVelocity( vecForward * 200 + pPlayer->GetAbsVelocity() ); } // play hunt sound CPASAttenuationFilter filter( this ); switch ( random->RandomInt( 0, 1 ) ) { case 0: enginesound->EmitSound( filter, entindex(), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, 105 ); break; case 1: enginesound->EmitSound( filter, entindex(), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, 105 ); break; } CSoundEnt::InsertSound( SOUND_DANGER, GetAbsOrigin(), 200, 0.2 ); pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType ); m_bJustThrown = true; m_flNextPrimaryAttack = gpGlobals->curtime + 0.3; SetWeaponIdleTime( gpGlobals->curtime + 1.0 ); }
void CWeaponMP5::PrimaryAttack( void ) { // Only the player fires this way so we can cast CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( !pPlayer ) { return; } if ( m_iClip1 <= 0 ) { DryFire(); return; } WeaponSound( SINGLE ); pPlayer->m_fEffects |= EF_MUZZLEFLASH; m_iClip1--; SendWeaponAnim( ACT_VM_PRIMARYATTACK ); pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_flNextPrimaryAttack = gpGlobals->curtime + 0.1; Vector vecSrc = pPlayer->Weapon_ShootPosition(); Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); if ( !g_pGameRules->IsMultiplayer() ) { // optimized multiplayer. Widened to make it easier to hit a moving player pPlayer->FireBullets( 1, vecSrc, vecAiming, VECTOR_CONE_6DEGREES, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2 ); } else { // single player spread pPlayer->FireBullets( 1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2 ); } pPlayer->ViewPunch( QAngle( random->RandomFloat( -2, 2 ), 0, 0 ) ); pPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 0.5 ); CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 400, 0.2 ); if ( !m_iClip1 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) { // HEV suit - indicate out of ammo condition pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); } SetWeaponIdleTime( gpGlobals->curtime + random->RandomFloat( 10, 15 ) ); }
void CWeaponUSP::WeaponIdle() { if (m_flTimeWeaponIdle > gpGlobals->curtime) return; // only idle if the slid isn't back if (m_iClip1 != 0) { SetWeaponIdleTime( gpGlobals->curtime + 6.0 ); } }
void CWeaponCSBaseGun::WeaponIdle() { if (m_flTimeWeaponIdle > gpGlobals->curtime) return; // only idle if the slid isn't back if ( m_iClip1 != 0 ) { SetWeaponIdleTime( gpGlobals->curtime + GetCSWpnData().m_flIdleInterval ); SendWeaponAnim( ACT_VM_IDLE ); } }
void CWeaponMP5::WeaponIdle() { if (m_flTimeWeaponIdle > gpGlobals->curtime) return; // only idle if the slid isn't back if ( m_iClip1 != 0 ) { SetWeaponIdleTime( gpGlobals->curtime + 5.0f ); SendWeaponAnim( ACT_VM_IDLE ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseSDKGrenade::ItemPostFrame() { CSDKPlayer *pPlayer = GetPlayerOwner(); if ( !pPlayer ) return; CBaseViewModel *vm = pPlayer->GetViewModel( m_nViewModelIndex ); if ( !vm ) return; // If they let go of the fire button, they want to throw the grenade. if ( m_bPinPulled && !(pPlayer->m_nButtons & IN_ATTACK) ) { pPlayer->DoAnimationEvent( PLAYERANIMEVENT_THROW_GRENADE ); StartGrenadeThrow(); DecrementAmmo( pPlayer ); m_bPinPulled = false; SendWeaponAnim( ACT_VM_THROW ); SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() ); } else if ((m_fThrowTime > 0) && (m_fThrowTime < gpGlobals->curtime)) { ThrowGrenade(); } else if( m_bRedraw ) { // Has the throw animation finished playing if( m_flTimeWeaponIdle < gpGlobals->curtime ) { #ifdef GAME_DLL // if we're officially out of grenades, ditch this weapon if( pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0 ) { pPlayer->Weapon_Drop( this, NULL, NULL ); UTIL_Remove(this); } else { pPlayer->SwitchToNextBestWeapon( this ); } #endif return; //don't animate this grenade any more! } } else if( !m_bRedraw ) { BaseClass::ItemPostFrame(); } }
void CWeaponBaseGun::WeaponIdle() { if (m_flTimeWeaponIdle > gpGlobals->curtime) return; // only idle if the slid isn't back #ifdef WEAPONS_USE_AMMO if (m_iClip1 != 0) #endif { SetWeaponIdleTime(gpGlobals->curtime + m_flIdleInterval); SendWeaponAnim(ACT_VM_IDLE); } }
bool CWeaponBaseGun::BaseGunFire(float flSpread, float flCycleTime, bool bPrimaryMode) { CMomentumPlayer *pPlayer = GetPlayerOwner(); if (!pPlayer) return false; m_bDelayFire = true; pPlayer->m_iShotsFired++; // Out of ammo? #ifdef WEAPONS_USE_AMMO if (m_iClip1 <= 0) { if (m_bFireOnEmpty) { PlayEmptySound(); m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; } return false; } m_iClip1--; #endif SendWeaponAnim(ACT_VM_PRIMARYATTACK); // player "shoot" animation pPlayer->SetAnimation(PLAYER_ATTACK1); FX_FireBullets(pPlayer->entindex(), pPlayer->Weapon_ShootPosition(), pPlayer->EyeAngles() + 2.0f * pPlayer->GetPunchAngle(), GetWeaponID(), bPrimaryMode ? Primary_Mode : Secondary_Mode, CBaseEntity::GetPredictionRandomSeed() & 255, flSpread); DoFireEffects(); m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + flCycleTime; #ifdef WEAPONS_USE_AMMO if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0) { // HEV suit - indicate out of ammo condition pPlayer->SetSuitUpdate("!HEV_AMO0", false, 0); } #endif SetWeaponIdleTime(gpGlobals->curtime + m_flTimeToIdleAfterFire); return true; }
void CWeaponM4A1::WeaponIdle() { if (m_flTimeWeaponIdle > gpGlobals->curtime) return; // only idle if the slid isn't back if (m_iClip1 != 0) { SetWeaponIdleTime(gpGlobals->curtime + GetCSWpnData().m_flIdleInterval); if (m_bSilencerOn) SendWeaponAnim(ACT_VM_IDLE_SILENCED); else SendWeaponAnim(ACT_VM_IDLE); } }