class
UnitThe Unit class is used to get information about individual units as well as issue orders to units.
Contents
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::
If Flag::
If Flag::
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.
Base classes
-
template<typename Interface, typename Data>struct InterfaceDataWrapper<Unit, UnitData>
Public functions
- auto exists() const -> bool
- Checks if the Unit exists in the view of the BWAPI player.
- auto getAcidSporeCount() const -> int
- Retrieves the number of acid spores that this unit is inflicted with.
- auto getAddon() const -> Unit
- Retrieves the add-on that is attached to this unit.
- auto getAirWeaponCooldown() const -> int
- Retrieves the unit's air weapon cooldown.
- auto getAngle() const -> double
- Retrieves the unit's facing direction in radians.
- auto getBottom() const -> int
- Retrieves the Y coordinate of the unit's bottom boundary, measured in pixels from the top of the map.
- auto getBuildType() const -> UnitType
- Retrieves the building type that a worker (SCV, Probe, Drone) is about to construct.
- auto getBuildUnit() const -> Unit
- Retrieves the unit currently being trained, or the corresponding paired unit for SCVs and Terran structures, depending on the context.
- auto getCarrier() const -> Unit
- Retrieves the parent Carrier that owns this Interceptor.
- auto getClosestUnit(const UnitFilter& pred = nullptr, int radius = 999999) const -> Unit
- Retrieves the closest unit to this one.
- auto getDefenseMatrixPoints() const -> int
- Retrieves the amount of hit points remaining on the Defensive Matrix created by a Science Vessel.
- auto getDefenseMatrixTimer() const -> int
- Retrieves the time, in frames, that the Defensive Matrix will remain active on the current unit.
- auto getDistance(Position target) const -> int
- Retrieves the distance between this unit and a target position.
- auto getDistance(Unit target) const -> int
- Retrieves the distance between this unit and a target unit.
- auto getEnergy() const -> int
- Retrieves the unit's current Energy Points (Energy) as seen in the game.
- auto getEnsnareTimer() const -> int
- Retrieves the time, in frames, that Ensnare will remain active on the current unit.
- auto getGroundWeaponCooldown() const -> int
- Retrieves the unit's ground weapon cooldown.
- auto getHatchery() const -> Unit
- Retrieves the parent Hatchery, Lair, or Hive that owns this particular unit.
- auto getHitPoints() const -> int
- Retrieves the unit's current Hit Points (HP) as seen in the game.
- auto getInitialHitPoints() const -> int
- Retrieves the amount of hit points that this unit started off with at the beginning of the game.
- auto getInitialPosition() const -> Position
- Retrieves the initial position of this unit.
- auto getInitialResources() const -> int
- Retrieves the amount of resources contained in the unit at the beginning of the game.
- auto getInitialTilePosition() const -> TilePosition
- Retrieves the initial build tile position of this unit.
- auto getInitialType() const -> UnitType
- Retrieves the initial type of the unit.
- auto getInterceptorCount() const -> int
- Retrieves the number of interceptors that this unit manages.
- auto getInterceptors() const -> Unitset
- Retrieves the set of Interceptors controlled by this unit.
- auto getIrradiateTimer() const -> int
- Retrieves the time, in frames, that Irradiate will remain active on the current unit.
- auto getKillCount() const -> int
- Retrieves the number of units that this unit has killed in total.
- auto getLarva() const -> Unitset
- Retrieves the set of Larvae that were spawned by this unit.
- auto getLastCommand() const -> UnitCommand
- Retrieves the last successful command that was sent to BWAPI.
- auto getLastCommandFrame() const -> int
- Retrieves the frame number that sent the last successful command.
- auto getLeft() const -> int
- Retrieves the X coordinate of the unit's left boundary, measured in pixels from the left side of the map.
- auto getLoadedUnits() const -> Unitset
- Retrieves the set of units that are contained within this Bunker or Transport(Dropship, Shuttle, Overlord ).
- auto getLockdownTimer() const -> int
- Retrieves the time, in frames, that Lockdown will remain active on the current unit.
- auto getMaelstromTimer() const -> int
- Retrieves the time, in frames, that Maelstrom will remain active on the current unit.
- auto getNydusExit() const -> Unit
- Retrieves the Nydus Canal that is attached to this one.
- auto getOrder() const -> Order
- Retrieves the primary Order that the unit is assigned.
- auto getOrderTarget() const -> Unit
- Retrieves the unit's primary order target.
- auto getOrderTargetPosition() const -> Position
- Retrieves the target position for the unit's order.
- auto getOrderTimer() const -> int
- Retrieves an internal timer used for the primary order.
- auto getPlagueTimer() const -> int
- Retrieves the time, in frames, that Plague will remain active on the current unit.
- auto getPlayer() const -> Player
- Retrieves the player that owns this unit.
- auto getPosition() const -> Position
- Retrieves the unit's position from the upper left corner of the map in pixels.
- auto getPowerUp() const -> Unit
- Retrieves the power-up that the worker unit is holding.
- auto getRallyPosition() const -> Position
- Retrieves the position the structure is rallying units to once they are completed.
- auto getRallyUnit() const -> Unit
- Retrieves the unit the structure is rallying units to once they are completed.
-
auto getRegion() const -> BWAPI::
Region - Retrieves the Region that the center of the unit is in.
- auto getRemainingBuildTime() const -> int
- Retrieves the remaining build time for a unit or structure that is being trained or constructed.
- auto getRemainingResearchTime() const -> int
- Retrieves the amount of time until the unit is done researching its currently assigned TechType.
- auto getRemainingTrainTime() const -> int
- Retrieves the remaining time, in frames, of the unit that is currently being trained.
- auto getRemainingUpgradeTime() const -> int
- Retrieves the amount of time until the unit is done upgrading its current upgrade.
- auto getRemoveTimer() const -> int
- Retrieves the time, in frames, until this temporary unit is destroyed or removed.
- auto getReplayID() const -> UnitID
- Retrieves the unit identifier for this unit as seen in replay data.
- auto getResourceGroup() const -> int
- Retrieves a grouping index from a resource container.
- auto getResources() const -> int
- Retrieves the resource amount from a resource container, such as a Mineral Field and Vespene Geyser.
- auto getRight() const -> int
- Retrieves the X coordinate of the unit's right boundary, measured in pixels from the left side of the map.
- auto getScarabCount() const -> int
- Retrieves the number of scarabs that this unit has for use.
- auto getSecondaryOrder() const -> Order
- Retrieves the secondary Order that the unit is assigned.
- auto getShields() const -> int
- Retrieves the unit's current Shield Points (Shields) as seen in the game.
- auto getSpaceRemaining() const -> int
- Retrieves the remaining unit-space available for Bunkers and Transports(Dropships, Shuttles, Overlords ).
- auto getSpellCooldown() const -> int
- Retrieves the unit's ability cooldown.
- auto getSpiderMineCount() const -> int
- Retrieves the amount of Spider Mines this unit has available.
- auto getStasisTimer() const -> int
- Retrieves the time, in frames, that Stasis Field will remain active on the current unit.
- auto getStimTimer() const -> int
- Retrieves the time, in frames, that Stim Packs will remain active on the current unit.
- auto getTarget() const -> Unit
- Generally returns the appropriate target unit after issuing an order that accepts a target unit (i.e.
- auto getTargetPosition() const -> Position
- Retrieves the target position the unit is moving to, provided a valid path to the target position exists.
- auto getTech() const -> TechType
- Retrieves the technology that this unit is currently researching.
- auto getTilePosition() const -> TilePosition
- Retrieves the unit's build position from the upper left corner of the map in tiles.
- auto getTop() const -> int
- Retrieves the Y coordinate of the unit's top boundary, measured in pixels from the top of the map.
-
auto getTrainingQueue() const -> UnitType::
list - Retrieves the list of units queued up to be trained.
- auto getTransport() const -> Unit
- Retrieves the Transport(Dropship, Shuttle, Overlord ) or Bunker unit that has this unit loaded inside of it.
- auto getType() const -> UnitType
- Retrieves the unit's type.
- auto getUnitsInRadius(int radius, const UnitFilter& pred = nullptr) const -> Unitset
- Retrieves the set of all units in a given radius of the current unit.
- auto getUnitsInWeaponRange(WeaponType weapon, const UnitFilter& pred = nullptr) const -> Unitset
- Obtains the set of units within weapon range of this unit.
- auto getUpgrade() const -> UpgradeType
- Retrieves the upgrade that this unit is currently upgrading.
- auto getVelocityX() const -> double
- Retrieves the x component of the unit's velocity, measured in pixels per frame.
- auto getVelocityY() const -> double
- Retrieves the y component of the unit's velocity, measured in pixels per frame.
- auto hasNuke() const -> bool
- Checks if the current unit is housing a Nuke.
- auto hasPath(Position target) const -> bool
- Using data provided by Starcraft, checks if there is a path available from this unit to the given target.
- auto hasPath(Unit target) const -> bool
- Using data provided by Starcraft, checks if there is a path available from this unit to the given target.
- auto isAccelerating() const -> bool
- Checks if the current unit is accelerating.
- auto isAttackFrame() const -> bool
- Checks if this unit is currently playing an attack animation.
- auto isAttacking() const -> bool
- Checks if this unit is currently attacking something.
- auto isBeingConstructed() const -> bool
- Checks if the current unit is being constructed.
- auto isBeingGathered() const -> bool
- Checks this Mineral Field or Refinery is currently being gathered from.
- auto isBeingHealed() const -> bool
- Checks if this unit is currently being healed by a Medic or repaired by a SCV.
- auto isBlind() const -> bool
- Checks if this unit is currently blinded by a Medic 's Optical Flare ability.
- auto isBraking() const -> bool
- Checks if the current unit is slowing down to come to a stop.
- auto isBurrowed() const -> bool
- Checks if the current unit is burrowed, either using the Burrow ability, or is an armed Spider Mine.
- auto isCarryingGas() const -> bool
- Checks if this worker unit is carrying some vespene gas.
- auto isCarryingMinerals() const -> bool
- Checks if this worker unit is carrying some minerals.
- auto isCloaked() const -> bool
- Checks if this unit is currently cloaked.
- auto isCompleted() const -> bool
- Checks if this unit has finished being constructed, trained, morphed, or warped in, and can now receive orders.
- auto isConstructing() const -> bool
- Checks if a unit is either constructing something or moving to construct something.
- auto isDefenseMatrixed() const -> bool
- Checks if this unit has the Defensive Matrix effect.
- auto isDetected() const -> bool
- Checks if this unit is visible or revealed by a detector unit.
- auto isEnsnared() const -> bool
- Checks if the Queen ability Ensnare has been used on this unit.
- auto isFlying() const -> bool
- This macro function checks if this unit is in the air.
- auto isFollowing() const -> bool
- Checks if this unit is following another unit.
- auto isGatheringGas() const -> bool
- Checks if this unit is currently gathering gas.
- auto isGatheringMinerals() const -> bool
- Checks if this unit is currently harvesting minerals.
- auto isHallucination() const -> bool
- Checks if this unit is a hallucination.
- auto isHoldingPosition() const -> bool
- Checks if the unit is currently holding position.
- auto isIdle() const -> bool
- Checks if this unit is running an idle order.
- auto isInterruptible() const -> bool
- Checks if the unit can be interrupted.
- auto isInvincible() const -> bool
- Checks the invincibility state for this unit.
- auto isInWeaponRange(Unit target) const -> bool
- Checks if the target unit can immediately be attacked by this unit in the current frame.
- auto isIrradiated() const -> bool
- Checks if this unit is irradiated by a Science Vessel 's Irradiate ability.
- auto isLifted() const -> bool
- Checks if this unit is a Terran building and lifted off the ground.
- auto isLoaded() const -> bool
- Checks if this unit is currently loaded into another unit such as a Transport(Dropship, Shuttle, Overlord ).
- auto isLockedDown() const -> bool
- Checks if this unit is currently locked by a Ghost.
- auto isMaelstrommed() const -> bool
- Checks if this unit has been maelstrommed by a Dark Archon.
- auto isMorphing() const -> bool
- Finds out if the current unit is morphing or not.
- auto isMoving() const -> bool
- Checks if this unit is currently moving.
- auto isParasited() const -> bool
- Checks if this unit has been parasited by some other player.
- auto isPatrolling() const -> bool
- Checks if this unit is patrolling between two positions.
- auto isPlagued() const -> bool
- Checks if this unit has been been plagued by a Defiler.
- auto isPowered() const -> bool since v4.0.1
- Checks if this unit has power.
- auto isRepairing() const -> bool
- Checks if this unit is repairing or moving to repair another unit.
- auto isResearching() const -> bool
- Checks if this unit is a structure that is currently researching a technology.
- auto isSelected() const -> bool
- Checks if this unit has been selected in the user interface
- auto isSieged() const -> bool
- Checks if this unit is currently sieged.
- auto isStartingAttack() const -> bool
- Checks if the unit is starting to attack.
- auto isStasised() const -> bool
- Checks if this unit is inflicted with Stasis Field by an Arbiter.
- auto isStimmed() const -> bool
- Checks if this unit is currently under the influence of a Stim Packs.
- auto isStuck() const -> bool
- Checks if this unit is currently trying to resolve a collision by randomly moving around.
- auto isTargetable() const -> bool
- 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.
- auto isTraining() const -> bool
- Checks if this unit is training a new unit.
- auto isUnderAttack() const -> bool
- Checks if the current unit is being attacked.
- auto isUnderDarkSwarm() const -> bool
- Checks if this unit is under the cover of a Dark Swarm.
- auto isUnderDisruptionWeb() const -> bool
- Checks if this unit is currently being affected by a Disruption Web.
- auto isUnderStorm() const -> bool
- Checks if this unit is currently taking damage from a Psionic Storm.
- auto isUpgrading() const -> bool
- Checks if this unit is a structure that is currently upgrading an upgrade.
- auto isVisible() const -> bool
- This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- auto isVisible(Player player) const -> bool
- Checks if this unit is visible.
Unit Commands
- auto issueCommand(UnitCommand command) const -> bool
- 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.
- auto attack(Position target, bool shiftQueueCommand = false) const -> bool
- Orders the unit(s) to attack move to the specified position.
- auto attack(Unit target, bool shiftQueueCommand = false) const -> bool
- Orders the unit(s) to attack the specified target unit.
-
auto build(UnitType type,
TilePosition target = TilePositions::
None) const -> bool - Orders the worker unit(s) to construct a structure at a target position.
- auto buildAddon(UnitType type) const -> bool
- Orders the Terran structure(s) to construct an add-on.
-
auto train(UnitType type = UnitTypes::
None) const -> bool - Orders the unit(s) to add a UnitType to its training queue, or morphs into the UnitType if it is Zerg.
- auto morph(UnitType type) const -> bool
- Orders the unit(s) to morph into a different UnitType.
- auto research(TechType tech) const -> bool
- Orders the unit to research the given tech type.
- auto upgrade(UpgradeType upgrade) const -> bool
- Orders the unit to upgrade the given upgrade type.
- auto setRallyPoint(Position target) const -> bool
- Orders the unit to set its rally position.
- auto setRallyPoint(Unit target) const -> bool
- Orders the unit to set its rally position to the specified unit.
- auto move(Position target, bool shiftQueueCommand = false) const -> bool
- Orders the unit to move from its current position to the specified position.
- auto patrol(Position target, bool shiftQueueCommand = false) const -> bool
- Orders the unit to patrol between its current position and the specified position.
- auto holdPosition(bool shiftQueueCommand = false) const -> bool
- Orders the unit to hold its position.
- auto stop(bool shiftQueueCommand = false) const -> bool
- Orders the unit to stop.
- auto follow(Unit target, bool shiftQueueCommand = false) const -> bool
- Orders the unit to follow the specified unit.
- auto gather(Unit target, bool shiftQueueCommand = false) const -> bool
- Orders the unit to gather the specified unit (must be mineral or refinery type).
- auto returnCargo(bool shiftQueueCommand = false) const -> bool
- Orders the unit to return its cargo to a nearby resource depot such as a Command Center.
- auto repair(Unit target, bool shiftQueueCommand = false) const -> bool
- Orders the unit to repair the specified unit.
- auto burrow() const -> bool
- Orders the unit to burrow.
- auto unburrow() const -> bool
- Orders a burrowed unit to unburrow.
- auto cloak() const -> bool
- Orders the unit to cloak.
- auto decloak() const -> bool
- Orders a cloaked unit to decloak.
- auto siege() const -> bool
- Orders the unit to siege.
- auto unsiege() const -> bool
- Orders the unit to unsiege.
- auto lift() const -> bool
- Orders the unit to lift.
- auto land(TilePosition target) const -> bool
- Orders the unit to land.
- auto load(Unit target, bool shiftQueueCommand = false) const -> bool
- Orders the unit to load the target unit.
- auto unload(Unit target) const -> bool
- Orders the unit to unload the target unit.
- auto unloadAll(bool shiftQueueCommand = false) const -> bool
- Orders the unit to unload all loaded units at the unit's current position.
- auto unloadAll(Position target, bool shiftQueueCommand = false) const -> bool
- Orders the unit to unload all loaded units at the specified location.
- auto rightClick(Position target, bool shiftQueueCommand = false) const -> bool
- Performs a right click action as it would work in StarCraft.
- auto rightClick(Unit target, bool shiftQueueCommand = false) const -> bool
- Performs a right click action as it would work in StarCraft.
- auto haltConstruction() const -> bool
- Orders a SCV to stop constructing a structure.
- auto cancelConstruction() const -> bool
- Orders this unit to cancel and refund itself from begin constructed.
- auto cancelAddon() const -> bool
- Orders this unit to cancel and refund an add-on that is being constructed.
- auto cancelTrain(int slot = -2) const -> bool
- Orders the unit to remove the specified unit from its training queue.
- auto cancelMorph() const -> bool
- Orders this unit to cancel and refund a unit that is morphing.
- auto cancelResearch() const -> bool
- Orders this unit to cancel and refund a research that is in progress.
- auto cancelUpgrade() const -> bool
- Orders this unit to cancel and refund an upgrade that is in progress.
- auto useTech(TechType tech, Position target) const -> bool
- Orders the unit to use a technology.
- auto useTech(TechType tech, Unit target) const -> bool
- Orders the unit to use a technology.
- auto useTech(TechType tech) const -> bool
- This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- auto placeCOP(TilePosition target) const -> bool
- Moves a Flag Beacon to a different location.
Command Verifiers
- auto canIssueCommand(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanBuildUnitType = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute the given command.
- auto canIssueCommandGrouped(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- 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).
- auto canCommand() const -> bool
- Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute any commands (eg the unit is stasised).
- auto canCommandGrouped(bool checkCommandibility = true) const -> bool
- 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).
- auto canIssueCommandType(UnitCommandType ct, bool checkCommandibility = true) const -> bool
- Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute the given command type (i.e.
- auto canIssueCommandTypeGrouped(UnitCommandType ct, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute the given command type (i.e.
- auto canTargetUnit(Unit targetUnit, bool checkCommandibility = true) const -> bool
- 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.
- auto canAttack(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute an attack command to attack-move or attack a unit.
- auto canAttack(Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an attack command to attack-move or attack a (non-null) unit.
- auto canAttack(Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- auto canAttackGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- 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.
- auto canAttackGrouped(Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- 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.
- auto canAttackGrouped(Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- auto canAttackMove(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an attack command to attack-move.
- auto canAttackMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an attack command to attack-move, as part of a Unitset.
- auto canAttackUnit(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute an attack command to attack a unit.
- auto canAttackUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an attack command to attack a unit.
- auto canAttackUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute an attack command to attack a unit, as part of a Unitset.
- auto canAttackUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an attack command to attack a unit, as part of a Unitset.
- auto canBuild(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a build command.
- auto canBuild(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a build command for the given UnitType.
-
auto canBuild(UnitType uType,
BWAPI::
TilePosition tilePos, bool checkTargetUnitType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - Checks whether the unit is able to execute a build command.
- auto canBuildAddon(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a buildAddon command.
- auto canBuildAddon(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a buildAddon command.
- auto canTrain(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a train command.
- auto canTrain(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a train command.
- auto canMorph(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a morph command.
- auto canMorph(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a morph command.
- auto canResearch(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a research command.
- auto canResearch(TechType type, bool checkCanIssueCommandType = true) const -> bool
- Checks whether the unit is able to execute a research command.
- auto canUpgrade(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute an upgrade command.
- auto canUpgrade(UpgradeType type, bool checkCanIssueCommandType = true) const -> bool
- Checks whether the unit is able to execute an upgrade command.
- auto canSetRallyPoint(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a setRallyPoint command to a position or unit.
- auto canSetRallyPoint(Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a setRallyPoint command to a position or (non-null) unit.
- auto canSetRallyPoint(Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- auto canSetRallyPosition(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a setRallyPoint command to a position.
- auto canSetRallyUnit(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a setRallyPoint command to a unit.
- auto canSetRallyUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a setRallyPoint command to a unit.
- auto canMove(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a move command.
- auto canMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a move command, as part of a Unitset.
- auto canPatrol(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a patrol command.
- auto canPatrolGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a patrol command, as part of a Unitset.
- auto canFollow(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a follow command.
- auto canFollow(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a follow command.
- auto canGather(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a gather command.
- auto canGather(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a gather command.
- auto canReturnCargo(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a returnCargo command.
- auto canHoldPosition(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a holdPosition command.
- auto canStop(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a stop command.
- auto canRepair(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a repair command.
- auto canRepair(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a repair command.
- auto canBurrow(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a burrow command.
- auto canUnburrow(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an unburrow command.
- auto canCloak(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a cloak command.
- auto canDecloak(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a decloak command.
- auto canSiege(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a siege command.
- auto canUnsiege(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an unsiege command.
- auto canLift(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a lift command.
- auto canLand(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a land command.
- auto canLand(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a land command.
- auto canLoad(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a load command.
- auto canLoad(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a load command.
- auto canUnloadWithOrWithoutTarget(bool checkCommandibility = true) const -> bool
- 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.
- auto canUnloadAtPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- 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.
- auto canUnload(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute an unload command.
- auto canUnload(Unit targetUnit, bool checkCanTargetUnit = true, bool checkPosition = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an unload command.
- auto canUnloadAll(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an unloadAll command for the current position.
- auto canUnloadAllPosition(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute an unloadAll command for a different position.
- auto canUnloadAllPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute an unloadAll command for a different position.
- auto canRightClick(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a rightClick command to a position or unit.
- auto canRightClick(Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a rightClick command to a position or (non-null) unit.
- auto canRightClick(Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- auto canRightClickGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a rightClick command to a position or unit, as part of a Unitset.
- auto canRightClickGrouped(Position target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a rightClick command to a position or (non-null) unit, as part of a Unitset.
- auto canRightClickGrouped(Unit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- auto canRightClickPosition(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a rightClick command for a position.
- auto canRightClickPositionGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a rightClick command for a position, as part of a Unitset.
- auto canRightClickUnit(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a rightClick command to a unit.
- auto canRightClickUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a rightClick command to a unit.
- auto canRightClickUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a rightClick command to a unit, as part of a Unitset.
- auto canRightClickUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a rightClick command to a unit, as part of a Unitset.
- auto canHaltConstruction(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a haltConstruction command.
- auto canCancelConstruction(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a cancelConstruction command.
- auto canCancelAddon(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a cancelAddon command.
- auto canCancelTrain(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a cancelTrain command for any slot.
- auto canCancelTrainSlot(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a cancelTrain command for an unspecified slot.
- auto canCancelTrainSlot(int slot, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a cancelTrain command for a specified slot.
- auto canCancelMorph(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a cancelMorph command.
- auto canCancelResearch(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a cancelResearch command.
- auto canCancelUpgrade(bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a cancelUpgrade command.
- auto canUseTechWithOrWithoutTarget(bool checkCommandibility = true) const -> bool
- 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.
-
auto canUseTechWithOrWithoutTarget(BWAPI::
TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - 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.
-
auto canUseTech(BWAPI::
TechType tech, Position target, bool checkCanTargetUnit = true, bool checkTargetsType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - 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).
-
auto canUseTech(BWAPI::
TechType tech, Unit target, bool checkCanTargetUnit = true, bool checkTargetsType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
auto canUseTech(BWAPI::
TechType tech, bool checkCanTargetUnit = true, bool checkTargetsType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
auto canUseTechWithoutTarget(BWAPI::
TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - Checks whether the unit is able to execute a useTech command without a target.
-
auto canUseTechUnit(BWAPI::
TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - Cheap checks for whether the unit is able to execute a useTech command with an unspecified target unit.
-
auto canUseTechUnit(BWAPI::
TechType tech, Unit targetUnit, bool checkCanTargetUnit = true, bool checkTargetsUnits = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - Checks whether the unit is able to execute a useTech command with a target unit.
-
auto canUseTechPosition(BWAPI::
TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - Checks whether the unit is able to execute a useTech command with an unspecified target position.
-
auto canUseTechPosition(BWAPI::
TechType tech, Position target, bool checkTargetsPositions = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool - Checks whether the unit is able to execute a useTech command with a target position.
- auto canPlaceCOP(bool checkCommandibility = true) const -> bool
- Cheap checks for whether the unit is able to execute a placeCOP command.
- auto canPlaceCOP(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const -> bool
- Checks whether the unit is able to execute a placeCOP command.
Function documentation
bool BWAPI:: Unit:: exists() const
Checks if the Unit exists in the view of the BWAPI player.
Returns | |
---|---|
true | If the unit exists on the map and is visible according to BWAPI. |
false | If the unit is not accessible or the unit is dead. |
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.
In the event that this function returns false, there are two cases to consider:
- You own the unit. This means the unit is dead.
- 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.
int BWAPI:: Unit:: getAcidSporeCount() const
Retrieves the number of acid spores that this unit is inflicted with.
Returns | Number of acid spores on this unit. |
---|
int BWAPI:: Unit:: getAirWeaponCooldown() const
Retrieves the unit's air weapon cooldown.
Returns | Number of frames needed for the unit's air weapon to become available again. |
---|
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.
double BWAPI:: Unit:: getAngle() const
Retrieves the unit's facing direction in radians.
Returns | A double with the angle measure in radians. |
---|
UnitType BWAPI:: Unit:: getBuildType() const
Retrieves the building type that a worker (SCV, Probe, Drone) is about to construct.
Returns | UnitType indicating the type that a worker (SCV, Probe, Drone) is about to construct, or an incomplete unit will be when completed. |
---|
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.
Unit BWAPI:: Unit:: getBuildUnit() const
Retrieves the unit currently being trained, or the corresponding paired unit for SCVs and Terran structures, depending on the context.
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. |
---|---|
nullptr | If there is no unit constructing this one, or this unit is not constructing another unit. |
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.
Unit BWAPI:: Unit:: getCarrier() const
Retrieves the parent Carrier that owns this Interceptor.
Returns | The parent Carrier unit that has ownership of this one. |
---|---|
nullptr | if the current unit is not an Interceptor. |
Unit BWAPI:: Unit:: getClosestUnit(const UnitFilter& pred = 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. |
int BWAPI:: Unit:: getDefenseMatrixPoints() const
Retrieves the amount of hit points remaining on the Defensive Matrix created by a Science Vessel.
Returns | Number of hit points remaining on this unit's Defensive Matrix. |
---|
The Defensive Matrix ability starts with 250 hit points when it is used.
int BWAPI:: Unit:: getDefenseMatrixTimer() const
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. |
---|
int BWAPI:: Unit:: getDistance(Position target) const
Retrieves the distance between this unit and a target position.
Parameters | |
---|---|
target | A Position to calculate the distance to. |
Returns | An integer representation of the number of pixels between this unit and the target . |
int BWAPI:: Unit:: getDistance(Unit target) const
Retrieves the distance between this unit and a target unit.
Parameters | |
---|---|
target | A 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 . |
int BWAPI:: Unit:: getEnsnareTimer() const
Retrieves the time, in frames, that Ensnare will remain active on the current unit.
Returns | Number of frames remaining until the effect is removed. |
---|
int BWAPI:: Unit:: getGroundWeaponCooldown() const
Retrieves the unit's ground weapon cooldown.
Returns | Number of frames needed for the unit's ground weapon to become available again. |
---|
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.
int BWAPI:: Unit:: getHitPoints() const
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. |
---|
int BWAPI:: Unit:: getInitialHitPoints() const
Retrieves the amount of hit points that this unit started off with at the beginning of the game.
Returns | Number of hit points that this unit started with. |
---|---|
0 | if this unit was not a neutral unit at the beginning of the game. |
The unit must be neutral.
Position BWAPI:: Unit:: getInitialPosition() const
Retrieves the initial position of this unit.
Returns | Position indicating the unit's initial position when it was created. |
---|---|
None | if this unit was not a static neutral unit in the beginning of the game. |
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.
int BWAPI:: Unit:: getInitialResources() const
Retrieves the amount of resources contained in the unit at the beginning of the game.
Returns | Amount of resources that this unit started with. |
---|---|
0 | if 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. |
The unit must be a neutral resource container.
TilePosition BWAPI:: Unit:: getInitialTilePosition() const
Retrieves the initial build tile position of this unit.
Returns | TilePosition indicating the unit's initial tile position when it was created. |
---|---|
None | if this unit was not a static neutral unit in the beginning of the game. |
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.
UnitType BWAPI:: Unit:: getInitialType() const
Retrieves the initial type of the unit.
Returns | UnitType of this unit as it was when it was created. |
---|---|
None | if this unit was not a static neutral unit in the beginning of the game. |
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.
int BWAPI:: Unit:: getInterceptorCount() const
Retrieves the number of interceptors that this unit manages.
Returns | Number of interceptors in this unit. |
---|
This function is only for the Carrier and its hero.
Unitset BWAPI:: Unit:: getInterceptors() const
Retrieves the set of Interceptors controlled by this unit.
Returns | Unitset containing Interceptor units owned by this carrier. |
---|
This is intended for Carriers and its hero.
int BWAPI:: Unit:: getIrradiateTimer() const
Retrieves the time, in frames, that Irradiate will remain active on the current unit.
Returns | Number of frames remaining until the effect is removed. |
---|
int BWAPI:: Unit:: getKillCount() const
Retrieves the number of units that this unit has killed in total.
Returns | integer indicating this unit's kill count. |
---|
Unitset BWAPI:: Unit:: getLarva() const
Retrieves the set of Larvae that were spawned by this unit.
Returns | Unitset containing Larva units owned by this unit. The set will be empty if there are none. |
---|
Only Hatcheries, Lairs, and Hives are capable of spawning Larvae. This is like clicking the "Select Larva" button and getting the selection of Larvae.
UnitCommand BWAPI:: Unit:: getLastCommand() const
Retrieves the last successful command that was sent to BWAPI.
Returns | A UnitCommand object containing information about the command that was processed. |
---|
int BWAPI:: Unit:: getLastCommandFrame() const
Retrieves the frame number that sent the last successful command.
Returns | The frame number that sent the last successfully processed command to BWAPI. |
---|
int BWAPI:: Unit:: getLockdownTimer() const
Retrieves the time, in frames, that Lockdown will remain active on the current unit.
Returns | Number of frames remaining until the effect is removed. |
---|
int BWAPI:: Unit:: getMaelstromTimer() const
Retrieves the time, in frames, that Maelstrom will remain active on the current unit.
Returns | Number of frames remaining until the effect is removed. |
---|
Unit BWAPI:: Unit:: getNydusExit() const
Retrieves the Nydus Canal that is attached to this one.
Returns | Unit interface representing the Nydus Canal connected to this one. |
---|---|
nullptr | if the unit is not a Nydus Canal, is not owned, or has not placed a Nydus Exit. |
Every Nydus Canal can place a "Nydus Exit" which, when connected, can be travelled through by Zerg units.
Order BWAPI:: Unit:: getOrder() const
Retrieves the primary Order that the unit is assigned.
Returns | The primary Order that the unit is executing. |
---|
Primary orders are distinct actions such as Orders::
Unit BWAPI:: Unit:: getOrderTarget() const
Retrieves the unit's primary order target.
Returns | The Unit that this unit is currently targetting. |
---|
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.
Position BWAPI:: Unit:: getOrderTargetPosition() const
Retrieves the target position for the unit's order.
Returns | Position that this unit is currently targetting. |
---|
For example, when Orders::
int BWAPI:: Unit:: getOrderTimer() const
Retrieves an internal timer used for the primary order.
Returns | A value used as a timer for the primary order. |
---|
Its use is specific to the order type that is currently assigned to the unit.
int BWAPI:: Unit:: getPlagueTimer() const
Retrieves the time, in frames, that Plague will remain active on the current unit.
Returns | Number of frames remaining until the effect is removed. |
---|
Position BWAPI:: Unit:: getPosition() const
Retrieves the unit's position from the upper left corner of the map in pixels.
Returns | Position object representing the unit's current position. |
---|---|
None | if this unit is inaccessible. |
The position returned is roughly the center if the unit.
Unit BWAPI:: Unit:: getPowerUp() const
Retrieves the power-up that the worker unit is holding.
Returns | The Unit interface object that represents the power-up. |
---|---|
nullptr | If the unit is not carrying anything. |
Power-ups are special units such as the Flag in the Capture The Flag game type, which can be picked up by worker units.
Example
for ( BWAPI::Unit u : game.self().getUnits()) { // 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 }
Position BWAPI:: Unit:: getRallyPosition() const
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. |
---|---|
None | If this building does not produce units. |
Unit BWAPI:: Unit:: getRallyUnit() const
Retrieves the unit the structure is rallying units to once they are completed.
Returns | Unit that a completed unit coming from this structure will travel to. |
---|---|
nullptr | If the structure is not rallied to a unit or it does not produce units. |
Units will then follow the targetted unit.
BWAPI:: Region BWAPI:: Unit:: getRegion() const
Retrieves the Region that the center of the unit is in.
Returns | The Region object that contains this unit. |
---|---|
nullptr | If the unit is inaccessible. |
Example
for ( BWAPI::Unit u : game.self().getUnits() ) { if ( u.isFlying() && u.isUnderAttack() ) // implies exists and isCompleted { BWAPI::Region r = u.getRegion(); if ( r ) u.move(r.getClosestInaccessibleRegion()); // Retreat to inaccessible region } }
int BWAPI:: Unit:: getRemainingBuildTime() const
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. |
---|
int BWAPI:: Unit:: getRemainingResearchTime() const
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. |
---|---|
0 | If the unit is not researching anything. |
int BWAPI:: Unit:: getRemainingTrainTime() const
Retrieves the remaining time, in frames, of the unit that is currently being trained.
Returns | Number of frames remaining until the current training unit becomes completed, or the number of frames remaining until the next larva spawns. |
---|---|
0 | If the unit is not training or has three larvae. |
int BWAPI:: Unit:: getRemainingUpgradeTime() const
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. |
---|---|
0 | If the unit is not upgrading anything. |
int BWAPI:: Unit:: getRemoveTimer() const
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.
UnitID BWAPI:: Unit:: getReplayID() const
Retrieves the unit identifier for this unit as seen in replay data.
Returns | An integer containing the replay unit identifier. |
---|
int BWAPI:: Unit:: getResourceGroup() const
Retrieves a grouping index from a resource container.
Returns | An integer with an identifier between 0 and 250 that determine which resources are grouped together to form an expansion. |
---|
Other resource containers of the same value are considered part of one expansion location (group of resources that are close together).
int BWAPI:: Unit:: getResources() const
Retrieves the resource amount from a resource container, such as a Mineral Field and Vespene Geyser.
Returns | An integer representing the last known amount of resources remaining in this resource. |
---|
If the unit is inaccessible, then the last known resource amount is returned.
int BWAPI:: Unit:: getScarabCount() const
Retrieves the number of scarabs that this unit has for use.
Returns | Number of scarabs this unit has ready. |
---|
This function is only for the Reaver.
Order BWAPI:: Unit:: getSecondaryOrder() const
Retrieves the secondary Order that the unit is assigned.
Returns | The secondary Order that the unit is executing. |
---|
Secondary orders are run in the background as a sub-order. An example would be Orders::
int BWAPI:: Unit:: getShields() const
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. |
---|
int BWAPI:: Unit:: getSpellCooldown() const
Retrieves the unit's ability cooldown.
Returns | Number of frames needed for the unit's abilities to become available again. |
---|
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.
int BWAPI:: Unit:: getSpiderMineCount() const
Retrieves the amount of Spider Mines this unit has available.
Returns | Number of spider mines available for placement. |
---|
This function is only for the Vulture.
int BWAPI:: Unit:: getStasisTimer() const
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. |
---|
int BWAPI:: Unit:: getStimTimer() const
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. |
---|
Unit BWAPI:: Unit:: getTarget() const
Generally returns the appropriate target unit after issuing an order that accepts a target unit (i.e.
Returns | Unit that is currently being targeted by this unit. |
---|
attack, repair, gather, etc.).
To get a target that has been acquired automatically without issuing an order, use getOrderTarget.
Position BWAPI:: Unit:: getTargetPosition() const
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. |
---|
TilePosition BWAPI:: Unit:: getTilePosition() const
Retrieves the unit's build position from the upper left corner of the map in tiles.
Returns | TilePosition object representing the unit's current tile position. |
---|---|
None | if this unit is inaccessible. |
UnitType:: list BWAPI:: Unit:: getTrainingQueue() const
Retrieves the list of units queued up to be trained.
Returns | a UnitType:: |
---|
Unit BWAPI:: Unit:: getTransport() const
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. |
---|---|
nullptr | if this unit is not in a Transport(Dropship, Shuttle, Overlord ). |
Unitset BWAPI:: Unit:: getUnitsInRadius(int radius,
const UnitFilter& pred = nullptr) const
Retrieves the set of all units in a given radius of the current unit.
Parameters | |
---|---|
radius | The 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. |
Takes into account this unit's dimensions. Can optionally specify a filter that is composed using BWAPI Filter semantics to include only specific units (such as only ground units, etc.)
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 BWAPI::Unitset myResources = pMain->getUnitsInRadius(1024, BWAPI::Filter::IsMineralField); if ( !myResources.empty() ) // check if we have resources nearby { BWAPI::Unitset myWorkers = pMain->getUnitsInRadius(512, BWAPI::Filter::IsWorker && BWAPI::Filter::IsIdle && BWAPI::Filter::IsOwned ); 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
Unitset BWAPI:: Unit:: getUnitsInWeaponRange(WeaponType weapon,
const UnitFilter& pred = nullptr) const
Obtains the set of units within weapon range of this unit.
Parameters | |
---|---|
weapon | The 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. |
UpgradeType BWAPI:: Unit:: getUpgrade() const
Retrieves the upgrade that this unit is currently upgrading.
Returns | UpgradeType indicating the upgrade in progress by this unit. |
---|---|
None | if this unit is not upgrading anything. |
double BWAPI:: Unit:: getVelocityX() const
Retrieves the x component of the unit's velocity, measured in pixels per frame.
Returns | A double that represents the velocity's x component. |
---|
double BWAPI:: Unit:: getVelocityY() const
Retrieves the y component of the unit's velocity, measured in pixels per frame.
Returns | A double that represents the velocity's y component. |
---|
bool BWAPI:: Unit:: hasNuke() const
Checks if the current unit is housing a Nuke.
Returns | true if this unit has a Nuke ready, and false if there is no Nuke. |
---|
This is only available for Nuclear Silos.
bool BWAPI:: Unit:: hasPath(Position target) const
Using data provided by Starcraft, checks if there is a path available from this unit to the given target.
Parameters | |
---|---|
target | A 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. |
bool BWAPI:: Unit:: hasPath(Unit target) const
Using data provided by Starcraft, checks if there is a path available from this unit to the given target.
Parameters | |
---|---|
target | A 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. |
false | If the target is on a different piece of land than this one (such as an island). |
bool BWAPI:: Unit:: isAccelerating() const
Checks if the current unit is accelerating.
Returns | true if this unit is accelerating, and false otherwise |
---|
bool BWAPI:: Unit:: isAttackFrame() const
Checks if this unit is currently playing an attack animation.
Returns | true if this unit is currently running an attack frame, and false if interrupting the unit is feasible. |
---|
Issuing commands while this returns true may interrupt the unit's next attack sequence.
bool BWAPI:: Unit:: isAttacking() const
Checks if this unit is currently attacking something.
Returns | true if this unit is attacking another unit, and false if it is not. |
---|
bool BWAPI:: Unit:: isBeingConstructed() const
Checks if the current unit is being constructed.
Returns | |
---|---|
true | if this is either a Protoss structure, Zerg structure, or Terran structure being constructed by an attached SCV. |
false | if this is either completed, not a structure, or has no SCV constructing it |
This is mostly applicable to Terran structures which require an SCV to be constructing a structure.
bool BWAPI:: Unit:: isBeingGathered() const
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 |
---|
bool BWAPI:: Unit:: isBeingHealed() const
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. |
---|
bool BWAPI:: Unit:: isBlind() const
Checks if this unit is currently blinded by a Medic 's Optical Flare ability.
Returns | true if this unit is blind, and false otherwise |
---|
Blinded units have reduced sight range and cannot detect other units.
bool BWAPI:: Unit:: isBraking() const
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. |
---|
bool BWAPI:: Unit:: isBurrowed() const
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 |
---|
bool BWAPI:: Unit:: isCarryingGas() const
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(); }
bool BWAPI:: Unit:: isCarryingMinerals() const
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(); }
bool BWAPI:: Unit:: isCompleted() const
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. |
---|
bool BWAPI:: Unit:: isConstructing() const
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. |
---|
bool BWAPI:: Unit:: 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. |
---|
bool BWAPI:: Unit:: isDetected() const
Checks if this unit is visible or revealed by a detector unit.
Returns | true if this unit is detected, and false if it needs a detector unit nearby in order to see it. |
---|
If this is false and isVisible is true, then the unit is only partially visible and requires a detector in order to be targetted.
bool BWAPI:: Unit:: 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:: Unit:: isFlying() const
This macro function checks if this unit is in the air.
Returns | true if this unit is in the air, and false if it is on the ground |
---|
That is, the unit is either a flyer or a flying building.
bool BWAPI:: Unit:: isFollowing() const
Checks if this unit is following another unit.
Returns | true if this unit is following another unit, and false if it is not |
---|
When a unit is following another unit, it simply moves where the other unit does, and does not attack enemies when it is following.
bool BWAPI:: Unit:: isGatheringGas() const
Checks if this unit is currently gathering gas.
Returns | true if this unit is harvesting gas, and false if it is not |
---|
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.
bool BWAPI:: Unit:: isGatheringMinerals() const
Checks if this unit is currently harvesting minerals.
Returns | true if this unit is gathering minerals, and false if it is not |
---|
That is, the unit is either moving to a Mineral Field, waiting to mine, mining minerals, or returning minerals to a resource depot.
bool BWAPI:: Unit:: isHallucination() const
Checks if this unit is a hallucination.
Returns | true if the unit is a hallucination and false otherwise. |
---|
Hallucinations are created by the High Templar using the Hallucination ability. Enemy hallucinations are unknown if Flag::
bool BWAPI:: Unit:: isHoldingPosition() const
Checks if the unit is currently holding position.
Returns | true if this unit is holding position, and false if it is not. |
---|
A unit that is holding position will attack other units, but will not chase after them.
bool BWAPI:: Unit:: isIdle() const
Checks if this unit is running an idle order.
Returns | true if this unit is idle, and false if this unit is performing any action, such as moving or attacking |
---|
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:
- Orders::
PlayerGuard: Player unit idle. - Orders::
Guard: Generic unit idle. - Orders::
Stop - Orders::
PickupIdle - Orders::
Nothing: Structure/generic idle. - Orders::
Medic: Medic idle. - Orders::
Carrier: Carrier idle. - Orders::
Reaver: Reaver idle. - Orders::
Critter: Critter idle. - Orders::
Neutral: Neutral unit idle. - Orders::
TowerGuard: Turret structure idle. - Orders::
Burrowed: Burrowed unit idle. - Orders::
NukeTrain - Orders::
Larva: Larva idle.
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 ) ); }
bool BWAPI:: Unit:: isInterruptible() const
Checks if the unit can be interrupted.
Returns | true if this unit can be interrupted, or false if this unit is uninterruptable |
---|
bool BWAPI:: Unit:: isInvincible() const
Checks the invincibility state for this unit.
Returns | true if this unit is currently invulnerable, and false if it is vulnerable |
---|
bool BWAPI:: Unit:: isInWeaponRange(Unit target) const
Checks if the target unit can immediately be attacked by this unit in the current frame.
Parameters | |
---|---|
target | The target unit to use in this check. |
Returns | true if target is within weapon range of this unit's appropriate weapon, and false otherwise. |
false | if target is invalid, inaccessible, too close, too far, or this unit does not have a weapon that can attack target . |
bool BWAPI:: Unit:: 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) ) { BWAPI::Unit medic = u->getClosestUnit( BWAPI::Filter::GetType == BWAPI::UnitTypes::Terran_Medic && BWAPI::Filter::Energy >= BWAPI::TechTypes::Restoration.energyCost() ); if ( medic ) medic->useTech(BWAPI::TechTypes::Restoration, *u); } }
bool BWAPI:: Unit:: isLifted() const
Checks if this unit is a Terran building and lifted off the ground.
Returns | true if this unit is a Terran structure lifted off the ground. |
---|
This function generally implies this->getType().isBuilding() and this->isCompleted() both return true.
bool BWAPI:: Unit:: isLockedDown() const
Checks if this unit is currently locked by a Ghost.
Returns | true if this unit is locked down, and false otherwise |
---|
bool BWAPI:: Unit:: isMaelstrommed() const
Checks if this unit has been maelstrommed by a Dark Archon.
Returns | true if this unit is maelstrommed, and false otherwise |
---|
bool BWAPI:: Unit:: isMorphing() const
Finds out if the current unit is morphing or not.
Returns | |
---|---|
true | if the unit is currently morphing. |
false | if the unit is not morphing |
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.
bool BWAPI:: Unit:: isMoving() const
Checks if this unit is currently moving.
Returns | true if this unit is moving, and false if it is not |
---|
bool BWAPI:: Unit:: isParasited() const
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:: Unit:: isPatrolling() const
Checks if this unit is patrolling between two positions.
Returns | true if this unit is patrolling and false if it is not |
---|
bool BWAPI:: Unit:: isPowered() const since v4.0.1
Checks if this unit has power.
Returns | true if this unit has power or is inaccessible, and false if this unit is unpowered. |
---|
Most structures are powered by default, but Protoss structures require a Pylon to be powered and functional.
bool BWAPI:: Unit:: isRepairing() const
Checks if this unit is repairing or moving to repair another unit.
Returns | true if this unit is currently repairing or moving to repair another unit, and false if it is not |
---|
This is only applicable to SCVs.
bool BWAPI:: Unit:: isResearching() const
Checks if this unit is a structure that is currently researching a technology.
Returns | true if this structure is researching a technology, false otherwise |
---|
See TechTypes for a complete list of technologies in Broodwar.
bool BWAPI:: Unit:: isSelected() const
Checks if this unit has been selected in the user interface
Returns | true if this unit is currently selected, and false if this unit is not selected |
---|
This function is only available if the flag Flag::
bool BWAPI:: Unit:: isSieged() const
Checks if this unit is currently sieged.
Returns | true if the unit is in siege mode, and false if it is either not in siege mode or not a Siege Tank |
---|
This is only applicable to Siege Tanks.
bool BWAPI:: Unit:: isStartingAttack() const
Checks if the unit is starting to attack.
Returns | true if this unit is starting an attack. |
---|
bool BWAPI:: Unit:: 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. |
---|
bool BWAPI:: Unit:: 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 |
---|
bool BWAPI:: Unit:: isStuck() const
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 |
---|
bool BWAPI:: Unit:: isTargetable() const
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.
Returns | |
---|---|
true | if BWAPI was unable to determine whether the unit can be a target. |
false | if an error occurred and the unit can not be a target. |
bool BWAPI:: Unit:: isTraining() const
Checks if this unit is training a new unit.
Returns | true if this unit is currently training another unit, and false otherwise. |
---|
bool BWAPI:: Unit:: isUnderAttack() const
Checks if the current unit is being attacked.
Returns | true if this unit has been attacked within the past few frames, and false if it has not |
---|
Has a small delay before this returns false again when the unit is no longer being attacked.
bool BWAPI:: Unit:: isUnderDarkSwarm() const
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 |
---|
bool BWAPI:: Unit:: isUnderDisruptionWeb() const
Checks if this unit is currently being affected by a Disruption Web.
Returns | true if this unit is under the effects of Disruption Web. |
---|
bool BWAPI:: Unit:: isUnderStorm() const
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. |
---|
bool BWAPI:: Unit:: isUpgrading() const
Checks if this unit is a structure that is currently upgrading an upgrade.
Returns | true if this structure is upgrading, false otherwise |
---|
See UpgradeTypes for a full list of upgrades in Broodwar.
bool BWAPI:: Unit:: isVisible(Player player) const
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:: |
Returns | true if this unit is visible to the specified player , and false if it is not. |
bool BWAPI:: Unit:: issueCommand(UnitCommand command) const
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 | |
---|---|
command | A 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. |
bool BWAPI:: Unit:: attack(Position target,
bool shiftQueueCommand = false) const
Orders the unit(s) to attack move to the specified position.
Parameters | |
---|---|
target | A 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. |
bool BWAPI:: Unit:: attack(Unit target,
bool shiftQueueCommand = false) const
Orders the unit(s) to attack the specified target unit.
Parameters | |
---|---|
target | A 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. |
bool BWAPI:: Unit:: build(UnitType type,
TilePosition target = TilePositions:: None) const
Orders the worker unit(s) to construct a structure at a target position.
Parameters | |
---|---|
type | The UnitType to build. |
target | A 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. |
bool BWAPI:: Unit:: train(UnitType type = UnitTypes:: None) const
Orders the unit(s) to add a UnitType to its training queue, or morphs into the UnitType if it is Zerg.
Parameters | |
---|---|
type | The UnitType to train. |
Returns | true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail. |
bool BWAPI:: Unit:: upgrade(UpgradeType upgrade) const
Orders the unit to upgrade the given upgrade type.
Parameters | |
---|---|
upgrade | The UpgradeType to upgrade. |
Returns | true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail. |
bool BWAPI:: Unit:: setRallyPoint(Position target) const
Orders the unit to set its rally position.
Parameters | |
---|---|
target | The 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. |
bool BWAPI:: Unit:: setRallyPoint(Unit target) const
Orders the unit to set its rally position to the specified unit.
Parameters | |
---|---|
target | The 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. |
bool BWAPI:: Unit:: move(Position target,
bool shiftQueueCommand = false) const
Orders the unit to move from its current position to the specified position.
Parameters | |
---|---|
target | The 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. |
bool BWAPI:: Unit:: patrol(Position target,
bool shiftQueueCommand = false) const
Orders the unit to patrol between its current position and the specified position.
Parameters | |
---|---|
target | The 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. |
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.
bool BWAPI:: Unit:: holdPosition(bool shiftQueueCommand = false) const
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. |
bool BWAPI:: Unit:: stop(bool shiftQueueCommand = false) const
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. |
bool BWAPI:: Unit:: follow(Unit target,
bool shiftQueueCommand = false) const
Orders the unit to follow the specified unit.
Parameters | |
---|---|
target | The 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. |
Units that are following other units will not perform any other actions such as attacking. They will ignore attackers.
bool BWAPI:: Unit:: gather(Unit target,
bool shiftQueueCommand = false) const
Orders the unit to gather the specified unit (must be mineral or refinery type).
Parameters | |
---|---|
target | The 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. |
bool BWAPI:: Unit:: returnCargo(bool shiftQueueCommand = false) const
Orders the unit to return its cargo to a nearby resource depot such as a Command Center.
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. |
Only workers that are carrying minerals or gas can be ordered to return cargo.
bool BWAPI:: Unit:: repair(Unit target,
bool shiftQueueCommand = false) const
Orders the unit to repair the specified unit.
Parameters | |
---|---|
target | The 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. |
Only Terran SCVs can be ordered to repair, and the target must be a mechanical Terran unit or building.
bool BWAPI:: Unit:: burrow() const
Orders the unit to burrow.
Returns | true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail. |
---|
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.
bool BWAPI:: Unit:: siege() const
Orders the unit to siege.
Returns | true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail. |
---|
Only works for Siege Tanks.
bool BWAPI:: Unit:: unsiege() const
Orders the unit to unsiege.
Returns | true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail. |
---|
Only works for sieged Siege Tanks.
bool BWAPI:: Unit:: land(TilePosition target) const
Orders the unit to land.
Parameters | |
---|---|
target | The 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. |
Only works for Terran structures that are currently lifted.
bool BWAPI:: Unit:: load(Unit target,
bool shiftQueueCommand = false) const
Orders the unit to load the target unit.
Parameters | |
---|---|
target | The 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. |
Only works if this unit is a Transport(Dropship, Shuttle, Overlord ) or Bunker type.
bool BWAPI:: Unit:: unload(Unit target) const
Orders the unit to unload the target unit.
Parameters | |
---|---|
target | Unloads 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. |
Only works for Transports(Dropships, Shuttles, Overlords ) and Bunkers.
bool BWAPI:: Unit:: unloadAll(bool shiftQueueCommand = false) const
Orders the unit to unload all loaded units at the unit's current 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. |
Only works for Transports(Dropships, Shuttles, Overlords ) and Bunkers.
bool BWAPI:: Unit:: unloadAll(Position target,
bool shiftQueueCommand = false) const
Orders the unit to unload all loaded units at the specified location.
Parameters | |
---|---|
target | The 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. |
Only works for Transports(Dropships, Shuttles, Overlords ). Not applicable to Bunkers.
bool BWAPI:: Unit:: rightClick(Position target,
bool shiftQueueCommand = false) const
Performs a right click action as it would work in StarCraft.
Parameters | |
---|---|
target | The 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. |
bool BWAPI:: Unit:: rightClick(Unit target,
bool shiftQueueCommand = false) const
Performs a right click action as it would work in StarCraft.
Parameters | |
---|---|
target | The 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. |
bool BWAPI:: Unit:: haltConstruction() const
Orders a SCV to stop constructing a structure.
Returns | true if the command was passed to Broodwar, and false if BWAPI determined that the command would fail. |
---|
This leaves the structure in an incomplete state until it is either cancelled, razed, or completed by another SCV.
bool BWAPI:: Unit:: cancelConstruction() const
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. |
---|
bool BWAPI:: Unit:: cancelAddon() const
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. |
---|
bool BWAPI:: Unit:: cancelTrain(int slot = -2) const
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. |
bool BWAPI:: Unit:: cancelMorph() const
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. |
---|
bool BWAPI:: Unit:: cancelResearch() const
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. |
---|
bool BWAPI:: Unit:: cancelUpgrade() const
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. |
---|
bool BWAPI:: Unit:: useTech(TechType tech,
Position target) const
Orders the unit to use a technology.
Parameters | |
---|---|
tech | The technology type to use. |
target | If 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. |
bool BWAPI:: Unit:: useTech(TechType tech,
Unit target) const
Orders the unit to use a technology.
Parameters | |
---|---|
tech | The 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. |
bool BWAPI:: Unit:: placeCOP(TilePosition target) const
Moves a Flag Beacon to a different location.
Parameters | |
---|---|
target | The 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. |
This is only used for Capture The Flag or Use Map Settings game types.
bool BWAPI:: Unit:: canIssueCommand(UnitCommand command,
bool checkCanUseTechPositionOnPositions = true,
bool checkCanUseTechUnitOnUnits = true,
bool checkCanBuildUnitType = true,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute the given command.
Parameters | |
---|---|
command | A UnitCommand to check. |
checkCanUseTechPositionOnPositions | Only used if the command type is UnitCommandTypes:: |
checkCanUseTechUnitOnUnits | Only used if the command type is UnitCommandTypes:: |
checkCanBuildUnitType | Only used if the command type is UnitCommandTypes:: |
checkCanTargetUnit | Only used for command types that can target a unit. A boolean for whether to perform Unit:: |
checkCanIssueCommandType | A boolean for whether to perform Unit:: |
checkCommandibility | A boolean for whether to perform Unit:: |
Returns | |
true | if BWAPI determined that the command is valid. |
false | if an error occurred and the command is invalid. |
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.
bool BWAPI:: Unit:: canIssueCommandGrouped(UnitCommand command,
bool checkCanUseTechPositionOnPositions = true,
bool checkCanUseTechUnitOnUnits = true,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
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.:
- 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.
- 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.
bool BWAPI:: Unit:: canCommand() const
Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute any commands (eg the unit is stasised).
Returns | |
---|---|
true | if BWAPI was unable to determine whether the unit can be commanded. |
false | if an error occurred and the unit can not be commanded. |
bool BWAPI:: Unit:: canCommandGrouped(bool checkCommandibility = true) const
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).
Returns | |
---|---|
true | if BWAPI was unable to determine whether the unit can be commanded grouped. |
false | if an error occurred and the unit can not be commanded grouped. |
bool BWAPI:: Unit:: canIssueCommandType(UnitCommandType ct,
bool checkCommandibility = true) const
Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute the given command type (i.e.
Parameters | |
---|---|
ct | A UnitCommandType. |
checkCommandibility | A boolean for whether to perform Unit:: |
Returns | |
true | if BWAPI was unable to determine whether the command type is invalid. |
false | if an error occurred and the command type is invalid. |
regardless of what other possible command parameters could be).
bool BWAPI:: Unit:: canIssueCommandTypeGrouped(UnitCommandType ct,
bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Performs some cheap checks to attempt to quickly detect whether the unit is unable to execute the given command type (i.e.
Parameters | |
---|---|
ct | A UnitCommandType. |
checkCommandibilityGrouped | A boolean for whether to perform Unit:: |
checkCommandibility | A boolean for whether to perform Unit:: |
Returns | |
true | if BWAPI was unable to determine whether the command type is invalid. |
false | if an error occurred and the command type is invalid. |
regardless of what other possible command parameters could be) as part of a Unitset.
bool BWAPI:: Unit:: canTargetUnit(Unit targetUnit,
bool checkCommandibility = true) const
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 | |
---|---|
targetUnit | A target unit for an unspecified command. |
checkCommandibility | A boolean for whether to perform Unit:: |
Returns | |
true | if BWAPI was unable to determine whether the unit can target the given unit. |
false | if an error occurred and the unit can not target the given unit. |
bool BWAPI:: Unit:: canAttack(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute an attack command to attack-move or attack a unit.
bool BWAPI:: Unit:: canAttackGrouped(bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
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.
bool BWAPI:: Unit:: canAttackGrouped(Position target,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
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.
bool BWAPI:: Unit:: canAttackMove(bool checkCommandibility = true) const
Checks whether the unit is able to execute an attack command to attack-move.
bool BWAPI:: Unit:: canAttackMoveGrouped(bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute an attack command to attack-move, as part of a Unitset.
bool BWAPI:: Unit:: canAttackUnit(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute an attack command to attack a unit.
bool BWAPI:: Unit:: canAttackUnit(Unit targetUnit,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute an attack command to attack a unit.
bool BWAPI:: Unit:: canAttackUnitGrouped(bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute an attack command to attack a unit, as part of a Unitset.
bool BWAPI:: Unit:: canAttackUnitGrouped(Unit targetUnit,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute an attack command to attack a unit, as part of a Unitset.
bool BWAPI:: Unit:: canBuild(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a build command.
bool BWAPI:: Unit:: canBuild(UnitType uType,
BWAPI:: TilePosition tilePos,
bool checkTargetUnitType = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a build command.
bool BWAPI:: Unit:: canBuildAddon(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a buildAddon command.
bool BWAPI:: Unit:: canBuildAddon(UnitType uType,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a buildAddon command.
bool BWAPI:: Unit:: canTrain(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a train command.
bool BWAPI:: Unit:: canMorph(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a morph command.
bool BWAPI:: Unit:: canResearch(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a research command.
bool BWAPI:: Unit:: canResearch(TechType type,
bool checkCanIssueCommandType = true) const
Checks whether the unit is able to execute a research command.
bool BWAPI:: Unit:: canUpgrade(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute an upgrade command.
bool BWAPI:: Unit:: canUpgrade(UpgradeType type,
bool checkCanIssueCommandType = true) const
Checks whether the unit is able to execute an upgrade command.
bool BWAPI:: Unit:: canSetRallyPoint(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a setRallyPoint command to a position or unit.
bool BWAPI:: Unit:: canSetRallyPoint(Position target,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a setRallyPoint command to a position or (non-null) unit.
bool BWAPI:: Unit:: canSetRallyPosition(bool checkCommandibility = true) const
Checks whether the unit is able to execute a setRallyPoint command to a position.
bool BWAPI:: Unit:: canSetRallyUnit(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a setRallyPoint command to a unit.
bool BWAPI:: Unit:: canSetRallyUnit(Unit targetUnit,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a setRallyPoint command to a unit.
bool BWAPI:: Unit:: canMove(bool checkCommandibility = true) const
Checks whether the unit is able to execute a move command.
bool BWAPI:: Unit:: canMoveGrouped(bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a move command, as part of a Unitset.
bool BWAPI:: Unit:: canPatrol(bool checkCommandibility = true) const
Checks whether the unit is able to execute a patrol command.
bool BWAPI:: Unit:: canPatrolGrouped(bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a patrol command, as part of a Unitset.
bool BWAPI:: Unit:: canFollow(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a follow command.
bool BWAPI:: Unit:: canGather(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a gather command.
bool BWAPI:: Unit:: canReturnCargo(bool checkCommandibility = true) const
Checks whether the unit is able to execute a returnCargo command.
bool BWAPI:: Unit:: canHoldPosition(bool checkCommandibility = true) const
Checks whether the unit is able to execute a holdPosition command.
bool BWAPI:: Unit:: canStop(bool checkCommandibility = true) const
Checks whether the unit is able to execute a stop command.
bool BWAPI:: Unit:: canRepair(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a repair command.
bool BWAPI:: Unit:: canBurrow(bool checkCommandibility = true) const
Checks whether the unit is able to execute a burrow command.
bool BWAPI:: Unit:: canUnburrow(bool checkCommandibility = true) const
Checks whether the unit is able to execute an unburrow command.
bool BWAPI:: Unit:: canCloak(bool checkCommandibility = true) const
Checks whether the unit is able to execute a cloak command.
bool BWAPI:: Unit:: canDecloak(bool checkCommandibility = true) const
Checks whether the unit is able to execute a decloak command.
bool BWAPI:: Unit:: canSiege(bool checkCommandibility = true) const
Checks whether the unit is able to execute a siege command.
bool BWAPI:: Unit:: canUnsiege(bool checkCommandibility = true) const
Checks whether the unit is able to execute an unsiege command.
bool BWAPI:: Unit:: canLift(bool checkCommandibility = true) const
Checks whether the unit is able to execute a lift command.
bool BWAPI:: Unit:: canLand(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a land command.
bool BWAPI:: Unit:: canLand(TilePosition target,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a land command.
bool BWAPI:: Unit:: canLoad(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a load command.
bool BWAPI:: Unit:: canUnloadWithOrWithoutTarget(bool checkCommandibility = true) const
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.
bool BWAPI:: Unit:: canUnloadAtPosition(Position targDropPos,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
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.
bool BWAPI:: Unit:: canUnload(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute an unload command.
bool BWAPI:: Unit:: canUnloadAll(bool checkCommandibility = true) const
Checks whether the unit is able to execute an unloadAll command for the current position.
bool BWAPI:: Unit:: canUnloadAllPosition(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute an unloadAll command for a different position.
bool BWAPI:: Unit:: canUnloadAllPosition(Position targDropPos,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute an unloadAll command for a different position.
bool BWAPI:: Unit:: canRightClick(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a rightClick command to a position or unit.
bool BWAPI:: Unit:: canRightClick(Position target,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a rightClick command to a position or (non-null) unit.
bool BWAPI:: Unit:: canRightClickGrouped(bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a rightClick command to a position or unit, as part of a Unitset.
bool BWAPI:: Unit:: canRightClickGrouped(Position target,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a rightClick command to a position or (non-null) unit, as part of a Unitset.
bool BWAPI:: Unit:: canRightClickPosition(bool checkCommandibility = true) const
Checks whether the unit is able to execute a rightClick command for a position.
bool BWAPI:: Unit:: canRightClickPositionGrouped(bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a rightClick command for a position, as part of a Unitset.
bool BWAPI:: Unit:: canRightClickUnit(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a rightClick command to a unit.
bool BWAPI:: Unit:: canRightClickUnit(Unit targetUnit,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a rightClick command to a unit.
bool BWAPI:: Unit:: canRightClickUnitGrouped(bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a rightClick command to a unit, as part of a Unitset.
bool BWAPI:: Unit:: canRightClickUnitGrouped(Unit targetUnit,
bool checkCanTargetUnit = true,
bool checkCanIssueCommandType = true,
bool checkCommandibilityGrouped = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a rightClick command to a unit, as part of a Unitset.
bool BWAPI:: Unit:: canHaltConstruction(bool checkCommandibility = true) const
Checks whether the unit is able to execute a haltConstruction command.
bool BWAPI:: Unit:: canCancelConstruction(bool checkCommandibility = true) const
Checks whether the unit is able to execute a cancelConstruction command.
bool BWAPI:: Unit:: canCancelAddon(bool checkCommandibility = true) const
Checks whether the unit is able to execute a cancelAddon command.
bool BWAPI:: Unit:: canCancelTrain(bool checkCommandibility = true) const
Checks whether the unit is able to execute a cancelTrain command for any slot.
bool BWAPI:: Unit:: canCancelTrainSlot(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a cancelTrain command for an unspecified slot.
bool BWAPI:: Unit:: canCancelTrainSlot(int slot,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a cancelTrain command for a specified slot.
bool BWAPI:: Unit:: canCancelMorph(bool checkCommandibility = true) const
Checks whether the unit is able to execute a cancelMorph command.
bool BWAPI:: Unit:: canCancelResearch(bool checkCommandibility = true) const
Checks whether the unit is able to execute a cancelResearch command.
bool BWAPI:: Unit:: canCancelUpgrade(bool checkCommandibility = true) const
Checks whether the unit is able to execute a cancelUpgrade command.
bool BWAPI:: Unit:: canUseTechWithOrWithoutTarget(bool checkCommandibility = true) const
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.
bool BWAPI:: Unit:: canUseTechWithOrWithoutTarget(BWAPI:: TechType tech,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
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.
bool BWAPI:: Unit:: canUseTech(BWAPI:: TechType tech,
Position target,
bool checkCanTargetUnit = true,
bool checkTargetsType = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
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).
bool BWAPI:: Unit:: canUseTechWithoutTarget(BWAPI:: TechType tech,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a useTech command without a target.
bool BWAPI:: Unit:: canUseTechUnit(BWAPI:: TechType tech,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a useTech command with an unspecified target unit.
bool BWAPI:: Unit:: canUseTechUnit(BWAPI:: TechType tech,
Unit targetUnit,
bool checkCanTargetUnit = true,
bool checkTargetsUnits = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a useTech command with a target unit.
bool BWAPI:: Unit:: canUseTechPosition(BWAPI:: TechType tech,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a useTech command with an unspecified target position.
bool BWAPI:: Unit:: canUseTechPosition(BWAPI:: TechType tech,
Position target,
bool checkTargetsPositions = true,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a useTech command with a target position.
bool BWAPI:: Unit:: canPlaceCOP(bool checkCommandibility = true) const
Cheap checks for whether the unit is able to execute a placeCOP command.
bool BWAPI:: Unit:: canPlaceCOP(TilePosition target,
bool checkCanIssueCommandType = true,
bool checkCommandibility = true) const
Checks whether the unit is able to execute a placeCOP command.