Modifier and Type | Method and Description |
---|---|
List<Player> |
allies()
Retrieves a set of all the current player's remaining allies.
|
boolean |
canBuildHere(TilePosition position,
UnitType type) |
boolean |
canBuildHere(TilePosition position,
UnitType type,
Unit builder) |
boolean |
canBuildHere(TilePosition position,
UnitType type,
Unit builder,
boolean checkExplored)
Checks if the given unit type can be built at the given build tile position.
|
boolean |
canMake(UnitType type) |
boolean |
canMake(UnitType type,
Unit builder)
Checks all the requirements in order to make a given unit type for the current
player.
|
boolean |
canResearch(TechType type) |
boolean |
canResearch(TechType type,
Unit unit) |
boolean |
canResearch(TechType type,
Unit unit,
boolean checkCanIssueCommandType)
Checks all the requirements in order to research a given technology type for the
current player.
|
boolean |
canUpgrade(UpgradeType type) |
boolean |
canUpgrade(UpgradeType type,
Unit unit) |
boolean |
canUpgrade(UpgradeType type,
Unit unit,
boolean checkCanIssueCommandType)
Checks all the requirements in order to upgrade a given upgrade type for the
current player.
|
int |
countdownTimer()
Returns the remaining countdown time.
|
void |
drawBox(CoordinateType ctype,
int left,
int top,
int right,
int bottom,
Color color) |
void |
drawBox(CoordinateType ctype,
int left,
int top,
int right,
int bottom,
Color color,
boolean isSolid)
Draws a rectangle on the screen with the given color.
|
void |
drawBoxMap(int left,
int top,
int right,
int bottom,
Color color) |
void |
drawBoxMap(int left,
int top,
int right,
int bottom,
Color color,
boolean isSolid) |
void |
drawBoxMap(Position leftTop,
Position rightBottom,
Color color) |
void |
drawBoxMap(Position leftTop,
Position rightBottom,
Color color,
boolean isSolid) |
void |
drawBoxMouse(int left,
int top,
int right,
int bottom,
Color color) |
void |
drawBoxMouse(int left,
int top,
int right,
int bottom,
Color color,
boolean isSolid) |
void |
drawBoxMouse(Position leftTop,
Position rightBottom,
Color color) |
void |
drawBoxMouse(Position leftTop,
Position rightBottom,
Color color,
boolean isSolid) |
void |
drawBoxScreen(int left,
int top,
int right,
int bottom,
Color color) |
void |
drawBoxScreen(int left,
int top,
int right,
int bottom,
Color color,
boolean isSolid) |
void |
drawBoxScreen(Position leftTop,
Position rightBottom,
Color color) |
void |
drawBoxScreen(Position leftTop,
Position rightBottom,
Color color,
boolean isSolid) |
void |
drawCircle(CoordinateType ctype,
int x,
int y,
int radius,
Color color) |
void |
drawCircle(CoordinateType ctype,
int x,
int y,
int radius,
Color color,
boolean isSolid)
Draws a circle on the screen with the given color.
|
void |
drawCircleMap(int x,
int y,
int radius,
Color color) |
void |
drawCircleMap(int x,
int y,
int radius,
Color color,
boolean isSolid) |
void |
drawCircleMap(Position p,
int radius,
Color color) |
void |
drawCircleMap(Position p,
int radius,
Color color,
boolean isSolid) |
void |
drawCircleMouse(int x,
int y,
int radius,
Color color) |
void |
drawCircleMouse(int x,
int y,
int radius,
Color color,
boolean isSolid) |
void |
drawCircleMouse(Position p,
int radius,
Color color) |
void |
drawCircleMouse(Position p,
int radius,
Color color,
boolean isSolid) |
void |
drawCircleScreen(int x,
int y,
int radius,
Color color) |
void |
drawCircleScreen(int x,
int y,
int radius,
Color color,
boolean isSolid) |
void |
drawCircleScreen(Position p,
int radius,
Color color) |
void |
drawCircleScreen(Position p,
int radius,
Color color,
boolean isSolid) |
void |
drawDot(CoordinateType ctype,
int x,
int y,
Color color)
Draws a dot on the map or screen with a given color.
|
void |
drawDotMap(int x,
int y,
Color color) |
void |
drawDotMap(Position p,
Color color) |
void |
drawDotMouse(int x,
int y,
Color color) |
void |
drawDotMouse(Position p,
Color color) |
void |
drawDotScreen(int x,
int y,
Color color) |
void |
drawDotScreen(Position p,
Color color) |
void |
drawEllipse(CoordinateType ctype,
int x,
int y,
int xrad,
int yrad,
Color color) |
void |
drawEllipse(CoordinateType ctype,
int x,
int y,
int xrad,
int yrad,
Color color,
boolean isSolid)
Draws an ellipse on the screen with the given color.
|
void |
drawEllipseMap(int x,
int y,
int xrad,
int yrad,
Color color) |
void |
drawEllipseMap(int x,
int y,
int xrad,
int yrad,
Color color,
boolean isSolid) |
void |
drawEllipseMap(Position p,
int xrad,
int yrad,
Color color) |
void |
drawEllipseMap(Position p,
int xrad,
int yrad,
Color color,
boolean isSolid) |
void |
drawEllipseMouse(int x,
int y,
int xrad,
int yrad,
Color color) |
void |
drawEllipseMouse(int x,
int y,
int xrad,
int yrad,
Color color,
boolean isSolid) |
void |
drawEllipseMouse(Position p,
int xrad,
int yrad,
Color color) |
void |
drawEllipseMouse(Position p,
int xrad,
int yrad,
Color color,
boolean isSolid) |
void |
drawEllipseScreen(int x,
int y,
int xrad,
int yrad,
Color color) |
void |
drawEllipseScreen(int x,
int y,
int xrad,
int yrad,
Color color,
boolean isSolid) |
void |
drawEllipseScreen(Position p,
int xrad,
int yrad,
Color color) |
void |
drawEllipseScreen(Position p,
int xrad,
int yrad,
Color color,
boolean isSolid) |
void |
drawLine(CoordinateType ctype,
int x1,
int y1,
int x2,
int y2,
Color color)
Draws a line on the map or screen with a given color.
|
void |
drawLineMap(int x1,
int y1,
int x2,
int y2,
Color color) |
void |
drawLineMap(Position a,
Position b,
Color color) |
void |
drawLineMouse(int x1,
int y1,
int x2,
int y2,
Color color) |
void |
drawLineMouse(Position a,
Position b,
Color color) |
void |
drawLineScreen(int x1,
int y1,
int x2,
int y2,
Color color) |
void |
drawLineScreen(Position a,
Position b,
Color color) |
void |
drawText(CoordinateType ctype,
int x,
int y,
String string,
Text... colors) |
void |
drawTextMap(int x,
int y,
String string,
Text... colors) |
void |
drawTextMap(Position p,
String string,
Text... colors) |
void |
drawTextMouse(int x,
int y,
String string,
Text... colors) |
void |
drawTextMouse(Position p,
String string,
Text... colors) |
void |
drawTextScreen(int x,
int y,
String string,
Text... colors) |
void |
drawTextScreen(Position p,
String string,
Text... colors) |
void |
drawTriangle(CoordinateType ctype,
int ax,
int ay,
int bx,
int by,
int cx,
int cy,
Color color) |
void |
drawTriangle(CoordinateType ctype,
int ax,
int ay,
int bx,
int by,
int cx,
int cy,
Color color,
boolean isSolid)
Draws a triangle on the screen with the given color.
|
void |
drawTriangleMap(int ax,
int ay,
int bx,
int by,
int cx,
int cy,
Color color) |
void |
drawTriangleMap(int ax,
int ay,
int bx,
int by,
int cx,
int cy,
Color color,
boolean isSolid) |
void |
drawTriangleMap(Position a,
Position b,
Position c,
Color color) |
void |
drawTriangleMap(Position a,
Position b,
Position c,
Color color,
boolean isSolid) |
void |
drawTriangleMouse(int ax,
int ay,
int bx,
int by,
int cx,
int cy,
Color color) |
void |
drawTriangleMouse(int ax,
int ay,
int bx,
int by,
int cx,
int cy,
Color color,
boolean isSolid) |
void |
drawTriangleMouse(Position a,
Position b,
Position c,
Color color) |
void |
drawTriangleMouse(Position a,
Position b,
Position c,
Color color,
boolean isSolid) |
void |
drawTriangleScreen(int ax,
int ay,
int bx,
int by,
int cx,
int cy,
Color color) |
void |
drawTriangleScreen(int ax,
int ay,
int bx,
int by,
int cx,
int cy,
Color color,
boolean isSolid) |
void |
drawTriangleScreen(Position a,
Position b,
Position c,
Color color) |
void |
drawTriangleScreen(Position a,
Position b,
Position c,
Color color,
boolean isSolid) |
int |
elapsedTime()
Retrieves current amount of time in seconds that the game has elapsed.
|
void |
enableFlag(Flag flag)
Enables the state of a given flag.
|
List<Player> |
enemies()
Retrieves a set of all the current player's remaining enemies.
|
Player |
enemy()
Retrieves the
Player interface that represents the enemy player. |
List<Region> |
getAllRegions()
Retrieves the set of all regions on the map.
|
List<Unit> |
getAllUnits()
Retrieves the set of all accessible units.
|
int |
getAPM() |
int |
getAPM(boolean includeSelects)
Retrieves the Actions Per Minute (APM) that the bot is producing.
|
double |
getAverageFPS()
Retrieves the average logical frame rate of the game in frames per second (FPS).
|
TilePosition |
getBuildLocation(UnitType type,
TilePosition desiredPosition) |
TilePosition |
getBuildLocation(UnitType type,
TilePosition desiredPosition,
int maxRange) |
TilePosition |
getBuildLocation(UnitType type,
TilePosition desiredPosition,
int maxRange,
boolean creep)
Retrieves a basic build position just as the default Computer AI would.
|
List<Bullet> |
getBullets()
Retrieves the set of all accessible bullets.
|
Unit |
getClosestUnit(Position center) |
Unit |
getClosestUnit(Position center,
int radius) |
Unit |
getClosestUnit(Position center,
int radius,
UnitFilter pred)
Retrieves the closest unit to center that matches the criteria of the callback
pred within an optional radius.
|
Unit |
getClosestUnit(Position center,
UnitFilter pred) |
Unit |
getClosestUnitInRectangle(Position center,
int left,
int top,
int right,
int bottom) |
Unit |
getClosestUnitInRectangle(Position center,
int left,
int top,
int right,
int bottom,
UnitFilter pred)
Retrieves the closest unit to center that matches the criteria of the callback
pred within an optional rectangle.
|
int |
getDamageFrom(UnitType fromType,
UnitType toType) |
int |
getDamageFrom(UnitType fromType,
UnitType toType,
Player fromPlayer) |
int |
getDamageFrom(UnitType fromType,
UnitType toType,
Player fromPlayer,
Player toPlayer)
Calculates the damage received for a given player.
|
int |
getDamageTo(UnitType toType,
UnitType fromType) |
int |
getDamageTo(UnitType toType,
UnitType fromType,
Player toPlayer) |
int |
getDamageTo(UnitType toType,
UnitType fromType,
Player toPlayer,
Player fromPlayer)
Calculates the damage dealt for a given player.
|
Force |
getForce(int forceID)
Retrieves the
Force object associated with a given identifier. |
List<Force> |
getForces()
Retrieves the set of all teams/forces.
|
int |
getFPS()
Retrieves the logical frame rate of the game in frames per second (FPS).
|
int |
getFrameCount()
Retrieves the number of logical frames since the beginning of the match.
|
GameType |
getGameType()
Retrieves the
GameType of the current game. |
List<Unit> |
getGeysers()
Retrieves the set of all accessible @geysers in the game.
|
int |
getGroundHeight(int tileX,
int tileY)
Returns the ground height at the given tile position.
|
int |
getGroundHeight(TilePosition position) |
int |
getInstanceNumber()
Retrieves the Starcraft instance number recorded by BWAPI to identify which
Starcraft instance an AI module belongs to.
|
boolean |
getKeyState(Key key)
Retrieves the state of the given keyboard key.
|
int |
getLastEventTime()
Retrieves the amount of time (in milliseconds) that has elapsed when running the last AI
module callback.
|
Latency |
getLatency()
Retrieves the current latency setting that the game is set to.
|
int |
getLatencyFrames()
Retrieves the maximum delay, in number of frames, between a command being issued
and the command being executed by Broodwar.
|
int |
getLatencyTime()
Retrieves the maximum delay, in milliseconds, between a command being issued and
the command being executed by Broodwar.
|
List<Unit> |
getMinerals()
Retrieves the set of all accessible @minerals in the game.
|
Position |
getMousePosition()
Retrieves the position of the user's mouse on the screen, in
Position coordinates. |
boolean |
getMouseState(MouseButton button)
Retrieves the state of the given mouse button.
|
List<Unit> |
getNeutralUnits()
Retrieves the set of all accessible neutral units in the game.
|
List<Position> |
getNukeDots()
Retrieves the set of all accessible @Nuke dots.
|
Player |
getPlayer(int playerID)
Retrieves the
Player object associated with a given identifier. |
List<Player> |
getPlayers()
Retrieves the set of all players in the match.
|
int |
getRandomSeed()
Retrieves the initial random seed that was used in this game's creation.
|
Region |
getRegion(int regionID)
Retrieves the
Region object associated with a given identifier. |
Region |
getRegionAt(int x,
int y)
Retrieves the region at a given position.
|
Region |
getRegionAt(Position position) |
int |
getRemainingLatencyFrames()
Retrieves the number of frames it will take before a command sent in the current
frame will be executed by the game.
|
int |
getRemainingLatencyTime()
Retrieves the number of milliseconds it will take before a command sent in the
current frame will be executed by Broodwar.
|
int |
getReplayFrameCount()
Retrieves the maximum number of logical frames that have been recorded in a
replay.
|
int |
getRevision()
Retrieves the current revision of BWAPI.
|
Position |
getScreenPosition()
Retrieves the top left position of the viewport from the top left corner of the
map, in pixels.
|
List<Unit> |
getSelectedUnits()
Retrieves the set of units that are currently selected by the user outside of
BWAPI.
|
List<TilePosition> |
getStartLocations()
Retrieves the set of all starting locations for the current map.
|
List<Unit> |
getStaticGeysers()
Retrieves the set of all @geysers that were available at the beginning of the
game.
|
List<Unit> |
getStaticMinerals()
Retrieves the set of all @minerals that were available at the beginning of the
game.
|
List<Unit> |
getStaticNeutralUnits()
Retrieves the set of all units owned by the neutral player (resources, critters,
etc.) that were available at the beginning of the game.
|
Unit |
getUnit(int unitID)
Retrieves the
Unit object associated with a given identifier. |
List<Unit> |
getUnitsInRadius(int x,
int y,
int radius) |
List<Unit> |
getUnitsInRadius(int x,
int y,
int radius,
UnitFilter pred)
Retrieves the set of accessible units that are within a given radius of a
position.
|
List<Unit> |
getUnitsInRadius(Position center,
int radius) |
List<Unit> |
getUnitsInRadius(Position center,
int radius,
UnitFilter pred) |
List<Unit> |
getUnitsInRectangle(int left,
int top,
int right,
int bottom) |
List<Unit> |
getUnitsInRectangle(int left,
int top,
int right,
int bottom,
UnitFilter pred)
Retrieves the set of accessible units that are in a given rectangle.
|
List<Unit> |
getUnitsInRectangle(Position leftTop,
Position rightBottom) |
List<Unit> |
getUnitsInRectangle(Position leftTop,
Position rightBottom,
UnitFilter pred) |
List<Unit> |
getUnitsOnTile(int tileX,
int tileY) |
List<Unit> |
getUnitsOnTile(int tileX,
int tileY,
UnitFilter pred)
Retrieves the set of accessible units that are on a given build tile.
|
List<Unit> |
getUnitsOnTile(TilePosition tile) |
boolean |
hasCreep(int tileX,
int tileY)
Checks if the given tile position has @Zerg creep on it.
|
boolean |
hasCreep(TilePosition position) |
boolean |
hasPath(Position source,
Position destination)
Checks if there is a path from source to destination.
|
boolean |
hasPower(int tileX,
int tileY) |
boolean |
hasPower(int tileX,
int tileY,
int tileWidth,
int tileHeight) |
boolean |
hasPower(int tileX,
int tileY,
int tileWidth,
int tileHeight,
UnitType unitType)
Checks if the given tile position if powered by an owned @Protoss_Pylon for an
optional unit type.
|
boolean |
hasPower(int tileX,
int tileY,
UnitType unitType) |
boolean |
hasPower(TilePosition position) |
boolean |
hasPower(TilePosition position,
int tileWidth,
int tileHeight) |
boolean |
hasPower(TilePosition position,
int tileWidth,
int tileHeight,
UnitType unitType) |
boolean |
hasPower(TilePosition position,
UnitType unitType) |
boolean |
hasPowerPrecise(int x,
int y) |
boolean |
hasPowerPrecise(int x,
int y,
UnitType unitType)
Checks if the given pixel position is powered by an owned @Protoss_Pylon for an
optional unit type.
|
boolean |
hasPowerPrecise(Position position) |
boolean |
hasPowerPrecise(Position position,
UnitType unitType) |
boolean |
isBattleNet()
Checks if the client is in a game that was created through the Battle.net
multiplayer gaming service.
|
boolean |
isBuildable(int tileX,
int tileY) |
boolean |
isBuildable(int tileX,
int tileY,
boolean includeBuildings)
Checks if a given tile position is buildable.
|
boolean |
isBuildable(TilePosition position) |
boolean |
isBuildable(TilePosition position,
boolean includeBuildings) |
boolean |
isDebug()
Retrieves the debug state of the BWAPI build.
|
boolean |
isExplored(int tileX,
int tileY)
Checks if a given tile position has been explored by the player.
|
boolean |
isExplored(TilePosition position) |
boolean |
isFlagEnabled(Flag flag)
Checks if the state of the given flag is enabled or not.
|
boolean |
isInGame()
Checks if the current client is inside a game.
|
boolean |
isLatComEnabled()
Checks the state of latency compensation.
|
boolean |
isMultiplayer()
Checks if the current client is inside a multiplayer game.
|
boolean |
isPaused()
Checks if the current game is paused.
|
boolean |
isReplay()
Checks if the client is watching a replay.
|
boolean |
issueCommand(Collection<Unit> units,
UnitCommand command)
Issues a given command to a set of units.
|
boolean |
isVisible(int tileX,
int tileY)
Checks if a given tile position is visible to the current player.
|
boolean |
isVisible(TilePosition position) |
boolean |
isWalkable(int walkX,
int walkY)
Checks if the given mini-tile position is walkable.
|
boolean |
isWalkable(WalkPosition position) |
void |
leaveGame()
Leaves the current game by surrendering and enters the post-game statistics/score
screen.
|
String |
mapFileName()
Retrieves the file name of the currently loaded map.
|
String |
mapHash()
Calculates the SHA-1 hash of the currently loaded map file.
|
int |
mapHeight()
Retrieves the height of the map in build tile units.
|
String |
mapName()
Retrieves the title of the currently loaded map.
|
String |
mapPathName()
Retrieves the full path name of the currently loaded map.
|
int |
mapWidth()
Retrieves the width of the map in build tile units.
|
Player |
neutral()
Retrieves the
Player object representing the neutral player. |
List<Player> |
observers()
Retrieves a set of all players currently observing the game.
|
void |
pauseGame()
Pauses the game.
|
void |
pingMinimap(int x,
int y)
Pings the minimap at the given position.
|
void |
pingMinimap(Position p) |
void |
printf(String string,
Text... colors)
Prints text to the screen as a notification.
|
void |
restartGame()
Restarts the match.
|
void |
resumeGame()
Resumes the game from a paused state.
|
Player |
self()
Retrieves the player object that BWAPI is controlling.
|
void |
sendText(String string,
Text... colors)
Sends a text message to all other players in the game.
|
void |
sendTextEx(boolean toAllies,
String string,
Text... colors)
An extended version of
sendText(java.lang.String, bwapi.Text...) which allows messages to be forwarded to
allies. |
boolean |
setAlliance(Player player) |
boolean |
setAlliance(Player player,
boolean allied) |
boolean |
setAlliance(Player player,
boolean allied,
boolean alliedVictory)
Sets the alliance state of the current player with the target player.
|
void |
setCommandOptimizationLevel(int level)
Sets the command optimization level.
|
void |
setFrameSkip(int frameSkip)
Sets the number of graphical frames for every logical frame.
|
void |
setGUI(boolean enabled)
Sets the rendering state of the Starcraft GUI.
|
void |
setLatCom(boolean isEnabled)
Changes the state of latency compensation.
|
void |
setLocalSpeed(int speed)
Sets the number of milliseconds Broodwar spends in each frame.
|
boolean |
setMap(String mapFileName)
Changes the map to the one specified.
|
boolean |
setRevealAll() |
boolean |
setRevealAll(boolean reveal)
Sets the state of the fog of war when watching a replay.
|
void |
setScreenPosition(int x,
int y)
Moves the top left corner of the viewport to the provided position relative to
the map's origin (top left (0,0)).
|
void |
setScreenPosition(Position p) |
void |
setTextSize() |
void |
setTextSize(Text.Size size)
Sets the size of the text for all calls to
drawText(bwapi.CoordinateType, int, int, java.lang.String, bwapi.Text...) following this one. |
boolean |
setVision(Player player,
boolean enabled)
In a game, this function sets the vision of the current BWAPI player with the
target player.
|
public List<Force> getForces()
public List<Player> getPlayers()
public List<Unit> getAllUnits()
Flag.CompleteMapInformation
is enabled, then the set also includes units that are not
visible to the player.
Units that are inside refineries are not included in this set.
public List<Unit> getMinerals()
public List<Unit> getGeysers()
public List<Unit> getNeutralUnits()
public List<Unit> getStaticMinerals()
This set includes resources that have been mined out or are inaccessible.
public List<Unit> getStaticGeysers()
This set includes resources that are inaccessible.
public List<Unit> getStaticNeutralUnits()
This set includes units that are inaccessible.
public List<Bullet> getBullets()
Bullet
objects.public List<Position> getNukeDots()
Nuke dots are the red dots painted by a @Ghost when using the nuclear strike ability.
public Force getForce(int forceID)
Force
object associated with a given identifier.forceID
- The identifier for the Force object.Force
object mapped to the given forceID. Returns null if the given identifier is invalid.public Player getPlayer(int playerID)
Player
object associated with a given identifier.public Unit getUnit(int unitID)
Unit
object associated with a given identifier.public Region getRegion(int regionID)
Region
object associated with a given identifier.public Latency getLatency()
Latency
indicates the delay between issuing a command and having it processed.public int getFrameCount()
public int getReplayFrameCount()
public int getFPS()
getAverageFPS()
public double getAverageFPS()
getFPS()
public Position getMousePosition()
Position
coordinates.Position
indicating the location of the mouse. Returns Position.Unknown
if Flag.UserInput
is disabled.public final boolean getMouseState(MouseButton button)
button
- A MouseButton
enum member indicating which button on the mouse to check.Flag.UserInput
is disabled.MouseButton
public final boolean getKeyState(Key key)
key
- A Key
enum member indicating which key on the keyboard to check.Flag.UserInput
is disabled.Key
public Position getScreenPosition()
Position
containing the coordinates of the top left corner of the game's viewport. Returns Position.Unknown
always if Flag.UserInput
is disabled.setScreenPosition(bwapi.Position)
public void setScreenPosition(Position p)
public void setScreenPosition(int x, int y)
x
- The x coordinate to move the screen to, in pixels.y
- The y coordinate to move the screen to, in pixels.getScreenPosition()
public void pingMinimap(int x, int y)
x
- The x coordinate to ping at, in pixels, from the map's origin (left).y
- The y coordinate to ping at, in pixels, from the map's origin (top).public void pingMinimap(Position p)
public final boolean isFlagEnabled(Flag flag)
Flags may only be enabled at the start of the match during the BWEventListener.onStart()
callback.
public void enableFlag(Flag flag)
Flags may only be enabled at the start of the match during the BWEventListener.onStart()
callback.
public List<Unit> getUnitsOnTile(TilePosition tile)
public List<Unit> getUnitsOnTile(int tileX, int tileY, UnitFilter pred)
tileX
- The X position, in tiles.tileY
- The Y position, in tiles.pred
- A function predicate that indicates which units are included in the returned set.public List<Unit> getUnitsInRectangle(int left, int top, int right, int bottom, UnitFilter pred)
left
- The X coordinate of the left position of the bounding box, in pixels.top
- The Y coordinate of the top position of the bounding box, in pixels.right
- The X coordinate of the right position of the bounding box, in pixels.bottom
- The Y coordinate of the bottom position of the bounding box, in pixels.pred
- A function predicate that indicates which units are included in the returned set.public List<Unit> getUnitsInRectangle(Position leftTop, Position rightBottom, UnitFilter pred)
public List<Unit> getUnitsInRadius(int x, int y, int radius, UnitFilter pred)
x
- The x coordinate of the center, in pixels.y
- The y coordinate of the center, in pixels.radius
- The radius from the center, in pixels, to include units.pred
- A function predicate that indicates which units are included in the returned set.public List<Unit> getUnitsInRadius(Position center, int radius, UnitFilter pred)
public Unit getClosestUnitInRectangle(Position center, int left, int top, int right, int bottom)
public Unit getClosestUnitInRectangle(Position center, int left, int top, int right, int bottom, UnitFilter pred)
center
- The position to start searching for the closest unit.pred
- The UnitFilter
predicate to determine which units should be included. This includes all units by default.left
- The left position of the rectangle. This value is 0 by default.top
- The top position of the rectangle. This value is 0 by default.right
- The right position of the rectangle. This value includes the entire map width by default.bottom
- The bottom position of the rectangle. This value includes the entire map height by default.UnitFilter
public Unit getClosestUnit(Position center, UnitFilter pred)
public Unit getClosestUnit(Position center, int radius, UnitFilter pred)
center
- The position to start searching for the closest unit.pred
- The UnitFilter predicate to determine which units should be included. This includes all units by default.radius
- The radius to search in. If omitted, the entire map will be searched.UnitFilter
public int mapWidth()
public int mapHeight()
public String mapFileName()
mapPathName
,
mapName
public String mapPathName()
mapFileName
,
mapName
public String mapName()
mapFileName
,
mapPathName
public String mapHash()
Campaign maps will return a hash of their internal map chunk components(.chk), while standard maps will return a hash of their entire map archive (.scm,.scx).
public final boolean isWalkable(int walkX, int walkY)
This function only checks if the static terrain is walkable. Its current occupied
state is excluded from this check. To see if the space is currently occupied or not, then
see getUnitsInRectangle(int, int, int, int)
.
walkX
- The x coordinate of the mini-tile, in mini-tile units (8 pixels).walkY
- The y coordinate of the mini-tile, in mini-tile units (8 pixels).public final boolean isWalkable(WalkPosition position)
public final int getGroundHeight(int tileX, int tileY)
tileX
- X position to query, in tilestileY
- Y position to query, in tilespublic final int getGroundHeight(TilePosition position)
public final boolean isBuildable(int tileX, int tileY)
public final boolean isBuildable(int tileX, int tileY, boolean includeBuildings)
tileX
- The x value of the tile to check.tileY
- The y value of the tile to check.includeBuildings
- If this is true, then this function will also check if any visible structures are occupying the space. If this value is false, then it only checks the static map data for tile buildability. This value is false by default.public final boolean isBuildable(TilePosition position)
public final boolean isBuildable(TilePosition position, boolean includeBuildings)
public final boolean isVisible(int tileX, int tileY)
tileX
- The x value of the tile to check.tileY
- The y value of the tile to check.public final boolean isVisible(TilePosition position)
public final boolean isExplored(int tileX, int tileY)
tileX
- The x tile coordinate to check.tileY
- The y tile coordinate to check.isVisible(int, int)
public final boolean isExplored(TilePosition position)
public final boolean hasCreep(int tileX, int tileY)
tileX
- The x tile coordinate to check.tileY
- The y tile coordinate to check.public final boolean hasCreep(TilePosition position)
public final boolean hasPowerPrecise(int x, int y)
public final boolean hasPowerPrecise(int x, int y, UnitType unitType)
x
- The x pixel coordinate to check.y
- The y pixel coordinate to check.unitType
- Checks if the given UnitType
requires power or not. If ommitted, then it will assume that the position requires power for any unit type.public final boolean hasPowerPrecise(Position position)
public final boolean hasPower(TilePosition position)
public final boolean hasPower(int tileX, int tileY)
public final boolean hasPower(TilePosition position, UnitType unitType)
public final boolean hasPower(int tileX, int tileY, UnitType unitType)
public final boolean hasPower(int tileX, int tileY, int tileWidth, int tileHeight)
public final boolean hasPower(int tileX, int tileY, int tileWidth, int tileHeight, UnitType unitType)
tileX
- The x tile coordinate to check.tileY
- The y tile coordinate to check.unitType
- Checks if the given UnitType will be powered if placed at the given tile position. If omitted, then only the immediate tile position is checked for power, and the function will assume that the location requires power for any unit type.public final boolean hasPower(TilePosition position, int tileWidth, int tileHeight)
public final boolean hasPower(TilePosition position, int tileWidth, int tileHeight, UnitType unitType)
public final boolean canBuildHere(TilePosition position, UnitType type, Unit builder)
public final boolean canBuildHere(TilePosition position, UnitType type)
public final boolean canBuildHere(TilePosition position, UnitType type, Unit builder, boolean checkExplored)
If the type is an addon and a builer is provided, then the location of the addon will be placed 4 tiles to the right and 1 tile down from the given position. If the builder is not given, then the check for the addon will be conducted at position.
If type is UnitType.Special_Start_Location, then the area for a resource depot (@Command_Center, @Hatchery, @Nexus) is checked as normal, but any potential obstructions (existing structures, creep, units, etc.) are ignored.
position
- Indicates the tile position that the top left corner of the structure is intended to go.type
- The UnitType to check for.builder
- The intended unit that will build the structure. If specified, then this function will also check if there is a path to the build site and exclude the builder from the set of units that may be blocking the build site.checkExplored
- If this parameter is true, it will also check if the target position has been explored by the current player. This value is false by default, ignoring the explored state of the build site.public final boolean canMake(UnitType type)
public final boolean canMake(UnitType type, Unit builder)
type
- The UnitType
to check.builder
- The Unit that will be used to build/train the provided unit type. If this value is null or excluded, then the builder will be excluded in the check.public final boolean canResearch(TechType type)
public final boolean canResearch(TechType type, Unit unit, boolean checkCanIssueCommandType)
type
- The TechType
to check.unit
- The Unit
that will be used to research the provided technology type. If this value is null or excluded, then the unit will be excluded in the check.checkCanIssueCommandType
- TODO fill this inpublic final boolean canUpgrade(UpgradeType type, Unit unit)
public final boolean canUpgrade(UpgradeType type)
public final boolean canUpgrade(UpgradeType type, Unit unit, boolean checkCanIssueCommandType)
type
- The UpgradeType
to check.unit
- The Unit
that will be used to upgrade the provided upgrade type. If this value is null or excluded, then the unit will be excluded in the check.checkCanIssueCommandType
- TODO fill this inpublic List<TilePosition> getStartLocations()
TilePosition
objects that indicate a start
location.Player.getStartLocation()
public void printf(String string, Text... colors)
Text.formatText(java.lang.String, bwapi.Text)
.
That text printed through this function is not seen by other players or in replays.
string
- String to print.public void sendText(String string, Text... colors)
In a single player game this function can be used to execute cheat codes.
string
- String to send.sendTextEx(boolean, java.lang.String, bwapi.Text...)
public void sendTextEx(boolean toAllies, String string, Text... colors)
sendText(java.lang.String, bwapi.Text...)
which allows messages to be forwarded to
allies.toAllies
- If this parameter is set to true, then the message is only sent to allied players, otherwise it will be sent to all players.string
- String to send.sendText(java.lang.String, bwapi.Text...)
public final boolean isInGame()
public final boolean isMultiplayer()
public final boolean isBattleNet()
public final boolean isPaused()
BWEventListener.onFrame()
will still be called.pauseGame()
,
resumeGame()
public final boolean isReplay()
public void pauseGame()
BWEventListener.onFrame()
will still be called.resumeGame()
public void resumeGame()
pauseGame()
public void leaveGame()
public void restartGame()
public void setLocalSpeed(int speed)
Specifying a value of 0 will not guarantee that logical frames are executed as fast as possible. If that is the intention, use this in combination with #setFrameSkip.
Changing this value will cause the execution of @UMS scenario triggers to glitch. This will only happen in campaign maps and custom scenarios (non-melee).
speed
- The time spent per frame, in milliseconds. A value of 0 indicates that frames are executed immediately with no delay. Negative values will restore the default value as listed above.setFrameSkip(int)
,
getFPS()
public final boolean issueCommand(Collection<Unit> units, UnitCommand command)
units
- A Listcommand
- A UnitCommand
object containing relevant information about the command to be issued. The Unit
object associated with the command will be ignored.public List<Unit> getSelectedUnits()
Flag.UserInput
be enabled.Flag.UserInput
is disabled,
then this set is always empty.enableFlag(bwapi.Flag)
public Player self()
public Player enemy()
Player
interface that represents the enemy player. If
there is more than one enemy, and that enemy is destroyed, then this function will still
retrieve the same, defeated enemy. If you wish to handle multiple opponents, see the
enemies
function.enemies
public Player neutral()
Player
object representing the neutral player.
The neutral player owns all the resources and critters on the map by default.Player
indicating the neutral player.public List<Player> allies()
public List<Player> enemies()
public List<Player> observers()
public void drawText(CoordinateType ctype, int x, int y, String string, Text... colors)
public void drawBox(CoordinateType ctype, int left, int top, int right, int bottom, Color color)
public void drawBox(CoordinateType ctype, int left, int top, int right, int bottom, Color color, boolean isSolid)
ctype
- The coordinate type. Indicates the relative position to draw the shape.left
- The x coordinate, in pixels, relative to ctype, of the left edge of the rectangle.top
- The y coordinate, in pixels, relative to ctype, of the top edge of the rectangle.right
- The x coordinate, in pixels, relative to ctype, of the right edge of the rectangle.bottom
- The y coordinate, in pixels, relative to ctype, of the bottom edge of the rectangle.color
- The color of the rectangle.isSolid
- If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn as an outline. If omitted, this value will default to false.public void drawBoxMap(int left, int top, int right, int bottom, Color color)
public void drawBoxMap(int left, int top, int right, int bottom, Color color, boolean isSolid)
public void drawBoxMap(Position leftTop, Position rightBottom, Color color, boolean isSolid)
public void drawBoxMouse(int left, int top, int right, int bottom, Color color)
public void drawBoxMouse(int left, int top, int right, int bottom, Color color, boolean isSolid)
public void drawBoxMouse(Position leftTop, Position rightBottom, Color color, boolean isSolid)
public void drawBoxScreen(int left, int top, int right, int bottom, Color color)
public void drawBoxScreen(int left, int top, int right, int bottom, Color color, boolean isSolid)
public void drawBoxScreen(Position leftTop, Position rightBottom, Color color, boolean isSolid)
public void drawTriangle(CoordinateType ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color)
public void drawTriangle(CoordinateType ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color, boolean isSolid)
ctype
- The coordinate type. Indicates the relative position to draw the shape.ax
- The x coordinate, in pixels, relative to ctype, of the first point.ay
- The y coordinate, in pixels, relative to ctype, of the first point.bx
- The x coordinate, in pixels, relative to ctype, of the second point.by
- The y coordinate, in pixels, relative to ctype, of the second point.cx
- The x coordinate, in pixels, relative to ctype, of the third point.cy
- The y coordinate, in pixels, relative to ctype, of the third point.color
- The color of the triangle.isSolid
- If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn as an outline. If omitted, this value will default to false.public void drawTriangleMap(int ax, int ay, int bx, int by, int cx, int cy, Color color)
public void drawTriangleMap(int ax, int ay, int bx, int by, int cx, int cy, Color color, boolean isSolid)
public void drawTriangleMap(Position a, Position b, Position c, Color color, boolean isSolid)
public void drawTriangleMouse(int ax, int ay, int bx, int by, int cx, int cy, Color color)
public void drawTriangleMouse(int ax, int ay, int bx, int by, int cx, int cy, Color color, boolean isSolid)
public void drawTriangleMouse(Position a, Position b, Position c, Color color, boolean isSolid)
public void drawTriangleScreen(int ax, int ay, int bx, int by, int cx, int cy, Color color)
public void drawTriangleScreen(int ax, int ay, int bx, int by, int cx, int cy, Color color, boolean isSolid)
public void drawTriangleScreen(Position a, Position b, Position c, Color color, boolean isSolid)
public void drawCircle(CoordinateType ctype, int x, int y, int radius, Color color)
public void drawCircle(CoordinateType ctype, int x, int y, int radius, Color color, boolean isSolid)
ctype
- The coordinate type. Indicates the relative position to draw the shape.x
- The x coordinate, in pixels, relative to ctype.y
- The y coordinate, in pixels, relative to ctype.radius
- The radius of the circle, in pixels.color
- The color of the circle.isSolid
- If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn as an outline. If omitted, this value will default to false.public void drawCircleMap(int x, int y, int radius, Color color)
public void drawCircleMap(int x, int y, int radius, Color color, boolean isSolid)
public void drawCircleMouse(int x, int y, int radius, Color color)
public void drawCircleMouse(int x, int y, int radius, Color color, boolean isSolid)
public void drawCircleScreen(int x, int y, int radius, Color color)
public void drawCircleScreen(int x, int y, int radius, Color color, boolean isSolid)
public void drawEllipse(CoordinateType ctype, int x, int y, int xrad, int yrad, Color color)
public void drawEllipse(CoordinateType ctype, int x, int y, int xrad, int yrad, Color color, boolean isSolid)
ctype
- The coordinate type. Indicates the relative position to draw the shape.x
- The x coordinate, in pixels, relative to ctype.y
- The y coordinate, in pixels, relative to ctype.xrad
- The x radius of the ellipse, in pixels.yrad
- The y radius of the ellipse, in pixels.color
- The color of the ellipse.isSolid
- If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn as an outline. If omitted, this value will default to false.public void drawEllipseMap(int x, int y, int xrad, int yrad, Color color)
public void drawEllipseMap(int x, int y, int xrad, int yrad, Color color, boolean isSolid)
public void drawEllipseMap(Position p, int xrad, int yrad, Color color, boolean isSolid)
public void drawEllipseMouse(int x, int y, int xrad, int yrad, Color color)
public void drawEllipseMouse(int x, int y, int xrad, int yrad, Color color, boolean isSolid)
public void drawEllipseMouse(Position p, int xrad, int yrad, Color color, boolean isSolid)
public void drawEllipseScreen(int x, int y, int xrad, int yrad, Color color)
public void drawEllipseScreen(int x, int y, int xrad, int yrad, Color color, boolean isSolid)
public void drawEllipseScreen(Position p, int xrad, int yrad, Color color, boolean isSolid)
public void drawDot(CoordinateType ctype, int x, int y, Color color)
ctype
- The coordinate type. Indicates the relative position to draw the shape.x
- The x coordinate, in pixels, relative to ctype.y
- The y coordinate, in pixels, relative to ctype.color
- The color of the dot.public void drawDotMap(int x, int y, Color color)
public void drawDotMouse(int x, int y, Color color)
public void drawDotScreen(int x, int y, Color color)
public void drawLine(CoordinateType ctype, int x1, int y1, int x2, int y2, Color color)
ctype
- The coordinate type. Indicates the relative position to draw the shape.x1
- The starting x coordinate, in pixels, relative to ctype.y1
- The starting y coordinate, in pixels, relative to ctype.x2
- The ending x coordinate, in pixels, relative to ctype.y2
- The ending y coordinate, in pixels, relative to ctype.color
- The color of the line.public void drawLineMap(int x1, int y1, int x2, int y2, Color color)
public void drawLineMouse(int x1, int y1, int x2, int y2, Color color)
public void drawLineScreen(int x1, int y1, int x2, int y2, Color color)
public int getLatencyFrames()
In Broodwar, latency is used to keep the game synchronized between players without introducing lag.
getLatencyTime()
,
getRemainingLatencyFrames()
public int getLatencyTime()
getLatencyFrames()
,
getRemainingLatencyTime()
public int getRemainingLatencyFrames()
getRemainingLatencyTime()
,
getLatencyFrames()
public int getRemainingLatencyTime()
getRemainingLatencyFrames()
,
getLatencyTime()
public int getRevision()
public final boolean isDebug()
public final boolean isLatComEnabled()
setLatCom(boolean)
public void setLatCom(boolean isEnabled)
isEnabled
- Set whether the latency compensation feature will be enabled (true) or disabled (false).isLatComEnabled()
public int getInstanceNumber()
public int getAPM()
public int getAPM(boolean includeSelects)
includeSelects
- If true, the return value will include selections as individual commands, otherwise it will exclude selections. This value is false by default.public void setFrameSkip(int frameSkip)
frameSkip
- Number of graphical frames per logical frame. If this value is 0 or less, then it will default to 1.setLocalSpeed(int)
public final boolean setAlliance(Player player, boolean allied, boolean alliedVictory)
player
- The target player to set alliance with.allied
- If true, the current player will ally the target player. If false, the current player
will make the target player an enemy. This value is true by default.alliedVictory
- Sets the state of "allied victory". If true, the game will end in a victory if all
allied players have eliminated their opponents. Otherwise, the game will only end if
no other players are remaining in the game. This value is true by default.public final boolean setAlliance(Player player, boolean allied)
public final boolean setAlliance(Player player)
public final boolean setVision(Player player, boolean enabled)
In a replay, this function toggles the visibility of the target player.
player
- The target player to toggle vision.enabled
- The vision state. If true, and in a game, the current player will enable shared vision
with the target player, otherwise it will unshare vision. If in a replay, the vision
of the target player will be shown, otherwise the target player will be hidden. This
value is true by default.public void setGUI(boolean enabled)
This typically gives Starcraft a very low graphical frame rate and disables all drawing functionality in BWAPI.
enabled
- A boolean value that determines the state of the GUI. Passing false to this function
will disable the GUI, and true will enable it.isGUIEnabled()
public int getLastEventTime()
This is used by tournament modules to penalize AI modules that use too much processing time.
public final boolean setMap(String mapFileName)
Once restarted, the game will load the map that was provided. Changes do not take effect unless the game is restarted.
mapFileName
- A string containing the path and file name to the desired map.public final boolean setRevealAll(boolean reveal)
reveal
- The state of the reveal all flag. If false, all fog of war will be enabled. If true,
then the fog of war will be revealed. It is true by default.public final boolean setRevealAll()
public final boolean hasPath(Position source, Position destination)
If making queries on a unit, it's better to call Unit.hasPath(bwapi.Position)
, since it is
a more lenient version of this function that accounts for some edge cases.
source
- The source position.destination
- The destination position.Unit.hasPath(bwapi.Position)
public void setTextSize()
public void setTextSize(Text.Size size)
drawText(bwapi.CoordinateType, int, int, java.lang.String, bwapi.Text...)
following this one.size
- The size of the text. This value is one of Text#Size. If this value is omitted, then a default value of Text.Size.Default
is used.Text.Size
public int elapsedTime()
public void setCommandOptimizationLevel(int level)
level
- An integer representation of the aggressiveness for which commands are optimized. A lower level means less optimization, and a higher level means more optimization.
The values for level are as follows: - 0: No optimization. - 1: Some optimization. - Is not detected as a hack. - Does not alter behaviour. - Units performing the following actions are grouped and ordered 12 at a time: - Attack_Unit - Morph (@Larva only) - Hold_Position - Stop - Follow - Gather - Return_Cargo - Repair - Burrow - Unburrow - Cloak - Decloak - Siege - Unsiege - Right_Click_Unit - Halt_Construction - Cancel_Train (@Carrier and @Reaver only) - Cancel_Train_Slot (@Carrier and @Reaver only) - Cancel_Morph (for non-buildings only) - Use_Tech - Use_Tech_Unit . - The following order transformations are applied to allow better grouping: - Attack_Unit becomes Right_Click_Unit if the target is an enemy - Move becomes Right_Click_Position - Gather becomes Right_Click_Unit if the target contains resources - Set_Rally_Position becomes Right_Click_Position for buildings - Set_Rally_Unit becomes Right_Click_Unit for buildings - Use_Tech_Unit with Infestation becomes Right_Click_Unit if the target is valid . . - 2: More optimization by grouping structures. - Includes the optimizations made by all previous levels. - May be detected as a hack by some replay utilities. - Does not alter behaviour. - Units performing the following actions are grouped and ordered 12 at a time: - Attack_Unit (@Turrets, @Photon_Cannons, @Sunkens, @Spores) - Train - Morph - Set_Rally_Unit - Lift - Cancel_Construction - Cancel_Addon - Cancel_Train - Cancel_Train_Slot - Cancel_Morph - Cancel_Research - Cancel_Upgrade . . - 3: Extensive optimization - Includes the optimizations made by all previous levels. - Units may behave or move differently than expected. - Units performing the following actions are grouped and ordered 12 at a time: - Attack_Move - Set_Rally_Position - Move - Patrol - Unload_All - Unload_All_Position - Right_Click_Position - Use_Tech_Position . . - 4: Aggressive optimization - Includes the optimizations made by all previous levels. - Positions used in commands will be rounded to multiples of 32. - @High_Templar and @Dark_Templar that merge into @Archons will be grouped and may choose a different target to merge with. It will not merge with a target that wasn't included. . .
public int countdownTimer()
public List<Region> getAllRegions()
public Region getRegionAt(int x, int y)
x
- The x coordinate, in pixels.y
- The y coordinate, in pixels.getAllRegions()
,
getRegion(int)
public TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition, int maxRange)
public TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition)
public TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition, int maxRange, boolean creep)
type
- A valid UnitType representing the unit type to accomodate space for.desiredPosition
- A valid TilePosition containing the desired placement position.maxRange
- The maximum distance (in tiles) to build from desiredPosition.creep
- A special boolean value that changes the behaviour of @Creep_Colony placement.TilePosition.Invalid
If a build location could not be found within maxRange.public int getDamageFrom(UnitType fromType, UnitType toType, Player fromPlayer, Player toPlayer)
fromType
- The unit type that will be dealing the damage.toType
- The unit type that will be receiving the damage.fromPlayer
- The player owner of the given type that will be dealing the damage. If omitted, then no player will be used to calculate the upgrades for fromType.toPlayer
- The player owner of the type that will be receiving the damage. If omitted, then this parameter will default to self
.getDamageTo(bwapi.UnitType, bwapi.UnitType, bwapi.Player)
public int getDamageTo(UnitType toType, UnitType fromType, Player toPlayer, Player fromPlayer)
This function is nearly the same as getDamageFrom(bwapi.UnitType, bwapi.UnitType, bwapi.Player)
. The only difference is that
the last parameter is intended to default to self
.
toType
- The unit type that will be receiving the damage.fromType
- The unit type that will be dealing the damage.toPlayer
- The player owner of the type that will be receiving the damage. If omitted, then no player will be used to calculate the upgrades for toType.fromPlayer
- The player owner of the given type that will be dealing the damage. If omitted, then this parameter will default to self
).getDamageFrom(bwapi.UnitType, bwapi.UnitType, bwapi.Player)
public int getRandomSeed()
Copyright © 2022. All rights reserved.