//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponCombatLaserRifle::RecalculateAccuracy( void ) { CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner(); if (!pPlayer) return; m_flAccuracyTime += gpGlobals->frametime; while ( m_flAccuracyTime > 0.05 ) { if ( !(pPlayer->GetFlags() & FL_ONGROUND) ) { m_flInaccuracy += 0.05; } else if ( pPlayer->GetFlags() & FL_DUCKING ) { m_flInaccuracy -= 0.08; } /* else if ( pPlayer->GetLocalVelocity().LengthSqr() > (100*100) ) { // Never get worse than 1/2 accuracy from running if ( m_flInaccuracy < 0.25 ) { m_flInaccuracy += 0.01; if ( m_flInaccuracy > 0.5 ) { m_flInaccuracy = 0.5; } } else if ( m_flInaccuracy > 0.25 ) { m_flInaccuracy -= 0.01; } } */ else { m_flInaccuracy -= 0.04; } // Crouching prevents accuracy ever going beyond a point if ( pPlayer->GetFlags() & FL_DUCKING ) { m_flInaccuracy = clamp(m_flInaccuracy, 0, 0.8); } else { m_flInaccuracy = clamp(m_flInaccuracy, 0, 1); } m_flAccuracyTime -= 0.05; #ifndef CLIENT_DLL //if ( m_flInaccuracy ) //Msg("Inaccuracy %.2f (%.2f)\n", m_flInaccuracy, gpGlobals->curtime ); #endif } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- float CWeaponCombatBurstRifle::GetFireRate( void ) { if ( !inv_demo.GetFloat() ) { float flFireRate = ( SequenceDuration() * 0.6f ) + SHARED_RANDOMFLOAT( 0.0, 0.035f ); CBaseTFPlayer *pPlayer = static_cast<CBaseTFPlayer*>( GetOwner() ); if ( pPlayer ) { // Ducking players should fire more rapidly. if ( pPlayer->GetFlags() & FL_DUCKING ) { flFireRate *= weapon_combat_burstrifle_ducking_mod.GetFloat(); } } return flFireRate; } // Get the player and check to see if we are powered up. CBaseTFPlayer *pPlayer = ( CBaseTFPlayer* )GetOwner(); if ( pPlayer && pPlayer->HasPowerup( POWERUP_BOOST ) ) { return BURSTRIFLE_BOOSTED_FIRERATE; } return SHARED_RANDOMFLOAT( 0.075f, 0.15f ); }
//----------------------------------------------------------------------------- // Purpose: Run through all the Bots in the game and let them think. //----------------------------------------------------------------------------- void Bot_RunAll( void ) { for ( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseTFPlayer *pPlayer = ToBaseTFPlayer( UTIL_PlayerByIndex( i ) ); if ( pPlayer && (pPlayer->GetFlags() & FL_FAKECLIENT) ) { Bot_Think( pPlayer ); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- float CWeaponCombatLaserRifle::GetFireRate( void ) { float flFireRate = ( SequenceDuration() * 0.4 ) + SHARED_RANDOMFLOAT( 0.0, 0.035f ); CBaseTFPlayer *pPlayer = static_cast<CBaseTFPlayer*>( GetOwner() ); if ( pPlayer ) { // Ducking players should fire more rapidly. if ( pPlayer->GetFlags() & FL_DUCKING ) { flFireRate *= weapon_combat_laserrifle_ducking_mod.GetFloat(); } } return flFireRate; }