BWAPI  4.2.0
An API for interacting with Starcraft: Broodwar (1.16.1)
Public Member Functions | List of all members
BWAPI::UnitInterface Class Referenceabstract
Inheritance diagram for BWAPI::UnitInterface:
Inheritance graph

Public Member Functions

virtual bool exists () const =0
virtual int getAcidSporeCount () const =0
virtual Unit getAddon () const =0
virtual int getAirWeaponCooldown () const =0
virtual double getAngle () const =0
int getBottom () const
virtual UnitType getBuildType () const =0
virtual Unit getBuildUnit () const =0
virtual Unit getCarrier () const =0
Unit getClosestUnit (const UnitFilter &pred=nullptr, int radius=999999) const
virtual int getDefenseMatrixPoints () const =0
virtual int getDefenseMatrixTimer () const =0
int getDistance (Position target) const
int getDistance (Unit target) const
virtual int getEnergy () const =0
virtual int getEnsnareTimer () const =0
virtual int getGroundWeaponCooldown () const =0
virtual Unit getHatchery () const =0
virtual int getHitPoints () const =0
virtual int getID () const =0
virtual int getInitialHitPoints () const =0
virtual Position getInitialPosition () const =0
virtual int getInitialResources () const =0
virtual TilePosition getInitialTilePosition () const =0
virtual UnitType getInitialType () const =0
virtual int getInterceptorCount () const =0
virtual Unitset getInterceptors () const =0
virtual int getIrradiateTimer () const =0
virtual int getKillCount () const =0
virtual Unitset getLarva () const =0
virtual BWAPI::Player getLastAttackingPlayer () const =0
virtual UnitCommand getLastCommand () const =0
virtual int getLastCommandFrame () const =0
int getLeft () const
virtual Unitset getLoadedUnits () const =0
virtual int getLockdownTimer () const =0
virtual int getMaelstromTimer () const =0
virtual Unit getNydusExit () const =0
virtual Order getOrder () const =0
virtual Unit getOrderTarget () const =0
virtual Position getOrderTargetPosition () const =0
virtual int getOrderTimer () const =0
virtual int getPlagueTimer () const =0
virtual Player getPlayer () const =0
virtual Position getPosition () const =0
virtual Unit getPowerUp () const =0
virtual Position getRallyPosition () const =0
virtual Unit getRallyUnit () const =0
BWAPI::Region getRegion () const
virtual int getRemainingBuildTime () const =0
virtual int getRemainingResearchTime () const =0
virtual int getRemainingTrainTime () const =0
virtual int getRemainingUpgradeTime () const =0
virtual int getRemoveTimer () const =0
virtual int getReplayID () const =0
virtual int getResourceGroup () const =0
virtual int getResources () const =0
int getRight () const
virtual int getScarabCount () const =0
virtual Order getSecondaryOrder () const =0
virtual int getShields () const =0
int getSpaceRemaining () const
virtual int getSpellCooldown () const =0
virtual int getSpiderMineCount () const =0
virtual int getStasisTimer () const =0
virtual int getStimTimer () const =0
virtual Unit getTarget () const =0
virtual Position getTargetPosition () const =0
virtual TechType getTech () const =0
TilePosition getTilePosition () const
int getTop () const
virtual UnitType::list getTrainingQueue () const =0
virtual Unit getTransport () const =0
virtual UnitType getType () const =0
Unitset getUnitsInRadius (int radius, const UnitFilter &pred=nullptr) const
Unitset getUnitsInWeaponRange (WeaponType weapon, const UnitFilter &pred=nullptr) const
virtual UpgradeType getUpgrade () const =0
virtual double getVelocityX () const =0
virtual double getVelocityY () const =0
virtual bool hasNuke () const =0
bool hasPath (Position target) const
bool hasPath (Unit target) const
virtual bool isAccelerating () const =0
virtual bool isAttackFrame () const =0
virtual bool isAttacking () const =0
bool isBeingConstructed () const
virtual bool isBeingGathered () const =0
virtual bool isBeingHealed () const =0
virtual bool isBlind () const =0
virtual bool isBraking () const =0
virtual bool isBurrowed () const =0
virtual bool isCarryingGas () const =0
virtual bool isCarryingMinerals () const =0
virtual bool isCloaked () const =0
virtual bool isCompleted () const =0
virtual bool isConstructing () const =0
bool isDefenseMatrixed () const
virtual bool isDetected () const =0
bool isEnsnared () const
bool isFlying () const
bool isFollowing () const
virtual bool isGatheringGas () const =0
virtual bool isGatheringMinerals () const =0
virtual bool isHallucination () const =0
bool isHoldingPosition () const
virtual bool isIdle () const =0
virtual bool isInterruptible () const =0
virtual bool isInvincible () const =0
bool isInWeaponRange (Unit target) const
bool isIrradiated () const
virtual bool isLifted () const =0
bool isLoaded () const
bool isLockedDown () const
bool isMaelstrommed () const
virtual bool isMorphing () const =0
virtual bool isMoving () const =0
virtual bool isParasited () const =0
bool isPatrolling () const
bool isPlagued () const
virtual bool isPowered () const =0
bool isRepairing () const
bool isResearching () const
virtual bool isSelected () const =0
bool isSieged () const
virtual bool isStartingAttack () const =0
bool isStasised () const
bool isStimmed () const
virtual bool isStuck () const =0
virtual bool isTargetable () const =0
virtual bool isTraining () const =0
virtual bool isUnderAttack () const =0
virtual bool isUnderDarkSwarm () const =0
virtual bool isUnderDisruptionWeb () const =0
virtual bool isUnderStorm () const =0
bool isUpgrading () const
virtual bool isVisible (Player player=nullptr) const =0
Unit Commands
virtual bool issueCommand (UnitCommand command)=0
bool attack (Position target, bool shiftQueueCommand=false)
bool attack (Unit target, bool shiftQueueCommand=false)
bool build (UnitType type, TilePosition target=TilePositions::None)
bool buildAddon (UnitType type)
bool train (UnitType type=UnitTypes::None)
bool morph (UnitType type)
bool research (TechType tech)
bool upgrade (UpgradeType upgrade)
bool setRallyPoint (Position target)
bool setRallyPoint (Unit target)
bool move (Position target, bool shiftQueueCommand=false)
bool patrol (Position target, bool shiftQueueCommand=false)
bool holdPosition (bool shiftQueueCommand=false)
bool stop (bool shiftQueueCommand=false)
bool follow (Unit target, bool shiftQueueCommand=false)
bool gather (Unit target, bool shiftQueueCommand=false)
bool returnCargo (bool shiftQueueCommand=false)
bool repair (Unit target, bool shiftQueueCommand=false)
bool burrow ()
bool unburrow ()
bool cloak ()
bool decloak ()
bool siege ()
bool unsiege ()
bool lift ()
bool land (TilePosition target)
bool load (Unit target, bool shiftQueueCommand=false)
bool unload (Unit target)
bool unloadAll (bool shiftQueueCommand=false)
bool unloadAll (Position target, bool shiftQueueCommand=false)
bool rightClick (Position target, bool shiftQueueCommand=false)
bool rightClick (Unit target, bool shiftQueueCommand=false)
bool haltConstruction ()
bool cancelConstruction ()
bool cancelAddon ()
bool cancelTrain (int slot=-2)
bool cancelMorph ()
bool cancelResearch ()
bool cancelUpgrade ()
bool useTech (TechType tech, Position target)
bool useTech (TechType tech, Unit target=nullptr)
bool placeCOP (TilePosition target)
Command Verifiers
virtual bool canIssueCommand (UnitCommand command, bool checkCanUseTechPositionOnPositions=true, bool checkCanUseTechUnitOnUnits=true, bool checkCanBuildUnitType=true, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canIssueCommandGrouped (UnitCommand command, bool checkCanUseTechPositionOnPositions=true, bool checkCanUseTechUnitOnUnits=true, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canCommand () const =0
virtual bool canCommandGrouped (bool checkCommandibility=true) const =0
virtual bool canIssueCommandType (UnitCommandType ct, bool checkCommandibility=true) const =0
virtual bool canIssueCommandTypeGrouped (UnitCommandType ct, bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canTargetUnit (Unit targetUnit, bool checkCommandibility=true) const =0
virtual bool canAttack (bool checkCommandibility=true) const =0
virtual bool canAttack (Position target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canAttack (Unit target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canAttackGrouped (bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canAttackGrouped (Position target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canAttackGrouped (Unit target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canAttackMove (bool checkCommandibility=true) const =0
virtual bool canAttackMoveGrouped (bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canAttackUnit (bool checkCommandibility=true) const =0
virtual bool canAttackUnit (Unit targetUnit, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canAttackUnitGrouped (bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canAttackUnitGrouped (Unit targetUnit, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canBuild (bool checkCommandibility=true) const =0
virtual bool canBuild (UnitType uType, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canBuild (UnitType uType, BWAPI::TilePosition tilePos, bool checkTargetUnitType=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canBuildAddon (bool checkCommandibility=true) const =0
virtual bool canBuildAddon (UnitType uType, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canTrain (bool checkCommandibility=true) const =0
virtual bool canTrain (UnitType uType, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canMorph (bool checkCommandibility=true) const =0
virtual bool canMorph (UnitType uType, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canResearch (bool checkCommandibility=true) const =0
virtual bool canResearch (TechType type, bool checkCanIssueCommandType=true) const =0
virtual bool canUpgrade (bool checkCommandibility=true) const =0
virtual bool canUpgrade (UpgradeType type, bool checkCanIssueCommandType=true) const =0
virtual bool canSetRallyPoint (bool checkCommandibility=true) const =0
virtual bool canSetRallyPoint (Position target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canSetRallyPoint (Unit target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canSetRallyPosition (bool checkCommandibility=true) const =0
virtual bool canSetRallyUnit (bool checkCommandibility=true) const =0
virtual bool canSetRallyUnit (Unit targetUnit, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canMove (bool checkCommandibility=true) const =0
virtual bool canMoveGrouped (bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canPatrol (bool checkCommandibility=true) const =0
virtual bool canPatrolGrouped (bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canFollow (bool checkCommandibility=true) const =0
virtual bool canFollow (Unit targetUnit, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canGather (bool checkCommandibility=true) const =0
virtual bool canGather (Unit targetUnit, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canReturnCargo (bool checkCommandibility=true) const =0
virtual bool canHoldPosition (bool checkCommandibility=true) const =0
virtual bool canStop (bool checkCommandibility=true) const =0
virtual bool canRepair (bool checkCommandibility=true) const =0
virtual bool canRepair (Unit targetUnit, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canBurrow (bool checkCommandibility=true) const =0
virtual bool canUnburrow (bool checkCommandibility=true) const =0
virtual bool canCloak (bool checkCommandibility=true) const =0
virtual bool canDecloak (bool checkCommandibility=true) const =0
virtual bool canSiege (bool checkCommandibility=true) const =0
virtual bool canUnsiege (bool checkCommandibility=true) const =0
virtual bool canLift (bool checkCommandibility=true) const =0
virtual bool canLand (bool checkCommandibility=true) const =0
virtual bool canLand (TilePosition target, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canLoad (bool checkCommandibility=true) const =0
virtual bool canLoad (Unit targetUnit, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUnloadWithOrWithoutTarget (bool checkCommandibility=true) const =0
virtual bool canUnloadAtPosition (Position targDropPos, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUnload (bool checkCommandibility=true) const =0
virtual bool canUnload (Unit targetUnit, bool checkCanTargetUnit=true, bool checkPosition=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUnloadAll (bool checkCommandibility=true) const =0
virtual bool canUnloadAllPosition (bool checkCommandibility=true) const =0
virtual bool canUnloadAllPosition (Position targDropPos, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canRightClick (bool checkCommandibility=true) const =0
virtual bool canRightClick (Position target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canRightClick (Unit target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canRightClickGrouped (bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canRightClickGrouped (Position target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canRightClickGrouped (Unit target, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canRightClickPosition (bool checkCommandibility=true) const =0
virtual bool canRightClickPositionGrouped (bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canRightClickUnit (bool checkCommandibility=true) const =0
virtual bool canRightClickUnit (Unit targetUnit, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canRightClickUnitGrouped (bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canRightClickUnitGrouped (Unit targetUnit, bool checkCanTargetUnit=true, bool checkCanIssueCommandType=true, bool checkCommandibilityGrouped=true, bool checkCommandibility=true) const =0
virtual bool canHaltConstruction (bool checkCommandibility=true) const =0
virtual bool canCancelConstruction (bool checkCommandibility=true) const =0
virtual bool canCancelAddon (bool checkCommandibility=true) const =0
virtual bool canCancelTrain (bool checkCommandibility=true) const =0
virtual bool canCancelTrainSlot (bool checkCommandibility=true) const =0
virtual bool canCancelTrainSlot (int slot, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canCancelMorph (bool checkCommandibility=true) const =0
virtual bool canCancelResearch (bool checkCommandibility=true) const =0
virtual bool canCancelUpgrade (bool checkCommandibility=true) const =0
virtual bool canUseTechWithOrWithoutTarget (bool checkCommandibility=true) const =0
virtual bool canUseTechWithOrWithoutTarget (BWAPI::TechType tech, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUseTech (BWAPI::TechType tech, Position target, bool checkCanTargetUnit=true, bool checkTargetsType=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUseTech (BWAPI::TechType tech, Unit target=nullptr, bool checkCanTargetUnit=true, bool checkTargetsType=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUseTechWithoutTarget (BWAPI::TechType tech, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUseTechUnit (BWAPI::TechType tech, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUseTechUnit (BWAPI::TechType tech, Unit targetUnit, bool checkCanTargetUnit=true, bool checkTargetsUnits=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUseTechPosition (BWAPI::TechType tech, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canUseTechPosition (BWAPI::TechType tech, Position target, bool checkTargetsPositions=true, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0
virtual bool canPlaceCOP (bool checkCommandibility=true) const =0
virtual bool canPlaceCOP (TilePosition target, bool checkCanIssueCommandType=true, bool checkCommandibility=true) const =0

Detailed Description

The Unit class is used to get information about individual units as well as issue orders to units.

Each unit in the game has a unique Unit object, and Unit objects are not deleted until the end of the match (so you don't need to worry about unit pointers becoming invalid).

Every Unit in the game is either accessible or inaccessible. To determine if an AI can access a particular unit, BWAPI checks to see if Flag::CompleteMapInformation is enabled. So there are two cases to consider - either the flag is enabled, or it is disabled:

If Flag::CompleteMapInformation is disabled, then a unit is accessible if and only if it is visible.

Note
Some properties of visible enemy units will not be made available to the AI (such as the contents of visible enemy dropships). If a unit is not visible, UnitInterface::exists will return false, regardless of whether or not the unit exists. This is because absolutely no state information on invisible enemy units is made available to the AI. To determine if an enemy unit has been destroyed, the AI must watch for AIModule::onUnitDestroy messages from BWAPI, which is only called for visible units which get destroyed.

If Flag::CompleteMapInformation is enabled, then all units that exist in the game are accessible, and UnitInterface::exists is accurate for all units. Similarly AIModule::onUnitDestroy messages are generated for all units that get destroyed, not just visible ones.

If a Unit is not accessible, then only the getInitial__ functions will be available to the AI. However for units that were owned by the player, getPlayer and getType will continue to work for units that have been destroyed.

Member Function Documentation

virtual int BWAPI::UnitInterface::getID () const pure virtual

Retrieves a unique identifier for this unit.

Returns
An integer containing the unit's identifier.
See also
getReplayID
virtual bool BWAPI::UnitInterface::exists () const pure virtual

Checks if the Unit exists in the view of the BWAPI player.

This is used primarily to check if BWAPI has access to a specific unit, or if the unit is alive. This function is more general and would be synonymous to an isAlive function if such a function were necessary.

Return values
trueIf the unit exists on the map and is visible according to BWAPI.
falseIf the unit is not accessible or the unit is dead.

In the event that this function returns false, there are two cases to consider:

  1. You own the unit. This means the unit is dead.
  2. Another player owns the unit. This could either mean that you don't have access to the unit or that the unit has died. You can specifically identify dead units by polling onUnitDestroy.
See also
isVisible, isCompleted
virtual int BWAPI::UnitInterface::getReplayID () const pure virtual

Retrieves the unit identifier for this unit as seen in replay data.

Note
This is only available if Flag::CompleteMapInformation is enabled.
Returns
An integer containing the replay unit identifier.
See also
getID
virtual Player BWAPI::UnitInterface::getPlayer () const pure virtual

Retrieves the player that owns this unit.

Return values
Game::neutral()If the unit is a neutral unit or inaccessible.
Returns
The owning Player interface object.
virtual UnitType BWAPI::UnitInterface::getType () const pure virtual

Retrieves the unit's type.

Return values
UnitTypes::Unknownif this unit is inaccessible or cannot be determined.
Returns
A UnitType objects representing the unit's type.
See also
getInitialType
virtual Position BWAPI::UnitInterface::getPosition () const pure virtual

Retrieves the unit's position from the upper left corner of the map in pixels.

The position returned is roughly the center if the unit.

Note
The unit bounds are defined as this value plus/minus the values of UnitType::dimensionLeft, UnitType::dimensionUp, UnitType::dimensionRight, and UnitType::dimensionDown, which is conveniently expressed in UnitInterface::getLeft, UnitInterface::getTop, UnitInterface::getRight, and UnitInterface::getBottom respectively.
Return values
Positions::Unknownif this unit is inaccessible.
Returns
Position object representing the unit's current position.
See also
getTilePosition, getInitialPosition, getLeft, getTop
TilePosition BWAPI::UnitInterface::getTilePosition () const

Retrieves the unit's build position from the upper left corner of the map in tiles.

Note
: This tile position is the tile that is at the top left corner of the structure.
Return values
TilePositions::Unknownif this unit is inaccessible.
Returns
TilePosition object representing the unit's current tile position.
See also
getPosition, getInitialTilePosition
virtual double BWAPI::UnitInterface::getAngle () const pure virtual

Retrieves the unit's facing direction in radians.

Note
A value of 0.0 means the unit is facing east.
Returns
A double with the angle measure in radians.
virtual double BWAPI::UnitInterface::getVelocityX () const pure virtual

Retrieves the x component of the unit's velocity, measured in pixels per frame.

Returns
A double that represents the velocity's x component.
See also
getVelocityY
virtual double BWAPI::UnitInterface::getVelocityY () const pure virtual

Retrieves the y component of the unit's velocity, measured in pixels per frame.

Returns
A double that represents the velocity's y component.
See also
getVelocityX
BWAPI::Region BWAPI::UnitInterface::getRegion () const

Retrieves the Region that the center of the unit is in.

Return values
nullptrIf the unit is inaccessible.
Returns
The Region object that contains this unit.

Example

Unitset myUnits = Broodwar->self()->getUnits();
for ( auto u = myUnits.begin(); u != myUnits.end(); ++u )
{
if ( u->isFlying() && u->isUnderAttack() ) // implies exists and isCompleted
{
Region r = u->getRegion();
if ( r )
u->move(r->getClosestInaccessibleRegion()); // Retreat to inaccessible region
}
}
Note
If this function returns a successful state, then the following function calls will also return a successful state: exists
int BWAPI::UnitInterface::getLeft () const

Retrieves the X coordinate of the unit's left boundary, measured in pixels from the left side of the map.

Returns
An integer representing the position of the left side of the unit.
See also
getTop, getRight, getBottom
int BWAPI::UnitInterface::getTop () const

Retrieves the Y coordinate of the unit's top boundary, measured in pixels from the top of the map.

Returns
An integer representing the position of the top side of the unit.
See also
getLeft, getRight, getBottom
int BWAPI::UnitInterface::getRight () const

Retrieves the X coordinate of the unit's right boundary, measured in pixels from the left side of the map.

Returns
An integer representing the position of the right side of the unit.
See also
getLeft, getTop, getBottom
int BWAPI::UnitInterface::getBottom () const

Retrieves the Y coordinate of the unit's bottom boundary, measured in pixels from the top of the map.

Returns
An integer representing the position of the bottom side of the unit.
See also
getLeft, getTop, getRight
virtual int BWAPI::UnitInterface::getHitPoints () const pure virtual

Retrieves the unit's current Hit Points (HP) as seen in the game.

Returns
An integer representing the amount of hit points a unit currently has.
Note
In Starcraft, a unit usually dies when its HP reaches 0. It is possible however, to have abnormal HP values in the Use Map Settings game type and as the result of a hack over Battle.net. Such values include units that have 0 HP (can't be killed conventionally) or even negative HP (death in one hit).
See also
UnitType::maxHitPoints, getShields, getInitialHitPoints
virtual int BWAPI::UnitInterface::getShields () const pure virtual

Retrieves the unit's current Shield Points (Shields) as seen in the game.

Returns
An integer representing the amount of shield points a unit currently has.
See also
UnitType::maxShields, getHitPoints
virtual int BWAPI::UnitInterface::getEnergy () const pure virtual

Retrieves the unit's current Energy Points (Energy) as seen in the game.

Returns
An integer representing the amount of energy points a unit currently has.
Note
Energy is required in order for units to use abilities.
See also
UnitType::maxEnergy
virtual int BWAPI::UnitInterface::getResources () const pure virtual

Retrieves the resource amount from a resource container, such as a Mineral Field and Vespene Geyser.

If the unit is inaccessible, then the last known resource amount is returned.

Returns
An integer representing the last known amount of resources remaining in this resource.
See also
getInitialResources
virtual int BWAPI::UnitInterface::getResourceGroup () const pure virtual

Retrieves a grouping index from a resource container.

Other resource containers of the same value are considered part of one expansion location (group of resources that are close together).

Note
This grouping method is explicitly determined by Starcraft itself and is used only by the internal AI.
Returns
An integer with an identifier between 0 and 250 that determine which resources are grouped together to form an expansion.
int BWAPI::UnitInterface::getDistance (Position target) const

Retrieves the distance between this unit and a target position.

Note
Distance is calculated from the edge of this unit, using Starcraft's own distance algorithm. Ignores collisions.
Parameters
targetA Position to calculate the distance to.
Returns
An integer representation of the number of pixels between this unit and the target.
int BWAPI::UnitInterface::getDistance (Unit target) const

Retrieves the distance between this unit and a target unit.

Note
Distance is calculated from the edge of this unit, using Starcraft's own distance algorithm. Ignores collisions.
Parameters
targetA Unit to calculate the distance to. Calculate the distance to the edge of the target unit.
Returns
An integer representation of the number of pixels between this unit and the target.
bool BWAPI::UnitInterface::hasPath (Position target) const

Using data provided by Starcraft, checks if there is a path available from this unit to the given target.

Note
This function only takes into account the terrain data, and does not include buildings when determining if a path is available. However, the complexity of this function is constant ( O(1) ), and no extensive calculations are necessary.
If the current unit is an air unit, then this function will always return true.
If the unit somehow gets stuck in unwalkable terrain, then this function may still return true if one of the unit's corners is on walkable terrain (i.e. if the unit is expected to return to the walkable terrain).
Parameters
targetA Position or a Unit that is used to determine if this unit has a path to the target.
Returns
true If there is a path between this unit and the target position, otherwise it will return false.
See also
Game::hasPath
bool BWAPI::UnitInterface::hasPath (Unit target) const

Using data provided by Starcraft, checks if there is a path available from this unit to the given target.

Note
This function only takes into account the terrain data, and does not include buildings when determining if a path is available. However, the complexity of this function is constant ( O(1) ), and no extensive calculations are necessary.
If the current unit is an air unit, then this function will always return true.
Parameters
targetA Position or a Unit that is used to determine if this unit has a path to the target.
Return values
trueIf there is a path between this unit and the target.
falseIf the target is on a different piece of land than this one (such as an island).
virtual int BWAPI::UnitInterface::getLastCommandFrame () const pure virtual

Retrieves the frame number that sent the last successful command.

Note
This value is comparable to Game::getFrameCount.
Returns
The frame number that sent the last successfully processed command to BWAPI.
See also
Game::getFrameCount, getLastCommand
virtual UnitCommand BWAPI::UnitInterface::getLastCommand () const pure virtual

Retrieves the last successful command that was sent to BWAPI.

Returns
A UnitCommand object containing information about the command that was processed.
See also
getLastCommandFrame
virtual BWAPI::Player BWAPI::UnitInterface::getLastAttackingPlayer () const pure virtual

Retrieves the Player that last attacked this unit.

Returns
Player interface object representing the player that last attacked this unit.
Return values
nullptrIf this unit was not attacked.
Note
If this function returns a successful state, then the following function calls will also return a successful state: exists()
virtual UnitType BWAPI::UnitInterface::getInitialType () const pure virtual

Retrieves the initial type of the unit.

This is the type that the unit starts as in the beginning of the game. This is used to access the types of static neutral units such as mineral fields when they are not visible.

Returns
UnitType of this unit as it was when it was created.
Return values
UnitTypes::Unknownif this unit was not a static neutral unit in the beginning of the game.
virtual Position BWAPI::UnitInterface::getInitialPosition () const pure virtual

Retrieves the initial position of this unit.

This is the position that the unit starts at in the beginning of the game. This is used to access the positions of static neutral units such as mineral fields when they are not visible.

Returns
Position indicating the unit's initial position when it was created.
Return values
Positions::Unknownif this unit was not a static neutral unit in the beginning of the game.
virtual TilePosition BWAPI::UnitInterface::getInitialTilePosition () const pure virtual

Retrieves the initial build tile position of this unit.

This is the tile position that the unit starts at in the beginning of the game. This is used to access the tile positions of static neutral units such as mineral fields when they are not visible. The build tile position corresponds to the upper left corner of the unit.

Returns
TilePosition indicating the unit's initial tile position when it was created.
Return values
TilePositions::Unknownif this unit was not a static neutral unit in the beginning of the game.
virtual int BWAPI::UnitInterface::getInitialHitPoints () const pure virtual

Retrieves the amount of hit points that this unit started off with at the beginning of the game.

The unit must be neutral.

Returns
Number of hit points that this unit started with.
Return values
0if this unit was not a neutral unit at the beginning of the game.
Note
: It is possible for the unit's initial hit points to differ from the maximum hit points.
See also
Game::getStaticNeutralUnits
virtual int BWAPI::UnitInterface::getInitialResources () const pure virtual

Retrieves the amount of resources contained in the unit at the beginning of the game.

The unit must be a neutral resource container.

Returns
Amount of resources that this unit started with.
Return values
0if this unit was not a neutral unit at the beginning of the game, or if this unit does not contain resources. It is possible that the unit simply contains 0 resources.
See also
Game::getStaticNeutralUnits
virtual int BWAPI::UnitInterface::getKillCount () const pure virtual

Retrieves the number of units that this unit has killed in total.

Note
The maximum amount of recorded kills per unit is 255.
Returns
integer indicating this unit's kill count.
virtual int BWAPI::UnitInterface::getAcidSporeCount () const pure virtual

Retrieves the number of acid spores that this unit is inflicted with.

Returns
Number of acid spores on this unit.
virtual int BWAPI::UnitInterface::getInterceptorCount () const pure virtual

Retrieves the number of interceptors that this unit manages.

This function is only for the Carrier and its hero.

Note
This number may differ from the number of units returned from getInterceptors. This occurs for cases in which you can see the number of enemy interceptors in the Carrier HUD, but don't actually have access to the individual interceptors.
Returns
Number of interceptors in this unit.
See also
getInterceptors
virtual int BWAPI::UnitInterface::getScarabCount () const pure virtual

Retrieves the number of scarabs that this unit has for use.

This function is only for the Reaver.

Returns
Number of scarabs this unit has ready.
virtual int BWAPI::UnitInterface::getSpiderMineCount () const pure virtual

Retrieves the amount of Spider Mines this unit has available.

This function is only for the Vulture.

Returns
Number of spider mines available for placement.
virtual int BWAPI::UnitInterface::getGroundWeaponCooldown () const pure virtual

Retrieves the unit's ground weapon cooldown.

This value decreases every frame, until it reaches 0. When the value is 0, this indicates that the unit is capable of using its ground weapon, otherwise it must wait until it reaches 0.

Note
This value will vary, because Starcraft adds an additional random value between (-1) and (+2) to the unit's weapon cooldown.
Returns
Number of frames needed for the unit's ground weapon to become available again.
virtual int BWAPI::UnitInterface::getAirWeaponCooldown () const pure virtual

Retrieves the unit's air weapon cooldown.

This value decreases every frame, until it reaches 0. When the value is 0, this indicates that the unit is capable of using its air weapon, otherwise it must wait until it reaches 0.

Note
This value will vary, because Starcraft adds an additional random value between (-1) and (+2) to the unit's weapon cooldown.
Returns
Number of frames needed for the unit's air weapon to become available again.
virtual int BWAPI::UnitInterface::getSpellCooldown () const pure virtual

Retrieves the unit's ability cooldown.

This value decreases every frame, until it reaches 0. When the value is 0, this indicates that the unit is capable of using one of its special abilities, otherwise it must wait until it reaches 0.

Note
This value will vary, because Starcraft adds an additional random value between (-1) and (+2) to the unit's ability cooldown.
Returns
Number of frames needed for the unit's abilities to become available again.
virtual int BWAPI::UnitInterface::getDefenseMatrixPoints () const pure virtual

Retrieves the amount of hit points remaining on the Defensive Matrix created by a Science Vessel.

The Defensive Matrix ability starts with 250 hit points when it is used.

Returns
Number of hit points remaining on this unit's Defensive Matrix.
See also
getDefenseMatrixTimer, isDefenseMatrixed
virtual int BWAPI::UnitInterface::getDefenseMatrixTimer () const pure virtual

Retrieves the time, in frames, that the Defensive Matrix will remain active on the current unit.

Returns
Number of frames remaining until the effect is removed.
See also
getDefenseMatrixPoints, isDefenseMatrixed
virtual int BWAPI::UnitInterface::getEnsnareTimer () const pure virtual

Retrieves the time, in frames, that Ensnare will remain active on the current unit.

Returns
Number of frames remaining until the effect is removed.
See also
isEnsnared
virtual int BWAPI::UnitInterface::getIrradiateTimer () const pure virtual

Retrieves the time, in frames, that Irradiate will remain active on the current unit.

Returns
Number of frames remaining until the effect is removed.
See also
isIrradiated
virtual int BWAPI::UnitInterface::getLockdownTimer () const pure virtual

Retrieves the time, in frames, that Lockdown will remain active on the current unit.

Returns
Number of frames remaining until the effect is removed.
See also
isLockdowned
virtual int BWAPI::UnitInterface::getMaelstromTimer () const pure virtual

Retrieves the time, in frames, that Maelstrom will remain active on the current unit.

Returns
Number of frames remaining until the effect is removed.
See also
isMaelstrommed
virtual int BWAPI::UnitInterface::getOrderTimer () const pure virtual

Retrieves an internal timer used for the primary order.

Its use is specific to the order type that is currently assigned to the unit.

Returns
A value used as a timer for the primary order.
See also
getOrder
virtual int BWAPI::UnitInterface::getPlagueTimer () const pure virtual

Retrieves the time, in frames, that Plague will remain active on the current unit.

Returns
Number of frames remaining until the effect is removed.
See also
isPlagued
virtual int BWAPI::UnitInterface::getRemoveTimer () const pure virtual

Retrieves the time, in frames, until this temporary unit is destroyed or removed.

This is used to determine the remaining time for the following units that were created by abilities:

Once this value reaches 0, the unit is destroyed.

virtual int BWAPI::UnitInterface::getStasisTimer () const pure virtual

Retrieves the time, in frames, that Stasis Field will remain active on the current unit.

Returns
Number of frames remaining until the effect is removed.
See also
isPlagued
virtual int BWAPI::UnitInterface::getStimTimer () const pure virtual

Retrieves the time, in frames, that Stim Packs will remain active on the current unit.

Returns
Number of frames remaining until the effect is removed.
See also
isPlagued
virtual UnitType BWAPI::UnitInterface::getBuildType () const pure virtual

Retrieves the building type that a worker (SCV, Probe, Drone) is about to construct.

If the unit is morphing or is an incomplete structure, then this returns the UnitType that it will become when it has completed morphing/constructing.

Returns
UnitType indicating the type that a worker (SCV, Probe, Drone) is about to construct, or an incomplete unit will be when completed.
virtual UnitType::list BWAPI::UnitInterface::getTrainingQueue () const pure virtual

Retrieves the list of units queued up to be trained.

Returns
a UnitType::list containing all the types that are in this factory's training queue, from oldest to most recent.
See also
train, cancelTrain, isTraining
virtual TechType BWAPI::UnitInterface::getTech () const pure virtual

Retrieves the technology that this unit is currently researching.

Returns
TechType indicating the technology being researched by this unit.
Return values
TechTypes::Noneif this unit is not researching anything.
See also
research, cancelResearch, isResearching, getRemainingResearchTime
virtual UpgradeType BWAPI::UnitInterface::getUpgrade () const pure virtual

Retrieves the upgrade that this unit is currently upgrading.

Returns
UpgradeType indicating the upgrade in progress by this unit.
Return values
UpgradeTypes::Noneif this unit is not upgrading anything.
See also
upgrade, cancelUpgrade, isUpgrading, getRemainingUpgradeTime
virtual int BWAPI::UnitInterface::getRemainingBuildTime () const pure virtual

Retrieves the remaining build time for a unit or structure that is being trained or constructed.

Returns
Number of frames remaining until the unit's completion.
virtual int BWAPI::UnitInterface::getRemainingTrainTime () const pure virtual

Retrieves the remaining time, in frames, of the unit that is currently being trained.

Note
If the unit is a Hatchery, Lair, or Hive, this retrieves the amount of time until the next larva spawns.
Returns
Number of frames remaining until the current training unit becomes completed, or the number of frames remaining until the next larva spawns.
Return values
0If the unit is not training or has three larvae.
See also
train, getTrainingQueue
virtual int BWAPI::UnitInterface::getRemainingResearchTime () const pure virtual

Retrieves the amount of time until the unit is done researching its currently assigned TechType.

Returns
The remaining research time, in frames, for the current technology being researched by this unit.
Return values
0If the unit is not researching anything.
See also
research, cancelResearch, isResearching, getTech
virtual int BWAPI::UnitInterface::getRemainingUpgradeTime () const pure virtual

Retrieves the amount of time until the unit is done upgrading its current upgrade.

Returns
The remaining upgrade time, in frames, for the current upgrade.
Return values
0If the unit is not upgrading anything.
See also
upgrade, cancelUpgrade, isUpgrading, getUpgrade
virtual Unit BWAPI::UnitInterface::getBuildUnit () const pure virtual

Retrieves the unit currently being trained, or the corresponding paired unit for SCVs and Terran structures, depending on the context.

For example, if this unit is a Factory under construction, this function will return the SCV that is constructing it. If this unit is a SCV, then it will return the structure it is currently constructing. If this unit is a Nexus, and it is training a Probe, then the probe will be returned.

Returns
Paired build unit that is either constructing this unit, structure being constructed by this unit, or the unit that is being trained by this structure.
Return values
nullptrIf there is no unit constructing this one, or this unit is not constructing another unit.
virtual Unit BWAPI::UnitInterface::getTarget () const pure virtual

Generally returns the appropriate target unit after issuing an order that accepts a target unit (i.e.

attack, repair, gather, etc.).

To get a target that has been acquired automatically without issuing an order, use getOrderTarget.

Returns
Unit that is currently being targeted by this unit.
See also
getOrderTarget
virtual Position BWAPI::UnitInterface::getTargetPosition () const pure virtual

Retrieves the target position the unit is moving to, provided a valid path to the target position exists.

Returns
Target position of a movement action.
virtual Order BWAPI::UnitInterface::getOrder () const pure virtual

Retrieves the primary Order that the unit is assigned.

Primary orders are distinct actions such as Orders::AttackUnit and Orders::PlayerGuard.

Returns
The primary Order that the unit is executing.
virtual Order BWAPI::UnitInterface::getSecondaryOrder () const pure virtual

Retrieves the secondary Order that the unit is assigned.

Secondary orders are run in the background as a sub-order. An example would be Orders::TrainFighter, because a Carrier can move and train fighters at the same time.

Returns
The secondary Order that the unit is executing.
virtual Unit BWAPI::UnitInterface::getOrderTarget () const pure virtual

Retrieves the unit's primary order target.

This is usually set when the low level unit AI acquires a new target automatically. For example if an enemy Probe comes in range of your Marine, the Marine will start attacking it, and getOrderTarget will be set in this case, but not getTarget.

Returns
The Unit that this unit is currently targetting.
See also
getTarget, getOrder
virtual Position BWAPI::UnitInterface::getOrderTargetPosition () const pure virtual

Retrieves the target position for the unit's order.

For example, when Orders::Move is assigned, getTargetPosition returns the end of the unit's path, but this returns the location that the unit is trying to move to.

Returns
Position that this unit is currently targetting.
See also
getTargetPosition, getOrder
virtual Position BWAPI::UnitInterface::getRallyPosition () const pure virtual

Retrieves the position the structure is rallying units to once they are completed.

Returns
Position that a completed unit coming from this structure will travel to.
Return values
Positions::NoneIf this building does not produce units.
Note
If getRallyUnit is valid, then this value is ignored.
See also
setRallyPoint, getRallyUnit
virtual Unit BWAPI::UnitInterface::getRallyUnit () const pure virtual

Retrieves the unit the structure is rallying units to once they are completed.

Units will then follow the targetted unit.

Returns
Unit that a completed unit coming from this structure will travel to.
Return values
nullptrIf the structure is not rallied to a unit or it does not produce units.
Note
A rallied unit takes precedence over a rallied position. That is if the return value is valid(non-null), then getRallyPosition is ignored.
See also
setRallyPoint, getRallyPosition
virtual Unit BWAPI::UnitInterface::getAddon () const pure virtual

Retrieves the add-on that is attached to this unit.

Returns
Unit interface that represents the add-on that is attached to this unit.
Return values
nullptrif this unit does not have an add-on.
virtual Unit BWAPI::UnitInterface::getNydusExit () const pure virtual

Retrieves the Nydus Canal that is attached to this one.

Every Nydus Canal can place a "Nydus Exit" which, when connected, can be travelled through by Zerg units.

Returns
Unit interface representing the Nydus Canal connected to this one.
Return values
nullptrif the unit is not a Nydus Canal, is not owned, or has not placed a Nydus Exit.
virtual Unit BWAPI::UnitInterface::getPowerUp () const pure virtual

Retrieves the power-up that the worker unit is holding.

Power-ups are special units such as the Flag in the Capture The Flag game type, which can be picked up by worker units.

Note
If your bot is strictly melee/1v1, then this method is not necessary.
Returns
The Unit interface object that represents the power-up.
Return values
nullptrIf the unit is not carrying anything.

Example

BWAPI::Unitset myUnits = BWAPI::Broodwar->self()getUnits();
for ( auto u = myUnits.begin(); u != myUnits.end(); ++u )
{
// If we are carrying a flag
if ( u->getPowerUp() && u->getPowerUp()->getType() == BWAPI::UnitTypes::Powerup_Flag )
u->move( u->getClosestUnit(BWAPI::Filter::IsFlagBeacon && BWAPI::Filter::IsOwned) ); // return it to our flag beacon to score
}
Note
If this function returns a successful state, then the following function calls will also return a successful state: getType().isWorker(), isCompleted()
virtual Unit BWAPI::UnitInterface::getTransport () const pure virtual

Retrieves the Transport(Dropship, Shuttle, Overlord ) or Bunker unit that has this unit loaded inside of it.

Returns
Unit interface object representing the Transport(Dropship, Shuttle, Overlord ) containing this unit.
Return values
nullptrif this unit is not in a Transport(Dropship, Shuttle, Overlord ).
virtual Unitset BWAPI::UnitInterface::getLoadedUnits () const pure virtual

Retrieves the set of units that are contained within this Bunker or Transport(Dropship, Shuttle, Overlord ).

Returns
A Unitset object containing all of the units that are loaded inside of the current unit.
int BWAPI::UnitInterface::getSpaceRemaining () const

Retrieves the remaining unit-space available for Bunkers and Transports(Dropships, Shuttles, Overlords ).

Returns
The number of spots available to transport a unit.
See also
getLoadedUnits
virtual Unit BWAPI::UnitInterface::getCarrier () const pure virtual

Retrieves the parent Carrier that owns this Interceptor.

Returns
The parent Carrier unit that has ownership of this one.
Return values
nullptrif the current unit is not an Interceptor.
virtual Unitset BWAPI::UnitInterface::getInterceptors () const pure virtual

Retrieves the set of Interceptors controlled by this unit.

This is intended for Carriers and its hero.

Returns
Unitset containing Interceptor units owned by this carrier.
See also
getInterceptorCount
virtual Unit BWAPI::UnitInterface::getHatchery () const pure virtual

Retrieves the parent Hatchery, Lair, or Hive that owns this particular unit.

This is intended for Larvae.

Returns
Hatchery unit that has ownership of this larva.
Return values
nullptrif the current unit is not a Larva or has no parent.
See also
getLarva
virtual Unitset BWAPI::UnitInterface::getLarva () const pure virtual

Retrieves the set of Larvae that were spawned by this unit.

Only Hatcheries, Lairs, and Hives are capable of spawning Larvae. This is like clicking the "Select Larva" button and getting the selection of Larvae.

Returns
Unitset containing Larva units owned by this unit. The set will be empty if there are none.
See also
getHatchery
Unitset BWAPI::UnitInterface::getUnitsInRadius (int radius, const UnitFilterpred = nullptr ) const

Retrieves the set of all units in a given radius of the current unit.

Takes into account this unit's dimensions. Can optionally specify a filter that is composed using BWAPIFilter semantics to include only specific units (such as only ground units, etc.)

Parameters
radiusThe radius, in pixels, to search for units.
pred(optional) The composed function predicate to include only specific (desired) units in the set. Defaults to nullptr, which means no filter.
Returns
A Unitset containing the set of units that match the given criteria.

Example usage:

// Get main building closest to start location.
BWAPI::Unit pMain = BWAPI::Broodwar->getClosestUnit( BWAPI::Broodwar->self()->getStartLocation(), BWAPI::Filter::IsResourceDepot );
if ( pMain ) // check if pMain is valid
{
// Get sets of resources and workers
if ( !myResources.empty() ) // check if we have resources nearby
{
while ( !myWorkers.empty() ) // make sure we command all nearby idle workers, if any
{
for ( auto u = myResources.begin(); u != myResources.end() && !myWorkers.empty(); ++u )
{
myWorkers.back()->gather(*u);
myWorkers.pop_back();
}
}
} // myResources not empty
} // pMain != nullptr
See also
getClosestUnit, getUnitsInWeaponRange, Game::getUnitsInRadius, Game::getUnitsInRectangle
Unitset BWAPI::UnitInterface::getUnitsInWeaponRange (WeaponType weapon, const UnitFilterpred = nullptr ) const

Obtains the set of units within weapon range of this unit.

Parameters
weaponThe weapon type to use as a filter for distance and units that can be hit by it.
pred(optional) A predicate used as an additional filter. If omitted, no additional filter is used.
See also
getUnitsInRadius, getClosestUnit, Game::getUnitsInRadius, Game::getUnitsInRectangle
Unit BWAPI::UnitInterface::getClosestUnit (const UnitFilterpred = nullptr, int radius = 999999 ) const

Retrieves the closest unit to this one.

Parameters
pred(optional) A function predicate used to identify which conditions must be matched for a unit to be considered. If omitted, then the closest unit owned by any player will be returned.
radius(optional) The maximum radius to check for the closest unit. For performance reasons, a developer can limit the radius that is checked. If omitted, then the entire map is checked.
See also
getUnitsInRadius, Game::getUnitsInRadius, Game::getUnitsInRectangle
virtual bool BWAPI::UnitInterface::hasNuke () const pure virtual

Checks if the current unit is housing a Nuke.

This is only available for Nuclear Silos.

Returns
true if this unit has a Nuke ready, and false if there is no Nuke.
virtual bool BWAPI::UnitInterface::isAccelerating () const pure virtual

Checks if the current unit is accelerating.

Returns
true if this unit is accelerating, and false otherwise
virtual bool BWAPI::UnitInterface::isAttacking () const pure virtual

Checks if this unit is currently attacking something.

Returns
true if this unit is attacking another unit, and false if it is not.
virtual bool BWAPI::UnitInterface::isAttackFrame () const pure virtual

Checks if this unit is currently playing an attack animation.

Issuing commands while this returns true may interrupt the unit's next attack sequence.

Returns
true if this unit is currently running an attack frame, and false if interrupting the unit is feasible.
Note
This function is only available to some unit types, specifically those that play special animations when they attack.
bool BWAPI::UnitInterface::isBeingConstructed () const

Checks if the current unit is being constructed.

This is mostly applicable to Terran structures which require an SCV to be constructing a structure.

Return values
trueif this is either a Protoss structure, Zerg structure, or Terran structure being constructed by an attached SCV.
falseif this is either completed, not a structure, or has no SCV constructing it
See also
build, cancelConstruction, haltConstruction, isConstructing
virtual bool BWAPI::UnitInterface::isBeingGathered () const pure virtual

Checks this Mineral Field or Refinery is currently being gathered from.

Returns
true if this unit is a resource container and being harvested by a worker, and false otherwise
virtual bool BWAPI::UnitInterface::isBeingHealed () const pure virtual

Checks if this unit is currently being healed by a Medic or repaired by a SCV.

Returns
true if this unit is being healed, and false otherwise.
virtual bool BWAPI::UnitInterface::isBlind () const pure virtual

Checks if this unit is currently blinded by a Medic 's Optical Flare ability.

Blinded units have reduced sight range and cannot detect other units.

Returns
true if this unit is blind, and false otherwise
virtual bool BWAPI::UnitInterface::isBraking () const pure virtual

Checks if the current unit is slowing down to come to a stop.

Returns
true if this unit is breaking, false if it has stopped or is still moving at full speed.
virtual bool BWAPI::UnitInterface::isBurrowed () const pure virtual

Checks if the current unit is burrowed, either using the Burrow ability, or is an armed Spider Mine.

Returns
true if this unit is burrowed, and false otherwise
See also
burrow, unburrow
virtual bool BWAPI::UnitInterface::isCarryingGas () const pure virtual

Checks if this worker unit is carrying some vespene gas.

Returns
true if this is a worker unit carrying vespene gas, and false if it is either not a worker, or not carrying gas.

Example

BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits();
for ( auto u = myUnits.begin(); u != myUnits.end(); ++u )
{
if ( u->isIdle() && (u->isCarryingGas() || u->isCarryingMinerals()) )
u->returnCargo();
}
Note
If this function returns a successful state, then the following function calls will also return a successful state: isCompleted(), getType().isWorker()
See also
returnCargo, isGatheringGas, isCarryingMinerals
virtual bool BWAPI::UnitInterface::isCarryingMinerals () const pure virtual

Checks if this worker unit is carrying some minerals.

Returns
true if this is a worker unit carrying minerals, and false if it is either not a worker, or not carrying minerals.

Example

BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits();
for ( auto u = myUnits.begin(); u != myUnits.end(); ++u )
{
if ( u->isIdle() && (u->isCarryingGas() || u->isCarryingMinerals()) )
u->returnCargo();
}
Note
If this function returns a successful state, then the following function calls will also return a successful state: isCompleted(), getType().isWorker()
See also
returnCargo, isGatheringMinerals, isCarryingMinerals
virtual bool BWAPI::UnitInterface::isCloaked () const pure virtual

Checks if this unit is currently cloaked.

Returns
true if this unit is cloaked, and false if it is visible.
See also
cloak, decloak
virtual bool BWAPI::UnitInterface::isCompleted () const pure virtual

Checks if this unit has finished being constructed, trained, morphed, or warped in, and can now receive orders.

Returns
true if this unit is completed, and false if it is under construction or inaccessible.
virtual bool BWAPI::UnitInterface::isConstructing () const pure virtual

Checks if a unit is either constructing something or moving to construct something.

Returns
true when a unit has been issued an order to build a structure and is moving to the build location, or is currently constructing something.
See also
isBeingConstructed, build, cancelConstruction, haltConstruction
bool BWAPI::UnitInterface::isDefenseMatrixed () const

Checks if this unit has the Defensive Matrix effect.

Returns
true if the Defensive Matrix ability was used on this unit, and false otherwise.
virtual bool BWAPI::UnitInterface::isDetected () const pure virtual

Checks if this unit is visible or revealed by a detector unit.

If this is false and isVisible is true, then the unit is only partially visible and requires a detector in order to be targetted.

Returns
true if this unit is detected, and false if it needs a detector unit nearby in order to see it.
Note
If this function returns a successful state, then the following function calls will also return a successful state: isVisible
bool BWAPI::UnitInterface::isEnsnared () const

Checks if the Queen ability Ensnare has been used on this unit.

Returns
true if the unit is ensnared, and false if it is not
bool BWAPI::UnitInterface::isFlying () const

This macro function checks if this unit is in the air.

That is, the unit is either a flyer or a flying building.

Returns
true if this unit is in the air, and false if it is on the ground
See also
UnitType::isFlyer, UnitInterface::isLifted
bool BWAPI::UnitInterface::isFollowing () const

Checks if this unit is following another unit.

When a unit is following another unit, it simply moves where the other unit does, and does not attack enemies when it is following.

Returns
true if this unit is following another unit, and false if it is not
Note
If this function returns a successful state, then the following function calls will also return a successful state: isCompleted
See also
follow, getTarget
virtual bool BWAPI::UnitInterface::isGatheringGas () const pure virtual

Checks if this unit is currently gathering gas.

That is, the unit is either moving to a refinery, waiting to enter a refinery, harvesting from the refinery, or returning gas to a resource depot.

Returns
true if this unit is harvesting gas, and false if it is not
Note
If this function returns a successful state, then the following function calls will also return a successful state: isCompleted, getType().isWorker()
See also
isCarryingGas
virtual bool BWAPI::UnitInterface::isGatheringMinerals () const pure virtual

Checks if this unit is currently harvesting minerals.

That is, the unit is either moving to a Mineral Field, waiting to mine, mining minerals, or returning minerals to a resource depot.

Returns
true if this unit is gathering minerals, and false if it is not
Note
If this function returns a successful state, then the following function calls will also return a successful state: isCompleted, getType().isWorker()
See also
isCarryingMinerals
virtual bool BWAPI::UnitInterface::isHallucination () const pure virtual

Checks if this unit is a hallucination.

Hallucinations are created by the High Templar using the Hallucination ability. Enemy hallucinations are unknown if Flag::CompleteMapInformation is disabled. Hallucinations have a time limit until they are destroyed (see UnitInterface::getRemoveTimer).

Returns
true if the unit is a hallucination and false otherwise.
See also
getRemoveTimer
bool BWAPI::UnitInterface::isHoldingPosition () const

Checks if the unit is currently holding position.

A unit that is holding position will attack other units, but will not chase after them.

Returns
true if this unit is holding position, and false if it is not.
See also
holdPosition
virtual bool BWAPI::UnitInterface::isIdle () const pure virtual

Checks if this unit is running an idle order.

This function is particularly useful when checking for units that aren't doing any tasks that you assigned.

A unit is considered idle if it is not doing any of the following:

  • Training
  • Constructing
  • Morphing
  • Researching
  • Upgrading

In addition to running one of the following orders:

BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits();
for ( auto u = myUnits.begin(); u != myUnits.end(); ++u )
{
// Order idle worker to gather from closest mineral field
if ( u->getType().isWorker() && u->isIdle() )
u->gather( u->getClosestUnit( BWAPI::Filter::IsMineralField ) );
}
Returns
true if this unit is idle, and false if this unit is performing any action, such as moving or attacking
Note
If this function returns a successful state, then the following function calls will also return a successful state: isCompleted
See also
UnitInterface::stop
virtual bool BWAPI::UnitInterface::isInterruptible () const pure virtual

Checks if the unit can be interrupted.

Returns
true if this unit can be interrupted, or false if this unit is uninterruptable
virtual bool BWAPI::UnitInterface::isInvincible () const pure virtual

Checks the invincibility state for this unit.

Returns
true if this unit is currently invulnerable, and false if it is vulnerable
bool BWAPI::UnitInterface::isInWeaponRange (Unit target) const

Checks if the target unit can immediately be attacked by this unit in the current frame.

Parameters
targetThe target unit to use in this check.
Returns
true if target is within weapon range of this unit's appropriate weapon, and false otherwise.
Return values
falseif target is invalid, inaccessible, too close, too far, or this unit does not have a weapon that can attack target.
bool BWAPI::UnitInterface::isIrradiated () const

Checks if this unit is irradiated by a Science Vessel 's Irradiate ability.

Returns
true if this unit is irradiated, and false otherwise

Example usage:

BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits();
for ( auto u = myUnits.begin(); u != myUnits.end(); ++u )
{
if ( u->isIrradiated() && u->getIrradiateTimer > 50 && BWAPI::Broodwar->self()->hasResearched(BWAPI::TechTypes::Restoration) )
{
if ( medic )
}
}
See also
getIrradiateTimer
virtual bool BWAPI::UnitInterface::isLifted () const pure virtual

Checks if this unit is a Terran building and lifted off the ground.

This function generally implies this->getType().isBuilding() and this->isCompleted() both return true.

Returns
true if this unit is a Terran structure lifted off the ground.
Note
If this function returns a successful state, then the following function calls will also return a successful state: isCompleted, getType().isFlyingBuilding()
See also
isFlying
bool BWAPI::UnitInterface::isLoaded () const

Checks if this unit is currently loaded into another unit such as a Transport(Dropship, Shuttle, Overlord ).

Returns
true if this unit is loaded in another one, and false otherwise
Note
If this function returns a successful state, then the following function calls will also return a successful state: isCompleted
See also
load, unload, unloadAll
bool BWAPI::UnitInterface::isLockedDown () const

Checks if this unit is currently locked by a Ghost.

Returns
true if this unit is locked down, and false otherwise
See also
getLockdownTimer
bool BWAPI::UnitInterface::isMaelstrommed () const

Checks if this unit has been maelstrommed by a Dark Archon.

Returns
true if this unit is maelstrommed, and false otherwise
See also
getMaelstromTimer
virtual bool BWAPI::UnitInterface::isMorphing () const pure virtual

Finds out if the current unit is morphing or not.

Zerg units and structures often have the ability to morph into different types of units. This function allows you to identify when this process is occurring.

Return values
trueif the unit is currently morphing.
falseif the unit is not morphing
See also
morph, cancelMorph, getBuildType, getRemainingBuildTime
virtual bool BWAPI::UnitInterface::isMoving () const pure virtual

Checks if this unit is currently moving.

Returns
true if this unit is moving, and false if it is not
See also
stop
virtual bool BWAPI::UnitInterface::isParasited () const pure virtual

Checks if this unit has been parasited by some other player.

Returns
true if this unit is inflicted with Parasite, and false if it is clean
bool BWAPI::UnitInterface::isPatrolling () const

Checks if this unit is patrolling between two positions.

Returns
true if this unit is patrolling and false if it is not
See also
patrol
bool BWAPI::UnitInterface::isPlagued () const

Checks if this unit has been been plagued by a Defiler.

Returns
true if this unit is inflicted with Plague and is taking damage, and false if it is clean
See also
getPlagueTimer
bool BWAPI::UnitInterface::isRepairing () const

Checks if this unit is repairing or moving to repair another unit.

This is only applicable to SCVs.

Returns
true if this unit is currently repairing or moving to repair another unit, and false if it is not
bool BWAPI::UnitInterface::isResearching () const

Checks if this unit is a structure that is currently researching a technology.

See TechTypes for a complete list of technologies in Broodwar.

Returns
true if this structure is researching a technology, false otherwise
See also
research, cancelResearch, getTech, getRemainingResearchTime,
Note
If this function returns a successful state, then the following function calls will also return a successful state: exists(), isCompleted(), getType().isBuilding()
virtual bool BWAPI::UnitInterface::isSelected () const pure virtual

Checks if this unit has been selected in the user interface.

This function is only available if the flag Flag::UserInput is enabled.

Returns
true if this unit is currently selected, and false if this unit is not selected
See also
Game::getSelectedUnits
bool BWAPI::UnitInterface::isSieged () const

Checks if this unit is currently sieged.

This is only applicable to Siege Tanks.

Returns
true if the unit is in siege mode, and false if it is either not in siege mode or not a Siege Tank
See also
siege, unsiege
virtual bool BWAPI::UnitInterface::isStartingAttack () const pure virtual

Checks if the unit is starting to attack.

Returns
true if this unit is starting an attack.
See also
attack, getGroundWeaponCooldown, getAirWeaponCooldown
bool BWAPI::UnitInterface::isStasised () const

Checks if this unit is inflicted with Stasis Field by an Arbiter.

Returns
true if this unit is locked in a Stasis Field and is unable to move, and false if it is free.
Note
This function does not necessarily imply that the unit is invincible, since there is a feature in the Use Map Settings game type that allows stasised units to be vulnerable.
See also
getStasisTimer
bool BWAPI::UnitInterface::isStimmed () const

Checks if this unit is currently under the influence of a Stim Packs.

Returns
true if this unit has used a stim pack, false otherwise
See also
getStimTimer
virtual bool BWAPI::UnitInterface::isStuck () const pure virtual

Checks if this unit is currently trying to resolve a collision by randomly moving around.

Returns
true if this unit is currently stuck and trying to resolve a collision, and false if this unit is free
virtual bool BWAPI::UnitInterface::isTraining () const pure virtual

Checks if this unit is training a new unit.

For example, a Barracks training a Marine.

Note
It is possible for a unit to remain in the training queue with no progress. In that case, this function will return false because of supply or unit count limitations.
Returns
true if this unit is currently training another unit, and false otherwise.
See also
train, getTrainingQueue, cancelTrain, getRemainingTrainTime
virtual bool BWAPI::UnitInterface::isUnderAttack () const pure virtual

Checks if the current unit is being attacked.

Has a small delay before this returns false again when the unit is no longer being attacked.

Returns
true if this unit has been attacked within the past few frames, and false if it has not
virtual bool BWAPI::UnitInterface::isUnderDarkSwarm () const pure virtual

Checks if this unit is under the cover of a Dark Swarm.

Returns
true if this unit is protected by a Dark Swarm, and false if it is not
virtual bool BWAPI::UnitInterface::isUnderDisruptionWeb () const pure virtual

Checks if this unit is currently being affected by a Disruption Web.

Returns
true if this unit is under the effects of Disruption Web.
virtual bool BWAPI::UnitInterface::isUnderStorm () const pure virtual

Checks if this unit is currently taking damage from a Psionic Storm.

Returns
true if this unit is losing hit points from a Psionic Storm, and false otherwise.
virtual bool BWAPI::UnitInterface::isPowered () const pure virtual

Checks if this unit has power.

Most structures are powered by default, but Protoss structures require a Pylon to be powered and functional.

Returns
true if this unit has power or is inaccessible, and false if this unit is unpowered.
Since
4.0.1 Beta (previously isUnpowered)
bool BWAPI::UnitInterface::isUpgrading () const

Checks if this unit is a structure that is currently upgrading an upgrade.

See UpgradeTypes for a full list of upgrades in Broodwar.

Returns
true if this structure is upgrading, false otherwise
See also
upgrade, cancelUpgrade, getUpgrade, getRemainingUpgradeTime
Note
If this function returns a successful state, then the following function calls will also return a successful state: exists(), isCompleted(), getType().isBuilding()
virtual bool BWAPI::UnitInterface::isVisible (Player player = nullptr) const pure virtual

Checks if this unit is visible.

Parameters
player(optional) The player to check visibility for. If this parameter is omitted, then the BWAPI player obtained from Game::self will be used.
Returns
true if this unit is visible to the specified player, and false if it is not.
Note
If the Flag::CompleteMapInformation flag is enabled, existing units hidden by the fog of war will be accessible, but isVisible will still return false.
See also
exists
virtual bool BWAPI::UnitInterface::isTargetable () const pure virtual

Performs some cheap checks to attempt to quickly detect whether the unit is unable to be targetted as the target unit of an unspecified command.

Return values
trueif BWAPI was unable to determine whether the unit can be a target.
falseif an error occurred and the unit can not be a target.
See also
Game::getLastError, UnitInterface::canTargetUnit
virtual bool BWAPI::UnitInterface::issueCommand (UnitCommand command) pure virtual

This function issues a command to the unit(s), however it is used for interfacing only, and is recommended to use one of the more specific command functions when writing an AI.

Parameters
commandA UnitCommand containing command parameters such as the type, position, target, etc.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
UnitCommandTypes, Game::getLastError, UnitInterface::canIssueCommand
bool BWAPI::UnitInterface::attack (Position target, bool shiftQueueCommand = false )

Orders the unit(s) to attack move to the specified position.

Parameters
targetA Position to designate as the target. The unit will perform an Attack Move command.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
A Medic will use Heal Move instead of attack.
See also
Game::getLastError, UnitInterface::canAttack
bool BWAPI::UnitInterface::attack (Unit target, bool shiftQueueCommand = false )

Orders the unit(s) to attack the specified target unit.

Parameters
targetA Unit to designate as the target.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
Game::getLastError, UnitInterface::canAttack
bool BWAPI::UnitInterface::build (UnitType type, TilePosition target = TilePositions::None )

Orders the worker unit(s) to construct a structure at a target position.

Parameters
typeThe UnitType to build.
targetA TilePosition to specify the build location, specifically the upper-left corner of the location. If the target is not specified, then the function call will be redirected to the train command.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
You must have sufficient resources and meet the necessary requirements in order to build a structure.
See also
Game::getLastError, UnitInterface::train, UnitInterface::cancelConstruction, UnitInterface::canBuild
bool BWAPI::UnitInterface::buildAddon (UnitType type)

Orders the Terran structure(s) to construct an add-on.

Parameters
typeThe add-on UnitType to construct.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
You must have sufficient resources and meet the necessary requirements in order to build a structure.
See also
Game::getLastError, UnitInterface::build, UnitInterface::cancelAddon, UnitInterface::canBuildAddon
bool BWAPI::UnitInterface::train (UnitType type = UnitTypes::None)

Orders the unit(s) to add a UnitType to its training queue, or morphs into the UnitType if it is Zerg.

Parameters
typeThe UnitType to train.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
You must have sufficient resources, supply, and meet the necessary requirements in order to train a unit.
This command is also used for training Interceptors and Scarabs.
If you call this using a Hatchery, Lair, or Hive, then it will automatically pass the command to one of its Larvae.
See also
Game::getLastError, UnitInterface::build, UnitInterface::morph, UnitInterface::cancelTrain, UnitInterface::isTraining, UnitInterface::canTrain
bool BWAPI::UnitInterface::morph (UnitType type)

Orders the unit(s) to morph into a different UnitType.

Parameters
typeThe UnitType to morph into.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
Game::getLastError, UnitInterface::build, UnitInterface::morph, UnitInterface::canMorph
bool BWAPI::UnitInterface::research (TechType tech)

Orders the unit to research the given tech type.

Parameters
techThe TechType to research.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
cancelResearch, isResearching, getRemainingResearchTime, getTech, canResearch
bool BWAPI::UnitInterface::upgrade (UpgradeType upgrade)

Orders the unit to upgrade the given upgrade type.

Parameters
upgradeThe UpgradeType to upgrade.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
cancelUpgrade, isUpgrading, getRemainingUpgradeTime, getUpgrade, canUpgrade
bool BWAPI::UnitInterface::setRallyPoint (Position target)

Orders the unit to set its rally position.

Parameters
targetThe target position that this structure will rally completed units to.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
getRallyPosition, getRallyUnit, canSetRallyPoint, canSetRallyPosition, canSetRallyUnit
bool BWAPI::UnitInterface::setRallyPoint (Unit target)

Orders the unit to set its rally position to the specified unit.

Parameters
targetThe target unit that this structure will rally completed units to.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
getRallyPosition, getRallyUnit, canSetRallyPoint, canSetRallyPosition, canSetRallyUnit
bool BWAPI::UnitInterface::move (Position target, bool shiftQueueCommand = false )

Orders the unit to move from its current position to the specified position.

Parameters
targetThe target position to move to.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
isMoving, canMove
bool BWAPI::UnitInterface::patrol (Position target, bool shiftQueueCommand = false )

Orders the unit to patrol between its current position and the specified position.

While patrolling, units will attack and chase enemy units that they encounter, and then return to its patrol route. Medics will automatically heal units and then return to their patrol route.

Parameters
targetThe position to patrol to.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
isPatrolling, canPatrol
bool BWAPI::UnitInterface::holdPosition (bool shiftQueueCommand = false)

Orders the unit to hold its position.

Parameters
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
canHoldPosition, isHoldingPosition
bool BWAPI::UnitInterface::stop (bool shiftQueueCommand = false)

Orders the unit to stop.

Parameters
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
canStop, isIdle
bool BWAPI::UnitInterface::follow (Unit target, bool shiftQueueCommand = false )

Orders the unit to follow the specified unit.

Units that are following other units will not perform any other actions such as attacking. They will ignore attackers.

Parameters
targetThe target unit to start following.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
isFollowing, canFollow, getOrderTarget
bool BWAPI::UnitInterface::gather (Unit target, bool shiftQueueCommand = false )

Orders the unit to gather the specified unit (must be mineral or refinery type).

Parameters
targetThe target unit to gather from.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
isGatheringGas, isGatheringMinerals, canGather
bool BWAPI::UnitInterface::returnCargo (bool shiftQueueCommand = false)

Orders the unit to return its cargo to a nearby resource depot such as a Command Center.

Only workers that are carrying minerals or gas can be ordered to return cargo.

Parameters
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
isCarryingGas, isCarryingMinerals, canReturnCargo
bool BWAPI::UnitInterface::repair (Unit target, bool shiftQueueCommand = false )

Orders the unit to repair the specified unit.

Only Terran SCVs can be ordered to repair, and the target must be a mechanical Terran unit or building.

Parameters
targetThe unit to repair.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
isRepairing, canRepair
bool BWAPI::UnitInterface::burrow ()

Orders the unit to burrow.

Either the unit must be a Lurker, or the unit must be a Zerg ground unit that is capable of Burrowing, and Burrow technology must be researched.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
unburrow, isBurrowed, canBurrow
bool BWAPI::UnitInterface::unburrow ()

Orders a burrowed unit to unburrow.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
burrow, isBurrowed, canUnburrow
bool BWAPI::UnitInterface::cloak ()

Orders the unit to cloak.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
decloak, isCloaked, canCloak
bool BWAPI::UnitInterface::decloak ()

Orders a cloaked unit to decloak.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
cloak, isCloaked, canDecloak
bool BWAPI::UnitInterface::siege ()

Orders the unit to siege.

Only works for Siege Tanks.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
unsiege, isSieged, canSiege
bool BWAPI::UnitInterface::unsiege ()

Orders the unit to unsiege.

Only works for sieged Siege Tanks.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
siege, isSieged, canUnsiege
bool BWAPI::UnitInterface::lift ()

Orders the unit to lift.

Only works for liftable Terran structures.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
land, isLifted, canLift
bool BWAPI::UnitInterface::land (TilePosition target)

Orders the unit to land.

Only works for Terran structures that are currently lifted.

Parameters
targetThe tile position to land this structure at.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
lift, isLifted, canLand
bool BWAPI::UnitInterface::load (Unit target, bool shiftQueueCommand = false )

Orders the unit to load the target unit.

Only works if this unit is a Transport(Dropship, Shuttle, Overlord ) or Bunker type.

Parameters
targetThe target unit to load into this Transport(Dropship, Shuttle, Overlord ) or Bunker.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
unload, unloadAll, getLoadedUnits, isLoaded
bool BWAPI::UnitInterface::unload (Unit target)

Orders the unit to unload the target unit.

Only works for Transports(Dropships, Shuttles, Overlords ) and Bunkers.

Parameters
targetUnloads the target unit from this Transport(Dropship, Shuttle, Overlord ) or Bunker.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
load, unloadAll, getLoadedUnits, isLoaded, canUnload, canUnloadAtPosition
bool BWAPI::UnitInterface::unloadAll (bool shiftQueueCommand = false)

Orders the unit to unload all loaded units at the unit's current position.

Only works for Transports(Dropships, Shuttles, Overlords ) and Bunkers.

Parameters
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
load, unload, getLoadedUnits, isLoaded, canUnloadAll, canUnloadAtPosition
bool BWAPI::UnitInterface::unloadAll (Position target, bool shiftQueueCommand = false )

Orders the unit to unload all loaded units at the specified location.

Only works for Transports(Dropships, Shuttles, Overlords ). Not applicable to Bunkers.

Parameters
targetThe target position to unload the units at.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
load, unload, getLoadedUnits, isLoaded, canUnloadAllPosition, canUnloadAtPosition
bool BWAPI::UnitInterface::rightClick (Position target, bool shiftQueueCommand = false )

Performs a right click action as it would work in StarCraft.

Parameters
targetThe target position to right click.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
canRightClick, canRightClickPosition, canRightClickUnit
bool BWAPI::UnitInterface::rightClick (Unit target, bool shiftQueueCommand = false )

Performs a right click action as it would work in StarCraft.

Parameters
targetThe target unit to right click.
shiftQueueCommand(optional) If this value is true, then the order will be queued instead of immediately executed. If this value is omitted, then the order will be executed immediately by default.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
canRightClick, canRightClickPosition, canRightClickUnit
bool BWAPI::UnitInterface::haltConstruction ()

Orders a SCV to stop constructing a structure.

This leaves the structure in an incomplete state until it is either cancelled, razed, or completed by another SCV.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
isConstructing, canHaltConstruction
bool BWAPI::UnitInterface::cancelConstruction ()

Orders this unit to cancel and refund itself from begin constructed.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
isBeingConstructed, build, canCancelConstruction
bool BWAPI::UnitInterface::cancelAddon ()

Orders this unit to cancel and refund an add-on that is being constructed.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
canCancelAddon, buildAddon
bool BWAPI::UnitInterface::cancelTrain (int slot = -2)

Orders the unit to remove the specified unit from its training queue.

Parameters
slot(optional) Identifies the slot that will be cancelled. If the specified value is at least 0, then the unit in the corresponding slot from the list provided by getTrainingQueue will be cancelled. If the value is either omitted or -2, then the last slot is cancelled.
Note
The value of slot is passed directly to Broodwar. Other negative values have no effect.
See also
train, cancelTrain, isTraining, getTrainingQueue, canCancelTrain, canCancelTrainSlot
bool BWAPI::UnitInterface::cancelMorph ()

Orders this unit to cancel and refund a unit that is morphing.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
morph, isMorphing, canCancelMorph
bool BWAPI::UnitInterface::cancelResearch ()

Orders this unit to cancel and refund a research that is in progress.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
research, isResearching, getTech, canCancelResearch
bool BWAPI::UnitInterface::cancelUpgrade ()

Orders this unit to cancel and refund an upgrade that is in progress.

Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
See also
upgrade, isUpgrading, getUpgrade, canCancelUpgrade
bool BWAPI::UnitInterface::useTech (TechType tech, Position target )

Orders the unit to use a technology.

Parameters
techThe technology type to use.
targetIf specified, indicates the target location to use the tech on.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
See also
canUseTechWithOrWithoutTarget, canUseTech, canUseTechWithoutTarget, canUseTechUnit, canUseTechPosition, TechTypes
bool BWAPI::UnitInterface::useTech (TechType tech, Unit target = nullptr )

Orders the unit to use a technology.

Parameters
techThe technology type to use.
target(optional) If specified, indicates the target unit to use the tech on. If unspecified, causes the tech to be used without a target (i.e. Stim Packs).
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
See also
canUseTechWithOrWithoutTarget, canUseTech, canUseTechWithoutTarget, canUseTechUnit, canUseTechPosition, TechTypes
bool BWAPI::UnitInterface::placeCOP (TilePosition target)

Moves a Flag Beacon to a different location.

This is only used for Capture The Flag or Use Map Settings game types.

Parameters
targetThe target tile position to place the Flag Beacon.
Returns
true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail.
Note
There is a small chance for a command to fail after it has been passed to Broodwar.
This command is only available for the first 10 minutes of the game, as in Broodwar.
See also
canPlaceCOP
virtual bool BWAPI::UnitInterface::canIssueCommand (UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanBuildUnitType = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute the given command.

If you are calling this function repeatedly (e.g. to generate a collection of valid commands), you can avoid repeating the same kinds of checks by specifying false for some of the optional boolean arguments. Make sure that the state hasn't changed since the check was done though (eg a new frame/event, or a command issued). Also see the more specific functions.

Parameters
commandA UnitCommand to check.
checkCanUseTechPositionOnPositionsOnly used if the command type is UnitCommandTypes::Enum::Use_Tech_Position. A boolean for whether to perform cheap checks for whether the unit is unable to target any positions using the command's TechType (i.e. regardless of what the other command parameters are). You can set this to false if you know this check has already just been performed.
checkCanUseTechUnitOnUnitsOnly used if the command type is UnitCommandTypes::Enum::Use_Tech_Unit. A boolean for whether to perform cheap checks for whether the unit is unable to target any units using the command's TechType (i.e. regardless of what the other command parameters are). You can set this to false if you know this check has already just been performed.
checkCanBuildUnitTypeOnly used if the command type is UnitCommandTypes::Build. A boolean for whether to perform cheap checks for whether the unit is unable to build the specified UnitType (i.e. regardless of what the other command parameters are). You can set this to false if you know this check has already just been performed.
checkCanTargetUnitOnly used for command types that can target a unit. A boolean for whether to perform UnitInterface::canTargetUnit as a check. You can set this to false if you know this check has already just been performed.
checkCanIssueCommandTypeA boolean for whether to perform UnitInterface::canIssueCommandType as a check. You can set this to false if you know this check has already just been performed.
checkCommandibilityA boolean for whether to perform UnitInterface::canCommand as a check. You can set this to false if you know this check has already just been performed.
Return values
trueif BWAPI determined that the command is valid.
falseif an error occurred and the command is invalid.
See also
UnitCommandTypes, Game::getLastError, UnitInterface::canCommand, UnitInterface::canIssueCommandType, UnitInterface::canTargetUnit
virtual bool BWAPI::UnitInterface::canIssueCommandGrouped (UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute the given command as part of a Unitset (even if none of the units in the Unitset are able to execute the command individually).

The reason this function exists is because some commands are valid for an individual unit but not for those individuals as a group (e.g. buildings, critters) and some commands are only valid for a unit if it is commanded as part of a unit group, e.g.:

  1. attackMove/attackUnit for a Unitset, some of which can't attack, e.g. High Templar. This is supported simply for consistency with BW's behaviour - you could issue move command(s) individually instead.
  2. attackMove/move/patrol/rightClickPosition for air unit(s) + e.g. Larva, as part of the air stacking technique. This is supported simply for consistency with BW's behaviour - you could issue move/patrol/rightClickPosition command(s) for them individually instead.
Note
BWAPI allows the following special cases to command a unit individually (rather than only allowing it to be commanded as part of a Unitset). These commands are not available to a user in BW when commanding units individually, but BWAPI allows them for convenience:
  • attackMove for Medic, which is equivalent to Heal Move.
  • holdPosition for burrowed Lurker, for ambushes.
  • stop for Larva, to move it to a different side of the Hatchery / Lair / Hive (e.g. so that Drones morphed later morph nearer to minerals/gas).
See also
UnitCommandTypes, Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::canCommandGrouped, UnitInterface::canIssueCommandTypeGrouped, UnitInterface::canTargetUnit
virtual bool BWAPI::UnitInterface::canCommand () const pure virtual

Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute any commands (eg the unit is stasised).

Return values
trueif BWAPI was unable to determine whether the unit can be commanded.
falseif an error occurred and the unit can not be commanded.
See also
Game::getLastError, UnitInterface::canIssueCommand
virtual bool BWAPI::UnitInterface::canCommandGrouped (bool checkCommandibility = true) const pure virtual

Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute any commands as part of a Unitset (eg buildings, critters).

Return values
trueif BWAPI was unable to determine whether the unit can be commanded grouped.
falseif an error occurred and the unit can not be commanded grouped.
See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canIssueCommand
virtual bool BWAPI::UnitInterface::canIssueCommandType (UnitCommandType ct, bool checkCommandibility = true ) const pure virtual

Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute the given command type (i.e.

regardless of what other possible command parameters could be).

Parameters
ctA UnitCommandType.
checkCommandibilityA boolean for whether to perform UnitInterface::canCommand as a check. You can set this to false if you know this check has already just been performed.
Return values
trueif BWAPI was unable to determine whether the command type is invalid.
falseif an error occurred and the command type is invalid.
See also
UnitCommandTypes, Game::getLastError, UnitInterface::canIssueCommand
virtual bool BWAPI::UnitInterface::canIssueCommandTypeGrouped (UnitCommandType ct, bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute the given command type (i.e.

regardless of what other possible command parameters could be) as part of a Unitset.

Parameters
ctA UnitCommandType.
checkCommandibilityGroupedA boolean for whether to perform UnitInterface::canCommandGrouped as a check. You can set this to false if you know this check has already just been performed.
checkCommandibilityA boolean for whether to perform UnitInterface::canCommand as a check. You can set this to false if you know this check has already just been performed.
Return values
trueif BWAPI was unable to determine whether the command type is invalid.
falseif an error occurred and the command type is invalid.
See also
UnitCommandTypes, Game::getLastError, UnitInterface::canIssueCommandGrouped
virtual bool BWAPI::UnitInterface::canTargetUnit (Unit targetUnit, bool checkCommandibility = true ) const pure virtual

Performs some cheap checks to attempt to quickly detect whether the unit is unable to use the given unit as the target unit of an unspecified command.

Parameters
targetUnitA target unit for an unspecified command.
checkCommandibilityA boolean for whether to perform UnitInterface::canCommand as a check. You can set this to false if you know this check has already just been performed.
Return values
trueif BWAPI was unable to determine whether the unit can target the given unit.
falseif an error occurred and the unit can not target the given unit.
See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::isTargetable
virtual bool BWAPI::UnitInterface::canAttack (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute an attack command to attack-move or attack a unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack, UnitInterface::canAttackMove, UnitInterface::canAttackUnit
virtual bool BWAPI::UnitInterface::canAttack (Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute an attack command to attack-move or attack a (non-null) unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack, UnitInterface::canAttackMove, UnitInterface::canAttackUnit
virtual bool BWAPI::UnitInterface::canAttack (Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual bool BWAPI::UnitInterface::canAttackGrouped (bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Cheap checks for whether the unit is able to execute an attack command to attack-move or attack a unit, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttack
virtual bool BWAPI::UnitInterface::canAttackGrouped (Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute an attack command to attack-move or attack a (non-null) unit, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttack
virtual bool BWAPI::UnitInterface::canAttackGrouped (Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual bool BWAPI::UnitInterface::canAttackMove (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute an attack command to attack-move.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack
virtual bool BWAPI::UnitInterface::canAttackMoveGrouped (bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute an attack command to attack-move, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttackMove
virtual bool BWAPI::UnitInterface::canAttackUnit (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute an attack command to attack a unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack
virtual bool BWAPI::UnitInterface::canAttackUnit (Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute an attack command to attack a unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack
virtual bool BWAPI::UnitInterface::canAttackUnitGrouped (bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Cheap checks for whether the unit is able to execute an attack command to attack a unit, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttackUnit
virtual bool BWAPI::UnitInterface::canAttackUnitGrouped (Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute an attack command to attack a unit, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttackUnit
virtual bool BWAPI::UnitInterface::canBuild (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a build command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::build
virtual bool BWAPI::UnitInterface::canBuild (UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Cheap checks for whether the unit is able to execute a build command for the given UnitType.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::build
virtual bool BWAPI::UnitInterface::canBuild (UnitType uType, BWAPI::TilePosition tilePos, bool checkTargetUnitType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a build command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::build
virtual bool BWAPI::UnitInterface::canBuildAddon (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a buildAddon command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::buildAddon
virtual bool BWAPI::UnitInterface::canBuildAddon (UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a buildAddon command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::buildAddon
virtual bool BWAPI::UnitInterface::canTrain (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a train command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::train
virtual bool BWAPI::UnitInterface::canTrain (UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a train command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::train
virtual bool BWAPI::UnitInterface::canMorph (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a morph command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::morph
virtual bool BWAPI::UnitInterface::canMorph (UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a morph command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::morph
virtual bool BWAPI::UnitInterface::canResearch (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a research command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::research
virtual bool BWAPI::UnitInterface::canResearch (TechType type, bool checkCanIssueCommandType = true ) const pure virtual

Checks whether the unit is able to execute a research command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::research
virtual bool BWAPI::UnitInterface::canUpgrade (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute an upgrade command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::upgrade
virtual bool BWAPI::UnitInterface::canUpgrade (UpgradeType type, bool checkCanIssueCommandType = true ) const pure virtual

Checks whether the unit is able to execute an upgrade command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::upgrade
virtual bool BWAPI::UnitInterface::canSetRallyPoint (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a setRallyPoint command to a position or unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint, UnitInterface::canSetRallyPosition, UnitInterface::canSetRallyUnit.
virtual bool BWAPI::UnitInterface::canSetRallyPoint (Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a setRallyPoint command to a position or (non-null) unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint, UnitInterface::canSetRallyPosition, UnitInterface::canSetRallyUnit.
virtual bool BWAPI::UnitInterface::canSetRallyPoint (Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual bool BWAPI::UnitInterface::canSetRallyPosition (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a setRallyPoint command to a position.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint
virtual bool BWAPI::UnitInterface::canSetRallyUnit (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a setRallyPoint command to a unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint
virtual bool BWAPI::UnitInterface::canSetRallyUnit (Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a setRallyPoint command to a unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint
virtual bool BWAPI::UnitInterface::canMove (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a move command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::move
virtual bool BWAPI::UnitInterface::canMoveGrouped (bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a move command, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canMove
virtual bool BWAPI::UnitInterface::canPatrol (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a patrol command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::patrol
virtual bool BWAPI::UnitInterface::canPatrolGrouped (bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a patrol command, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canPatrol
virtual bool BWAPI::UnitInterface::canFollow (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a follow command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::follow
virtual bool BWAPI::UnitInterface::canFollow (Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a follow command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::follow
virtual bool BWAPI::UnitInterface::canGather (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a gather command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::gather
virtual bool BWAPI::UnitInterface::canGather (Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a gather command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::gather
virtual bool BWAPI::UnitInterface::canReturnCargo (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a returnCargo command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::returnCargo
virtual bool BWAPI::UnitInterface::canHoldPosition (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a holdPosition command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::holdPosition
virtual bool BWAPI::UnitInterface::canStop (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a stop command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::stop
virtual bool BWAPI::UnitInterface::canRepair (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a repair command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::repair
virtual bool BWAPI::UnitInterface::canRepair (Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a repair command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::repair
virtual bool BWAPI::UnitInterface::canBurrow (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a burrow command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::burrow
virtual bool BWAPI::UnitInterface::canUnburrow (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute an unburrow command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unburrow
virtual bool BWAPI::UnitInterface::canCloak (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a cloak command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cloak
virtual bool BWAPI::UnitInterface::canDecloak (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a decloak command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::decloak
virtual bool BWAPI::UnitInterface::canSiege (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a siege command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::siege
virtual bool BWAPI::UnitInterface::canUnsiege (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute an unsiege command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unsiege
virtual bool BWAPI::UnitInterface::canLift (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a lift command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::lift
virtual bool BWAPI::UnitInterface::canLand (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a land command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::land
virtual bool BWAPI::UnitInterface::canLand (TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a land command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::land
virtual bool BWAPI::UnitInterface::canLoad (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a load command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::load
virtual bool BWAPI::UnitInterface::canLoad (Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a load command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::load
virtual bool BWAPI::UnitInterface::canUnloadWithOrWithoutTarget (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute an unload command or unloadAll at current position command or unloadAll at a different position command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unload, UnitInterface::unloadAll
virtual bool BWAPI::UnitInterface::canUnloadAtPosition (Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Cheap checks for whether the unit is able to execute an unload command or unloadAll at current position command or unloadAll at a different position command, for a given position.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unload, UnitInterface::unloadAll
virtual bool BWAPI::UnitInterface::canUnload (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute an unload command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unload
virtual bool BWAPI::UnitInterface::canUnload (Unit targetUnit, bool checkCanTargetUnit = true, bool checkPosition = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute an unload command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unload, UnitInterface::canUnloadAtPosition
virtual bool BWAPI::UnitInterface::canUnloadAll (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute an unloadAll command for the current position.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unloadAll
virtual bool BWAPI::UnitInterface::canUnloadAllPosition (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute an unloadAll command for a different position.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unloadAll
virtual bool BWAPI::UnitInterface::canUnloadAllPosition (Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute an unloadAll command for a different position.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unloadAll
virtual bool BWAPI::UnitInterface::canRightClick (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a rightClick command to a position or unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick, UnitInterface::canRightClickPosition, UnitInterface::canRightClickUnit.
virtual bool BWAPI::UnitInterface::canRightClick (Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a rightClick command to a position or (non-null) unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick, UnitInterface::canRightClickPosition, UnitInterface::canRightClickUnit.
virtual bool BWAPI::UnitInterface::canRightClick (Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual
virtual bool BWAPI::UnitInterface::canRightClickGrouped (bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Cheap checks for whether the unit is able to execute a rightClick command to a position or unit, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClickUnit
virtual bool BWAPI::UnitInterface::canRightClickGrouped (Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a rightClick command to a position or (non-null) unit, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClickUnit
virtual bool BWAPI::UnitInterface::canRightClickGrouped (Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual bool BWAPI::UnitInterface::canRightClickPosition (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a rightClick command for a position.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick
virtual bool BWAPI::UnitInterface::canRightClickPositionGrouped (bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a rightClick command for a position, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClick
virtual bool BWAPI::UnitInterface::canRightClickUnit (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a rightClick command to a unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick
virtual bool BWAPI::UnitInterface::canRightClickUnit (Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a rightClick command to a unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick
virtual bool BWAPI::UnitInterface::canRightClickUnitGrouped (bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Cheap checks for whether the unit is able to execute a rightClick command to a unit, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClickUnit
virtual bool BWAPI::UnitInterface::canRightClickUnitGrouped (Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a rightClick command to a unit, as part of a Unitset.

See also
Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClickUnit
virtual bool BWAPI::UnitInterface::canHaltConstruction (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a haltConstruction command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::haltConstruction
virtual bool BWAPI::UnitInterface::canCancelConstruction (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a cancelConstruction command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelConstruction
virtual bool BWAPI::UnitInterface::canCancelAddon (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a cancelAddon command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelAddon
virtual bool BWAPI::UnitInterface::canCancelTrain (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a cancelTrain command for any slot.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelTrain
virtual bool BWAPI::UnitInterface::canCancelTrainSlot (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a cancelTrain command for an unspecified slot.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelTrain
virtual bool BWAPI::UnitInterface::canCancelTrainSlot (int slot, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a cancelTrain command for a specified slot.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelTrain
virtual bool BWAPI::UnitInterface::canCancelMorph (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a cancelMorph command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelMorph
virtual bool BWAPI::UnitInterface::canCancelResearch (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a cancelResearch command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelResearch
virtual bool BWAPI::UnitInterface::canCancelUpgrade (bool checkCommandibility = true) const pure virtual

Checks whether the unit is able to execute a cancelUpgrade command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelUpgrade
virtual bool BWAPI::UnitInterface::canUseTechWithOrWithoutTarget (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a useTech command without a target or or a useTech command with a target position or a useTech command with a target unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech
virtual bool BWAPI::UnitInterface::canUseTechWithOrWithoutTarget (BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Cheap checks for whether the unit is able to execute a useTech command without a target or or a useTech command with a target position or a useTech command with a target unit, for a given TechType.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech
virtual bool BWAPI::UnitInterface::canUseTech (BWAPI::TechType tech, Position target, bool checkCanTargetUnit = true, bool checkTargetsType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a useTech command for a specified position or unit (only specify nullptr if the TechType does not target another position/unit).

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech, UnitInterface::canUseTechWithoutTarget, UnitInterface::canUseTechUnit, UnitInterface::canUseTechPosition
virtual bool BWAPI::UnitInterface::canUseTech (BWAPI::TechType tech, Unit target = nullptr, bool checkCanTargetUnit = true, bool checkTargetsType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual bool BWAPI::UnitInterface::canUseTechWithoutTarget (BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a useTech command without a target.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech
virtual bool BWAPI::UnitInterface::canUseTechUnit (BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Cheap checks for whether the unit is able to execute a useTech command with an unspecified target unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech
virtual bool BWAPI::UnitInterface::canUseTechUnit (BWAPI::TechType tech, Unit targetUnit, bool checkCanTargetUnit = true, bool checkTargetsUnits = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a useTech command with a target unit.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech
virtual bool BWAPI::UnitInterface::canUseTechPosition (BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a useTech command with an unspecified target position.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech
virtual bool BWAPI::UnitInterface::canUseTechPosition (BWAPI::TechType tech, Position target, bool checkTargetsPositions = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a useTech command with a target position.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech
virtual bool BWAPI::UnitInterface::canPlaceCOP (bool checkCommandibility = true) const pure virtual

Cheap checks for whether the unit is able to execute a placeCOP command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::placeCOP
virtual bool BWAPI::UnitInterface::canPlaceCOP (TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true ) const pure virtual

Checks whether the unit is able to execute a placeCOP command.

See also
Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::placeCOP