diff --git a/src/game/server/tf/bot/tf_bot.cpp b/src/game/server/tf/bot/tf_bot.cpp index 240941a8bf0..9e207d4bb2e 100644 --- a/src/game/server/tf/bot/tf_bot.cpp +++ b/src/game/server/tf/bot/tf_bot.cpp @@ -4989,3 +4989,22 @@ float CTFBot::GetUberDeployDelayDuration() return -1.f; } + +bool CTFBot::IsEnemy( const CBaseEntity *them ) const +{ + if ( them == NULL ) + return false; + + int theirTeamNum = them->GetTeamNumber(); + + // Check if a truce is active, as this will make enemy players no longer an "enemy" as they cannot be damaged during this state. + if ( TFGameRules() && TFGameRules()->IsTruceActive() ) + { + return theirTeamNum != TF_TEAM_BLUE && theirTeamNum != TF_TEAM_RED; + } + else + { + // this is not strictly correct, as spectators are not enemies + return ( ( INextBot * ) this )->GetEntity()->GetTeamNumber() != theirTeamNum; + } +} \ No newline at end of file diff --git a/src/game/server/tf/bot/tf_bot.h b/src/game/server/tf/bot/tf_bot.h index cce41e3a474..86e8ba2ecef 100644 --- a/src/game/server/tf/bot/tf_bot.h +++ b/src/game/server/tf/bot/tf_bot.h @@ -491,6 +491,7 @@ class CTFBot: public NextBotPlayer< CTFPlayer >, public CGameEventListener bool ShouldReEvaluateCurrentClass( void ) const; void ReEvaluateCurrentClass( void ); + bool IsEnemy( const CBaseEntity* ) const; private: CTFBotLocomotion *m_locomotor;