static bool IsValidFn_PlayersWantingAssist( void *pUserData, int a ) { CSortBase *pSortBase = (CSortBase*)pUserData; CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)pSortBase->m_pPlayer->GetTeam()->GetPlayer( a ); if ( !pPlayer->IsAlive() ) { // This guy sure could have used an assist but YOU'RE TOO SLOW!!! return false; } // Don't try to assist yourself... if ( pPlayer == pSortBase->m_pPlayer ) return false; // Make sure this guy was shot recently. if ( (gpGlobals->curtime - pPlayer->LastTimeDamagedByEnemy()) > COMMANDO_ASSIST_SHOT_DELAY ) return false; // Is the guy close enough? if ( pSortBase->m_pPlayer->GetAbsOrigin().DistToSqr( pPlayer->GetAbsOrigin() ) > COMMAND_ASSIST_DISTANCE_SQR ) return false; return true; }
//----------------------------------------------------------------------------- // Boost those attached to me as long as I'm not EMPed //----------------------------------------------------------------------------- void CObjectBuffStation::BoostPlayerThink( void ) { // Are we emped? bool bIsEmped = HasPowerup( POWERUP_EMP ); // Get range (squared = faster test). float flMaxRangeSq = obj_buff_station_range.GetFloat(); flMaxRangeSq *= flMaxRangeSq; // Boost all attached players and objects. for ( int iPlayer = 0; iPlayer < BUFF_STATION_MAX_PLAYERS; iPlayer++ ) { // Clean up dangling pointers + dead players, subversion, disconnection CBaseTFPlayer *pPlayer = m_hPlayers[iPlayer].Get(); if ( !pPlayer || !pPlayer->IsAlive() || !InSameTeam( pPlayer ) || !pPlayer->PlayerClass() ) { DetachPlayerByIndex( iPlayer ); continue; } // Check for out of range. float flDistSq = GetAbsOrigin().DistToSqr( pPlayer->GetAbsOrigin() ); if ( flDistSq > flMaxRangeSq ) { DetachPlayerByIndex( iPlayer ); continue; } bool bBoosted = false; if ( !bIsEmped ) { float flHealAmount = obj_buff_station_heal_rate.GetFloat() * BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL; bBoosted = pPlayer->AttemptToPowerup( POWERUP_BOOST, 0, flHealAmount, this, &m_aPlayerAttachInfo[iPlayer].m_DamageModifier ); } if ( !bBoosted ) { m_aPlayerAttachInfo[iPlayer].m_DamageModifier.RemoveModifier(); } } // Set next think time. if ( m_nPlayerCount > 0 ) { SetNextThink( gpGlobals->curtime + BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL, BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT ); } else { SetNextThink( gpGlobals->curtime + 1.0f, BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT ); } }
//----------------------------------------------------------------------------- // Purpose: Called every frame by postthink //----------------------------------------------------------------------------- void CPlayerClassCommando::ClassThink( void ) { // Check bullrush m_ClassData.m_bCanBullRush = true; // Do the init thing here! if ( m_bOldBullRush != m_ClassData.m_bBullRush ) { if ( m_ClassData.m_bBullRush ) { PreBullRush(); } else { PostBullRush(); } m_bOldBullRush = (bool)m_ClassData.m_bBullRush; } // Check for melee attack if ( m_bCanBoot && m_pPlayer->IsAlive() && m_flNextBootCheck < gpGlobals->curtime ) { m_flNextBootCheck = gpGlobals->curtime + 0.2; CBaseEntity *pEntity = NULL; Vector vecSrc = m_pPlayer->Weapon_ShootPosition( ); Vector vecDir = m_pPlayer->BodyDirection2D( ); Vector vecTarget = vecSrc + (vecDir * 48); for ( CEntitySphereQuery sphere( vecTarget, 16 ); pEntity = sphere.GetCurrentEntity(); sphere.NextEntity() ) { if ( pEntity->IsPlayer() && (pEntity != m_pPlayer) ) { CBaseTFPlayer *pPlayer = (CBaseTFPlayer *)pEntity; // Target needs to be on the enemy team if ( !pPlayer->IsClass( TFCLASS_UNDECIDED ) && pPlayer->IsAlive() && pPlayer->InSameTeam( m_pPlayer ) == false ) { Boot( pPlayer ); m_flNextBootCheck = gpGlobals->curtime + 1.5; } } } } BaseClass::ClassThink(); }
//----------------------------------------------------------------------------- // Purpose: Bash enemies in front of me with my shield //----------------------------------------------------------------------------- void CWeaponCombatShield::ShieldBash( void ) { #if 0 // ROBIN: Disabled shield bash return; // Get any players in front of me CBaseTFPlayer *pOwner = ToBaseTFPlayer( GetOwner() ); if ( !pOwner ) return; // Get the target point and location Vector vecAiming; Vector vecSrc = pOwner->Weapon_ShootPosition( pOwner->GetOrigin() ); pOwner->EyeVectors( &vecAiming ); // Find a player in range of this player, and make sure they're healable trace_t tr; Vector vecEnd = vecSrc + (vecAiming * SHIELD_BASH_RANGE); UTIL_TraceLine( vecSrc, vecEnd, MASK_SHOT, pOwner->edict(), COLLISION_GROUP_NONE, &tr); if (tr.fraction != 1.0) { CBaseEntity *pEntity = CBaseEntity::Instance(tr.u.ent); if ( pEntity ) { CBaseTFPlayer *pPlayer = ToBaseTFPlayer( pEntity ); if ( pPlayer && (pPlayer != pOwner) ) { // Target needs to be on the eneny team if ( pPlayer->IsAlive() && !pPlayer->InSameTeam( pOwner ) ) { // Ok, we have an enemy player pPlayer->TakeShieldBash( pOwner ); } } } } #endif }