BWAPI 4.2.0 An API for interacting with Starcraft: Broodwar (1.16.1) |
Public Member Functions | |
Unit | getClosestUnit (const UnitFilter &pred=nullptr, int radius=999999) const |
Unitset | getInterceptors () const |
Unitset | getLarva () const |
Unitset | getLoadedUnits () const |
Position | getPosition () const |
Unitset | getUnitsInRadius (int radius, const UnitFilter &pred=nullptr) const |
Unitset & | operator= (const Unitset &other) |
void | setClientInfo (void *clientInfo=nullptr, int index=0) const |
void | setClientInfo (int clientInfo=0, int index=0) const |
Unit Commands | |
bool | issueCommand (UnitCommand command) const |
bool | attack (Position target, bool shiftQueueCommand=false) const |
bool | attack (Unit target, bool shiftQueueCommand=false) const |
bool | build (UnitType type, TilePosition target=TilePositions::None) const |
bool | buildAddon (UnitType type) const |
bool | train (UnitType type) const |
bool | morph (UnitType type) const |
bool | setRallyPoint (Unit target) const |
bool | setRallyPoint (Position target) const |
bool | move (Position target, bool shiftQueueCommand=false) const |
bool | patrol (Position target, bool shiftQueueCommand=false) const |
bool | holdPosition (bool shiftQueueCommand=false) const |
bool | stop (bool shiftQueueCommand=false) const |
bool | follow (Unit target, bool shiftQueueCommand=false) const |
bool | gather (Unit target, bool shiftQueueCommand=false) const |
bool | returnCargo (bool shiftQueueCommand=false) const |
bool | repair (Unit target, bool shiftQueueCommand=false) const |
bool | burrow () const |
bool | unburrow () const |
bool | cloak () const |
bool | decloak () const |
bool | siege () const |
bool | unsiege () const |
bool | lift () const |
bool | load (Unit target, bool shiftQueueCommand=false) const |
bool | unloadAll (bool shiftQueueCommand=false) const |
bool | unloadAll (Position target, bool shiftQueueCommand=false) const |
bool | rightClick (Unit target, bool shiftQueueCommand=false) const |
bool | rightClick (Position target, bool shiftQueueCommand=false) const |
bool | haltConstruction () const |
bool | cancelConstruction () const |
bool | cancelAddon () const |
bool | cancelTrain (int slot=-2) const |
bool | cancelMorph () const |
bool | cancelResearch () const |
bool | cancelUpgrade () const |
bool | useTech (TechType tech, Unit target=nullptr) const |
bool | useTech (TechType tech, Position target) const |
Public Member Functions inherited from std::unordered_set< K > | |
T | unordered_set (T...args) |
T | begin (T...args) |
T | begin(int) (T...args) |
T | bucket (T...args) |
T | bucket_count (T...args) |
T | bucket_size (T...args) |
T | cbegin (T...args) |
T | cbegin(int) (T...args) |
T | cend (T...args) |
T | cend(int) (T...args) |
T | clear (T...args) |
T | count (T...args) |
T | emplace (T...args) |
T | emplace_hint (T...args) |
T | empty (T...args) |
T | end (T...args) |
T | end(int) (T...args) |
T | equal_range (T...args) |
T | erase (T...args) |
T | find (T...args) |
T | get_allocator (T...args) |
T | hash_function (T...args) |
T | insert (T...args) |
T | key_eq (T...args) |
T | load_factor (T...args) |
T | max_bucket_count (T...args) |
T | max_load_factor (T...args) |
T | max_size (T...args) |
T | operator= (T...args) |
T | rehash (T...args) |
T | reserve (T...args) |
T | size (T...args) |
T | swap (T...args) |
Static Public Attributes | |
static const Unitset | none |
Additional Inherited Members | |
Public Attributes inherited from std::unordered_set< K > | |
K | keys |
The Unitset is a container for a set of pointers to Unit objects.
It is typically used for groups of units instead of having to manage each Unit individually.
References attack(), std::unordered_set< K >::begin(), build(), buildAddon(), burrow(), cancelAddon(), cancelConstruction(), cancelMorph(), cancelResearch(), cancelTrain(), cancelUpgrade(), std::unordered_set< K >::clear(), cloak(), std::copy(), decloak(), std::unordered_set< K >::end(), follow(), gather(), getClosestUnit(), getInterceptors(), getLarva(), getLoadedUnits(), getPosition(), getUnitsInRadius(), haltConstruction(), holdPosition(), std::inserter(), issueCommand(), lift(), load(), morph(), move(), BWAPI::TilePositions::None, patrol(), repair(), returnCargo(), rightClick(), setClientInfo(), setRallyPoint(), siege(), stop(), train(), unburrow(), unloadAll(), unsiege(), and useTech().
Calculates the average of all valid Unit positions in this set.
Referenced by operator=().
Creates a single set containing all units that are loaded into units of this set.
Referenced by operator=().
Creates a single set containing all the Interceptors of all Carriers in this set.
Referenced by operator=().
Creates a single set containing all the Larvae of all Hatcheries, Lairs, and Hives in this set.
Referenced by operator=().
nullptr
, int index = 0
) constSets the client info for every unit in this set.
clientInfo | (optional) A pointer to client information, managed by the AI module, or nullptr if client information is to be cleared. |
index | (optional) An key value for the client info mapping so that more than one piece of data can be mapped to the same unit. |
Referenced by operator=().
0
, int index = 0
) constThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Retrieves the set of all units in a given radius of the current unit.
Takes into account this unit's dimensions. Can optionally specify a filter that is composed using BWAPIFilter semantics to include only specific units (such as only ground units, etc.)
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. |
Example usage:
Referenced by operator=().
Retrieves the closest unit to this one.
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. |
Referenced by operator=().
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.
command | A UnitCommand containing command parameters such as the type, position, target, etc. |
Referenced by operator=().
Orders the unit(s) to attack move to the specified position.
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. |
Referenced by operator=().
Orders the unit(s) to attack move to the specified position.
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. |
Orders the worker unit(s) to construct a structure at a target position.
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. |
Referenced by operator=().
Orders the Terran structure(s) to construct an add-on.
type | The add-on UnitType to construct. |
Referenced by operator=().
Orders the unit(s) to add a UnitType to its training queue, or morphs into the UnitType if it is Zerg.
type | The UnitType to train. |
Referenced by operator=().
Orders the unit(s) to morph into a different UnitType.
type | The UnitType to morph into. |
Referenced by operator=().
Orders the unit to set its rally position.
target | The target position that this structure will rally completed units to. |
Referenced by operator=().
Orders the unit to set its rally position.
target | The target position that this structure will rally completed units to. |
Orders the unit to move from its current position to the specified position.
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. |
Referenced by operator=().
Orders the unit to patrol between its current position and the specified position.
While patrolling, units will attack and chase enemy units that they encounter, and then return to its patrol route. Medics will automatically heal units and then return to their patrol route.
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. |
Referenced by operator=().
false
) constOrders the unit to hold its position.
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. |
Referenced by operator=().
false
) constOrders the unit to stop.
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. |
Referenced by operator=().
Orders the unit to follow the specified unit.
Units that are following other units will not perform any other actions such as attacking. They will ignore attackers.
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. |
Referenced by operator=().
Orders the unit to gather the specified unit (must be mineral or refinery type).
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. |
Referenced by operator=().
false
) constOrders the unit to return its cargo to a nearby resource depot such as a Command Center.
Only workers that are carrying minerals or gas can be ordered to return cargo.
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. |
Referenced by operator=().
Orders the unit to repair the specified unit.
Only Terran SCVs can be ordered to repair, and the target must be a mechanical Terran unit or building.
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. |
Referenced by operator=().
Orders the unit to burrow.
Either the unit must be a Lurker, or the unit must be a Zerg ground unit that is capable of Burrowing, and Burrow technology must be researched.
Referenced by operator=().
Orders a burrowed unit to unburrow.
Referenced by operator=().
Orders the unit to cloak.
Referenced by operator=().
Orders a cloaked unit to decloak.
Referenced by operator=().
Orders the unit to siege.
Only works for Siege Tanks.
Referenced by operator=().
Orders the unit to unsiege.
Only works for sieged Siege Tanks.
Referenced by operator=().
Orders the unit to lift.
Only works for liftable Terran structures.
Referenced by operator=().
Orders the unit to load the target unit.
Only works if this unit is a Transport(Dropship, Shuttle, Overlord ) or Bunker type.
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. |
Referenced by operator=().
false
) constOrders the unit to unload all loaded units at the unit's current position.
Only works for Transports(Dropships, Shuttles, Overlords ) and Bunkers.
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. |
Referenced by operator=().
Orders the unit to unload all loaded units at the specified location.
Only works for Transports(Dropships, Shuttles, Overlords ). Not applicable to Bunkers.
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. |
Performs a right click action as it would work in StarCraft.
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. |
Referenced by operator=().
Performs a right click action as it would work in StarCraft.
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. |
Orders a SCV to stop constructing a structure.
This leaves the structure in an incomplete state until it is either cancelled, razed, or completed by another SCV.
Referenced by operator=().
Orders this unit to cancel and refund itself from begin constructed.
Referenced by operator=().
Orders this unit to cancel and refund an add-on that is being constructed.
Referenced by operator=().
-2
) constOrders the unit to remove the specified unit from its training queue.
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. |
Referenced by operator=().
Orders this unit to cancel and refund a unit that is morphing.
Referenced by operator=().
Orders this unit to cancel and refund a research that is in progress.
Referenced by operator=().
Orders this unit to cancel and refund an upgrade that is in progress.
Referenced by operator=().
Orders the unit to use a technology.
tech | The technology type to use. |
target | If specified, indicates the target location to use the tech on. |
Referenced by operator=().
Orders the unit to use a technology.
tech | The technology type to use. |
target | If specified, indicates the target location to use the tech on. |