TeamAI
Each team in UT2003 has a TeamAI instance that creates SquadAIs, gives them orders and assigns Bots to them. You can specify a TeamGame's TeamAI class by settings its TeamAIType property.
Properties
- UnrealTeamInfo? Team
UnrealTeamInfo? EnemyTeam - References to the own and enemy team's UnrealTeamInfo?. Set by PostBeginPlay in TeamGame (which also spawns the TeamAI actors).
- GameObjective Objectives
- First of a linked list of GameObjective actors, set by SetObjectiveLists (which in turn is called by PostBeginPlay in TeamGame). The GameObjective actors are linked via their NextObjective property. The list itself is set up by PostBeginPlay in class GameObjective.
- GameObjective PickedObjective
- Objective selected for attack by this team. Set and returned by GetPriorityAttackObjective. (PickedObjective caches the return value of GetPriorityAttackObjective and is only updated when the picked objective has been disabled since the last call.)
- SquadAI Squads
- First of a linked list of SquadAI actors, linked by their NextSquad property. The list is maintained by TeamAI.
- SquadAI AttackSquad
- The squad ordered to attack the enemy. Automatically created by PutOnOffense.
- SquadAI FreelanceSquad
- The squad ordered to freelance. Automatically created by PutOnFreelance. ReAssessStrategy dynamically changes this squad's orders to "attack" or "defense" when time runs out or when a team is more than two points apart from the other team.
- class<SquadAI> SquadType
- Class of the squads spawned by this TeamAI. – There's only a single class despite of squads having different tasks like offense or defense. The GameObjective assigned to a squad by the TeamAI makes the difference.
- int OrderOffset
name OrderList[8] - List of orders (and an index into it) used by SetBotOrders (which is in turn called by InitializeBot in DeathMatch to set a newly spawned bot's orders).
- int NumSupportingPlayer
- Not used anywhere.
Methods
Events
- PostBeginPlay ( )
- Starts the timer with a five-second interval.
- Timer ( )
- Periodically calls ReAssessStrategy which checks whether the freelance team should be ordered to freelance or to reinforce either offense or defense.
Public
- SetObjectiveLists ( )
- Initializes the Objectives variable. Called by PostBeginPlay in TeamGame directly after the TeamAI is spawned, and by SetBotOrders.
- SetBotOrders (Bot NewBot, RosterEntry? R)
- Initially set a newly spawned bot 's orders. Unlike in UT, UT2003 bots don't have individual orders anymore; only squads have, and every bot is a member of a squad. Called by SetBotOrders in UnrealTeamInfo? (which in turn is called by InitializeBot in DeathMatch).
- SetOrders (Bot B, name NewOrders, Controller OrderGiver)
- Called when a human player gives orders to a bot.
- SquadAI GetSquadLedBy (Controller C)
- Returns the squad led by the given controller.
- SquadAI FindSquadOf (Controller C)
- Returns the squad the given controller is part of.
- SquadAI FindHumanSquad ( )
- Returns the first squad found whose leader is a human player.
- bool OnThisTeam (Pawn Other)
- Checks whether the given pawn is controlled by a player or bot on this team.
- bool FriendlyToward (Pawn Other)
- Checks whether players of this team should be friendly toward the given pawn. Called by FriendlyToward in SquadAI.
- NotifyKilled (Controller Killer, Controller Killed, Pawn KilledPawn)
- Forwards a kill notification from NotifyKilled in TeamGame to all squads.
- FindNewObjectives (GameObjective DisabledObjective)
- Called by FindNewObjectives in TeamGame for both teams when an objective has been disabled. Calls FindNewObjectiveFor for each squad on this team.
- GameObjective GetPriorityAttackObjective ( )
- Returns the objective that has should be attacked by this team. (Subsequent calls to this function return the same objective until it has been disabled; the objective reference is cached in the PickedObjective variable.) Used internally by TeamAI and called by RemovePlayer in SquadAI when a squad's human leader is removed.
- RemoveSquad (SquadAI Squad)
- Removes the given squad from the linked squad list.
- RemoveFromTeam (Controller Other)
- Removes the given controller from the team and the squad it was in.
Internal
- ReAssessStrategy ( )
- Orders the freelance squad to reinforce this team's offense or defense under certain circumstances:
- If a game with a time limit is in progress, orders the freelance squad to...
- ...defend if the team is currently leading in score.
- ...attack if the team is currently behind in score by more than two points (or, in the last three minutes, at all).
- If a game without a time limit is in progress, orders the freelance squad to...
- ...defend if the team is currently leading by more than two points.
- ...attack if the team is currently behind in score by more than two points.
- If a game with a time limit is in progress, orders the freelance squad to...
- GameObjective GetLeastDefendedObjective ( )
- Returns the least defended objective. (Calls GetNumDefenders in GameObjective to get the number of defenders of an objective, and takes the objectives' DefensePriority into account.)
- GameObjective GetMostDefendedObjective ( )
- Returns the most defended objective. Not used anywhere.
- GameObjective GetPriorityFreelanceObjective ( )
- Returns the objective for freelance squads. By default, simply calls GetPriorityAttackObjective.
- FindNewObjectiveFor (SquadAI S, bool bForceUpdate)
- Called by FindNewObjectives. For squads not currently led by a human player, finds a new objective for the given squad using GetPriorityFreelanceObjective, GetPriorityAttackObjective and GetLeastDefendedObjective. If the squad is to defend an objective that already has a defense squad, merges both squads; otherwise just sets the squad's new objective.
- SquadAI AddHumanSquad ( )
- If no squad led by a human player already exists, creates one and assigns the first human player found in the game as its leader. Used by SetBotOrders when a newly spawned bot is initially ordered to follow a human player by the TeamAI's OrderList.
- SquadAI AddSquadWithLeader (Controller C, GameObjective O)
- Creates and returns a reference to a new squad with the given objective. The given controller is assigned as the squad's leader.
- PutBotOnSquadLedBy (Controller C, Bot B)
- Puts the given bot on the squad led by the given controller. Used by SetOrders to put bots ordered by a human player to "hold" or "follow" on that player's squad.
- bool PutOnDefense (Bot B)
- Puts the given bot on the least defended objective's defense squad. Creates the squad if none exists yet for the selected objective.
- PutOnOffense (Bot B)
- Adds the given bot to the attack squad. Creates the squad if it doesn't exist yet.
- PutOnFreelance (Bot B)
- Adds the given bot to the freelance squad. Creates the squad if it doesn't exist yet.