BWAPI
|
#include <UnitAgent.h>
The UnitAgent is the base agent class for all agents handling mobile units. If a unit is created and no specific agent for that type is found, the unit is assigned to a UnitAgents. UnitAgents can attack and assist building under enemy fire, but cannot use any special abilities. To use abilities such as Terran Vultures dropping spider mines, an agent implementation for that unit type must be created.
Author: Johan Hagelback (johan.hagelback@gmail.com)
UnitAgent::UnitAgent | ( | Unit * | mUnit | ) |
void UnitAgent::assignToAttack | ( | ) | [virtual] |
Assigns this agent to be in the attack force.
Reimplemented from BaseAgent.
void UnitAgent::assignToDefend | ( | ) | [virtual] |
Assigns this agent to defend the base.
Reimplemented from BaseAgent.
void UnitAgent::assignToExplore | ( | ) | [virtual] |
Assigns this agent to explore the game world.
Reimplemented from BaseAgent.
bool UnitAgent::canAttack | ( | UnitType | attacker, |
UnitType | target | ||
) | [static] |
Returns true if the attacker UnitType can attack target UnitType. Note: Does not take spells into account, only weapons.
bool UnitAgent::chargeShields | ( | ) |
Orders a Protoss unit to recharge shields.
void UnitAgent::clearGoal | ( | ) | [virtual] |
void UnitAgent::computeActions | ( | ) | [virtual] |
Called each update to issue orders.
Reimplemented from BaseAgent.
Reimplemented in ScienceVesselAgent, HighTemplarAgent, MarineAgent, DarkTemplarAgent, DefilerAgent, DropshipAgent, FirebatAgent, MedicAgent, VultureAgent, BattlecruiserAgent, GhostAgent, OverlordAgent, QueenAgent, WraithAgent, CorsairAgent, MutaliskAgent, ObserverAgent, ArbiterAgent, CarrierAgent, DevourerAgent, DragoonAgent, GoliathAgent, GuardianAgent, HydraliskAgent, InfestedTerranAgent, LurkerAgent, ReaverAgent, ScourgeAgent, ScoutAgent, ShuttleAgent, UltraliskAgent, ValkyrieAgent, ZealotAgent, ZerglingAgent, and SiegeTankAgent.
void UnitAgent::computeKitingActions | ( | ) |
Handles actions for kiting agents.
int UnitAgent::enemyAirAttackingUnitsWithinRange | ( | TilePosition | center, |
int | maxRange | ||
) |
Returns the number of flying unit that are within maxRange of the center tile, and can attack the agent.
int UnitAgent::enemyAirToGroundUnitsWithinRange | ( | int | maxRange | ) |
Returns the number of flying units that can target ground and are within maxRange of the agent.
int UnitAgent::enemyAirUnitsWithinRange | ( | int | maxRange | ) |
Returns the number of flying units that are within maxRange of the agent.
Returns the number of enemy units and buildings that can attack and are within firerange of the agent.
int UnitAgent::enemyAttackingUnitsWithinRange | ( | int | maxRange, |
TilePosition | center | ||
) |
Returns the number of enemy units and buildings that can attack and are within range of the center tile.
int UnitAgent::enemyAttackingUnitsWithinRange | ( | UnitType | type | ) |
Returns the number of enemy units and buildings that can attack and are within firerange of the specified unit type.
int UnitAgent::enemyGroundAttackingUnitsWithinRange | ( | TilePosition | center, |
int | maxRange | ||
) |
Returns the number of enemy ground units and buildings that are within maxRange of the center tile, and can attack the agent.
int UnitAgent::enemyGroundUnitsWithinRange | ( | int | maxRange | ) |
Returns the number of enemy ground units and buildings that are within maxRange of the agent.
int UnitAgent::enemySiegedTanksWithinRange | ( | TilePosition | center | ) |
Calculates the number of enemy sieged Siege Tanks within Siege Tank range.
int UnitAgent::enemyUnitsWithinRange | ( | int | maxRange | ) |
Returns the number of enemy units and buildings that are within maxRange of the agent.
Returns the number of own units that are within 6 tiles range of the agent.
int UnitAgent::friendlyUnitsWithinRange | ( | int | maxRange | ) |
Returns the number of own units that are within maxRange of the agent.
int UnitAgent::friendlyUnitsWithinRange | ( | TilePosition | tilePos, |
int | maxRange | ||
) |
Returns the number of own units that are within maxRange of the specified tile.
int UnitAgent::getAirRange | ( | ) |
Returns the max firerange of the air weapon this agent has, or -1 if it cannot attack air.
int UnitAgent::getAirRange | ( | UnitType | type | ) | [static] |
Returns the max firerange of the ground weapon a unit of the specified type has, or -1 if it cannot attack air.
Unit * UnitAgent::getClosestEnemyAirDefense | ( | int | maxRange | ) |
Returns the closest enemy turret, other attacking building or mechanical unit within maxRange that can attack air units, or NULL if not found.
Unit * UnitAgent::getClosestEnemyTurret | ( | int | maxRange | ) |
Returns the closest enemy turret or other attacking building within maxRange, or NULL if not found.
Unit * UnitAgent::getClosestOrganicEnemy | ( | int | maxRange | ) |
Returns the closest organic enemy unit within maxRange, or NULL if not found.
Unit * UnitAgent::getClosestShieldedEnemy | ( | int | maxRange | ) |
Returns the closest enemy unit that is shielded and within maxRange, or NULL if not found.
int UnitAgent::getGroundRange | ( | ) |
Returns the max firerange of the ground weapon this agent has, or -1 if it cannot attack ground.
int UnitAgent::getGroundRange | ( | UnitType | type | ) | [static] |
Returns the max firerange of the ground weapon a unit of the specified type has, or -1 if it cannot attack ground.
string UnitAgent::getTypeName | ( | ) | [virtual] |
Returns the unique type name for unit agents.
Reimplemented from BaseAgent.
Reimplemented in ScienceVesselAgent, HighTemplarAgent, MarineAgent, DarkTemplarAgent, DefilerAgent, DropshipAgent, FirebatAgent, MedicAgent, VultureAgent, BattlecruiserAgent, GhostAgent, OverlordAgent, QueenAgent, WraithAgent, CorsairAgent, MutaliskAgent, ObserverAgent, ArbiterAgent, CarrierAgent, DevourerAgent, DragoonAgent, GoliathAgent, GuardianAgent, HydraliskAgent, InfestedTerranAgent, LurkerAgent, ReaverAgent, ScourgeAgent, ScoutAgent, ShuttleAgent, UltraliskAgent, ValkyrieAgent, ZealotAgent, ZerglingAgent, and SiegeTankAgent.
bool UnitAgent::isAttacking | ( | ) | [virtual] |
Returns true if this agent is used to attack the enemy.
Reimplemented from BaseAgent.
bool UnitAgent::isBunkered | ( | ) |
Returns true if this agent is inside a Terran Bunker.
Reimplemented in MarineAgent, and FirebatAgent.
bool UnitAgent::isDefending | ( | ) | [virtual] |
Returns true if this agent is defending the own base.
Reimplemented from BaseAgent.
bool UnitAgent::isExploring | ( | ) | [virtual] |
Returns true if this agent is used to explore the game world.
Reimplemented from BaseAgent.
void UnitAgent::printInfo | ( | ) | [virtual] |
Used to print info about this agent to the screen.
Reimplemented from BaseAgent.
void UnitAgent::setGoal | ( | TilePosition | goal | ) | [virtual] |
Sets the goal for this unit. Goals are set from either the SquadCommander for attacking or defending units, or from ExplorationManager for explore units.
Reimplemented from BaseAgent.
Reimplemented in ReaverAgent.
bool UnitAgent::useDefensiveMode | ( | ) |
Checks if a unit can be in defensive mode. This happens if 1) the unit is in cooldown and 2) there are opponent units that can attack it.
const int UnitAgent::ATTACK = 1 [static, protected] |
const int UnitAgent::BUNKERED = 4 [static, protected] |
int UnitAgent::currentState [protected] |
const int UnitAgent::DEFEND = 3 [static, protected] |
const int UnitAgent::EXPLORE = 2 [static, protected] |