BTHAI 2.3
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes
UnitAgent Class Reference

#include <UnitAgent.h>

Inheritance diagram for UnitAgent:
BaseAgent ArbiterAgent BattlecruiserAgent CarrierAgent CorsairAgent DarkTemplarAgent DefilerAgent DevourerAgent DragoonAgent DropshipAgent FirebatAgent GhostAgent GoliathAgent GuardianAgent HighTemplarAgent HydraliskAgent InfestedTerranAgent LurkerAgent MarineAgent MedicAgent MutaliskAgent ObserverAgent OverlordAgent QueenAgent ReaverAgent ScienceVesselAgent ScourgeAgent ScoutAgent ShuttleAgent SiegeTankAgent UltraliskAgent ValkyrieAgent VultureAgent WraithAgent ZealotAgent ZerglingAgent

List of all members.

Public Member Functions

 UnitAgent (Unit *mUnit)
void computeActions ()
void computeKitingActions ()
string getTypeName ()
virtual void setGoal (TilePosition goal)
virtual void clearGoal ()
int friendlyUnitsWithinRange ()
int friendlyUnitsWithinRange (int maxRange)
int friendlyUnitsWithinRange (TilePosition tilePos, int maxRange)
int enemyAttackingUnitsWithinRange ()
int enemyAttackingUnitsWithinRange (int maxRange, TilePosition center)
int enemyAttackingUnitsWithinRange (UnitType type)
int enemyUnitsWithinRange (int maxRange)
int enemyGroundUnitsWithinRange (int maxRange)
int enemySiegedTanksWithinRange (TilePosition center)
int enemyGroundAttackingUnitsWithinRange (TilePosition center, int maxRange)
int enemyAirUnitsWithinRange (int maxRange)
bool useDefensiveMode ()
int enemyAirToGroundUnitsWithinRange (int maxRange)
int enemyAirAttackingUnitsWithinRange (TilePosition center, int maxRange)
int getGroundRange ()
int getAirRange ()
void assignToExplore ()
void assignToAttack ()
void assignToDefend ()
bool isExploring ()
bool isAttacking ()
bool isDefending ()
bool isBunkered ()
Unit * getClosestOrganicEnemy (int maxRange)
Unit * getClosestShieldedEnemy (int maxRange)
Unit * getClosestEnemyTurret (int maxRange)
Unit * getClosestEnemyAirDefense (int maxRange)
bool chargeShields ()
virtual void printInfo ()

Static Public Member Functions

static int getGroundRange (UnitType type)
static bool canAttack (UnitType attacker, UnitType target)
static int getAirRange (UnitType type)

Public Attributes

int dropped

Protected Attributes

int currentState

Static Protected Attributes

static const int ATTACK = 1
static const int EXPLORE = 2
static const int DEFEND = 3
static const int BUNKERED = 4

Detailed Description

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)


Member Function Documentation

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]

Clears the goal for this unit.

Reimplemented from BaseAgent.

Reimplemented in ReaverAgent.

void UnitAgent::computeActions ( ) [virtual]
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.

int UnitAgent::enemyAttackingUnitsWithinRange ( )

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.

int UnitAgent::friendlyUnitsWithinRange ( )

Returns the number of own units that are within 6 tiles range 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::friendlyUnitsWithinRange ( int  maxRange)

Returns the number of own units that are within maxRange of the agent.

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]
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 FirebatAgent, and MarineAgent.

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.


The documentation for this class was generated from the following files:
 All Classes Functions Variables