BWAPI4 experimental support & BWMIrror 1.1 generator
This commit is contained in:
parent
a61eb5d8f3
commit
05901f5562
|
@ -7,128 +7,60 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
The Bullet class is used to get information about individual bullets, missiles, spells, and generally any sort of non-melee attack. Unlike Units, Bullet objects are reused after they are destroyed, however the ID of the bullet is updated when it represents a new bullet.
|
||||
If <a href="Misc.html">Flag::CompleteMapInformation</a> is disabled, then a bullet is accessible if and only if it is visible. If a bullet is not visible, <a href="Bullet.html">Bullet::exists</a> will return false, regardless of whether or not the bullet exists. This is because absolutely no state information on invisible enemy bullets is made available to the AI.
|
||||
If <a href="Misc.html">Flag::CompleteMapInformation</a> is enabled, then all bullets that exist in the game are accessible, and <a href="Bullet.html">Bullet::exists</a> is accurate for all bullets.
|
||||
No message similar to <a href="AIModule.html">AIModule::onUnitDestroy</a> exists for bullets. To determine if a bullet has been destroyed, check to see if exists() is false or getID() has changed to a new value.
|
||||
|
||||
|
||||
*/
|
||||
public class Bullet {
|
||||
|
||||
/**
|
||||
Returns a unique ID for this bullet.
|
||||
|
||||
*/
|
||||
public int getID() {
|
||||
return getID_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the player of the source unit, or NULL if the source unit has been destroyed or is otherwise inaccessible.
|
||||
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return getPlayer_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the type of the bullet.
|
||||
|
||||
*/
|
||||
public BulletType getType() {
|
||||
return getType_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the unit that fired the bullet. If the unit is inaccessible (such as a cloaked or burrowed enemy unit with no detection around and complete map information disabled), this will return NULL.
|
||||
|
||||
*/
|
||||
public Unit getSource() {
|
||||
return getSource_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the position of the bullet, or an invalid position if the bullet is inaccessible.
|
||||
|
||||
*/
|
||||
public Position getPosition() {
|
||||
return getPosition_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the direction the bullet is facing/traveling in, measured in radians. An angle of 0 means the bullet is facing east/right. If the bullet is inaccessible this will return 0.
|
||||
|
||||
*/
|
||||
public double getAngle() {
|
||||
return getAngle_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the x component of the bullet's velocity, measured in pixels per frame. If the bullet is inaccessible this will return 0.
|
||||
|
||||
*/
|
||||
public double getVelocityX() {
|
||||
return getVelocityX_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the y component of the bullet's velocity, measured in pixels per frame. If the bullet is inaccessible this will return 0.
|
||||
|
||||
*/
|
||||
public double getVelocityY() {
|
||||
return getVelocityY_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the unit that the bullet is trying to hit. If the unit is inaccessible (such as a cloaked or burrowed enemy unit with no detection around and complete map information disabled), this will return NULL. If the bullet is inaccessible this will return NULL.
|
||||
|
||||
*/
|
||||
public Unit getTarget() {
|
||||
return getTarget_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the target position of the bullet. If the bullet is inaccessible this will return an invalid position.
|
||||
|
||||
*/
|
||||
public Position getTargetPosition() {
|
||||
return getTargetPosition_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the maximum number of frames until this bullet is removed. Generally bullets hit their targets before this timer reaches 0. If the bullet is inaccessible this will return 0.
|
||||
|
||||
*/
|
||||
public int getRemoveTimer() {
|
||||
return getRemoveTimer_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns true if the bullet is accessible. If <a href="Misc.html">Flag::CompleteMapInformation</a> is enabled, all bullets that actually exist in the game will be accessible. If it is disabled, then only visible bullets will be accessible.
|
||||
|
||||
*/
|
||||
public boolean exists() {
|
||||
return exists_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
bool isVisible(<a href="Player.html">Player</a><tt>*</tt> player) const;
|
||||
Returns true if the bullet is visible.
|
||||
If <a href="Misc.html">Flag::CompleteMapInformation</a> is enabled, you can also specify to which player you want to check visibility for, otherwise <a href="Game.html">Game::self</a> is used.
|
||||
|
||||
*/
|
||||
public boolean isVisible() {
|
||||
return isVisible_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
bool isVisible(<a href="Player.html">Player</a><tt>*</tt> player) const;
|
||||
Returns true if the bullet is visible.
|
||||
If <a href="Misc.html">Flag::CompleteMapInformation</a> is enabled, you can also specify to which player you want to check visibility for, otherwise <a href="Game.html">Game::self</a> is used.
|
||||
|
||||
*/
|
||||
public boolean isVisible(Player player) {
|
||||
return isVisible_native(pointer, player);
|
||||
}
|
||||
|
@ -141,6 +73,9 @@ If <a href="Misc.html">Flag::CompleteMapInformation</a> is enabled, you can also
|
|||
}
|
||||
|
||||
private static Bullet get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Bullet instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new Bullet(pointer);
|
||||
|
|
|
@ -7,14 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
Each <a href="Bullet.html">Bullet</a> object in the game has a certain type. The list of all the possible Bullet types is available here: <a href="BulletType.html">BulletTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class BulletType {
|
||||
|
||||
/** Returns the name of this bullet type. */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -105,6 +99,9 @@ public class BulletType {
|
|||
}
|
||||
|
||||
private static BulletType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
BulletType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new BulletType(pointer);
|
||||
|
|
|
@ -7,43 +7,20 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
The Client class manages the connection between a BWAPI client program and the BWAPI server running in BWAPI.dll. For examples of how to use this class please see the Example AI Client and the AI Module Loader that are included in the latest release of BWAPI.
|
||||
The BWAPIClient.lib library contains the implementation of the Client class along with classes which implement the <a href="Game.html">Game</a>, <a href="Force.html">Force</a>, <a href="Player.html">Player</a>, <a href="Unit.html">Unit</a>, and <a href="Bullet.html">Bullet</a> interfaces.
|
||||
Stand-alone programs made with BWAPIClient should keep all interaction with dynamic BWAPI classes (Game, Force, Player, Unit, Bullet) in a single thread that runs synchronously with Starcraft: Broodwar via calls to <a href="update.html">update()</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class Client {
|
||||
|
||||
/**
|
||||
Returns true if the client is currently connected to the server.
|
||||
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return isConnected_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Attempts to connect the client to the server. If it succeeds, it returns true. If Starcraft/BWAPI is not yet running, this will fail and return false.
|
||||
|
||||
*/
|
||||
public boolean connect() {
|
||||
return connect_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Disconnects the client from the server.
|
||||
|
||||
*/
|
||||
public void disconnect() {
|
||||
disconnect_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
This is a blocking command that tells the server to process commands sent from the client and proceed to the next frame in the game. Thus update() will only return once the next game frame (or if in menus, next menu frame) has been received. Once the server proceeds to the next frame, the client will update some local information and then return so the AI can execute its code for the current frame. Rather than sending callbacks to the client for things like <a href="AIModule.html">AIModule::onUnitCreate</a>, BWAPI generates a list of event objects, which can be accessed via <a href="Game.html">Game::getEvents</a>. These events correspond to AIModule callbacks.
|
||||
|
||||
*/
|
||||
public void update() {
|
||||
update_native(pointer);
|
||||
}
|
||||
|
@ -56,6 +33,9 @@ This is a blocking command that tells the server to process commands sent from t
|
|||
}
|
||||
|
||||
private static Client get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Client instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new Client(pointer);
|
||||
|
|
|
@ -7,9 +7,6 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**<br/><br/>
|
||||
* Used in UnitCommand
|
||||
*/
|
||||
public enum Enum {
|
||||
|
||||
None(0),
|
||||
|
|
|
@ -7,15 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
Each type of Unit in Starcraft: Broodwar has a particular <a href="WeaponType.html">WeaponType</a> for its ground weapon and air weapon (either of which could be <a href="WeaponType.html">WeaponTypes</a>::None). Each type of Weapon has a particular damage type, which could be explosive, concussive, or something else. Here is the list of all the possible <a href="DamageType.html">DamageTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class DamageType {
|
||||
|
||||
/** Returns the name of this damage type. For example DamageTypes::Explosive.getName() will return
|
||||
* std::string("Explosive"). */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -46,6 +39,9 @@ public class DamageType {
|
|||
}
|
||||
|
||||
private static DamageType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
DamageType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new DamageType(pointer);
|
||||
|
|
|
@ -7,49 +7,24 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
Events correspond to <a href="AIModule.html">AIModule</a> callbacks and can be obtained by calling <a href="Game.html">Game::getEvents</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class Event {
|
||||
|
||||
/**
|
||||
Returns the Position. Used in EventType::NukeDetect.
|
||||
|
||||
*/
|
||||
public Position getPosition() {
|
||||
return getPosition_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the text. Used in EventType::SendText, EventType::ReceiveText, EventType::SaveGame.
|
||||
|
||||
*/
|
||||
public String getText() {
|
||||
return getText_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the unit. Used in EventType::UnitDiscover, EventType::UnitEvade, EventType::UnitCreate, EventType::UnitDestroy, EventType::UnitShow, EventType::UnitHide, EventType::UnitMorph, EventType::UnitRenegade, and EventType::UnitComplete.
|
||||
|
||||
*/
|
||||
public Unit getUnit() {
|
||||
return getUnit_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the player. Used in EventType::ReceiveText and EventType::PlayerLeft.
|
||||
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return getPlayer_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns true if the BWAPI-controlled player is the winner. Used in EventType::MatchEnd.
|
||||
|
||||
*/
|
||||
public boolean isWinner() {
|
||||
return isWinner_native(pointer);
|
||||
}
|
||||
|
@ -62,6 +37,9 @@ Returns true if the BWAPI-controlled player is the winner. Used in EventType::Ma
|
|||
}
|
||||
|
||||
private static Event get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Event instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new Event(pointer);
|
||||
|
|
|
@ -7,14 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
Each type of Unit in Starcraft: Broodwar has a particular <a href="WeaponType.html">WeaponType</a> for its ground weapon and air weapon (either of which could be <a href="WeaponType.html">WeaponTypes</a>::None). Each type of Weapon has a particular explosion type. Here is the list of all the possible <a href="ExplosionType.html">ExplosionTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class ExplosionType {
|
||||
|
||||
/** Returns the name of this explosion type. */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -81,6 +75,9 @@ public class ExplosionType {
|
|||
}
|
||||
|
||||
private static ExplosionType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
ExplosionType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new ExplosionType(pointer);
|
||||
|
|
|
@ -7,21 +7,16 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/** The Force class is used to get information about each force in the match, such as the name of the force
|
||||
* and the set of players in the force. */
|
||||
public class Force {
|
||||
|
||||
/** Returns a unique ID for the force. */
|
||||
public int getID() {
|
||||
return getID_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the name of the force. */
|
||||
public String getName() {
|
||||
return getName_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of players in the force. */
|
||||
public List<Player> getPlayers() {
|
||||
return getPlayers_native(pointer);
|
||||
}
|
||||
|
@ -34,6 +29,9 @@ public class Force {
|
|||
}
|
||||
|
||||
private static Force get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Force instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new Force(pointer);
|
||||
|
|
183
bwapi/Game.java
183
bwapi/Game.java
|
@ -7,116 +7,84 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/** The abstract Game class is implemented by BWAPI and offers many methods for retrieving information
|
||||
* about the current Broodwar game, including the set of players, units, map information, as well as
|
||||
* information about the user, such as mouse position, screen position, and the current selection of
|
||||
* units. */
|
||||
public class Game {
|
||||
|
||||
/** Returns the set of all forces in the match. */
|
||||
public List<Force> getForces() {
|
||||
return getForces_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of all players in the match. Note that this includes the Neutral player, which owns
|
||||
* all the neutral units such as minerals, critters, etc. */
|
||||
public List<Player> getPlayers() {
|
||||
return getPlayers_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns all the visible units. If Flag::CompleteMapInformation is enabled, the set of all units
|
||||
* is returned, not just visible ones. Note that units inside refineries are not included in this set
|
||||
* yet. */
|
||||
public List<Unit> getAllUnits() {
|
||||
return getAllUnits_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of all accessible mineral patches. */
|
||||
public List<Unit> getMinerals() {
|
||||
return getMinerals_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of all accessible vespene geysers. */
|
||||
public List<Unit> getGeysers() {
|
||||
return getGeysers_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of all accessible neutral units. */
|
||||
public List<Unit> getNeutralUnits() {
|
||||
return getNeutralUnits_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of all mineral patches (including mined out and other inaccessible ones). */
|
||||
public List<Unit> getStaticMinerals() {
|
||||
return getStaticMinerals_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of all vespene geysers (including mined out and other inaccessible ones). */
|
||||
public List<Unit> getStaticGeysers() {
|
||||
return getStaticGeysers_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of all neutral units (including mined out and other inaccessible ones). */
|
||||
public List<Unit> getStaticNeutralUnits() {
|
||||
return getStaticNeutralUnits_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns all visible bullets. If Flag::CompleteMapInformation is enabled, the set of all bullets is
|
||||
* returned, not just visible ones. */
|
||||
public List<Bullet> getBullets() {
|
||||
return getBullets_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns all visible nuke dots. If Flag::CompleteMapInformation is enabled, the set of all nuke dots
|
||||
* is returned, not just visible ones. */
|
||||
public List<Position> getNukeDots() {
|
||||
return getNukeDots_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the list of events */
|
||||
public Force getForce(int forceID) {
|
||||
return getForce_native(pointer, forceID);
|
||||
}
|
||||
|
||||
/** Returns the player with the given ID, or NULL if no player has the given ID */
|
||||
public Player getPlayer(int playerID) {
|
||||
return getPlayer_native(pointer, playerID);
|
||||
}
|
||||
|
||||
/** Returns the unit with the given ID, or NULL if no unit has the given ID */
|
||||
public Unit getUnit(int unitID) {
|
||||
return getUnit_native(pointer, unitID);
|
||||
}
|
||||
|
||||
/** Returns a pointer to a Unit given an index. */
|
||||
public Unit indexToUnit(int unitIndex) {
|
||||
return indexToUnit_native(pointer, unitIndex);
|
||||
}
|
||||
|
||||
/** Returns the Region with the given ID, or NULL if no region has the given ID */
|
||||
public Region getRegion(int regionID) {
|
||||
return getRegion_native(pointer, regionID);
|
||||
}
|
||||
|
||||
/** Returns the game type */
|
||||
public GameType getGameType() {
|
||||
return getGameType_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of latency the current game has. Currently only returns Latency::SinglePlayer,
|
||||
* Latency::LanLow, Latency::LanMedium, or Latency::LanHigh. */
|
||||
public int getLatency() {
|
||||
return getLatency_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the number of logical frames since the match started. If the game is paused,
|
||||
* Game::getFrameCount will not increase however AIModule::onFrame will still be called while paused.
|
||||
* On Fastest, there are about 23.8 - 24 frames per second. */
|
||||
public int getFrameCount() {
|
||||
return getFrameCount_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the Frames Per Second (FPS) that the game is currently running at */
|
||||
public int getFPS() {
|
||||
return getFPS_native(pointer);
|
||||
}
|
||||
|
@ -125,88 +93,58 @@ public class Game {
|
|||
return getAverageFPS_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the position of the mouse on the screen. Returns Positions::Unknown if Flag::UserInput is
|
||||
* disabled. */
|
||||
public Position getMousePosition() {
|
||||
return getMousePosition_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the specified mouse button is pressed. Returns false if Flag::UserInput is
|
||||
* disabled. */
|
||||
public boolean getMouseState(MouseButton button) {
|
||||
return getMouseState_native(pointer, button);
|
||||
}
|
||||
|
||||
/** Returns true if the specified mouse button is pressed. Returns false if Flag::UserInput is
|
||||
* disabled. */
|
||||
public boolean getMouseState(int button) {
|
||||
return getMouseState_native(pointer, button);
|
||||
}
|
||||
|
||||
/** Returns true if the specified key is pressed. Returns false if Flag::UserInput is disabled.
|
||||
* Unfortunately this does not read the raw keyboard input yet - when you hold down a key, the
|
||||
* getKeyState function is true for a frame, then false for a few frames, and then alternates between
|
||||
* true and false (as if you were holding down the key in a text box). Hopefully this will be fixed in
|
||||
* a later version. */
|
||||
public boolean getKeyState(Key key) {
|
||||
return getKeyState_native(pointer, key);
|
||||
}
|
||||
|
||||
/** Returns true if the specified key is pressed. Returns false if Flag::UserInput is disabled.
|
||||
* Unfortunately this does not read the raw keyboard input yet - when you hold down a key, the
|
||||
* getKeyState function is true for a frame, then false for a few frames, and then alternates between
|
||||
* true and false (as if you were holding down the key in a text box). Hopefully this will be fixed in
|
||||
* a later version. */
|
||||
public boolean getKeyState(int key) {
|
||||
return getKeyState_native(pointer, key);
|
||||
}
|
||||
|
||||
/** Returns the position of the top left corner of the screen on the map. Returns Positions::Unknown if
|
||||
* Flag::UserInput is disabled. */
|
||||
public Position getScreenPosition() {
|
||||
return getScreenPosition_native(pointer);
|
||||
}
|
||||
|
||||
/** Moves the screen to the given position on the map. The position specified where the top left corner
|
||||
* of the screen will be. */
|
||||
public void setScreenPosition(int x, int y) {
|
||||
setScreenPosition_native(pointer, x, y);
|
||||
}
|
||||
|
||||
/** Moves the screen to the given position on the map. The position specified where the top left corner
|
||||
* of the screen will be. */
|
||||
public void setScreenPosition(Position p) {
|
||||
setScreenPosition_native(pointer, p);
|
||||
}
|
||||
|
||||
/** Pings the given position on the minimap. */
|
||||
public void pingMinimap(int x, int y) {
|
||||
pingMinimap_native(pointer, x, y);
|
||||
}
|
||||
|
||||
/** Pings the given position on the minimap. */
|
||||
public void pingMinimap(Position p) {
|
||||
pingMinimap_native(pointer, p);
|
||||
}
|
||||
|
||||
/** Returns true if the given flag has been enabled. Note that flags can only be enabled at the
|
||||
* beginning of a match, during the AIModule::onStart callback. */
|
||||
public boolean isFlagEnabled(int flag) {
|
||||
return isFlagEnabled_native(pointer, flag);
|
||||
}
|
||||
|
||||
/** Enables the specified flag. Note that flags can only be enabled at the beginning of a match, during
|
||||
* the AIModule::onStart callback. */
|
||||
public void enableFlag(int flag) {
|
||||
enableFlag_native(pointer, flag);
|
||||
}
|
||||
|
||||
/** Returns the set of accessible units that are on the given build tile. */
|
||||
public List<Unit> getUnitsOnTile(int tileX, int tileY) {
|
||||
return getUnitsOnTile_native(pointer, tileX, tileY);
|
||||
}
|
||||
|
||||
/** Returns the set of accessible units that are in or overlapping the given rectangle. */
|
||||
public List<Unit> getUnitsInRectangle(int left, int top, int right, int bottom) {
|
||||
return getUnitsInRectangle_native(pointer, left, top, right, bottom);
|
||||
}
|
||||
|
@ -215,65 +153,46 @@ public class Game {
|
|||
return getUnitsInRectangle_native(pointer, topLeft, bottomRight);
|
||||
}
|
||||
|
||||
/** Returns the set of accessible units within or overlapping a circle at the given point with the given radius. */
|
||||
public List<Unit> getUnitsInRadius(Position center, int radius) {
|
||||
return getUnitsInRadius_native(pointer, center, radius);
|
||||
}
|
||||
|
||||
/** Returns the last error that was set. If you try to order enemy units around, or morph bunkers into
|
||||
* lurkers, BWAPI will set error codes, which can be retrieved using this function. */
|
||||
public Error getLastError() {
|
||||
return getLastError_native(pointer);
|
||||
}
|
||||
|
||||
/** Sets the last error code. */
|
||||
public boolean setLastError(Error e) {
|
||||
return setLastError_native(pointer, e);
|
||||
}
|
||||
|
||||
/** Returns the width of the current map, in build tile units. To get the width of the current map in
|
||||
* walk tile units, multiply by 4. To get the width of the current map in Position units, multiply by
|
||||
* TILE_SIZE (which is 32). */
|
||||
public int mapWidth() {
|
||||
return mapWidth_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the height of the current map, in build tile units. To get the height of the current map in
|
||||
* walk tile units, multiply by 4. To get the height of the current map in Position units, multiply by
|
||||
* TILE_SIZE (which is 32). */
|
||||
public int mapHeight() {
|
||||
return mapHeight_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the file name of the current map. */
|
||||
public String mapFileName() {
|
||||
return mapFileName_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the full path name of the current map. */
|
||||
public String mapPathName() {
|
||||
return mapPathName_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the name/title of the current map. */
|
||||
public String mapName() {
|
||||
return mapName_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the SHA-1 hash of the map file. */
|
||||
public String mapHash() {
|
||||
return mapHash_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the specified walk tile is walkable. The values of x and y are in walk tile
|
||||
* coordinates (different from build tile coordinates). Note that this just uses the static map data.
|
||||
* You will also need to make sure no ground units are on the coresponding build tile to see if its
|
||||
* currently walkable. To do this, see unitsOnTile. */
|
||||
public boolean isWalkable(int walkX, int walkY) {
|
||||
return isWalkable_native(pointer, walkX, walkY);
|
||||
}
|
||||
|
||||
/** Returns the ground height of the given build tile. 0 = normal, 1 = high ground. 2 = very high ground. */
|
||||
public boolean isBuildable(int tileX, int tileY) {
|
||||
return isBuildable_native(pointer, tileX, tileY);
|
||||
}
|
||||
|
@ -282,7 +201,6 @@ public class Game {
|
|||
return isBuildable_native(pointer, tileX, tileY, includeBuildings);
|
||||
}
|
||||
|
||||
/** Returns the ground height of the given build tile. 0 = normal, 1 = high ground. 2 = very high ground. */
|
||||
public boolean isBuildable(TilePosition position) {
|
||||
return isBuildable_native(pointer, position);
|
||||
}
|
||||
|
@ -291,43 +209,30 @@ public class Game {
|
|||
return isBuildable_native(pointer, position, includeBuildings);
|
||||
}
|
||||
|
||||
/** Returns true if the specified build tile is visible. If the tile is concealed by fog of war, the
|
||||
* function will return false. */
|
||||
public boolean isVisible(int tileX, int tileY) {
|
||||
return isVisible_native(pointer, tileX, tileY);
|
||||
}
|
||||
|
||||
/** Returns true if the specified build tile is visible. If the tile is concealed by fog of war, the
|
||||
* function will return false. */
|
||||
public boolean isVisible(TilePosition position) {
|
||||
return isVisible_native(pointer, position);
|
||||
}
|
||||
|
||||
/** Returns true if the specified build tile has been explored (i.e. was visible at some point in the
|
||||
* match). */
|
||||
public boolean isExplored(int tileX, int tileY) {
|
||||
return isExplored_native(pointer, tileX, tileY);
|
||||
}
|
||||
|
||||
/** Returns true if the specified build tile has been explored (i.e. was visible at some point in the
|
||||
* match). */
|
||||
public boolean isExplored(TilePosition position) {
|
||||
return isExplored_native(pointer, position);
|
||||
}
|
||||
|
||||
/** Returns true if the specified build tile has zerg creep on it. If the tile is concealed by fog of
|
||||
* war, the function will return false. */
|
||||
public boolean hasCreep(int tileX, int tileY) {
|
||||
return hasCreep_native(pointer, tileX, tileY);
|
||||
}
|
||||
|
||||
/** Returns true if the specified build tile has zerg creep on it. If the tile is concealed by fog of
|
||||
* war, the function will return false. */
|
||||
public boolean hasCreep(TilePosition position) {
|
||||
return hasCreep_native(pointer, position);
|
||||
}
|
||||
|
||||
/** Returns true if the given build location is powered by a nearby friendly pylon. */
|
||||
public boolean hasPower(int tileX, int tileY) {
|
||||
return hasPower_native(pointer, tileX, tileY);
|
||||
}
|
||||
|
@ -336,7 +241,6 @@ public class Game {
|
|||
return hasPower_native(pointer, tileX, tileY, unitType);
|
||||
}
|
||||
|
||||
/** Returns true if the given build location is powered by a nearby friendly pylon. */
|
||||
public boolean hasPower(TilePosition position) {
|
||||
return hasPower_native(pointer, position);
|
||||
}
|
||||
|
@ -345,7 +249,6 @@ public class Game {
|
|||
return hasPower_native(pointer, position, unitType);
|
||||
}
|
||||
|
||||
/** Returns true if the given build location is powered by a nearby friendly pylon. */
|
||||
public boolean hasPower(int tileX, int tileY, int tileWidth, int tileHeight) {
|
||||
return hasPower_native(pointer, tileX, tileY, tileWidth, tileHeight);
|
||||
}
|
||||
|
@ -354,7 +257,6 @@ public class Game {
|
|||
return hasPower_native(pointer, tileX, tileY, tileWidth, tileHeight, unitType);
|
||||
}
|
||||
|
||||
/** Returns true if the given build location is powered by a nearby friendly pylon. */
|
||||
public boolean hasPower(TilePosition position, int tileWidth, int tileHeight) {
|
||||
return hasPower_native(pointer, position, tileWidth, tileHeight);
|
||||
}
|
||||
|
@ -363,7 +265,6 @@ public class Game {
|
|||
return hasPower_native(pointer, position, tileWidth, tileHeight, unitType);
|
||||
}
|
||||
|
||||
/** Returns true if the given pixel location is powered by a nearby friendly pylon. */
|
||||
public boolean hasPowerPrecise(int x, int y) {
|
||||
return hasPowerPrecise_native(pointer, x, y);
|
||||
}
|
||||
|
@ -372,7 +273,6 @@ public class Game {
|
|||
return hasPowerPrecise_native(pointer, x, y, unitType);
|
||||
}
|
||||
|
||||
/** Returns true if the given pixel location is powered by a nearby friendly pylon. */
|
||||
public boolean hasPowerPrecise(Position position) {
|
||||
return hasPowerPrecise_native(pointer, position);
|
||||
}
|
||||
|
@ -381,9 +281,6 @@ public class Game {
|
|||
return hasPowerPrecise_native(pointer, position, unitType);
|
||||
}
|
||||
|
||||
/** Returns true if the given unit type can be built at the given build tile position. Note the tile
|
||||
* position specifies the top left tile of the building. If builder is not null, the unit will be
|
||||
* discarded when determining whether or not any ground units are blocking the build location. */
|
||||
public boolean canBuildHere(Unit builder, TilePosition position, UnitType type) {
|
||||
return canBuildHere_native(pointer, builder, position, type);
|
||||
}
|
||||
|
@ -392,40 +289,26 @@ public class Game {
|
|||
return canBuildHere_native(pointer, builder, position, type, checkExplored);
|
||||
}
|
||||
|
||||
/** Returns true if the AI player has enough resources, supply, tech, and required units in order to
|
||||
* make the given unit type. If builder is not null, canMake will return true only if the builder unit
|
||||
* can build the given unit type. */
|
||||
public boolean canMake(Unit builder, UnitType type) {
|
||||
return canMake_native(pointer, builder, type);
|
||||
}
|
||||
|
||||
/** Returns true if the AI player has enough resources required to research the given tech type. If unit
|
||||
* is not null, canResearch will return true only if the given unit can research the given tech type. */
|
||||
public boolean canResearch(Unit unit, TechType type) {
|
||||
return canResearch_native(pointer, unit, type);
|
||||
}
|
||||
|
||||
/** Returns true if the AI player has enough resources required to upgrade the given upgrade type. If
|
||||
* unit is not null, canUpgrade will return true only if the given unit can upgrade the given upgrade
|
||||
* type. */
|
||||
public boolean canUpgrade(Unit unit, UpgradeType type) {
|
||||
return canUpgrade_native(pointer, unit, type);
|
||||
}
|
||||
|
||||
/** Returns the set of starting locations for the given map. To determine the starting location for the
|
||||
* players in the current match, see Player::getStartLocation. */
|
||||
public List<TilePosition> getStartLocations() {
|
||||
return getStartLocations_native(pointer);
|
||||
}
|
||||
|
||||
/** Prints text on the screen. Text is not sent to other players in multiplayer games. */
|
||||
public void printf(String cstr_format) {
|
||||
printf_native(pointer, cstr_format);
|
||||
}
|
||||
|
||||
/** Sends text to other players - as if it were entered in chat. In single player games and replays,
|
||||
* this will just print the text on the screen. If the game is a single player match and not a replay,
|
||||
* then this function can be used to execute cheat codes, i.e. Broodwar->sendText("show me the money"). */
|
||||
public void sendText(String cstr_format) {
|
||||
sendText_native(pointer, cstr_format);
|
||||
}
|
||||
|
@ -434,71 +317,50 @@ public class Game {
|
|||
sendTextEx_native(pointer, toAllies, cstr_format);
|
||||
}
|
||||
|
||||
/** Used to change the race while in a lobby. Note that there is no onLobbyEnter callback yet, so this
|
||||
* function cannot be used at this time. */
|
||||
public void changeRace(Race race) {
|
||||
changeRace_native(pointer, race);
|
||||
}
|
||||
|
||||
/** Returns true if Broodwar is in a game. Returns false for lobby and menu screens */
|
||||
public boolean isInGame() {
|
||||
return isInGame_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if Broodwar is in a multiplayer game. Returns false for single player games and
|
||||
* replays. */
|
||||
public boolean isMultiplayer() {
|
||||
return isMultiplayer_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if Broodwar is in a BNet multiplayer game.
|
||||
*/
|
||||
public boolean isBattleNet() {
|
||||
return isBattleNet_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if Broodwar is paused. If the game is paused, Game::getFrameCount will continue to
|
||||
* increase and AIModule::onFrame will still be called while paused. */
|
||||
public boolean isPaused() {
|
||||
return isPaused_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if Broodwar is in a replay. */
|
||||
public boolean isReplay() {
|
||||
return isReplay_native(pointer);
|
||||
}
|
||||
|
||||
/** Used to start the game while in a lobby. Note that there is no onLobbyEnter callback yet, so this
|
||||
* function cannot be used at this time. */
|
||||
public void startGame() {
|
||||
startGame_native(pointer);
|
||||
}
|
||||
|
||||
/** Pauses the game. If the game is paused, Game::getFrameCount will not increase however
|
||||
* AIModule::onFrame will still be called while paused. */
|
||||
public void pauseGame() {
|
||||
pauseGame_native(pointer);
|
||||
}
|
||||
|
||||
/** Resumes the game. */
|
||||
public void resumeGame() {
|
||||
resumeGame_native(pointer);
|
||||
}
|
||||
|
||||
/** Leaves the current match and goes to the after-game stats screen. */
|
||||
public void leaveGame() {
|
||||
leaveGame_native(pointer);
|
||||
}
|
||||
|
||||
/** Restarts the match. Works the same way as if you restarted the match from the menu screen. Only
|
||||
* available in single player mode. */
|
||||
public void restartGame() {
|
||||
restartGame_native(pointer);
|
||||
}
|
||||
|
||||
/** Sets the speed of the game to the given number. Lower numbers are faster. 0 is the fastest speed
|
||||
* StarCraft can handle (which is about as fast as the fastest speed you can view a replay at). Any
|
||||
* negative value will reset the speed to the StarCraft default. */
|
||||
public void setLocalSpeed() {
|
||||
setLocalSpeed_native(pointer);
|
||||
}
|
||||
|
@ -507,45 +369,34 @@ public class Game {
|
|||
setLocalSpeed_native(pointer, speed);
|
||||
}
|
||||
|
||||
/** Issues a command to a group of units */
|
||||
public boolean issueCommand(List<Unit> units, UnitCommand command) {
|
||||
return issueCommand_native(pointer, units, command);
|
||||
}
|
||||
|
||||
/** Returns the set of units currently selected by the user in the GUI. If Flag?::UserInput? was not
|
||||
* enabled during the AIModule::onStart callback, this function will always return an empty set. */
|
||||
public List<Unit> getSelectedUnits() {
|
||||
return getSelectedUnits_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns a pointer to the player that BWAPI controls. In replays this will return null. */
|
||||
public Player self() {
|
||||
return self_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns a pointer to the enemy player. If there is more than one enemy, this returns a pointer to
|
||||
* just one enemy (see enemies to get all enemies still in game). In replays this will
|
||||
* return NULL. */
|
||||
public Player enemy() {
|
||||
return enemy_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns a pointer to the neutral player. */
|
||||
public Player neutral() {
|
||||
return neutral_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns a set of all the ally players that have not left or been defeated. Does not include self. */
|
||||
public List<Player> allies() {
|
||||
return allies_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns a set of all the enemy players that have not left or been defeated. */
|
||||
public List<Player> enemies() {
|
||||
return enemies_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns a set of all the observer players that have not left. */
|
||||
public List<Player> observers() {
|
||||
return observers_native(pointer);
|
||||
}
|
||||
|
@ -558,8 +409,6 @@ public class Game {
|
|||
setTextSize_native(pointer, size);
|
||||
}
|
||||
|
||||
/** Draws text on the screen at the given position. Text can be drawn in different colors by using the
|
||||
* following control characters: TODO: add image from wiki.*/
|
||||
public void drawText(int ctype, int x, int y, String cstr_format) {
|
||||
drawText_native(pointer, ctype, x, y, cstr_format);
|
||||
}
|
||||
|
@ -576,8 +425,6 @@ public class Game {
|
|||
drawTextScreen_native(pointer, x, y, cstr_format);
|
||||
}
|
||||
|
||||
/** Draws a box on the screen, with the given color. If isSolid is true, the entire box will be
|
||||
* rendered, otherwise just the outline will be drawn. */
|
||||
public void drawBox(int ctype, int left, int top, int right, int bottom, Color color) {
|
||||
drawBox_native(pointer, ctype, left, top, right, bottom, color);
|
||||
}
|
||||
|
@ -610,8 +457,6 @@ public class Game {
|
|||
drawBoxScreen_native(pointer, left, top, right, bottom, color, isSolid);
|
||||
}
|
||||
|
||||
/** Draws a triangle on the screen. If isSolid is true, a solid triangle is drawn, otherwise just the
|
||||
* outline of the triangle will be drawn. */
|
||||
public void drawTriangle(int ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color) {
|
||||
drawTriangle_native(pointer, ctype, ax, ay, bx, by, cx, cy, color);
|
||||
}
|
||||
|
@ -644,8 +489,6 @@ public class Game {
|
|||
drawTriangleScreen_native(pointer, ax, ay, bx, by, cx, cy, color, isSolid);
|
||||
}
|
||||
|
||||
/** Draws a circle on the screen, with the given color. If isSolid is true, a solid circle is drawn,
|
||||
* otherwise just the outline of a circle will be drawn. */
|
||||
public void drawCircle(int ctype, int x, int y, int radius, Color color) {
|
||||
drawCircle_native(pointer, ctype, x, y, radius, color);
|
||||
}
|
||||
|
@ -678,8 +521,6 @@ public class Game {
|
|||
drawCircleScreen_native(pointer, x, y, radius, color, isSolid);
|
||||
}
|
||||
|
||||
/** Draws an ellipse on the screen, with the given color. If isSolid is true, a solid ellipse is drawn,
|
||||
* otherwise just the outline of an ellipse will be drawn. */
|
||||
public void drawEllipse(int ctype, int x, int y, int xrad, int yrad, Color color) {
|
||||
drawEllipse_native(pointer, ctype, x, y, xrad, yrad, color);
|
||||
}
|
||||
|
@ -712,7 +553,6 @@ public class Game {
|
|||
drawEllipseScreen_native(pointer, x, y, xrad, yrad, color, isSolid);
|
||||
}
|
||||
|
||||
/** Draws a dot on the screen at the given position with the given color. */
|
||||
public void drawDot(int ctype, int x, int y, Color color) {
|
||||
drawDot_native(pointer, ctype, x, y, color);
|
||||
}
|
||||
|
@ -729,7 +569,6 @@ public class Game {
|
|||
drawDotScreen_native(pointer, x, y, color);
|
||||
}
|
||||
|
||||
/** Draws a line on the screen from (x1,y1) to (x2,y2) with the given color. */
|
||||
public void drawLine(int ctype, int x1, int y1, int x2, int y2, Color color) {
|
||||
drawLine_native(pointer, ctype, x1, y1, x2, y2, color);
|
||||
}
|
||||
|
@ -746,12 +585,10 @@ public class Game {
|
|||
drawLineScreen_native(pointer, x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
/** Retrieves the screen buffer for the game (excluding the HUD) */
|
||||
public void getScreenBuffer() {
|
||||
getScreenBuffer_native(pointer);
|
||||
}
|
||||
|
||||
/** Retrieves latency values for the game. Includes latency, speed, and mode */
|
||||
public int getLatencyFrames() {
|
||||
return getLatencyFrames_native(pointer);
|
||||
}
|
||||
|
@ -768,32 +605,26 @@ public class Game {
|
|||
return getRemainingLatencyTime_native(pointer);
|
||||
}
|
||||
|
||||
/** Retrieves the current revision of BWAPI. */
|
||||
public int getRevision() {
|
||||
return getRevision_native(pointer);
|
||||
}
|
||||
|
||||
/** Retrieves the debug state of the BWAPI build. */
|
||||
public boolean isDebug() {
|
||||
return isDebug_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if latency compensation is enabled */
|
||||
public boolean isLatComEnabled() {
|
||||
return isLatComEnabled_native(pointer);
|
||||
}
|
||||
|
||||
/** Use to enable or disable latency compensation. Default: Enabled */
|
||||
public void setLatCom(boolean isEnabled) {
|
||||
setLatCom_native(pointer, isEnabled);
|
||||
}
|
||||
|
||||
/** Retrieves the number of frames in the replay */
|
||||
public int getReplayFrameCount() {
|
||||
return getReplayFrameCount_native(pointer);
|
||||
}
|
||||
|
||||
/** Sets the rendering state of the Starcraft GUI */
|
||||
public void setGUI() {
|
||||
setGUI_native(pointer);
|
||||
}
|
||||
|
@ -802,7 +633,6 @@ public class Game {
|
|||
setGUI_native(pointer, enabled);
|
||||
}
|
||||
|
||||
/** Retrieves the instance number recorded by BWAPI to identify which instance an AI module belongs to */
|
||||
public int getAPM() {
|
||||
return getAPM_native(pointer);
|
||||
}
|
||||
|
@ -811,12 +641,10 @@ public class Game {
|
|||
return getAPM_native(pointer, includeSelects);
|
||||
}
|
||||
|
||||
/** Changes the map to the one specified. Changes do not take effect unless the game is restarted. */
|
||||
public boolean setMap(String cstr_mapFileName) {
|
||||
return setMap_native(pointer, cstr_mapFileName);
|
||||
}
|
||||
|
||||
/** Sets the frame skip value. 1 = normal */
|
||||
public void setFrameSkip() {
|
||||
setFrameSkip_native(pointer);
|
||||
}
|
||||
|
@ -825,12 +653,10 @@ public class Game {
|
|||
setFrameSkip_native(pointer, frameSkip);
|
||||
}
|
||||
|
||||
/** Returns true if Starcraft can find a path from the source to the destination. */
|
||||
public boolean hasPath(Position source, Position destination) {
|
||||
return hasPath_native(pointer, source, destination);
|
||||
}
|
||||
|
||||
/** Sets the BWAPI player's alliance with another player. */
|
||||
public boolean setAlliance(Player player, boolean allied) {
|
||||
return setAlliance_native(pointer, player, allied);
|
||||
}
|
||||
|
@ -843,7 +669,6 @@ public class Game {
|
|||
return setAlliance_native(pointer, player, allied, alliedVictory);
|
||||
}
|
||||
|
||||
/** Sets the BWAPI player's vision with another player. */
|
||||
public boolean setVision(Player player) {
|
||||
return setVision_native(pointer, player);
|
||||
}
|
||||
|
@ -852,7 +677,6 @@ public class Game {
|
|||
return setVision_native(pointer, player, enabled);
|
||||
}
|
||||
|
||||
/** Returns the elapsed game time in seconds. */
|
||||
public void setCommandOptimizationLevel() {
|
||||
setCommandOptimizationLevel_native(pointer);
|
||||
}
|
||||
|
@ -861,7 +685,6 @@ public class Game {
|
|||
setCommandOptimizationLevel_native(pointer, level);
|
||||
}
|
||||
|
||||
/** Returns the remaining countdown time in seconds. */
|
||||
public Region getRegionAt(int x, int y) {
|
||||
return getRegionAt_native(pointer, x, y);
|
||||
}
|
||||
|
@ -870,12 +693,10 @@ public class Game {
|
|||
return getRegionAt_native(pointer, position);
|
||||
}
|
||||
|
||||
/** Returns the time taken to perform the previous event call. Used for tournament management. */
|
||||
public int getLastEventTime() {
|
||||
return getLastEventTime_native(pointer);
|
||||
}
|
||||
|
||||
/** Hides or reveals a player in a replay. */
|
||||
public boolean setReplayVision(Player player) {
|
||||
return setReplayVision_native(pointer, player);
|
||||
}
|
||||
|
@ -884,7 +705,6 @@ public class Game {
|
|||
return setReplayVision_native(pointer, player, enabled);
|
||||
}
|
||||
|
||||
/** Enables or disables the Fog of War in a replay. */
|
||||
public boolean setRevealAll() {
|
||||
return setRevealAll_native(pointer);
|
||||
}
|
||||
|
@ -901,6 +721,9 @@ public class Game {
|
|||
}
|
||||
|
||||
private static Game get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Game instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new Game(pointer);
|
||||
|
|
|
@ -7,15 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
List of all <a href="GameType.html">GameTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class GameType {
|
||||
|
||||
/** Returns the name of the game type. For example GameTypes::Melee.getName() will return an
|
||||
* std::string object containing "Melee". */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -64,6 +57,9 @@ public class GameType {
|
|||
}
|
||||
|
||||
private static GameType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
GameType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new GameType(pointer);
|
||||
|
|
|
@ -56,11 +56,11 @@ public class Mirror {
|
|||
|
||||
private static final boolean EXTRACT_JAR = true;
|
||||
|
||||
private static final String VERSION = "1_0";
|
||||
private static final String VERSION = "1_1";
|
||||
|
||||
static {
|
||||
String arch = System.getProperty("os.arch");
|
||||
String dllNames[] = {"bwapi_bridge", "gmp-vc90-mt", "mpfr-vc90-mt"};
|
||||
String dllNames[] = {"bwapi_bridge" + VERSION, "gmp-vc90-mt", "mpfr-vc90-mt"};
|
||||
if(!arch.equals("x86")){
|
||||
throw new UnsupportedOperationException("BWMirror API supports only x86 architecture.");
|
||||
}
|
||||
|
|
|
@ -7,14 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/** To get detailed information about what a unit is doing, you can use the Unit::getOrder method, which
|
||||
* will return an Order object. Note that a single command, like gather minerals, can consist of several
|
||||
* orders ( MoveToMinerals, HarvestMinerals2, MiningMinerals, ReturnMinerals, etc) which will indicate what
|
||||
* state the unit is in while executing the command. For information about how to issue commands to units,
|
||||
* go to Unit. */
|
||||
public class Order {
|
||||
|
||||
/** Returns the name of this order. */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -345,6 +339,9 @@ public class Order {
|
|||
}
|
||||
|
||||
private static Order get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Order instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new Order(pointer);
|
||||
|
|
|
@ -7,134 +7,100 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/** Each player in a match will have his or her own player instance. There is also a neutral player which
|
||||
* owns all the neutral units. */
|
||||
public class Player {
|
||||
|
||||
/** Returns a unique ID for the player. */
|
||||
public int getID() {
|
||||
return getID_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the name of the player. */
|
||||
public String getName() {
|
||||
return getName_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of units the player own. Note that units loaded into Terran dropships, Terran
|
||||
* bunkers, Terran refineries, Protoss assimilators, and Zerg extractors are not yet included in the
|
||||
* set. */
|
||||
public List<Unit> getUnits() {
|
||||
return getUnits_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the race of the player. */
|
||||
public Race getRace() {
|
||||
return getRace_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the type of the player. */
|
||||
public PlayerType getType() {
|
||||
return getType_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the force the player is on. */
|
||||
public Force getForce() {
|
||||
return getForce_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if other player is an ally of this player. */
|
||||
public boolean isAlly(Player player) {
|
||||
return isAlly_native(pointer, player);
|
||||
}
|
||||
|
||||
/** Returns true if other player is an enemy of this player. */
|
||||
public boolean isEnemy(Player player) {
|
||||
return isEnemy_native(pointer, player);
|
||||
}
|
||||
|
||||
/** Returns true if the player is the neutral player. */
|
||||
public boolean isNeutral() {
|
||||
return isNeutral_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the starting location of the player. If complete map information is disabled, this function
|
||||
* will return TilePositions::Unknown for enemy players. For the complete set of starting locations for
|
||||
* the current map, see Game::getStartLocations. */
|
||||
public TilePosition getStartLocation() {
|
||||
return getStartLocation_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the player has achieved victory. */
|
||||
public boolean isVictorious() {
|
||||
return isVictorious_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the player has been defeated. */
|
||||
public boolean isDefeated() {
|
||||
return isDefeated_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the player left the game. */
|
||||
public boolean leftGame() {
|
||||
return leftGame_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of minerals the player has. */
|
||||
public int minerals() {
|
||||
return minerals_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of vespene gas the player has. */
|
||||
public int gas() {
|
||||
return gas_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the cumulative amount of minerals the player has mined up to this point (including the 50
|
||||
* minerals at the start of the game). */
|
||||
public int gatheredMinerals() {
|
||||
return gatheredMinerals_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the cumulative amount of gas the player has harvested up to this point. */
|
||||
public int gatheredGas() {
|
||||
return gatheredGas_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the cumulative amount of minerals the player has spent on repairs up to this point. */
|
||||
public int repairedMinerals() {
|
||||
return repairedMinerals_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the cumulative amount of gas the player has spent on repairs up to this point. */
|
||||
public int repairedGas() {
|
||||
return repairedGas_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the cumulative amount of minerals the player has gained from refunded units up to this point. */
|
||||
public int refundedMinerals() {
|
||||
return refundedMinerals_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the cumulative amount of gas the player has gained from refunded units up to this point. */
|
||||
public int refundedGas() {
|
||||
return refundedGas_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the cumulative amount of minerals the player has spent up to this point (not including repairs). */
|
||||
public int spentMinerals() {
|
||||
return spentMinerals_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the cumulative amount of gas the player has spent up to this point (not including repairs). */
|
||||
public int spentGas() {
|
||||
return spentGas_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the total amount of supply the player has. If a race is provided, the total supply for the
|
||||
* given race will be returned, otherwise the player's initial race will be used. Supply counts returned
|
||||
* by BWAPI are double what you would expect to see from playing the game. This is because zerglings
|
||||
* take up 0.5 in-game supply. */
|
||||
public int supplyTotal() {
|
||||
return supplyTotal_native(pointer);
|
||||
}
|
||||
|
@ -143,10 +109,6 @@ public class Player {
|
|||
return supplyTotal_native(pointer, race);
|
||||
}
|
||||
|
||||
/** Returns how much of the supply is actually being used by units. If a race is provided, the used
|
||||
* supply for the given race will be returned, otherwise the player's initial race will be used. Supply
|
||||
* counts returned by BWAPI are double what you would expect to see from playing the game. This is
|
||||
* because zerglings take up 0.5 in-game supply. */
|
||||
public int supplyUsed() {
|
||||
return supplyUsed_native(pointer);
|
||||
}
|
||||
|
@ -155,140 +117,110 @@ public class Player {
|
|||
return supplyUsed_native(pointer, race);
|
||||
}
|
||||
|
||||
/** Returns the number of all accessible units of the given type. */
|
||||
public int allUnitCount(UnitType unit) {
|
||||
return allUnitCount_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the number of visible units of the given type. */
|
||||
public int visibleUnitCount(UnitType unit) {
|
||||
return visibleUnitCount_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the number of completed units of the given type. */
|
||||
public int completedUnitCount(UnitType unit) {
|
||||
return completedUnitCount_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the number of incomplete units of the given type. */
|
||||
public int incompleteUnitCount(UnitType unit) {
|
||||
return incompleteUnitCount_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the number of dead units of the given type. */
|
||||
public int deadUnitCount(UnitType unit) {
|
||||
return deadUnitCount_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the number of killed units of the given type. */
|
||||
public int killedUnitCount(UnitType unit) {
|
||||
return killedUnitCount_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the player's current upgrade level of the given upgrade. To order a unit to upgrade a given
|
||||
* upgrade type, see Unit::upgrade. */
|
||||
public boolean hasResearched(TechType tech) {
|
||||
return hasResearched_native(pointer, tech);
|
||||
}
|
||||
|
||||
/** Returns true if the player is researching the given tech. To order a unit to research a given tech
|
||||
* type, see Unit::reseach. */
|
||||
public boolean isResearching(TechType tech) {
|
||||
return isResearching_native(pointer, tech);
|
||||
}
|
||||
|
||||
/** Returns true if the player is upgrading the given upgrade. To order a unit to upgrade a given
|
||||
* upgrade type, see Unit::upgrade. */
|
||||
public boolean isUpgrading(UpgradeType upgrade) {
|
||||
return isUpgrading_native(pointer, upgrade);
|
||||
}
|
||||
|
||||
/** Returns the color of the player for drawing */
|
||||
public Color getColor() {
|
||||
return getColor_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the color of the player for text messages */
|
||||
public int getTextColor() {
|
||||
return getTextColor_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the max energy of the given unit type, taking into account upgrades */
|
||||
public int maxEnergy(UnitType unit) {
|
||||
return maxEnergy_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the top speed of the given unit type, includes upgrades */
|
||||
public double topSpeed(UnitType unit) {
|
||||
return topSpeed_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the max ground weapon range of the given unit type, includes upgrades */
|
||||
public int groundWeaponMaxRange(UnitType unit) {
|
||||
return groundWeaponMaxRange_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the max air weapon range of the given unit type, includes upgrades */
|
||||
public int airWeaponMaxRange(UnitType unit) {
|
||||
return airWeaponMaxRange_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the max range of the given weapon with upgrades */
|
||||
public int weaponMaxRange(WeaponType weapon) {
|
||||
return weaponMaxRange_native(pointer, weapon);
|
||||
}
|
||||
|
||||
/** Returns the sight range of the given unit type, includes upgrades */
|
||||
public int sightRange(UnitType unit) {
|
||||
return sightRange_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the ground weapon cooldown of the given unit type, includes upgrades */
|
||||
public int groundWeaponDamageCooldown(UnitType unit) {
|
||||
return groundWeaponDamageCooldown_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the armor of the given unit type, includes upgrades */
|
||||
public int armor(UnitType unit) {
|
||||
return armor_native(pointer, unit);
|
||||
}
|
||||
|
||||
/** Returns the Player's Total Unit Score */
|
||||
public int getUnitScore() {
|
||||
return getUnitScore_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the Player's Total Kill Score */
|
||||
public int getKillScore() {
|
||||
return getKillScore_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the Player's Total Buildings Score */
|
||||
public int getBuildingScore() {
|
||||
return getBuildingScore_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the Player's Total Razings Score */
|
||||
public int getRazingScore() {
|
||||
return getRazingScore_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the Player's Custom Score */
|
||||
public int getCustomScore() {
|
||||
return getCustomScore_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the Player is only observing the game, and not participating */
|
||||
public boolean isObserver() {
|
||||
return isObserver_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the maximum upgrades available specific to the player (Use Map Settings). */
|
||||
public boolean isResearchAvailable(TechType tech) {
|
||||
return isResearchAvailable_native(pointer, tech);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is available for the player to build (Use Map Settings). */
|
||||
public boolean isUnitAvailable(UnitType unit) {
|
||||
return isUnitAvailable_native(pointer, unit);
|
||||
}
|
||||
|
@ -301,6 +233,9 @@ public class Player {
|
|||
}
|
||||
|
||||
private static Player get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Player instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new Player(pointer);
|
||||
|
|
|
@ -7,15 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
List of all <a href="PlayerType.html">PlayerTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class PlayerType {
|
||||
|
||||
/** Returns the name of the player type. For example PlayerTypes::Computer.getName() will return an
|
||||
* std::string object containing "Computer". */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -54,6 +47,9 @@ public class PlayerType {
|
|||
}
|
||||
|
||||
private static PlayerType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
PlayerType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new PlayerType(pointer);
|
||||
|
|
|
@ -7,15 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
List of all <a href="Race.html">Races</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class Race {
|
||||
|
||||
/** Returns the name of the race. For example Races::Terran.getName() will return a std::string object
|
||||
* containing "Terran". */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -24,34 +17,22 @@ public class Race {
|
|||
return c_str();
|
||||
}
|
||||
|
||||
/** Returns the worker unit type for the given race. For example Races::Protoss.getWorker() will return
|
||||
* a pointer to UnitTypes::Protoss_Probe. */
|
||||
public UnitType getWorker() {
|
||||
return getWorker_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the center unit type for the given race. For example Races::Terran.getCenter() will return a
|
||||
* pointer to UnitTypes::Terran_Command_Center. While there are three center types for Zerg
|
||||
* (Hatchery, Lair, and Hive), Races::Zerg.getCenter() will only return a pointer to
|
||||
* UnitTypes::Zerg_Hatchery, since it is the unit type needed to make a new center. */
|
||||
public UnitType getCenter() {
|
||||
return getCenter_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the refinery unit type for the given race. For example: Races::Zerg.getRefinery() will
|
||||
* return a pointer to UnitTypes::Zerg_Extractor?. */
|
||||
public UnitType getRefinery() {
|
||||
return getRefinery_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the transport unit type for the given race. For example: Races::Protoss.getTransport() will
|
||||
* return a pointer to UnitTypes::Protoss_Shuttle. */
|
||||
public UnitType getTransport() {
|
||||
return getTransport_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the main supply provider unit type for the given race. For example:
|
||||
* Races::Terran.getSupplyProvider() will return a pointer to UnitTypes::Terran_Supply_Depot?. */
|
||||
public UnitType getSupplyProvider() {
|
||||
return getSupplyProvider_native(pointer);
|
||||
}
|
||||
|
@ -78,6 +59,9 @@ public class Race {
|
|||
}
|
||||
|
||||
private static Race get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Race instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new Race(pointer);
|
||||
|
|
|
@ -7,84 +7,56 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
The Region class provides access to some of Broodwar's pathing information and offers members that can assist in navigation, scouting, construction, and information for key areas such as chokepoints. Though not always accurate, it is a lightweight alternative to BWTA that beginners can start with.
|
||||
These regions are not so advanced as to cover everything up to a choke point with accurate polygons, but instead are small clusters of tiles connected to each other, kind of like a honeycomb.
|
||||
|
||||
|
||||
*/
|
||||
public class Region {
|
||||
|
||||
/** Returns the unique ID for this region assigned by Broodwar. */
|
||||
public int getID() {
|
||||
return getID_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns an ID for the body of land that this region belongs to. */
|
||||
public int getRegionGroupID() {
|
||||
return getRegionGroupID_native(pointer);
|
||||
}
|
||||
|
||||
/** Retrieves the center of the region. */
|
||||
public Position getCenter() {
|
||||
return getCenter_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if this region belongs to strategic higher ground, assigned by Broodwar. */
|
||||
public boolean isHigherGround() {
|
||||
return isHigherGround_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns a value representing the strategic advantage of this region according to Broodwar. */
|
||||
public int getDefensePriority() {
|
||||
return getDefensePriority_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the region can be walked on by ground units. */
|
||||
public boolean isWalkable() {
|
||||
return isWalkable_native(pointer);
|
||||
}
|
||||
|
||||
/** Retrieves the set of neighbors that this region is connected to. */
|
||||
public int getBoundsLeft() {
|
||||
return getBoundsLeft_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
public int getBoundsTop() {
|
||||
return getBoundsTop_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
public int getBoundsRight() {
|
||||
return getBoundsRight_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
public int getBoundsBottom() {
|
||||
return getBoundsBottom_native(pointer);
|
||||
}
|
||||
|
||||
/** Retrieves the closest accessable neighbor region. */
|
||||
public Region getClosestAccessibleRegion() {
|
||||
return getClosestAccessibleRegion_native(pointer);
|
||||
}
|
||||
|
||||
/** Retrieves the closest inaccessable neighbor region. */
|
||||
public Region getClosestInaccessibleRegion() {
|
||||
return getClosestInaccessibleRegion_native(pointer);
|
||||
}
|
||||
|
||||
/** Retrieves the center-to-center distance between two regions. */
|
||||
public int getDistance(Region other) {
|
||||
return getDistance_native(pointer, other);
|
||||
}
|
||||
|
@ -97,6 +69,9 @@ public class Region {
|
|||
}
|
||||
|
||||
private static Region get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Region instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new Region(pointer);
|
||||
|
|
|
@ -7,9 +7,6 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**<br/><br/>
|
||||
* Used in UnitCommand
|
||||
*/
|
||||
public enum Enum {
|
||||
|
||||
None(0),
|
||||
|
|
|
@ -7,14 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
List of all <a href="TechType.html">TechTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class TechType {
|
||||
|
||||
/** Returns the name of the tech type. */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -23,62 +17,46 @@ public class TechType {
|
|||
return c_str();
|
||||
}
|
||||
|
||||
/** Returns the race that uses the TechType. For example, TechTypes::Scanner_Sweep?.getRace() will
|
||||
* return Races::Terran. */
|
||||
public Race getRace() {
|
||||
return getRace_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the mineral cost of the tech type. */
|
||||
public int mineralPrice() {
|
||||
return mineralPrice_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the vespene gas price of the tech type. */
|
||||
public int gasPrice() {
|
||||
return gasPrice_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the number of frames needed to research the tech type. */
|
||||
public int researchTime() {
|
||||
return researchTime_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of energy used each time this tech type is used. */
|
||||
public int energyUsed() {
|
||||
return energyUsed_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the type of unit that researches this tech type. If this tech type is available for free
|
||||
* (does not need to be researched), then this method will return UnitTypes::None. */
|
||||
public UnitType whatResearches() {
|
||||
return whatResearches_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the corresponding weapon for this tech type, or TechTypes::None if no corresponding weapon
|
||||
* exists. For example, TechTypes::Dark_Swarm.getWeapon() will return a pointer to
|
||||
* WeaponTypes::Dark_Swarm. */
|
||||
public WeaponType getWeapon() {
|
||||
return getWeapon_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if this tech type must be used on another unit (i.e. Irradiate) */
|
||||
public boolean targetsUnit() {
|
||||
return targetsUnit_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if this tech type must be specified a position (i.e. Dark Swarm) */
|
||||
public boolean targetsPosition() {
|
||||
return targetsPosition_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of units that can use this tech type. Usually this will just be a set of one unit
|
||||
* type, however in some cases, such as TechTypes::Burrowing, several unit types will be returned. */
|
||||
public List<UnitType> whatUses() {
|
||||
return whatUses_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the order used to execute this tech type as an action. */
|
||||
public Order getOrder() {
|
||||
return getOrder_native(pointer);
|
||||
}
|
||||
|
@ -163,6 +141,9 @@ public class TechType {
|
|||
}
|
||||
|
||||
private static TechType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
TechType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new TechType(pointer);
|
||||
|
|
329
bwapi/Unit.java
329
bwapi/Unit.java
File diff suppressed because it is too large
Load diff
|
@ -7,17 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
<a href="UnitCommand.html">UnitCommand</a> objects are currently used only as arguments to one function - <a href="Unit.html">Unit::issueCommand</a>. While units can be issued commands the normal way via the <a href="Unit.html">Unit</a> methods (i.e. <a href="Unit.html">Unit::attack</a>), in some cases you may want to have a function that can process any unit command, such as when you're writing a proxy for BWAPI.
|
||||
|
||||
|
||||
*/
|
||||
public class UnitCommand {
|
||||
|
||||
/**
|
||||
Returns the type of the command
|
||||
|
||||
*/
|
||||
public UnitCommandType getType() {
|
||||
return getType_native(pointer);
|
||||
}
|
||||
|
@ -30,6 +21,9 @@ Returns the type of the command
|
|||
}
|
||||
|
||||
private static UnitCommand get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
UnitCommand instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new UnitCommand(pointer);
|
||||
|
|
|
@ -7,16 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
Specifies the type of <a href="UnitCommand.html">UnitCommand</a>. Used when constructing <a href="UnitCommand.html">UnitCommand</a> objects, which are then passed to <a href="Unit.html">Unit::issueCommand</a> which uses this type to determine which Unit member function to call.
|
||||
List of all <a href="UnitCommandType.html">UnitCommandTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class UnitCommandType {
|
||||
|
||||
/** Returns the string corresponding to the UnitCommandType object. For example,
|
||||
* UnitCommandTypes::Set_Rally_Position.getName() returns std::string("Set Rally Position")*/
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -125,6 +117,9 @@ public class UnitCommandType {
|
|||
}
|
||||
|
||||
private static UnitCommandType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
UnitCommandType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new UnitCommandType(pointer);
|
||||
|
|
|
@ -7,15 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
List of all <a href="UnitSizeType.html">UnitSizeTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class UnitSizeType {
|
||||
|
||||
/** Returns the string corresponding to the UnitSizeType object. For example,
|
||||
* UnitSizeTypes::Medium.getName() returns std::string("Medium")*/
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -44,6 +37,9 @@ public class UnitSizeType {
|
|||
}
|
||||
|
||||
private static UnitSizeType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
UnitSizeType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new UnitSizeType(pointer);
|
||||
|
|
|
@ -7,11 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/** The UnitType class is used to get information about a particular type of unit, such as the build time
|
||||
* of a Lurker, or the mineral price of an Ultralisk. TODO Add the unittype table from the wiki*/
|
||||
public class UnitType {
|
||||
|
||||
/** Returns the name of the unit. */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -20,164 +17,118 @@ public class UnitType {
|
|||
return c_str();
|
||||
}
|
||||
|
||||
/** Returns the race that the unit belongs to. For example UnitTypes::Terran_SCV.getRace() will return
|
||||
* Races::Terran. */
|
||||
public Race getRace() {
|
||||
return getRace_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns what builds this unit type. The second number will usually be 1 unless the unit type is
|
||||
* Protoss_Archon or Protoss_Dark_Archon. Units that cannot be created, such as critters and mineral
|
||||
* fields, will return a pair where the unit type is UnitTypes::None, and the second component is 0.
|
||||
*<br/><br/>
|
||||
* Example: UnitTypes::Terran_Marine.whatBuilds() will return an std::pair, where the first component
|
||||
* is UnitTypes::Terran_Barracks. */
|
||||
public TechType requiredTech() {
|
||||
return requiredTech_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the tech used to cloak the unit, or TechTypes::None if the unit cannot cloak or is
|
||||
permanently cloaked */
|
||||
public TechType cloakingTech() {
|
||||
return cloakingTech_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of tech types this unit can use, provided the tech types have been researched and
|
||||
* the unit has enough energy. */
|
||||
public List<TechType> abilities() {
|
||||
return abilities_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the set of upgrade types that can affect this unit. */
|
||||
public List<UpgradeType> upgrades() {
|
||||
return upgrades_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the upgrade that increase's the unit's armor, or UpgradeTypes::None if no upgrade
|
||||
* increase's this unit's armor. For example UnitTypes::Terran_Marine.armorUpgrade() will return a
|
||||
* pointer to UpgradeTypes::Terran_Infantry_Armor. */
|
||||
public UpgradeType armorUpgrade() {
|
||||
return armorUpgrade_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the maximum amount of hit points the unit type can have. */
|
||||
public int maxHitPoints() {
|
||||
return maxHitPoints_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the maximum amount of shields the unit type can have. */
|
||||
public int maxShields() {
|
||||
return maxShields_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the maximum amount of energy the unit type can have. */
|
||||
public int maxEnergy() {
|
||||
return maxEnergy_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of armor the non-upgraded unit type has. */
|
||||
public int armor() {
|
||||
return armor_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the mineral price of the unit.
|
||||
*<br/><br/>
|
||||
* Example: UnitTypes::Siege_Tank_Tank_Mode.mineralPrice() returns 150. */
|
||||
public int mineralPrice() {
|
||||
return mineralPrice_native(pointer);
|
||||
}
|
||||
|
||||
/** UnitTypes::Siege_Tank_Tank_Mode.gasPrice() returns 100. */
|
||||
public int gasPrice() {
|
||||
return gasPrice_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the number of frames needed to make this unit type. */
|
||||
public int buildTime() {
|
||||
return buildTime_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of supply used by this unit. Supply counts returned by BWAPI are double what you
|
||||
* would expect to see from playing the game. This is because zerglings take up 0.5 in-game supply. */
|
||||
public int supplyRequired() {
|
||||
return supplyRequired_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of supply produced by this unit (i.e. for a Protoss_Pylon). Supply counts
|
||||
* returned by BWAPI are double what you would expect to see from playing the game. This is because
|
||||
* zerglings take up 0.5 in-game supply. */
|
||||
public int supplyProvided() {
|
||||
return supplyProvided_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of space this unit type takes up inside a bunker or transport unit. */
|
||||
public int spaceRequired() {
|
||||
return spaceRequired_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of space this unit type provides. */
|
||||
public int spaceProvided() {
|
||||
return spaceProvided_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the score which is used to determine the total scores in the after-game stats screen. */
|
||||
public int buildScore() {
|
||||
return buildScore_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the score which is used to determine the total scores in the after-game stats screen. */
|
||||
public int destroyScore() {
|
||||
return destroyScore_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the size of the unit - either Small, Medium, Large, or Independent. */
|
||||
public UnitSizeType size() {
|
||||
return size_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the tile width of the unit. Useful for determining the size of buildings. For example
|
||||
* UnitTypes::Terran_Supply_Depot.tileWidth() will return 3. */
|
||||
public int tileWidth() {
|
||||
return tileWidth_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the tile height of the unit. Useful for determining the size of buildings. For example
|
||||
* UnitTypes::Terran_Supply_Depot.tileHeight() will return 2. */
|
||||
public int tileHeight() {
|
||||
return tileHeight_native(pointer);
|
||||
}
|
||||
|
||||
/** Distance from the center of the unit to the left edge of the unit, measured in pixels. */
|
||||
public int dimensionLeft() {
|
||||
return dimensionLeft_native(pointer);
|
||||
}
|
||||
|
||||
/** Distance from the center of the unit to the top edge of the unit, measured in pixels. */
|
||||
public int dimensionUp() {
|
||||
return dimensionUp_native(pointer);
|
||||
}
|
||||
|
||||
/** Distance from the center of the unit to the right edge of the unit, measured in pixels. */
|
||||
public int dimensionRight() {
|
||||
return dimensionRight_native(pointer);
|
||||
}
|
||||
|
||||
/** Distance from the center of the unit to the bottom edge of the unit, measured in pixels. */
|
||||
public int dimensionDown() {
|
||||
return dimensionDown_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the range at which the unit will start targeting enemy units, measured in pixels. */
|
||||
public int seekRange() {
|
||||
return seekRange_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns how far the un-upgraded unit type can see into the fog of war, measured in pixels. */
|
||||
public int sightRange() {
|
||||
return sightRange_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the unit's ground weapon. */
|
||||
public WeaponType groundWeapon() {
|
||||
return groundWeapon_native(pointer);
|
||||
}
|
||||
|
@ -186,7 +137,6 @@ public class UnitType {
|
|||
return maxGroundHits_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the unit's air weapon. */
|
||||
public WeaponType airWeapon() {
|
||||
return airWeapon_native(pointer);
|
||||
}
|
||||
|
@ -195,210 +145,154 @@ public class UnitType {
|
|||
return maxAirHits_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the unit's non-upgraded top speed in pixels per frame. For Terran buildings that can lift
|
||||
* off and the Zerg Infested Command Center, this returns how fast the building moves when it is
|
||||
* lifted. */
|
||||
public double topSpeed() {
|
||||
return topSpeed_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns how fast the unit can accelerate to its top speed. What units this quantity is measured in
|
||||
* is currently unknown. */
|
||||
public int acceleration() {
|
||||
return acceleration_native(pointer);
|
||||
}
|
||||
|
||||
/** Related to how fast the unit can halt. What units this quantity is measured in is currently
|
||||
* unknown. */
|
||||
public int haltDistance() {
|
||||
return haltDistance_native(pointer);
|
||||
}
|
||||
|
||||
/** Related to how fast the unit can turn. What units this quantity is measured in is currently
|
||||
* unknown. */
|
||||
public int turnRadius() {
|
||||
return turnRadius_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit can train other units. For example, UnitTypes::Terran_Barracks.canProduce()
|
||||
* will return true, while UnitTypes::Terran_Marine?.canProduce() will return false. This is also true
|
||||
* for two non-building units: Protoss Carrier (can produce interceptors) and Protoss Reaver
|
||||
* (can produce scarabs). */
|
||||
public boolean canProduce() {
|
||||
return canProduce_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit can attack (either ground or air). Returns false for units that can only
|
||||
* inflict damage via special abilities (such as Protoss High Templar). */
|
||||
public boolean canAttack() {
|
||||
return canAttack_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit can move. Note that buildings will return false, even Terran buildings
|
||||
* which can move once lifted. */
|
||||
public boolean canMove() {
|
||||
return canMove_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for flying/air units. */
|
||||
public boolean isFlyer() {
|
||||
return isFlyer_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for units that regenerate health (i.e. zerg units). */
|
||||
public boolean regeneratesHP() {
|
||||
return regeneratesHP_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit type is capable of casting spells / using technology. */
|
||||
public boolean isSpellcaster() {
|
||||
return isSpellcaster_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for the two units that are permanently cloaked - Protoss Observer and Protoss Dark
|
||||
* Templar. */
|
||||
public boolean hasPermanentCloak() {
|
||||
return hasPermanentCloak_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for units that cannot be destroyed (i.e. Terran Nuclear Missile, Mineral Field,
|
||||
* Vespene Geyser, etc) */
|
||||
public boolean isInvincible() {
|
||||
return isInvincible_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is organic, such as a Terran Marine. */
|
||||
public boolean isOrganic() {
|
||||
return isOrganic_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is mechanical such as a Terran Vulture. */
|
||||
public boolean isMechanical() {
|
||||
return isMechanical_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for the four robotic Protoss units - Probe, Shuttle, Reaver, and Observer. */
|
||||
public boolean isRobotic() {
|
||||
return isRobotic_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for the seven units that can detect cloaked units - Terran Science Vessel, Spell
|
||||
* Scanner Sweep, Zerg Overlord, Protoss Observer, Terran Missile Turret, Zerg Spore Colony, and Protoss
|
||||
* Photon Cannon. */
|
||||
public boolean isDetector() {
|
||||
return isDetector_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for the five units that hold resources - Mineral Field, Vespene Geyser,
|
||||
* Terran Refinery, Zerg Extractor, and Protoss Assimilator. */
|
||||
public boolean isResourceContainer() {
|
||||
return isResourceContainer_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for the five units that can accept resources - Terran Command Center, Protoss Nexus,
|
||||
* Zerg Hatchery, Zerg Lair, and Zerg Hive. */
|
||||
public boolean isResourceDepot() {
|
||||
return isResourceDepot_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for Terran Refinery, Zerg Extractor, and Protoss Assimilator. */
|
||||
public boolean isRefinery() {
|
||||
return isRefinery_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for Protoss Probe, Terran SCV, and Zerg Drone. */
|
||||
public boolean isWorker() {
|
||||
return isWorker_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for buildings that must be near a pylon to be constructed. */
|
||||
public boolean requiresPsi() {
|
||||
return requiresPsi_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for buildings that can only be built on zerg creep. */
|
||||
public boolean requiresCreep() {
|
||||
return requiresCreep_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for Zergling and Scourge. */
|
||||
public boolean isTwoUnitsInOneEgg() {
|
||||
return isTwoUnitsInOneEgg_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for Zerg Lurker and units that can burrow when burrow tech is researched. */
|
||||
public boolean isBurrowable() {
|
||||
return isBurrowable_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for units that can be cloaked - Terran Ghost and Terran Wraith. Does not include units
|
||||
* which have permanent cloak (Protoss Observer and Protoss Dark Templar). */
|
||||
public boolean isCloakable() {
|
||||
return isCloakable_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is a building (also true for mineral field and vespene geyser). */
|
||||
public boolean isBuilding() {
|
||||
return isBuilding_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is an add-on, such as a Terran Comsat Station. */
|
||||
public boolean isAddon() {
|
||||
return isAddon_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true for Terran buildings that can lift off (i.e. Barracks). */
|
||||
public boolean isFlyingBuilding() {
|
||||
return isFlyingBuilding_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is neutral, such as a critter or mineral field. */
|
||||
public boolean isNeutral() {
|
||||
return isNeutral_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is a Hero unit. */
|
||||
public boolean isHero() {
|
||||
return isHero_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is a Powerup unit. */
|
||||
public boolean isPowerup() {
|
||||
return isPowerup_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is a regular Beacon. */
|
||||
public boolean isBeacon() {
|
||||
return isBeacon_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is a flag Beacon. */
|
||||
public boolean isFlagBeacon() {
|
||||
return isFlagBeacon_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is a special building. */
|
||||
public boolean isSpecialBuilding() {
|
||||
return isSpecialBuilding_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is a spell unit. */
|
||||
public boolean isSpell() {
|
||||
return isSpell_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit produces larva. */
|
||||
public boolean producesLarva() {
|
||||
return producesLarva_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is one of the three mineral field types. */
|
||||
public boolean isMineralField() {
|
||||
return isMineralField_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if the unit is capable of constructing an addon.
|
||||
This consists of Command Center, Factory, Starport, and Science Facility. */
|
||||
public boolean canBuildAddon() {
|
||||
return canBuildAddon_native(pointer);
|
||||
}
|
||||
|
@ -833,6 +727,9 @@ public class UnitType {
|
|||
}
|
||||
|
||||
private static UnitType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
UnitType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new UnitType(pointer);
|
||||
|
|
|
@ -7,15 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
The <a href="UpgradeType.html">UpgradeType</a> class is used to get information about a particular upgrade.
|
||||
List of all <a href="UpgradeType.html">UpgradeTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class UpgradeType {
|
||||
|
||||
/** Returns the name for the upgrade type. */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -24,13 +17,10 @@ public class UpgradeType {
|
|||
return c_str();
|
||||
}
|
||||
|
||||
/** Returns the race the upgrade is for. For example, UpgradeTypes::Terran_Infantry_Armor.getRace()
|
||||
* will return Races::Terran. */
|
||||
public Race getRace() {
|
||||
return getRace_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the mineral price for the first upgrade. */
|
||||
public int mineralPrice() {
|
||||
return mineralPrice_native(pointer);
|
||||
}
|
||||
|
@ -39,12 +29,10 @@ public class UpgradeType {
|
|||
return mineralPrice_native(pointer, level);
|
||||
}
|
||||
|
||||
/** Returns the amount that the mineral price increases for each additional upgrade. */
|
||||
public int mineralPriceFactor() {
|
||||
return mineralPriceFactor_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the vespene gas price for the first upgrade. */
|
||||
public int gasPrice() {
|
||||
return gasPrice_native(pointer);
|
||||
}
|
||||
|
@ -53,12 +41,10 @@ public class UpgradeType {
|
|||
return gasPrice_native(pointer, level);
|
||||
}
|
||||
|
||||
/** Returns the amount that the vespene gas price increases for each additional upgrade. */
|
||||
public int gasPriceFactor() {
|
||||
return gasPriceFactor_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the number of frames needed to research the first upgrade. */
|
||||
public int upgradeTime() {
|
||||
return upgradeTime_native(pointer);
|
||||
}
|
||||
|
@ -67,22 +53,18 @@ public class UpgradeType {
|
|||
return upgradeTime_native(pointer, level);
|
||||
}
|
||||
|
||||
/** Returns the number of frames that the upgrade time increases for each additional upgrade. */
|
||||
public int upgradeTimeFactor() {
|
||||
return upgradeTimeFactor_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the maximum number of times the upgrade can be researched. */
|
||||
public int maxRepeats() {
|
||||
return maxRepeats_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the type of unit that researches the upgrade. */
|
||||
public UnitType whatUpgrades() {
|
||||
return whatUpgrades_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the type of unit that is additionally required for the upgrade. */
|
||||
public UnitType whatsRequired() {
|
||||
return whatsRequired_native(pointer);
|
||||
}
|
||||
|
@ -91,7 +73,6 @@ public class UpgradeType {
|
|||
return whatsRequired_native(pointer, level);
|
||||
}
|
||||
|
||||
/** Returns the set of units that are affected by this upgrade. */
|
||||
public List<UnitType> whatUses() {
|
||||
return whatUses_native(pointer);
|
||||
}
|
||||
|
@ -208,6 +189,9 @@ public class UpgradeType {
|
|||
}
|
||||
|
||||
private static UpgradeType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
UpgradeType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new UpgradeType(pointer);
|
||||
|
|
|
@ -7,14 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
List of all <a href="WeaponType.html">WeaponTypes</a>.
|
||||
|
||||
|
||||
*/
|
||||
public class WeaponType {
|
||||
|
||||
/** Returns the name of the weapon. */
|
||||
public String c_str() {
|
||||
return c_str_native(pointer);
|
||||
}
|
||||
|
@ -23,136 +17,94 @@ public class WeaponType {
|
|||
return c_str();
|
||||
}
|
||||
|
||||
/** Returns the tech type that must be researched before this weapon can be used, or TechTypes::None if
|
||||
* no tech type is required. */
|
||||
public TechType getTech() {
|
||||
return getTech_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the unit that can use this weapon. */
|
||||
public UnitType whatUses() {
|
||||
return whatUses_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of damage that this weapon deals per attack. */
|
||||
public int damageAmount() {
|
||||
return damageAmount_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public int damageBonus() {
|
||||
return damageBonus_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount of cooldown time between attacks. */
|
||||
public int damageCooldown() {
|
||||
return damageCooldown_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the amount that the damage increases per upgrade.
|
||||
* \see WeaponType::upgradeType. */
|
||||
public int damageFactor() {
|
||||
return damageFactor_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the upgrade type that can be upgraded to increase the attack damage. */
|
||||
public UpgradeType upgradeType() {
|
||||
return upgradeType_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the type of damage that this weapon uses (i.e. concussive, normal, explosive, etc). */
|
||||
public DamageType damageType() {
|
||||
return damageType_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the type of explosion that this weapon uses. */
|
||||
public ExplosionType explosionType() {
|
||||
return explosionType_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the minimum attack range of the weapon, measured in pixels, 0 for most things except
|
||||
* WeaponTypes::Arclite_Shock_Cannon (the weapon of the Terran Siege Tank in Siege Mode). */
|
||||
public int minRange() {
|
||||
return minRange_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns the maximum attack range of the weapon, measured in pixels. */
|
||||
public int maxRange() {
|
||||
return maxRange_native(pointer);
|
||||
}
|
||||
|
||||
/** Inner radius used in splash damage calculations. */
|
||||
public int innerSplashRadius() {
|
||||
return innerSplashRadius_native(pointer);
|
||||
}
|
||||
|
||||
/** Median radius used in splash damage calculations. */
|
||||
public int medianSplashRadius() {
|
||||
return medianSplashRadius_native(pointer);
|
||||
}
|
||||
|
||||
/** Outer radius used in splash damage calculations. */
|
||||
public int outerSplashRadius() {
|
||||
return outerSplashRadius_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if this weapon can attack air units. */
|
||||
public boolean targetsAir() {
|
||||
return targetsAir_native(pointer);
|
||||
}
|
||||
|
||||
/** Returns true if this weapon can attack ground units. */
|
||||
public boolean targetsGround() {
|
||||
return targetsGround_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public boolean targetsMechanical() {
|
||||
return targetsMechanical_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public boolean targetsOrganic() {
|
||||
return targetsOrganic_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public boolean targetsNonBuilding() {
|
||||
return targetsNonBuilding_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public boolean targetsNonRobotic() {
|
||||
return targetsNonRobotic_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public boolean targetsTerrain() {
|
||||
return targetsTerrain_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public boolean targetsOrgOrMech() {
|
||||
return targetsOrgOrMech_native(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public boolean targetsOwn() {
|
||||
return targetsOwn_native(pointer);
|
||||
}
|
||||
|
@ -369,6 +321,9 @@ public class WeaponType {
|
|||
}
|
||||
|
||||
private static WeaponType get(long pointer) {
|
||||
if (pointer == 0 ) {
|
||||
return null;
|
||||
}
|
||||
WeaponType instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new WeaponType(pointer);
|
||||
|
|
63
bwapi4-includes/BWAPI.h
Normal file
63
bwapi4-includes/BWAPI.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
#pragma once
|
||||
#include <BWAPI/InterfaceEvent.h>
|
||||
#include <BWAPI/Interface.h>
|
||||
#include <BWAPI/AIModule.h>
|
||||
#include <BWAPI/Bullet.h>
|
||||
#include <BWAPI/Bulletset.h>
|
||||
#include <BWAPI/BulletType.h>
|
||||
#include <BWAPI/Color.h>
|
||||
#include <BWAPI/Constants.h>
|
||||
#include <BWAPI/CoordinateType.h>
|
||||
#include <BWAPI/DamageType.h>
|
||||
#include <BWAPI/Error.h>
|
||||
#include <BWAPI/Event.h>
|
||||
#include <BWAPI/EventType.h>
|
||||
#include <BWAPI/ExplosionType.h>
|
||||
#include <BWAPI/Filters.h>
|
||||
#include <BWAPI/Flag.h>
|
||||
#include <BWAPI/Force.h>
|
||||
#include <BWAPI/Forceset.h>
|
||||
#include <BWAPI/Game.h>
|
||||
#include <BWAPI/GameType.h>
|
||||
#include <BWAPI/Input.h>
|
||||
#include <BWAPI/Latency.h>
|
||||
#include <BWAPI/Order.h>
|
||||
#include <BWAPI/Player.h>
|
||||
#include <BWAPI/Playerset.h>
|
||||
#include <BWAPI/PlayerType.h>
|
||||
#include <BWAPI/Position.h>
|
||||
#include <BWAPI/PositionUnit.h>
|
||||
#include <BWAPI/Race.h>
|
||||
#include <BWAPI/Region.h>
|
||||
#include <BWAPI/Regionset.h>
|
||||
#include <BWAPI/TechType.h>
|
||||
#include <BWAPI/TournamentAction.h>
|
||||
#include <BWAPI/Type.h>
|
||||
#include <BWAPI/Unit.h>
|
||||
#include <BWAPI/UnitCommand.h>
|
||||
#include <BWAPI/UnitCommandType.h>
|
||||
#include <BWAPI/Unitset.h>
|
||||
#include <BWAPI/UnitSizeType.h>
|
||||
#include <BWAPI/UnitType.h>
|
||||
#include <BWAPI/UpgradeType.h>
|
||||
#include <BWAPI/Vectorset.h>
|
||||
#include <BWAPI/WeaponType.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
/// Retrieves the revision of the BWAPILIB module currently being used.
|
||||
///
|
||||
/// @returns
|
||||
/// An integer representing the revision number of the library.
|
||||
///
|
||||
/// @threadsafe
|
||||
int BWAPI_getRevision();
|
||||
|
||||
/// Checks if the BWAPILIB module was compiled in DEBUG mode.
|
||||
///
|
||||
/// @retval true if this is a DEBUG build
|
||||
/// @retval false if this is a RELEASE build
|
||||
///
|
||||
/// @threadsafe
|
||||
bool BWAPI_isDebug();
|
||||
}
|
224
bwapi4-includes/BWAPI/AIModule.h
Normal file
224
bwapi4-includes/BWAPI/AIModule.h
Normal file
|
@ -0,0 +1,224 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Position.h>
|
||||
#include <BWAPI/TournamentAction.h>
|
||||
#include <BWAPI/Unit.h>
|
||||
#include <string>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forward declarations
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
class Color;
|
||||
|
||||
/// AIModule is a virtual class that is intended to be implemented or inherited by a custom AI
|
||||
/// class. The Broodwar interface is guaranteed to be initialized if any of these predefined
|
||||
/// interface functions are invoked by BWAPI.
|
||||
///
|
||||
/// @warning
|
||||
/// Using BWAPI in any thread other than the thread that invokes these functions can produce
|
||||
/// unexpected behaviour and possibly crash your bot. Multi-threaded AIs are possible so
|
||||
/// long as all BWAPI interaction is limited to the calling thread.
|
||||
///
|
||||
/// @note
|
||||
/// Replays are considered games and call all of the same callbacks as a standard game would.
|
||||
class AIModule
|
||||
{
|
||||
public:
|
||||
AIModule();
|
||||
virtual ~AIModule();
|
||||
|
||||
/// Called only once at the beginning of a game. It is intended that the AI module do any
|
||||
/// data initialization in this function.
|
||||
///
|
||||
/// @warning
|
||||
/// Using the Broodwar interface before this function is called can produce undefined
|
||||
/// behaviour and crash your bot. (During static initialization of a class for example)
|
||||
virtual void onStart();
|
||||
|
||||
/// Called once at the end of a game.
|
||||
///
|
||||
/// @param isWinner
|
||||
/// A boolean value to determine if the current player has won the match. This value will
|
||||
/// be true if the current player has won, and false if either the player has lost or the
|
||||
/// game is actually a replay.
|
||||
virtual void onEnd(bool isWinner);
|
||||
|
||||
/// Called once for every execution of a logical frame in Broodwar.
|
||||
/// Users will generally put most of their code in this function.
|
||||
virtual void onFrame();
|
||||
|
||||
/// Called when the user attempts to send a text message. This function can be used to make
|
||||
/// the bot execute text commands entered by the user for debugging purposes.
|
||||
///
|
||||
/// @param text
|
||||
/// A string containing the exact text message that was sent by the user.
|
||||
///
|
||||
/// @note
|
||||
/// If Flag::UserInput is disabled, then this function is not called.
|
||||
virtual void onSendText(std::string text);
|
||||
|
||||
/// Called when the client receives a message from another Player. This function can be used
|
||||
/// to retrieve information from allies in team games, or just to respond to other players.
|
||||
///
|
||||
/// @param player
|
||||
/// The Player interface object representing the owner of the text message.
|
||||
/// @param text
|
||||
/// The text message that the \p player sent.
|
||||
///
|
||||
/// @note
|
||||
/// Messages sent by the current player will never invoke this function.
|
||||
virtual void onReceiveText(Player player, std::string text);
|
||||
|
||||
/// Called when a Player leaves the game. All of their units are automatically given to the
|
||||
/// neutral player with their colour and alliance parameters preserved.
|
||||
///
|
||||
/// @param player
|
||||
/// The Player interface object representing the player that left the game.
|
||||
virtual void onPlayerLeft(Player player);
|
||||
|
||||
/// Called when a @Nuke has been launched somewhere on the map.
|
||||
///
|
||||
/// @param target
|
||||
/// A Position object containing the target location of the @Nuke. If the target location
|
||||
/// is not visible and Flag::CompleteMapInformation is disabled, then target will be
|
||||
/// Positions::Unknown.
|
||||
virtual void onNukeDetect(Position target);
|
||||
|
||||
/// Called when a Unit becomes accessible.
|
||||
///
|
||||
/// @param unit
|
||||
/// The Unit interface object representing the unit that has just become accessible.
|
||||
///
|
||||
/// @note
|
||||
/// This function INCLUDES the state of Flag::CompleteMapInformation.
|
||||
///
|
||||
/// @see onUnitShow
|
||||
virtual void onUnitDiscover(Unit unit);
|
||||
|
||||
/// Called when a Unit becomes inaccessible.
|
||||
///
|
||||
/// @param unit
|
||||
/// The Unit interface object representing the unit that has just become inaccessible.
|
||||
///
|
||||
/// @note
|
||||
/// This function INCLUDES the state of Flag::CompleteMapInformation.
|
||||
///
|
||||
/// @see onUnitHide
|
||||
virtual void onUnitEvade(Unit unit);
|
||||
|
||||
/// Called when a previously invisible unit becomes visible.
|
||||
///
|
||||
/// @param unit
|
||||
/// The Unit interface object representing the unit that has just become visible.
|
||||
///
|
||||
/// @note
|
||||
/// This function EXCLUDES the state of Flag::CompleteMapInformation.
|
||||
///
|
||||
/// @see onUnitDiscover
|
||||
virtual void onUnitShow(Unit unit);
|
||||
|
||||
/// Called just as a visible unit is becoming invisible.
|
||||
///
|
||||
/// @param unit
|
||||
/// The Unit interface object representing the unit that is about to go out of scope.
|
||||
///
|
||||
/// @note
|
||||
/// This function EXCLUDES the state of Flag::CompleteMapInformation.
|
||||
///
|
||||
/// @see onUnitEvade
|
||||
virtual void onUnitHide(Unit unit);
|
||||
|
||||
/// Called when any unit is created.
|
||||
///
|
||||
/// @param unit
|
||||
/// The Unit interface object representing the unit that has just been created.
|
||||
///
|
||||
/// @note
|
||||
/// Due to the internal workings of Broodwar, this function excludes Zerg morphing and
|
||||
/// the construction of structures over a @Geyser .
|
||||
///
|
||||
/// @see onUnitMorph
|
||||
virtual void onUnitCreate(Unit unit);
|
||||
|
||||
/// Called when a unit is removed from the game either through death or other means.
|
||||
///
|
||||
/// @param unit
|
||||
/// Unit object representing the unit that has just been destroyed or otherwise completely
|
||||
/// removed from the game.
|
||||
///
|
||||
/// @note
|
||||
/// When a @Drone morphs into an @Extractor, the @Drone is removed from the game and the
|
||||
/// @Geyser morphs into an @Extractor.
|
||||
///
|
||||
/// @note
|
||||
/// If a unit is visible and destroyed, then onUnitHide is called just before this.
|
||||
virtual void onUnitDestroy(Unit unit);
|
||||
|
||||
/// Called when a unit changes its UnitType. For example, when a @Drone transforms into a
|
||||
/// @Hatchery, a @SiegeTank uses @SiegeMode , or a @Geyser receives a @Refinery .
|
||||
///
|
||||
/// @param unit
|
||||
/// Unit object representing the unit that had its UnitType change.
|
||||
///
|
||||
/// @note
|
||||
/// This is NOT called if the unit type changes to or from UnitTypes::Unknown.
|
||||
virtual void onUnitMorph(Unit unit);
|
||||
|
||||
/// Called when a unit changes ownership. This occurs when the @Protoss ability @MindControl
|
||||
/// is used, or if a unit changes ownership in @UseMapSettings .
|
||||
///
|
||||
/// @param unit
|
||||
/// Unit interface object pertaining to the unit that has just changed ownership.
|
||||
virtual void onUnitRenegade(Unit unit);
|
||||
|
||||
/// Called when the state of the Broodwar game is saved to file.
|
||||
///
|
||||
/// @param gameName
|
||||
/// A String object containing the file name that the game was saved as.
|
||||
virtual void onSaveGame(std::string gameName);
|
||||
|
||||
/// Called when the state of a unit changes from incomplete to complete.
|
||||
///
|
||||
/// @param unit
|
||||
/// The Unit object representing the Unit that has just finished training or constructing.
|
||||
virtual void onUnitComplete(Unit unit);
|
||||
};
|
||||
|
||||
/// TournamentModule is a virtual class that is intended to be implemented or inherited by a
|
||||
/// custom Tournament class. Like AIModule, the Broodwar interface is guaranteed to be
|
||||
/// initialized if any of these predefined interface functions are invoked by BWAPI.
|
||||
///
|
||||
/// @note
|
||||
/// The TournamentModule is to be implemented by Tournament Modules ONLY. A standard AI module
|
||||
/// should never implement it. The Tournament Module is invoked only if it is explicitly
|
||||
/// defined in the configuration file. Tournament Modules also contain an AI Module interface
|
||||
/// so that it can monitor the time an AI module spent during its calls using
|
||||
/// Game::getLastEventTime.
|
||||
class TournamentModule
|
||||
{
|
||||
public:
|
||||
TournamentModule();
|
||||
virtual ~TournamentModule();
|
||||
|
||||
/// This function regulates the functions involving game settings that an AI module is
|
||||
/// allowed to execute. For example, if the tournament forbids the enabling of
|
||||
/// Flag::CompleteMapInformation, then this function can deny the request.
|
||||
///
|
||||
/// @param actionType
|
||||
/// An ActionID containing the action that the AI module is requesting.
|
||||
///
|
||||
/// @param parameter
|
||||
/// An optional parameter that pertains to certain action requests. For example, if
|
||||
/// \p actionType is Tournament::ActionID::SendText, then \p parameter is a pointer to a
|
||||
/// null-terminated character array containing the message. If \p actionType is
|
||||
/// Tournament::ActionID::SetLocalSpeed, then parameter is a pointer to an integer.
|
||||
virtual bool onAction(BWAPI::Tournament::ActionID actionType, void *parameter = nullptr);
|
||||
|
||||
/// This function is called if the current player is chosen to advertise the BWAPI revision.
|
||||
/// When tournament mode is enabled, to reduce spam, only one bot sends the revision message.
|
||||
/// The bot that is chosen depends on its player ID. Only one of the bots can call this
|
||||
/// function during a tournament game.
|
||||
virtual void onFirstAdvertisement();
|
||||
};
|
||||
}
|
0
bwapi4-includes/BWAPI/ArithmaticFilter.h
Normal file
0
bwapi4-includes/BWAPI/ArithmaticFilter.h
Normal file
58
bwapi4-includes/BWAPI/BestFilter.h
Normal file
58
bwapi4-includes/BWAPI/BestFilter.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
#pragma once
|
||||
#include <functional>
|
||||
#include "ComparisonFilter.h"
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
/// The BestFilter is used to compare two objects with each other. Each function object compares
|
||||
/// two of the same object and returns the most desirable one.
|
||||
///
|
||||
/// @note: A function object should return one of the two given parameters, never nullptr. Both
|
||||
/// parameters being given should never be nullptr.
|
||||
template<typename _PARAM>
|
||||
class BestFilter
|
||||
{
|
||||
private:
|
||||
std::function<_PARAM(_PARAM,_PARAM)> pred;
|
||||
public:
|
||||
// Constructor
|
||||
template <typename _T>
|
||||
BestFilter(const _T &predicate) : pred(predicate)
|
||||
{};
|
||||
|
||||
// Assignment
|
||||
template <typename _T>
|
||||
BestFilter<_PARAM> &operator =(const _T &other)
|
||||
{
|
||||
this->pred = other;
|
||||
return *this;
|
||||
};
|
||||
|
||||
// Bitwise operators
|
||||
template <typename _T>
|
||||
inline BestFilter<_PARAM> operator &&(const _T &other) const
|
||||
{
|
||||
return [=](_PARAM p1, _PARAM p2)->_PARAM{ return other( (*this)(p1, p2) ); };
|
||||
};
|
||||
|
||||
// call
|
||||
inline _PARAM operator()(const _PARAM &p1, const _PARAM &p2) const
|
||||
{
|
||||
return this->pred(p1, p2);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template <typename _PARAM>
|
||||
BestFilter<_PARAM> Lowest(const CompareFilter<_PARAM,int> &filter)
|
||||
{
|
||||
return [=](_PARAM p1, _PARAM p2)->_PARAM{ return filter(p2) < filter(p1) ? p2 : p1; };
|
||||
};
|
||||
template <typename _PARAM>
|
||||
BestFilter<_PARAM> Highest(const CompareFilter<_PARAM,int> &filter)
|
||||
{
|
||||
return [=](_PARAM p1, _PARAM p2)->_PARAM{ return filter(p2) > filter(p1) ? p2 : p1; };
|
||||
};
|
||||
|
||||
}
|
||||
|
167
bwapi4-includes/BWAPI/Bullet.h
Normal file
167
bwapi4-includes/BWAPI/Bullet.h
Normal file
|
@ -0,0 +1,167 @@
|
|||
#pragma once
|
||||
#include <BWAPI.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forward declarations
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
class BulletType;
|
||||
|
||||
class BulletInterface;
|
||||
typedef BulletInterface *Bullet;
|
||||
|
||||
/// An interface object representing a bullet or missile spawned from an attack.
|
||||
///
|
||||
/// The Bullet interface allows you to detect bullets, missiles, and other types
|
||||
/// of non-melee attacks or special abilities that would normally be visible through
|
||||
/// human eyes (A lurker spike or a Queen's flying parasite), allowing quicker reaction
|
||||
/// to unavoidable consequences.
|
||||
///
|
||||
/// For example, ordering medics to restore units that are about to receive a lockdown
|
||||
/// to compensate for latency and minimize its effects. You can't know entirely which unit
|
||||
/// will be receiving a lockdown unless you can detect the lockdown missile using the
|
||||
/// Bullet class.
|
||||
///
|
||||
/// Bullet objects are re-used after they are destroyed, however their ID is updated when it
|
||||
/// represents a new Bullet.
|
||||
///
|
||||
/// If Flag::CompleteMapInformation is disabled, then a Bullet is accessible if and only if
|
||||
/// it is visible. Otherwise if Flag::CompleteMapInformation is enabled, then all Bullets
|
||||
/// in the game are accessible.
|
||||
/// @see Game::getBullets, BulletInterface::exists
|
||||
class BulletInterface : public Interface<BulletInterface>
|
||||
{
|
||||
protected:
|
||||
virtual ~BulletInterface() {};
|
||||
public:
|
||||
/// Retrieves a unique identifier for the current Bullet.
|
||||
///
|
||||
/// @returns
|
||||
/// An integer value containing the identifier.
|
||||
virtual int getID() const = 0;
|
||||
|
||||
/// Checks if the Bullet exists in the view of the BWAPI player.
|
||||
///
|
||||
/// @retval true If the bullet exists or is visible.
|
||||
/// @retval false If the bullet was destroyed or has gone out of scope.
|
||||
///
|
||||
/// If Flag::CompleteMapInformation is disabled, and a Bullet is not visible, then the
|
||||
/// return value will be false regardless of the Bullet's true existence. This is because
|
||||
/// absolutely no state information on invisible enemy bullets is made available to the AI.
|
||||
///
|
||||
/// If Flag::CompleteMapInformation is enabled, then this function is accurate for all
|
||||
/// Bullet information.
|
||||
/// @see isVisible, UnitInterface::exists
|
||||
virtual bool exists() const = 0;
|
||||
|
||||
/// Retrieves the Player interface that owns the Bullet.
|
||||
///
|
||||
/// @retval nullptr If the Player object for this Bullet is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// The owning Player interface object.
|
||||
virtual Player getPlayer() const = 0;
|
||||
|
||||
/// Retrieves the type of this Bullet.
|
||||
///
|
||||
/// @retval BulletTypes::Unknown if the Bullet is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// A BulletType representing the Bullet's type.
|
||||
virtual BulletType getType() const = 0;
|
||||
|
||||
/// Retrieves the Unit interface that the Bullet spawned from.
|
||||
///
|
||||
/// @retval nullptr If the source can not be identified or is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// The owning Unit interface object.
|
||||
/// @see getTarget
|
||||
virtual Unit getSource() const = 0;
|
||||
|
||||
/// Retrieves the Bullet's current position.
|
||||
///
|
||||
/// @retval Positions::Unknown If the Bullet is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// A Position containing the Bullet's current coordinates.
|
||||
/// @see getTargetPosition
|
||||
virtual Position getPosition() const = 0;
|
||||
|
||||
/// Retrieve's the direction the Bullet is facing. If the angle is 0, then the Bullet is
|
||||
/// facing right.
|
||||
///
|
||||
/// @retval 0.0 If the bullet is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// A double representing the direction the Bullet is facing.
|
||||
virtual double getAngle() const = 0;
|
||||
|
||||
/// Retrieves the X component of the Bullet's velocity, measured in pixels per frame.
|
||||
///
|
||||
/// @retval 0.0 if the Bullet is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// A double representing the number of pixels moved on the X axis per frame.
|
||||
///
|
||||
/// @see getVelocityY, getAngle
|
||||
virtual double getVelocityX() const = 0;
|
||||
|
||||
/// Retrieves the Y component of the Bullet's velocity, measured in pixels per frame.
|
||||
///
|
||||
/// @retval 0.0 if the Bullet is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// A double representing the number of pixels moved on the Y axis per frame.
|
||||
///
|
||||
/// @see getVelocityX, getAngle
|
||||
virtual double getVelocityY() const = 0;
|
||||
|
||||
/// Retrieves the Unit interface that the Bullet is heading to.
|
||||
///
|
||||
/// @retval nullptr If the Bullet's target Unit is inaccessible, the Bullet is targetting the
|
||||
/// ground, or if the Bullet itself is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// The target Unit interface object, if one exists.
|
||||
/// @see getTargetPosition, getSource
|
||||
virtual Unit getTarget() const = 0;
|
||||
|
||||
/// Retrieves the target position that the Bullet is heading to.
|
||||
///
|
||||
/// @retval Positions::Unknown If the bullet is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// A Position indicating where the Bullet is headed.
|
||||
/// @see getTarget, getPosition
|
||||
virtual Position getTargetPosition() const = 0;
|
||||
|
||||
/// Retrieves the timer that indicates the Bullet's life span.
|
||||
///
|
||||
/// Bullets are not permanent objects, so they will often have a limited life span.
|
||||
/// This life span is measured in frames. Normally a Bullet will reach its target
|
||||
/// before being removed.
|
||||
///
|
||||
/// @retval 0 If the Bullet is inaccessible.
|
||||
///
|
||||
/// @returns
|
||||
/// An integer representing the remaining number of frames until the Bullet self-destructs.
|
||||
virtual int getRemoveTimer() const = 0;
|
||||
|
||||
/// Retrieves the visibility state of the Bullet.
|
||||
///
|
||||
/// @param player (optional)
|
||||
/// If this parameter is specified, then the Bullet's visibility to the given player is
|
||||
/// checked. If this parameter is omitted, then a default value of nullptr is used, which
|
||||
/// will check if the BWAPI player has vision of the Bullet.
|
||||
///
|
||||
/// @note If \c player is nullptr and Broodwar->self() is also nullptr, then the visibility of
|
||||
/// the Bullet is determined by checking if at least one other player has vision of the
|
||||
/// Bullet.
|
||||
///
|
||||
/// @retval true If the Bullet is visible to the specified player.
|
||||
/// @retval false If the Bullet is not visible to the specified player.
|
||||
virtual bool isVisible(Player player = nullptr) const = 0;
|
||||
};
|
||||
}
|
120
bwapi4-includes/BWAPI/BulletType.h
Normal file
120
bwapi4-includes/BWAPI/BulletType.h
Normal file
|
@ -0,0 +1,120 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace BulletTypes
|
||||
{
|
||||
/// Enumeration of bullet types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of bullet types
|
||||
enum Enum
|
||||
{
|
||||
Melee = 0,
|
||||
|
||||
Fusion_Cutter_Hit = 141,
|
||||
Gauss_Rifle_Hit,
|
||||
C_10_Canister_Rifle_Hit,
|
||||
Gemini_Missiles,
|
||||
Fragmentation_Grenade,
|
||||
Longbolt_Missile,
|
||||
Unused_Lockdown,
|
||||
ATS_ATA_Laser_Battery,
|
||||
Burst_Lasers,
|
||||
Arclite_Shock_Cannon_Hit,
|
||||
EMP_Missile,
|
||||
Dual_Photon_Blasters_Hit,
|
||||
Particle_Beam_Hit,
|
||||
Anti_Matter_Missile,
|
||||
Pulse_Cannon,
|
||||
Psionic_Shockwave_Hit,
|
||||
Psionic_Storm,
|
||||
Yamato_Gun,
|
||||
Phase_Disruptor,
|
||||
STA_STS_Cannon_Overlay,
|
||||
Sunken_Colony_Tentacle,
|
||||
Venom_Unused,
|
||||
Acid_Spore,
|
||||
Plasma_Drip_Unused,
|
||||
Glave_Wurm,
|
||||
Seeker_Spores,
|
||||
Queen_Spell_Carrier,
|
||||
Plague_Cloud,
|
||||
Consume,
|
||||
Ensnare,
|
||||
Needle_Spine_Hit,
|
||||
Invisible,
|
||||
|
||||
Optical_Flare_Grenade = 201,
|
||||
Halo_Rockets,
|
||||
Subterranean_Spines,
|
||||
Corrosive_Acid_Shot,
|
||||
Corrosive_Acid_Hit,
|
||||
Neutron_Flare,
|
||||
|
||||
None = 209,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
}
|
||||
}
|
||||
class BulletType : public Type<BulletType, BulletTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
BulletType(int id = BulletTypes::Enum::None);
|
||||
};
|
||||
|
||||
/// Namespace containing bullet types
|
||||
namespace BulletTypes
|
||||
{
|
||||
/// Retrieves the set of all the BulletTypes.
|
||||
///
|
||||
/// @returns Set of BulletTypes.
|
||||
const BulletType::const_set& allBulletTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const BulletType x
|
||||
BWAPI_DECL(Melee);
|
||||
BWAPI_DECL(Fusion_Cutter_Hit);
|
||||
BWAPI_DECL(Gauss_Rifle_Hit);
|
||||
BWAPI_DECL(C_10_Canister_Rifle_Hit);
|
||||
BWAPI_DECL(Gemini_Missiles);
|
||||
BWAPI_DECL(Fragmentation_Grenade);
|
||||
BWAPI_DECL(Longbolt_Missile);
|
||||
BWAPI_DECL(ATS_ATA_Laser_Battery);
|
||||
BWAPI_DECL(Burst_Lasers);
|
||||
BWAPI_DECL(Arclite_Shock_Cannon_Hit);
|
||||
BWAPI_DECL(EMP_Missile);
|
||||
BWAPI_DECL(Dual_Photon_Blasters_Hit);
|
||||
BWAPI_DECL(Particle_Beam_Hit);
|
||||
BWAPI_DECL(Anti_Matter_Missile);
|
||||
BWAPI_DECL(Pulse_Cannon);
|
||||
BWAPI_DECL(Psionic_Shockwave_Hit);
|
||||
BWAPI_DECL(Psionic_Storm);
|
||||
BWAPI_DECL(Yamato_Gun);
|
||||
BWAPI_DECL(Phase_Disruptor);
|
||||
BWAPI_DECL(STA_STS_Cannon_Overlay);
|
||||
BWAPI_DECL(Sunken_Colony_Tentacle);
|
||||
BWAPI_DECL(Acid_Spore);
|
||||
BWAPI_DECL(Glave_Wurm);
|
||||
BWAPI_DECL(Seeker_Spores);
|
||||
BWAPI_DECL(Queen_Spell_Carrier);
|
||||
BWAPI_DECL(Plague_Cloud);
|
||||
BWAPI_DECL(Consume);
|
||||
BWAPI_DECL(Ensnare);
|
||||
BWAPI_DECL(Needle_Spine_Hit);
|
||||
BWAPI_DECL(Invisible);
|
||||
BWAPI_DECL(Optical_Flare_Grenade);
|
||||
BWAPI_DECL(Halo_Rockets);
|
||||
BWAPI_DECL(Subterranean_Spines);
|
||||
BWAPI_DECL(Corrosive_Acid_Shot);
|
||||
BWAPI_DECL(Neutron_Flare);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
};
|
||||
}
|
18
bwapi4-includes/BWAPI/Bulletset.h
Normal file
18
bwapi4-includes/BWAPI/Bulletset.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Vectorset.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forward Declarations
|
||||
class BulletInterface;
|
||||
typedef BulletInterface *Bullet;
|
||||
|
||||
class Bulletset : public Vectorset<BWAPI::Bullet>
|
||||
{
|
||||
public:
|
||||
Bulletset(size_t initialSize = 16);
|
||||
Bulletset(const Bulletset &other);
|
||||
Bulletset(Bulletset &&other);
|
||||
};
|
||||
}
|
||||
|
17
bwapi4-includes/BWAPI/Client.h
Normal file
17
bwapi4-includes/BWAPI/Client.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Client/Client.h>
|
||||
#include <BWAPI/Client/Command.h>
|
||||
#include <BWAPI/Client/CommandType.h>
|
||||
#include <BWAPI/Client/Event.h>
|
||||
#include <BWAPI/Client/ForceData.h>
|
||||
#include <BWAPI/Client/ForceImpl.h>
|
||||
#include <BWAPI/Client/GameData.h>
|
||||
#include <BWAPI/Client/GameImpl.h>
|
||||
#include <BWAPI/Client/GameTable.h>
|
||||
#include <BWAPI/Client/PlayerData.h>
|
||||
#include <BWAPI/Client/PlayerImpl.h>
|
||||
#include <BWAPI/Client/Shape.h>
|
||||
#include <BWAPI/Client/ShapeType.h>
|
||||
#include <BWAPI/Client/UnitCommand.h>
|
||||
#include <BWAPI/Client/UnitData.h>
|
||||
#include <BWAPI/Client/UnitImpl.h>
|
23
bwapi4-includes/BWAPI/Client/BulletData.h
Normal file
23
bwapi4-includes/BWAPI/Client/BulletData.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
struct BulletData
|
||||
{
|
||||
int id;
|
||||
int player;
|
||||
int type;
|
||||
int source;
|
||||
int positionX;
|
||||
int positionY;
|
||||
double angle;
|
||||
double velocityX;
|
||||
double velocityY;
|
||||
int target;
|
||||
int targetPositionX;
|
||||
int targetPositionY;
|
||||
int removeTimer;
|
||||
bool exists;
|
||||
bool isVisible[9];
|
||||
};
|
||||
}
|
33
bwapi4-includes/BWAPI/Client/BulletImpl.h
Normal file
33
bwapi4-includes/BWAPI/Client/BulletImpl.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
#include <BWAPI.h>
|
||||
#include "BulletData.h"
|
||||
#include <string>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
|
||||
class BulletImpl : public BulletInterface
|
||||
{
|
||||
private:
|
||||
const BulletData* self;
|
||||
int index;
|
||||
public:
|
||||
|
||||
BulletImpl(int index);
|
||||
virtual int getID() const override;
|
||||
virtual bool exists() const override;
|
||||
virtual Player getPlayer() const override;
|
||||
virtual BulletType getType() const override;
|
||||
virtual Unit getSource() const override;
|
||||
virtual Position getPosition() const override;
|
||||
virtual double getAngle() const override;
|
||||
virtual double getVelocityX() const override;
|
||||
virtual double getVelocityY() const override;
|
||||
virtual Unit getTarget() const override;
|
||||
virtual Position getTargetPosition() const override;
|
||||
virtual int getRemoveTimer() const override;
|
||||
virtual bool isVisible(Player player = nullptr) const override;
|
||||
};
|
||||
}
|
34
bwapi4-includes/BWAPI/Client/Client.h
Normal file
34
bwapi4-includes/BWAPI/Client/Client.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
#include <windows.h>
|
||||
#include "GameData.h"
|
||||
#include "GameImpl.h"
|
||||
#include "ForceImpl.h"
|
||||
#include "PlayerImpl.h"
|
||||
#include "UnitImpl.h"
|
||||
#include "GameTable.h"
|
||||
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class Client
|
||||
{
|
||||
public:
|
||||
Client();
|
||||
~Client();
|
||||
|
||||
bool isConnected();
|
||||
bool connect();
|
||||
void disconnect();
|
||||
void update();
|
||||
|
||||
GameData *data;
|
||||
private:
|
||||
HANDLE pipeObjectHandle;
|
||||
HANDLE mapFileHandle;
|
||||
HANDLE gameTableFileHandle;
|
||||
GameTable *gameTable;
|
||||
|
||||
bool connected;
|
||||
};
|
||||
extern Client BWAPIClient;
|
||||
}
|
23
bwapi4-includes/BWAPI/Client/Command.h
Normal file
23
bwapi4-includes/BWAPI/Client/Command.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#include "CommandType.h"
|
||||
|
||||
namespace BWAPIC
|
||||
{
|
||||
struct Command
|
||||
{
|
||||
Command()
|
||||
: type( CommandType::None )
|
||||
, value1( 0 )
|
||||
, value2( 0 )
|
||||
{ }
|
||||
Command(CommandType::Enum _commandType, int _value1=0, int _value2=0)
|
||||
: type( _commandType )
|
||||
, value1( _value1 )
|
||||
, value2( _value2 )
|
||||
{ }
|
||||
|
||||
CommandType::Enum type;
|
||||
int value1;
|
||||
int value2;
|
||||
};
|
||||
}
|
33
bwapi4-includes/BWAPI/Client/CommandType.h
Normal file
33
bwapi4-includes/BWAPI/Client/CommandType.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
/**
|
||||
* Used in UnitCommand
|
||||
*/
|
||||
|
||||
namespace BWAPIC
|
||||
{
|
||||
namespace CommandType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
None,
|
||||
SetScreenPosition,
|
||||
PingMinimap,
|
||||
EnableFlag,
|
||||
Printf,
|
||||
SendText,
|
||||
PauseGame,
|
||||
ResumeGame,
|
||||
LeaveGame,
|
||||
RestartGame,
|
||||
SetLocalSpeed,
|
||||
SetLatCom,
|
||||
SetGui,
|
||||
SetFrameSkip,
|
||||
SetMap,
|
||||
SetAllies,
|
||||
SetVision,
|
||||
SetCommandOptimizerLevel,
|
||||
SetRevealAll
|
||||
};
|
||||
}
|
||||
}
|
14
bwapi4-includes/BWAPI/Client/Event.h
Normal file
14
bwapi4-includes/BWAPI/Client/Event.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <BWAPI/Event.h>
|
||||
#include <BWAPI/EventType.h>
|
||||
|
||||
namespace BWAPIC
|
||||
{
|
||||
struct Event
|
||||
{
|
||||
BWAPI::EventType::Enum type;
|
||||
int v1;
|
||||
int v2;
|
||||
};
|
||||
}
|
9
bwapi4-includes/BWAPI/Client/ForceData.h
Normal file
9
bwapi4-includes/BWAPI/Client/ForceData.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
struct ForceData
|
||||
{
|
||||
char name[32];
|
||||
};
|
||||
}
|
23
bwapi4-includes/BWAPI/Client/ForceImpl.h
Normal file
23
bwapi4-includes/BWAPI/Client/ForceImpl.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#include <BWAPI.h>
|
||||
#include "ForceData.h"
|
||||
#include <string>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class Game;
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
|
||||
class ForceImpl : public ForceInterface
|
||||
{
|
||||
private:
|
||||
const ForceData* self;
|
||||
int id;
|
||||
public:
|
||||
ForceImpl(int id);
|
||||
virtual int getID() const override;
|
||||
virtual std::string getName() const override;
|
||||
virtual Playerset getPlayers() const override;
|
||||
};
|
||||
}
|
163
bwapi4-includes/BWAPI/Client/GameData.h
Normal file
163
bwapi4-includes/BWAPI/Client/GameData.h
Normal file
|
@ -0,0 +1,163 @@
|
|||
#pragma once
|
||||
|
||||
#include "UnitCommand.h"
|
||||
#include "ForceData.h"
|
||||
#include "PlayerData.h"
|
||||
#include "RegionData.h"
|
||||
#include "UnitData.h"
|
||||
#include "BulletData.h"
|
||||
#include "Event.h"
|
||||
#include "Command.h"
|
||||
#include "Shape.h"
|
||||
namespace BWAPIC
|
||||
{
|
||||
struct Position
|
||||
{
|
||||
Position() {x=0;y=0;}
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
}
|
||||
namespace BWAPI
|
||||
{
|
||||
struct unitFinder
|
||||
{
|
||||
int unitIndex;
|
||||
int searchValue;
|
||||
};
|
||||
struct GameData
|
||||
{
|
||||
//revision and debug will stay at the top of struct so they don't move in memory from revision to revision.
|
||||
int revision;
|
||||
bool isDebug;
|
||||
|
||||
int instanceID;
|
||||
int botAPM_noselects;
|
||||
int botAPM_selects;
|
||||
|
||||
//forces
|
||||
int forceCount;
|
||||
ForceData forces[5];
|
||||
|
||||
//players
|
||||
int playerCount;
|
||||
PlayerData players[12];
|
||||
|
||||
//units
|
||||
int initialUnitCount;
|
||||
UnitData units[10000];
|
||||
|
||||
//unit table
|
||||
int unitArray[1700];
|
||||
|
||||
//bullets
|
||||
BulletData bullets[100];
|
||||
|
||||
// nuke dots
|
||||
int nukeDotCount;
|
||||
BWAPIC::Position nukeDots[200];
|
||||
|
||||
int gameType;
|
||||
int latency;
|
||||
int latencyFrames;
|
||||
int latencyTime;
|
||||
int remainingLatencyFrames;
|
||||
int remainingLatencyTime;
|
||||
bool hasLatCom;
|
||||
bool hasGUI;
|
||||
int replayFrameCount;
|
||||
int frameCount;
|
||||
int elapsedTime;
|
||||
int countdownTimer;
|
||||
int fps;
|
||||
double averageFPS;
|
||||
|
||||
// user input
|
||||
int mouseX;
|
||||
int mouseY;
|
||||
bool mouseState[M_MAX];
|
||||
bool keyState[K_MAX];
|
||||
int screenX;
|
||||
int screenY;
|
||||
|
||||
bool flags[BWAPI::Flag::Max];
|
||||
|
||||
// map
|
||||
int mapWidth;
|
||||
int mapHeight;
|
||||
char mapFileName[261]; //size based on broodwar memory
|
||||
char mapPathName[261]; //size based on broodwar memory
|
||||
char mapName[33]; //size based on broodwar memory
|
||||
char mapHash[41];
|
||||
|
||||
//tile data
|
||||
int getGroundHeight[256][256];
|
||||
bool isWalkable[1024][1024];
|
||||
bool isBuildable[256][256];
|
||||
bool isVisible[256][256];
|
||||
bool isExplored[256][256];
|
||||
bool hasCreep[256][256];
|
||||
bool isOccupied[256][256];
|
||||
|
||||
unsigned short mapTileRegionId[256][256];
|
||||
unsigned short mapSplitTilesMiniTileMask[5000];
|
||||
unsigned short mapSplitTilesRegion1[5000];
|
||||
unsigned short mapSplitTilesRegion2[5000];
|
||||
|
||||
int regionCount;
|
||||
RegionData regions[5000];
|
||||
|
||||
// start locations
|
||||
int startLocationCount;
|
||||
BWAPIC::Position startLocations[8];
|
||||
|
||||
// match mode
|
||||
bool isInGame;
|
||||
bool isMultiplayer;
|
||||
bool isBattleNet;
|
||||
bool isPaused;
|
||||
bool isReplay;
|
||||
|
||||
//selected units
|
||||
int selectedUnitCount;
|
||||
int selectedUnits[12];
|
||||
|
||||
// players
|
||||
int self;
|
||||
int enemy;
|
||||
int neutral;
|
||||
|
||||
static const int MAX_EVENTS = 10000;
|
||||
static const int MAX_EVENT_STRINGS = 1000;
|
||||
static const int MAX_STRINGS = 20000;
|
||||
static const int MAX_SHAPES = 20000;
|
||||
static const int MAX_COMMANDS = 20000;
|
||||
static const int MAX_UNIT_COMMANDS = 20000;
|
||||
|
||||
//events from server to client
|
||||
int eventCount;
|
||||
BWAPIC::Event events[MAX_EVENTS];
|
||||
|
||||
//strings used in events
|
||||
int eventStringCount;
|
||||
char eventStrings[MAX_EVENT_STRINGS][256];
|
||||
|
||||
//strings (used in shapes and commands)
|
||||
int stringCount;
|
||||
char strings[MAX_STRINGS][256];
|
||||
|
||||
//shapes, commands, unitCommands, from client to server
|
||||
int shapeCount;
|
||||
BWAPIC::Shape shapes[MAX_SHAPES];
|
||||
|
||||
int commandCount;
|
||||
BWAPIC::Command commands[MAX_COMMANDS];
|
||||
|
||||
int unitCommandCount;
|
||||
BWAPIC::UnitCommand unitCommands[MAX_UNIT_COMMANDS];
|
||||
|
||||
int unitSearchSize;
|
||||
unitFinder xUnitSearch[1700*2];
|
||||
unitFinder yUnitSearch[1700*2];
|
||||
};
|
||||
}
|
205
bwapi4-includes/BWAPI/Client/GameImpl.h
Normal file
205
bwapi4-includes/BWAPI/Client/GameImpl.h
Normal file
|
@ -0,0 +1,205 @@
|
|||
#pragma once
|
||||
#include <BWAPI.h>
|
||||
#include "GameData.h"
|
||||
#include "Client.h"
|
||||
#include "Shape.h"
|
||||
#include "Command.h"
|
||||
#include "UnitCommand.h"
|
||||
#include "ForceImpl.h"
|
||||
#include "PlayerImpl.h"
|
||||
#include "RegionImpl.h"
|
||||
#include "UnitImpl.h"
|
||||
#include "BulletImpl.h"
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include <BWAPI/Unitset.h>
|
||||
#include <BWAPI/Bulletset.h>
|
||||
#include <BWAPI/Playerset.h>
|
||||
#include <BWAPI/Forceset.h>
|
||||
#include <BWAPI/Regionset.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class ForceInterface;
|
||||
typedef ForceInterface *Force;
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
|
||||
class GameImpl : public Game
|
||||
{
|
||||
private :
|
||||
int addShape(const BWAPIC::Shape &s);
|
||||
int addString(const char* text);
|
||||
int addText(BWAPIC::Shape &s, const char* text);
|
||||
int addCommand(const BWAPIC::Command &c);
|
||||
void processInterfaceEvents();
|
||||
void clearAll();
|
||||
|
||||
GameData* data;
|
||||
std::vector<ForceImpl> forceVector;
|
||||
std::vector<PlayerImpl> playerVector;
|
||||
std::vector<UnitImpl> unitVector;
|
||||
std::vector<BulletImpl> bulletVector;
|
||||
RegionImpl *regionArray[5000];
|
||||
|
||||
Forceset forces;
|
||||
Playerset playerSet;
|
||||
Unitset accessibleUnits;//all units that are accessible (and definitely alive)
|
||||
//notDestroyedUnits - accessibleUnits = all units that may or may not be alive (status unknown)
|
||||
Unitset minerals;
|
||||
Unitset geysers;
|
||||
Unitset neutralUnits;
|
||||
Unitset staticMinerals;
|
||||
Unitset staticGeysers;
|
||||
Unitset staticNeutralUnits;
|
||||
Bulletset bullets;
|
||||
Position::set nukeDots;
|
||||
Unitset selectedUnits;
|
||||
Unitset pylons;
|
||||
Regionset regionsList;
|
||||
|
||||
TilePosition::set startLocations;
|
||||
std::list< Event > events;
|
||||
bool flagEnabled[2];
|
||||
Player thePlayer;
|
||||
Player theEnemy;
|
||||
Player theNeutral;
|
||||
Playerset _allies;
|
||||
Playerset _enemies;
|
||||
Playerset _observers;
|
||||
mutable Error lastError;
|
||||
int textSize;
|
||||
|
||||
public :
|
||||
Event makeEvent(BWAPIC::Event e);
|
||||
int addUnitCommand(BWAPIC::UnitCommand& c);
|
||||
bool inGame;
|
||||
GameImpl(GameData* data);
|
||||
void onMatchStart();
|
||||
void onMatchEnd();
|
||||
void onMatchFrame();
|
||||
const GameData* getGameData() const;
|
||||
Unit _unitFromIndex(int index);
|
||||
|
||||
virtual const Forceset& getForces() const override;
|
||||
virtual const Playerset& getPlayers() const override;
|
||||
virtual const Unitset& getAllUnits() const override;
|
||||
virtual const Unitset& getMinerals() const override;
|
||||
virtual const Unitset& getGeysers() const override;
|
||||
virtual const Unitset& getNeutralUnits() const override;
|
||||
|
||||
virtual const Unitset& getStaticMinerals() const override;
|
||||
virtual const Unitset& getStaticGeysers() const override;
|
||||
virtual const Unitset& getStaticNeutralUnits() const override;
|
||||
|
||||
virtual const Bulletset& getBullets() const override;
|
||||
virtual const Position::set& getNukeDots() const override;
|
||||
virtual const std::list< Event>& getEvents() const override;
|
||||
|
||||
virtual Force getForce(int forceID) const override;
|
||||
virtual Player getPlayer(int playerID) const override;
|
||||
virtual Unit getUnit(int unitID) const override;
|
||||
virtual Unit indexToUnit(int unitIndex) const override;
|
||||
virtual Region getRegion(int regionID) const override;
|
||||
|
||||
virtual GameType getGameType() const override;
|
||||
virtual int getLatency() const override;
|
||||
virtual int getFrameCount() const override;
|
||||
virtual int getReplayFrameCount() const override;
|
||||
virtual int getFPS() const override;
|
||||
virtual double getAverageFPS() const override;
|
||||
virtual BWAPI::Position getMousePosition() const override;
|
||||
virtual bool getMouseState(MouseButton button) const override;
|
||||
virtual bool getKeyState(Key key) const override;
|
||||
virtual BWAPI::Position getScreenPosition() const override;
|
||||
virtual void setScreenPosition(int x, int y) override;
|
||||
virtual void pingMinimap(int x, int y) override;
|
||||
|
||||
virtual bool isFlagEnabled(int flag) const override;
|
||||
virtual void enableFlag(int flag) override;
|
||||
virtual Unitset getUnitsInRectangle(int left, int top, int right, int bottom, const UnitFilter &pred = nullptr) const override;
|
||||
virtual Unit getClosestUnitInRectangle(Position center, const UnitFilter &pred = nullptr, int left = 0, int top = 0, int right = 999999, int bottom = 999999) const override;
|
||||
virtual Unit getBestUnit(const BestUnitFilter &best, const UnitFilter &pred, Position center = Positions::None, int radius = 999999) const override;
|
||||
virtual Error getLastError() const override;
|
||||
virtual bool setLastError(BWAPI::Error e = Errors::None) const override;
|
||||
|
||||
virtual int mapWidth() const override;
|
||||
virtual int mapHeight() const override;
|
||||
virtual std::string mapFileName() const override;
|
||||
virtual std::string mapPathName() const override;
|
||||
virtual std::string mapName() const override;
|
||||
virtual std::string mapHash() const override;
|
||||
|
||||
virtual bool isWalkable(int x, int y) const override;
|
||||
virtual int getGroundHeight(int x, int y) const override;
|
||||
virtual bool isBuildable(int x, int y, bool includeBuildings = false) const override;
|
||||
virtual bool isVisible(int x, int y) const override;
|
||||
virtual bool isExplored(int x, int y) const override;
|
||||
virtual bool hasCreep(int x, int y) const override;
|
||||
virtual bool hasPowerPrecise(int x, int y, UnitType unitType = UnitTypes::None ) const override;
|
||||
|
||||
virtual bool canBuildHere(TilePosition position, UnitType type, Unit builder = nullptr, bool checkExplored = false) override;
|
||||
virtual bool canMake(UnitType type, Unit builder = nullptr) const override;
|
||||
virtual bool canResearch(TechType type, Unit unit = nullptr, bool checkCanIssueCommandType = true) override;
|
||||
virtual bool canUpgrade(UpgradeType type, Unit unit = nullptr, bool checkCanIssueCommandType = true) override;
|
||||
virtual const TilePosition::set& getStartLocations() const override;
|
||||
|
||||
virtual void vPrintf(const char* format, va_list arg) override;
|
||||
virtual void vSendTextEx(bool toAllies, const char *format, va_list arg) override;
|
||||
|
||||
virtual bool isInGame() const override;
|
||||
virtual bool isMultiplayer() const override;
|
||||
virtual bool isBattleNet() const override;
|
||||
virtual bool isPaused() const override;
|
||||
virtual bool isReplay() const override;
|
||||
|
||||
virtual void pauseGame() override;
|
||||
virtual void resumeGame() override;
|
||||
virtual void leaveGame() override;
|
||||
virtual void restartGame() override;
|
||||
virtual void setLocalSpeed(int speed = -1) override;
|
||||
virtual bool issueCommand(const Unitset& units, UnitCommand command) override;
|
||||
virtual const Unitset& getSelectedUnits() const override;
|
||||
virtual Player self() const override;
|
||||
virtual Player enemy() const override;
|
||||
virtual Player neutral() const override;
|
||||
virtual Playerset& allies() override;
|
||||
virtual Playerset& enemies() override;
|
||||
virtual Playerset& observers() override;
|
||||
|
||||
virtual void setTextSize(Text::Size::Enum size = Text::Size::Default) override;
|
||||
virtual void vDrawText(CoordinateType::Enum ctype, int x, int y, const char *format, va_list arg) override;
|
||||
virtual void drawBox(CoordinateType::Enum ctype, int left, int top, int right, int bottom, Color color, bool isSolid = false) override;
|
||||
virtual void drawTriangle(CoordinateType::Enum ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false) override;
|
||||
virtual void drawCircle(CoordinateType::Enum ctype, int x, int y, int radius, Color color, bool isSolid = false) override;
|
||||
virtual void drawEllipse(CoordinateType::Enum ctype, int x, int y, int xrad, int yrad, Color color, bool isSolid = false) override;
|
||||
virtual void drawDot(CoordinateType::Enum ctype, int x, int y, Color color) override;
|
||||
virtual void drawLine(CoordinateType::Enum ctype, int x1, int y1, int x2, int y2, Color color) override;
|
||||
|
||||
virtual int getLatencyFrames() const override;
|
||||
virtual int getLatencyTime() const override;
|
||||
virtual int getRemainingLatencyFrames() const override;
|
||||
virtual int getRemainingLatencyTime() const override;
|
||||
virtual int getRevision() const override;
|
||||
virtual bool isDebug() const override;
|
||||
virtual bool isLatComEnabled() const override;
|
||||
virtual void setLatCom(bool isEnabled) override;
|
||||
virtual bool isGUIEnabled() const override;
|
||||
virtual void setGUI(bool enabled) override;
|
||||
virtual int getInstanceNumber() const override;
|
||||
virtual int getAPM(bool includeSelects = false) const override;
|
||||
virtual bool setMap(const char *mapFileName) override;
|
||||
virtual void setFrameSkip(int frameSkip) override;
|
||||
virtual bool hasPath(Position source, Position destination) const override;
|
||||
virtual bool setAlliance(BWAPI::Player player, bool allied = true, bool alliedVictory = true) override;
|
||||
virtual bool setVision(BWAPI::Player player, bool enabled = true) override;
|
||||
virtual int elapsedTime() const override;
|
||||
virtual void setCommandOptimizationLevel(int level) override;
|
||||
virtual int countdownTimer() const override;
|
||||
virtual const Regionset &getAllRegions() const override;
|
||||
virtual BWAPI::Region getRegionAt(int x, int y) const override;
|
||||
virtual int getLastEventTime() const override;
|
||||
virtual bool setRevealAll(bool reveal = true) override;
|
||||
};
|
||||
}
|
30
bwapi4-includes/BWAPI/Client/GameTable.h
Normal file
30
bwapi4-includes/BWAPI/Client/GameTable.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
struct GameInstance
|
||||
{
|
||||
GameInstance()
|
||||
: serverProcessID(0)
|
||||
, isConnected(false)
|
||||
, lastKeepAliveTime(0)
|
||||
{};
|
||||
GameInstance(unsigned int servID, bool connected, unsigned int lastAliveTime)
|
||||
: serverProcessID(servID)
|
||||
, isConnected(connected)
|
||||
, lastKeepAliveTime(lastAliveTime)
|
||||
{};
|
||||
|
||||
unsigned int serverProcessID;
|
||||
bool isConnected;
|
||||
//time_t lastKeepAliveTime;
|
||||
unsigned int lastKeepAliveTime;
|
||||
};
|
||||
struct GameTable
|
||||
{
|
||||
GameTable()
|
||||
{}
|
||||
static const int MAX_GAME_INSTANCES = 8;
|
||||
GameInstance gameInstances[MAX_GAME_INSTANCES];
|
||||
};
|
||||
}
|
59
bwapi4-includes/BWAPI/Client/PlayerData.h
Normal file
59
bwapi4-includes/BWAPI/Client/PlayerData.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
#pragma once
|
||||
|
||||
#include <BWAPI/UnitType.h>
|
||||
#include <BWAPI/UpgradeType.h>
|
||||
#include <BWAPI/TechType.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
struct PlayerData
|
||||
{
|
||||
char name[25];
|
||||
int race;
|
||||
int type;
|
||||
int force;
|
||||
bool isAlly[12];
|
||||
bool isEnemy[12];
|
||||
bool isNeutral;
|
||||
int startLocationX;
|
||||
int startLocationY;
|
||||
bool isVictorious;
|
||||
bool isDefeated;
|
||||
bool leftGame;
|
||||
bool isParticipating;
|
||||
|
||||
int minerals;
|
||||
int gas;
|
||||
int gatheredMinerals;
|
||||
int gatheredGas;
|
||||
int repairedMinerals;
|
||||
int repairedGas;
|
||||
int refundedMinerals;
|
||||
int refundedGas;
|
||||
int supplyTotal[3];
|
||||
int supplyUsed[3];
|
||||
|
||||
int allUnitCount[UnitTypes::Enum::MAX];
|
||||
int visibleUnitCount[UnitTypes::Enum::MAX];
|
||||
int completedUnitCount[UnitTypes::Enum::MAX];
|
||||
int deadUnitCount[UnitTypes::Enum::MAX];
|
||||
int killedUnitCount[UnitTypes::Enum::MAX];
|
||||
|
||||
int upgradeLevel[UpgradeTypes::Enum::MAX];
|
||||
bool hasResearched[TechTypes::Enum::MAX];
|
||||
bool isResearching[TechTypes::Enum::MAX];
|
||||
bool isUpgrading[UpgradeTypes::Enum::MAX];
|
||||
|
||||
int color;
|
||||
|
||||
int totalUnitScore;
|
||||
int totalKillScore;
|
||||
int totalBuildingScore;
|
||||
int totalRazingScore;
|
||||
int customScore;
|
||||
|
||||
int maxUpgradeLevel[UpgradeTypes::Enum::MAX];
|
||||
bool isResearchAvailable[TechTypes::Enum::MAX];
|
||||
bool isUnitAvailable[UnitTypes::Enum::MAX];
|
||||
};
|
||||
}
|
75
bwapi4-includes/BWAPI/Client/PlayerImpl.h
Normal file
75
bwapi4-includes/BWAPI/Client/PlayerImpl.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
#pragma once
|
||||
#include <BWAPI.h>
|
||||
#include "PlayerData.h"
|
||||
#include <string>
|
||||
|
||||
#include <BWAPI/Unitset.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class ForceInterface;
|
||||
typedef ForceInterface *Force;
|
||||
|
||||
class PlayerImpl : public PlayerInterface
|
||||
{
|
||||
private:
|
||||
int id;
|
||||
public:
|
||||
PlayerData* self;
|
||||
Unitset units;
|
||||
void clear();
|
||||
PlayerImpl(int id);
|
||||
virtual int getID() const override;
|
||||
virtual std::string getName() const override;
|
||||
virtual const Unitset &getUnits() const override;
|
||||
virtual Race getRace() const override;
|
||||
virtual PlayerType getType() const override;
|
||||
virtual Force getForce() const override;
|
||||
virtual bool isAlly(Player player) const override;
|
||||
virtual bool isEnemy(Player player) const override;
|
||||
virtual bool isNeutral() const override;
|
||||
virtual TilePosition getStartLocation() const override;
|
||||
virtual bool isVictorious() const override;
|
||||
virtual bool isDefeated() const override;
|
||||
virtual bool leftGame() const override;
|
||||
|
||||
virtual int minerals() const override;
|
||||
virtual int gas() const override;
|
||||
virtual int gatheredMinerals() const override;
|
||||
virtual int gatheredGas() const override;
|
||||
virtual int repairedMinerals() const override;
|
||||
virtual int repairedGas() const override;
|
||||
virtual int refundedMinerals() const override;
|
||||
virtual int refundedGas() const override;
|
||||
virtual int spentMinerals() const override;
|
||||
virtual int spentGas() const override;
|
||||
|
||||
virtual int supplyTotal(Race race = Races::None) const override;
|
||||
virtual int supplyUsed(Race race = Races::None) const override;
|
||||
|
||||
virtual int allUnitCount(UnitType unit) const override;
|
||||
virtual int visibleUnitCount(UnitType unit) const override;
|
||||
virtual int completedUnitCount(UnitType unit) const override;
|
||||
virtual int deadUnitCount(UnitType unit) const override;
|
||||
virtual int killedUnitCount(UnitType unit) const override;
|
||||
|
||||
virtual int getUpgradeLevel(UpgradeType upgrade) const override;
|
||||
virtual bool hasResearched(TechType tech) const override;
|
||||
virtual bool isResearching(TechType tech) const override;
|
||||
virtual bool isUpgrading(UpgradeType upgrade) const override;
|
||||
|
||||
virtual BWAPI::Color getColor() const override;
|
||||
|
||||
virtual int getUnitScore() const override;
|
||||
virtual int getKillScore() const override;
|
||||
virtual int getBuildingScore() const override;
|
||||
virtual int getRazingScore() const override;
|
||||
virtual int getCustomScore() const override;
|
||||
|
||||
virtual bool isObserver() const override;
|
||||
|
||||
virtual int getMaxUpgradeLevel(UpgradeType upgrade) const override;
|
||||
virtual bool isResearchAvailable(TechType tech) const override;
|
||||
virtual bool isUnitAvailable(UnitType unit) const override;
|
||||
};
|
||||
};
|
25
bwapi4-includes/BWAPI/Client/RegionData.h
Normal file
25
bwapi4-includes/BWAPI/Client/RegionData.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
struct RegionData
|
||||
{
|
||||
int id;
|
||||
int islandID;
|
||||
int center_x;
|
||||
int center_y;
|
||||
int priority;
|
||||
|
||||
// region boundary
|
||||
int leftMost;
|
||||
int rightMost;
|
||||
int topMost;
|
||||
int bottomMost;
|
||||
|
||||
int neighborCount;
|
||||
int neighbors[256];
|
||||
|
||||
bool isAccessible;
|
||||
bool isHigherGround;
|
||||
};
|
||||
};
|
39
bwapi4-includes/BWAPI/Client/RegionImpl.h
Normal file
39
bwapi4-includes/BWAPI/Client/RegionImpl.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Region.h>
|
||||
#include <BWAPI/Position.h>
|
||||
#include <BWAPI/Client/RegionData.h>
|
||||
|
||||
#include <BWAPI/Regionset.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class RegionImpl : public RegionInterface
|
||||
{
|
||||
private:
|
||||
RegionData *self;
|
||||
Regionset neighbors;
|
||||
BWAPI::Region closestAccessibleRgn;
|
||||
BWAPI::Region closestInaccessibleRgn;
|
||||
public:
|
||||
RegionImpl(int index);
|
||||
void setNeighbors();
|
||||
virtual int getID() const override;
|
||||
virtual int getRegionGroupID() const override;
|
||||
virtual BWAPI::Position getCenter() const override;
|
||||
virtual bool isHigherGround() const override;
|
||||
virtual int getDefensePriority() const override;
|
||||
virtual bool isAccessible() const override;
|
||||
|
||||
virtual const Regionset &getNeighbors() const override;
|
||||
|
||||
virtual int getBoundsLeft() const override;
|
||||
virtual int getBoundsTop() const override;
|
||||
virtual int getBoundsRight() const override;
|
||||
virtual int getBoundsBottom() const override;
|
||||
|
||||
virtual BWAPI::Region getClosestAccessibleRegion() const override;
|
||||
virtual BWAPI::Region getClosestInaccessibleRegion() const override;
|
||||
};
|
||||
|
||||
};
|
||||
|
48
bwapi4-includes/BWAPI/Client/Shape.h
Normal file
48
bwapi4-includes/BWAPI/Client/Shape.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
#pragma once
|
||||
#include "ShapeType.h"
|
||||
#include <BWAPI/CoordinateType.h>
|
||||
|
||||
namespace BWAPIC
|
||||
{
|
||||
struct Shape
|
||||
{
|
||||
Shape()
|
||||
:type(ShapeType::None)
|
||||
,ctype(BWAPI::CoordinateType::None)
|
||||
,x1(0)
|
||||
,y1(0)
|
||||
,x2(0)
|
||||
,y2(0)
|
||||
,extra1(0)
|
||||
,extra2(0)
|
||||
,color(0)
|
||||
,isSolid(false)
|
||||
{
|
||||
}
|
||||
|
||||
Shape(ShapeType::Enum _shapeType, BWAPI::CoordinateType::Enum _ctype, int _x1, int _y1, int _x2, int _y2, int _extra1, int _extra2, int _color, bool _isSolid)
|
||||
:type(_shapeType)
|
||||
,ctype(_ctype)
|
||||
,x1(_x1)
|
||||
,y1(_y1)
|
||||
,x2(_x2)
|
||||
,y2(_y2)
|
||||
,extra1(_extra1)
|
||||
,extra2(_extra2)
|
||||
,color(_color)
|
||||
,isSolid(_isSolid)
|
||||
{
|
||||
}
|
||||
|
||||
ShapeType::Enum type;
|
||||
BWAPI::CoordinateType::Enum ctype;
|
||||
int x1;
|
||||
int y1;
|
||||
int x2;
|
||||
int y2;
|
||||
int extra1;
|
||||
int extra2;
|
||||
int color;
|
||||
bool isSolid;
|
||||
};
|
||||
}
|
22
bwapi4-includes/BWAPI/Client/ShapeType.h
Normal file
22
bwapi4-includes/BWAPI/Client/ShapeType.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
/**
|
||||
* Used in UnitCommand
|
||||
*/
|
||||
|
||||
namespace BWAPIC
|
||||
{
|
||||
namespace ShapeType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
None,
|
||||
Text,
|
||||
Box,
|
||||
Triangle,
|
||||
Circle,
|
||||
Ellipse,
|
||||
Dot,
|
||||
Line
|
||||
};
|
||||
}
|
||||
}
|
20
bwapi4-includes/BWAPI/Client/UnitCommand.h
Normal file
20
bwapi4-includes/BWAPI/Client/UnitCommand.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <BWAPI.h>
|
||||
|
||||
/**
|
||||
* UnitOrder contains a single whole order
|
||||
*/
|
||||
|
||||
namespace BWAPIC
|
||||
{
|
||||
struct UnitCommand
|
||||
{
|
||||
BWAPI::UnitCommandType type;
|
||||
int unitIndex;
|
||||
int targetIndex;
|
||||
int x;
|
||||
int y;
|
||||
int extra;
|
||||
};
|
||||
}
|
111
bwapi4-includes/BWAPI/Client/UnitData.h
Normal file
111
bwapi4-includes/BWAPI/Client/UnitData.h
Normal file
|
@ -0,0 +1,111 @@
|
|||
#pragma once
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
struct UnitData
|
||||
{
|
||||
int clearanceLevel;
|
||||
int id;
|
||||
int player;
|
||||
int type;
|
||||
int positionX;
|
||||
int positionY;
|
||||
double angle;
|
||||
double velocityX;
|
||||
double velocityY;
|
||||
int hitPoints;
|
||||
int lastHitPoints;
|
||||
int shields;
|
||||
int energy;
|
||||
int resources;
|
||||
int resourceGroup;
|
||||
|
||||
int killCount;
|
||||
int acidSporeCount;
|
||||
int scarabCount;
|
||||
int spiderMineCount;
|
||||
int groundWeaponCooldown;
|
||||
int airWeaponCooldown;
|
||||
int spellCooldown;
|
||||
int defenseMatrixPoints;
|
||||
|
||||
int defenseMatrixTimer;
|
||||
int ensnareTimer;
|
||||
int irradiateTimer;
|
||||
int lockdownTimer;
|
||||
int maelstromTimer;
|
||||
int orderTimer;
|
||||
int plagueTimer;
|
||||
int removeTimer;
|
||||
int stasisTimer;
|
||||
int stimTimer;
|
||||
|
||||
int buildType;
|
||||
int trainingQueueCount;
|
||||
int trainingQueue[5];
|
||||
int tech;
|
||||
int upgrade;
|
||||
int remainingBuildTime;
|
||||
int remainingTrainTime;
|
||||
int remainingResearchTime;
|
||||
int remainingUpgradeTime;
|
||||
int buildUnit;
|
||||
|
||||
int target;
|
||||
int targetPositionX;
|
||||
int targetPositionY;
|
||||
int order;
|
||||
int orderTarget;
|
||||
int orderTargetPositionX;
|
||||
int orderTargetPositionY;
|
||||
int secondaryOrder;
|
||||
int rallyPositionX;
|
||||
int rallyPositionY;
|
||||
int rallyUnit;
|
||||
int addon;
|
||||
int nydusExit;
|
||||
int powerUp;
|
||||
|
||||
int transport;
|
||||
int carrier;
|
||||
int hatchery;
|
||||
|
||||
bool exists;
|
||||
bool hasNuke;
|
||||
bool isAccelerating;
|
||||
bool isAttacking;
|
||||
bool isAttackFrame;
|
||||
bool isBeingGathered;
|
||||
bool isBlind;
|
||||
bool isBraking;
|
||||
bool isBurrowed;
|
||||
int carryResourceType;
|
||||
bool isCloaked;
|
||||
bool isCompleted;
|
||||
bool isConstructing;
|
||||
bool isDetected;
|
||||
bool isGathering;
|
||||
bool isHallucination;
|
||||
bool isIdle;
|
||||
bool isInterruptible;
|
||||
bool isInvincible;
|
||||
bool isLifted;
|
||||
bool isMorphing;
|
||||
bool isMoving;
|
||||
bool isParasited;
|
||||
bool isSelected;
|
||||
bool isStartingAttack;
|
||||
bool isStuck;
|
||||
bool isTraining;
|
||||
bool isUnderStorm;
|
||||
bool isUnderDarkSwarm;
|
||||
bool isUnderDWeb;
|
||||
bool isPowered;
|
||||
bool isVisible[9];
|
||||
int buttonset;
|
||||
|
||||
int lastAttackerPlayer;
|
||||
bool recentlyAttacked;
|
||||
int replayID;
|
||||
};
|
||||
}
|
242
bwapi4-includes/BWAPI/Client/UnitImpl.h
Normal file
242
bwapi4-includes/BWAPI/Client/UnitImpl.h
Normal file
|
@ -0,0 +1,242 @@
|
|||
#pragma once
|
||||
#include <BWAPI.h>
|
||||
#include "UnitData.h"
|
||||
#include <string>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
|
||||
class UnitImpl : public UnitInterface
|
||||
{
|
||||
private:
|
||||
int id;
|
||||
UnitType initialType;
|
||||
int initialResources;
|
||||
int initialHitPoints;
|
||||
Position initialPosition;
|
||||
int lastCommandFrame;
|
||||
UnitCommand lastCommand;
|
||||
public:
|
||||
UnitData* self;
|
||||
Unitset connectedUnits;
|
||||
Unitset loadedUnits;
|
||||
void clear();
|
||||
void saveInitialState();
|
||||
|
||||
UnitImpl(int id);
|
||||
|
||||
virtual int getID() const override;
|
||||
virtual bool exists() const override;
|
||||
virtual int getReplayID() const override;
|
||||
virtual Player getPlayer() const override;
|
||||
virtual UnitType getType() const override;
|
||||
virtual Position getPosition() const override;
|
||||
virtual double getAngle() const override;
|
||||
virtual double getVelocityX() const override;
|
||||
virtual double getVelocityY() const override;
|
||||
virtual int getHitPoints() const override;
|
||||
virtual int getShields() const override;
|
||||
virtual int getEnergy() const override;
|
||||
virtual int getResources() const override;
|
||||
virtual int getResourceGroup() const override;
|
||||
|
||||
virtual int getLastCommandFrame() const override;
|
||||
virtual UnitCommand getLastCommand() const override;
|
||||
virtual BWAPI::Player getLastAttackingPlayer() const override;
|
||||
|
||||
virtual UnitType getInitialType() const override;
|
||||
virtual Position getInitialPosition() const override;
|
||||
virtual TilePosition getInitialTilePosition() const override;
|
||||
virtual int getInitialHitPoints() const override;
|
||||
virtual int getInitialResources() const override;
|
||||
|
||||
virtual int getKillCount() const override;
|
||||
virtual int getAcidSporeCount() const override;
|
||||
virtual int getInterceptorCount() const override;
|
||||
virtual int getScarabCount() const override;
|
||||
virtual int getSpiderMineCount() const override;
|
||||
virtual int getGroundWeaponCooldown() const override;
|
||||
virtual int getAirWeaponCooldown() const override;
|
||||
virtual int getSpellCooldown() const override;
|
||||
virtual int getDefenseMatrixPoints() const override;
|
||||
|
||||
virtual int getDefenseMatrixTimer() const override;
|
||||
virtual int getEnsnareTimer() const override;
|
||||
virtual int getIrradiateTimer() const override;
|
||||
virtual int getLockdownTimer() const override;
|
||||
virtual int getMaelstromTimer() const override;
|
||||
virtual int getOrderTimer() const override;
|
||||
virtual int getPlagueTimer() const override;
|
||||
virtual int getRemoveTimer() const override;
|
||||
virtual int getStasisTimer() const override;
|
||||
virtual int getStimTimer() const override;
|
||||
|
||||
virtual UnitType getBuildType() const override;
|
||||
virtual UnitType::set getTrainingQueue() const override;
|
||||
virtual TechType getTech() const override;
|
||||
virtual UpgradeType getUpgrade() const override;
|
||||
virtual int getRemainingBuildTime() const override;
|
||||
virtual int getRemainingTrainTime() const override;
|
||||
virtual int getRemainingResearchTime() const override;
|
||||
virtual int getRemainingUpgradeTime() const override;
|
||||
virtual Unit getBuildUnit() const override;
|
||||
|
||||
virtual Unit getTarget() const override;
|
||||
virtual Position getTargetPosition() const override;
|
||||
virtual Order getOrder() const override;
|
||||
virtual Unit getOrderTarget() const override;
|
||||
virtual Position getOrderTargetPosition() const override;
|
||||
virtual Order getSecondaryOrder() const override;
|
||||
virtual Position getRallyPosition() const override;
|
||||
virtual Unit getRallyUnit() const override;
|
||||
virtual Unit getAddon() const override;
|
||||
virtual Unit getNydusExit() const override;
|
||||
virtual Unit getPowerUp() const override;
|
||||
|
||||
virtual Unit getTransport() const override;
|
||||
virtual Unitset getLoadedUnits() const override;
|
||||
virtual Unit getCarrier() const override;
|
||||
virtual Unitset getInterceptors() const override;
|
||||
virtual Unit getHatchery() const override;
|
||||
virtual Unitset getLarva() const override;
|
||||
|
||||
virtual bool hasNuke() const override;
|
||||
virtual bool isAccelerating() const override;
|
||||
virtual bool isAttackFrame() const override;
|
||||
virtual bool isAttacking() const override;
|
||||
virtual bool isBeingGathered() const override;
|
||||
virtual bool isBeingHealed() const override;
|
||||
virtual bool isBlind() const override;
|
||||
virtual bool isBraking() const override;
|
||||
virtual bool isBurrowed() const override;
|
||||
virtual bool isCarryingGas() const override;
|
||||
virtual bool isCarryingMinerals() const override;
|
||||
virtual bool isCloaked() const override;
|
||||
virtual bool isCompleted() const override;
|
||||
virtual bool isConstructing() const override;
|
||||
virtual bool isDetected() const override;
|
||||
virtual bool isGatheringGas() const override;
|
||||
virtual bool isGatheringMinerals() const override;
|
||||
virtual bool isHallucination() const override;
|
||||
virtual bool isIdle() const override;
|
||||
virtual bool isInterruptible() const override;
|
||||
virtual bool isInvincible() const override;
|
||||
virtual bool isLifted() const override;
|
||||
virtual bool isMorphing() const override;
|
||||
virtual bool isMoving() const override;
|
||||
virtual bool isParasited() const override;
|
||||
virtual bool isSelected() const override;
|
||||
virtual bool isStartingAttack() const override;
|
||||
virtual bool isStuck() const override;
|
||||
virtual bool isTraining() const override;
|
||||
virtual bool isUnderAttack() const override;
|
||||
virtual bool isUnderDarkSwarm() const override;
|
||||
virtual bool isUnderDisruptionWeb() const override;
|
||||
virtual bool isUnderStorm() const override;
|
||||
virtual bool isPowered() const override;
|
||||
virtual bool isVisible(Player player = nullptr) const override;
|
||||
virtual bool isTargetable() const override;
|
||||
|
||||
virtual bool canCommand() const override;
|
||||
virtual bool canCommandGrouped(bool checkCommandibility = true) const override;
|
||||
virtual bool canTargetUnit(Unit targetUnit, bool checkCommandibility = true) const override;
|
||||
|
||||
virtual bool canAttack(bool checkCommandibility = true) const override;
|
||||
virtual bool canAttack(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canAttackGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canAttackGrouped(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canAttackMove(bool checkCommandibility = true) const override;
|
||||
virtual bool canAttackMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canAttackUnit(bool checkCommandibility = true) const override;
|
||||
virtual bool canAttackUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canAttackUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canAttackUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canBuild(bool checkCommandibility = true) const override;
|
||||
virtual bool canBuild(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canBuild(UnitType uType, BWAPI::TilePosition tilePos, bool checkTargetUnitType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canBuildAddon(bool checkCommandibility = true) const override;
|
||||
virtual bool canBuildAddon(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canTrain(bool checkCommandibility = true) const override;
|
||||
virtual bool canTrain(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canMorph(bool checkCommandibility = true) const override;
|
||||
virtual bool canMorph(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canResearch(bool checkCommandibility = true) const override;
|
||||
virtual bool canResearch(TechType type, bool checkCanIssueCommandType = true) const override;
|
||||
virtual bool canUpgrade(bool checkCommandibility = true) const override;
|
||||
virtual bool canUpgrade(UpgradeType type, bool checkCanIssueCommandType = true) const override;
|
||||
virtual bool canSetRallyPoint(bool checkCommandibility = true) const override;
|
||||
virtual bool canSetRallyPoint(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canSetRallyPosition(bool checkCommandibility = true) const override;
|
||||
virtual bool canSetRallyUnit(bool checkCommandibility = true) const override;
|
||||
virtual bool canSetRallyUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canMove(bool checkCommandibility = true) const override;
|
||||
virtual bool canMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canPatrol(bool checkCommandibility = true) const override;
|
||||
virtual bool canPatrolGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canFollow(bool checkCommandibility = true) const override;
|
||||
virtual bool canFollow(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canGather(bool checkCommandibility = true) const override;
|
||||
virtual bool canGather(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canReturnCargo(bool checkCommandibility = true) const override;
|
||||
virtual bool canHoldPosition(bool checkCommandibility = true) const override;
|
||||
virtual bool canStop(bool checkCommandibility = true) const override;
|
||||
virtual bool canRepair(bool checkCommandibility = true) const override;
|
||||
virtual bool canRepair(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canBurrow(bool checkCommandibility = true) const override;
|
||||
virtual bool canUnburrow(bool checkCommandibility = true) const override;
|
||||
virtual bool canCloak(bool checkCommandibility = true) const override;
|
||||
virtual bool canDecloak(bool checkCommandibility = true) const override;
|
||||
virtual bool canSiege(bool checkCommandibility = true) const override;
|
||||
virtual bool canUnsiege(bool checkCommandibility = true) const override;
|
||||
virtual bool canLift(bool checkCommandibility = true) const override;
|
||||
virtual bool canLand(bool checkCommandibility = true) const override;
|
||||
virtual bool canLand(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canLoad(bool checkCommandibility = true) const override;
|
||||
virtual bool canLoad(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canUnloadWithOrWithoutTarget(bool checkCommandibility = true) const override;
|
||||
virtual bool canUnloadAtPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canUnload(bool checkCommandibility = true) const override;
|
||||
virtual bool canUnload(Unit targetUnit, bool checkCanTargetUnit = true, bool checkPosition = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canUnloadAll(bool checkCommandibility = true) const override;
|
||||
virtual bool canUnloadAllPosition(bool checkCommandibility = true) const override;
|
||||
virtual bool canUnloadAllPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClick(bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClick(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClickGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClickGrouped(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClickPosition(bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClickPositionGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClickUnit(bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClickUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClickUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canRightClickUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canHaltConstruction(bool checkCommandibility = true) const override;
|
||||
virtual bool canCancelConstruction(bool checkCommandibility = true) const override;
|
||||
virtual bool canCancelAddon(bool checkCommandibility = true) const override;
|
||||
virtual bool canCancelTrain(bool checkCommandibility = true) const override;
|
||||
virtual bool canCancelTrainSlot(bool checkCommandibility = true) const override;
|
||||
virtual bool canCancelTrainSlot(int slot, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canCancelMorph(bool checkCommandibility = true) const override;
|
||||
virtual bool canCancelResearch(bool checkCommandibility = true) const override;
|
||||
virtual bool canCancelUpgrade(bool checkCommandibility = true) const override;
|
||||
virtual bool canUseTechWithOrWithoutTarget(bool checkCommandibility = true) const override;
|
||||
virtual bool canUseTechWithOrWithoutTarget(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canUseTech(BWAPI::TechType tech, PositionOrUnit target = nullptr, bool checkCanTargetUnit = true, bool checkTargetsType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canUseTechWithoutTarget(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canUseTechUnit(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canUseTechUnit(BWAPI::TechType tech, Unit targetUnit, bool checkCanTargetUnit = true, bool checkTargetsUnits = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canUseTechPosition(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canUseTechPosition(BWAPI::TechType tech, Position target, bool checkTargetsPositions = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canPlaceCOP(bool checkCommandibility = true) const override;
|
||||
virtual bool canPlaceCOP(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
|
||||
virtual bool canIssueCommandType(BWAPI::UnitCommandType ct, bool checkCommandibility = true) const override;
|
||||
virtual bool canIssueCommandTypeGrouped(BWAPI::UnitCommandType ct, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canIssueCommand(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanBuildUnitType = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
|
||||
virtual bool canIssueCommandGrouped(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
|
||||
|
||||
virtual bool issueCommand(UnitCommand command) override;
|
||||
};
|
||||
}
|
209
bwapi4-includes/BWAPI/Color.h
Normal file
209
bwapi4-includes/BWAPI/Color.h
Normal file
|
@ -0,0 +1,209 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
/// The Color object is used in drawing routines to specify the color to use.
|
||||
///
|
||||
/// @note Starcraft uses a 256 color palette for rendering. Thus, the colors available are
|
||||
/// limited to this palette.
|
||||
class Color : public Type<Color, 255>
|
||||
{
|
||||
public:
|
||||
/// A constructor that uses the color at the specified palette index.
|
||||
///
|
||||
/// @param id
|
||||
/// The index of the color in the 256-color palette.
|
||||
Color(int id = 0);
|
||||
|
||||
/// A constructor that uses the color index in the palette that is closest to the given rgb
|
||||
/// values. On its first call, the colors in the palette will be sorted for fast indexing.
|
||||
///
|
||||
/// @note This function computes the distance of the RGB values and may not be accurate.
|
||||
///
|
||||
/// @param red
|
||||
/// The amount of red.
|
||||
/// @param green
|
||||
/// The amount of green.
|
||||
/// @param blue
|
||||
/// The amount of blue.
|
||||
Color(int red, int green, int blue);
|
||||
|
||||
/// Retrieves the red component of the color.
|
||||
///
|
||||
/// @returns integer containing the value of the red component.
|
||||
int red() const;
|
||||
|
||||
/// Retrieves the green component of the color.
|
||||
///
|
||||
/// @returns integer containing the value of the green component.
|
||||
int green() const;
|
||||
|
||||
/// Retrieves the blue component of the color.
|
||||
///
|
||||
/// @returns integer containing the value of the blue component.
|
||||
int blue() const;
|
||||
};
|
||||
|
||||
/// Namespace containing known colors.
|
||||
namespace Colors
|
||||
{
|
||||
/// The default color for Player 1.
|
||||
extern const Color Red;
|
||||
|
||||
/// The default color for Player 2.
|
||||
extern const Color Blue;
|
||||
|
||||
/// The default color for Player 3.
|
||||
extern const Color Teal;
|
||||
|
||||
/// The default color for Player 4.
|
||||
extern const Color Purple;
|
||||
|
||||
/// The default color for Player 5.
|
||||
extern const Color Orange;
|
||||
|
||||
/// The default color for Player 6.
|
||||
extern const Color Brown;
|
||||
|
||||
/// The default color for Player 7.
|
||||
extern const Color White;
|
||||
|
||||
/// The default color for Player 8.
|
||||
extern const Color Yellow;
|
||||
|
||||
/// The alternate color for Player 7 on Ice tilesets.
|
||||
extern const Color Green;
|
||||
|
||||
/// The default color for Neutral (Player 12).
|
||||
extern const Color Cyan;
|
||||
|
||||
/// The color black
|
||||
extern const Color Black;
|
||||
|
||||
/// The color grey
|
||||
extern const Color Grey;
|
||||
}
|
||||
|
||||
/// Namespace containing text formatting codes. Such codes are used in calls to Game::drawText,
|
||||
/// Game::printf, and Broodwar::operator<<
|
||||
namespace Text
|
||||
{
|
||||
// Enumeration of text formatting codes
|
||||
enum Enum
|
||||
{
|
||||
/// Uses the previous color that was specified before the current one.
|
||||
Previous = 1,
|
||||
|
||||
/// Uses the default blueish color. This color is used in standard game messages.
|
||||
Default = 2,
|
||||
|
||||
/// A solid yellow. This yellow is used in notifications and is also the default color when
|
||||
/// printing text to Broodwar.
|
||||
Yellow = 3,
|
||||
|
||||
/// A bright white. This is used for timers.
|
||||
White = 4,
|
||||
|
||||
/// A dark grey. This color code will override all color formatting that follows.
|
||||
Grey = 5,
|
||||
|
||||
/// A deep red. This color code is used for error messages.
|
||||
Red = 6,
|
||||
|
||||
/// A solid green. This color is used for sent messages and resource counters.
|
||||
Green = 7,
|
||||
|
||||
/// A type of red. This color is used to color the name of the red player.
|
||||
BrightRed = 8,
|
||||
|
||||
/// This code hides all text and formatting that follows.
|
||||
Invisible = 11,
|
||||
|
||||
/// A deep blue. This color is used to color the name of the blue player.
|
||||
Blue = 14,
|
||||
|
||||
/// A teal color. This color is used to color the name of the teal player.
|
||||
Teal = 15,
|
||||
|
||||
/// A deep purple. This color is used to color the name of the purple player.
|
||||
Purple = 16,
|
||||
|
||||
/// A solid orange. This color is used to color the name of the orange player.
|
||||
Orange = 17,
|
||||
|
||||
/// An alignment directive that aligns the text to the right side of the screen.
|
||||
Align_Right = 18,
|
||||
|
||||
/// An alignment directive that aligns the text to the center of the screen.
|
||||
Align_Center = 19,
|
||||
|
||||
/// @copydoc Invisible
|
||||
Invisible2 = 20,
|
||||
|
||||
/// A dark brown. This color is used to color the name of the brown player.
|
||||
Brown = 21,
|
||||
|
||||
/// A dirty white. This color is used to color the name of the white player.
|
||||
PlayerWhite = 22,
|
||||
|
||||
/// A deep yellow. This color is used to color the name of the yellow player.
|
||||
PlayerYellow = 23,
|
||||
|
||||
/// A dark green. This color is used to color the name of the green player.
|
||||
DarkGreen = 24,
|
||||
|
||||
/// A bright yellow.
|
||||
LightYellow = 25,
|
||||
|
||||
/// A cyan color. Similar to Default.
|
||||
Cyan = 26,
|
||||
|
||||
/// A tan color.
|
||||
Tan = 27,
|
||||
|
||||
/// A dark blueish color.
|
||||
GreyBlue = 28,
|
||||
|
||||
/// A type of Green.
|
||||
GreyGreen = 29,
|
||||
|
||||
/// A different type of Cyan.
|
||||
GreyCyan = 30,
|
||||
|
||||
/// A bright blue color.
|
||||
Turquoise = 31
|
||||
};
|
||||
|
||||
/// Namespace containing text sizes.
|
||||
namespace Size
|
||||
{
|
||||
/// Enumeration of available text sizes
|
||||
enum Enum
|
||||
{
|
||||
/// The smallest text size in the game.
|
||||
Small,
|
||||
|
||||
/// The standard text size, used for most things in the game such as chat messages.
|
||||
Default,
|
||||
|
||||
/// A larger text size. This size is used for the in-game countdown timer seen in @CTF and @UMS game types.
|
||||
Large,
|
||||
|
||||
/// The largest text size in the game.
|
||||
Huge
|
||||
};
|
||||
}
|
||||
|
||||
/// Standard output stream operator for text formatting codes. This is used to correctly
|
||||
/// format the codes for output.
|
||||
///
|
||||
/// @param out
|
||||
/// Reference to destination output stream.
|
||||
/// @param t
|
||||
/// Reference to the Text formatting code to insert into the output stream.
|
||||
///
|
||||
/// @returns Reference to the \p out parameter that was passed in.
|
||||
std::ostream &operator << (std::ostream &out, const Text::Enum &t);
|
||||
}
|
||||
}
|
92
bwapi4-includes/BWAPI/ComparisonFilter.h
Normal file
92
bwapi4-includes/BWAPI/ComparisonFilter.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
#pragma once
|
||||
// Prevent warnings if someone includes windows.h
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
|
||||
#include "UnaryFilter.h"
|
||||
|
||||
#define BWAPI_COMPARE_FILTER_OP(op) UnaryFilter<PType> operator op(const RType &cmp) const \
|
||||
{ return [=](PType v)->bool{ return (*this)(v) op cmp; }; }
|
||||
|
||||
#define BWAPI_ARITHMATIC_FILTER_OP(op) template <typename T> \
|
||||
CompareFilter<PType,RType,std::function<RType(PType)> > operator op(const T &other) const \
|
||||
{ return [=](PType v)->int{ return (*this)(v) op other(v); }; } \
|
||||
CompareFilter<PType,RType,std::function<RType(PType)> > operator op(RType other) const \
|
||||
{ return [=](PType v)->int{ return (*this)(v) op other; }; }
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
/// The CompareFilter is a container in which a stored function predicate returns a value.
|
||||
/// Arithmetic and bitwise operators will return a new CompareFilter that applies the operation
|
||||
/// to the result of the original functor. If any relational operators are used, then it creates
|
||||
/// a UnaryFilter that returns the result of the operation.
|
||||
///
|
||||
/// @tparam PType
|
||||
/// The parameter type, which is the type passed into the functor.
|
||||
/// @tparam RType (optional)
|
||||
/// The functor's return type. It is int by default.
|
||||
/// @tparam Container (optional)
|
||||
/// Storage container for the function predicate. It is std::function<RType(PType)> by default.
|
||||
template < typename PType, typename RType=int, class Container = std::function<RType(PType)> >
|
||||
class CompareFilter
|
||||
{
|
||||
private:
|
||||
Container pred;
|
||||
public:
|
||||
// ctor
|
||||
template <typename T>
|
||||
CompareFilter(const T &predicate) : pred(predicate) {}
|
||||
|
||||
// Default copy/move ctor/assign and dtor
|
||||
|
||||
// Comparison operators
|
||||
BWAPI_COMPARE_FILTER_OP(==);
|
||||
BWAPI_COMPARE_FILTER_OP(!=);
|
||||
BWAPI_COMPARE_FILTER_OP(<=);
|
||||
BWAPI_COMPARE_FILTER_OP(>=);
|
||||
BWAPI_COMPARE_FILTER_OP(<);
|
||||
BWAPI_COMPARE_FILTER_OP(>);
|
||||
|
||||
// Arithmetic operators
|
||||
BWAPI_ARITHMATIC_FILTER_OP(+);
|
||||
BWAPI_ARITHMATIC_FILTER_OP(-);
|
||||
BWAPI_ARITHMATIC_FILTER_OP(|);
|
||||
BWAPI_ARITHMATIC_FILTER_OP(&);
|
||||
BWAPI_ARITHMATIC_FILTER_OP(*);
|
||||
BWAPI_ARITHMATIC_FILTER_OP(^);
|
||||
|
||||
// Division
|
||||
template <typename T>
|
||||
CompareFilter<PType,RType,std::function<RType(PType)> > operator /(const T &other) const
|
||||
{
|
||||
return [=](PType v)->int{ int rval = other(v);
|
||||
return rval == 0 ? std::numeric_limits<int>::max() : (*this)(v) / rval;
|
||||
};
|
||||
};
|
||||
|
||||
// Modulus
|
||||
template <typename T>
|
||||
CompareFilter<PType,RType,std::function<RType(PType)> > operator %(const T &other) const
|
||||
{
|
||||
return [=](PType v)->int{ int rval = other(v);
|
||||
return rval == 0 ? 0 : (*this)(v) % rval;
|
||||
};
|
||||
};
|
||||
|
||||
// call
|
||||
inline RType operator()(PType u) const
|
||||
{
|
||||
return pred(u);
|
||||
};
|
||||
|
||||
inline bool isValid() const
|
||||
{
|
||||
return (bool)pred;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
364
bwapi4-includes/BWAPI/ConstVectorset.h
Normal file
364
bwapi4-includes/BWAPI/ConstVectorset.h
Normal file
|
@ -0,0 +1,364 @@
|
|||
#pragma once
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
#include <algorithm>
|
||||
|
||||
#include "Vectorset_iterator.h"
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
template<typename T>
|
||||
class Vectorset;
|
||||
|
||||
/// The Vectorset is a class template designed specifically for trivial classes or PODs and
|
||||
/// performance. It mimics the usage of various stl containers (specifically the Vector and Set)
|
||||
/// in order to replace them. The Vectorset is designed for BWAPI usage and is recommended,
|
||||
/// especially if stl containers are causing a bottleneck in your bot's code.
|
||||
///
|
||||
/// @warning The Vectorset should only be used with objects that have a trivial destructor and
|
||||
/// trivial copy constructor. Objects in the Vectorset should not do any memory management
|
||||
/// or the behaviour will be undefined. Use with caution.
|
||||
///
|
||||
/// @note The Vectorset will only free memory when the object is destroyed.
|
||||
///
|
||||
/// @see std::vector, std::set
|
||||
template<typename T>
|
||||
class ConstVectorset
|
||||
{
|
||||
#ifndef SWIG
|
||||
static_assert(
|
||||
#ifdef _MSC_VER
|
||||
std::has_trivial_copy<T>::value &&
|
||||
std::has_trivial_copy_constructor<T>::value &&
|
||||
std::has_trivial_destructor<T>::value,
|
||||
#else
|
||||
std::is_trivially_copyable<T>::value &&
|
||||
std::is_trivially_constructible<T>::value &&
|
||||
std::is_trivially_destructible<T>::value,
|
||||
#endif
|
||||
"Vectorset can only be used with classes that have a trivial destructor and trivial copy constructor.");
|
||||
#endif
|
||||
|
||||
private:
|
||||
ConstVectorset();
|
||||
public:
|
||||
/// The iterator is used to traverse the elements in the set. It is used the same way as in
|
||||
/// the stl containers.
|
||||
typedef BWAPI::VSetIterator<T> iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
|
||||
// ----------------------------------------------------------------- Constructors
|
||||
/// This constructor uses an existing array of objects and copies them into the vector.
|
||||
/// The Vectorset will allocate only enough memory to copy the array's contents.
|
||||
///
|
||||
/// @param pArray
|
||||
/// Pointer to an array of objects of type T.
|
||||
/// @param arrSize
|
||||
/// The number of elements contained in the given array.
|
||||
///
|
||||
/// @note Duplicate entries are not removed.
|
||||
ConstVectorset(const void *pArray, size_t arrSize = 0)
|
||||
: pStartArr( (T*)pArray )
|
||||
, pEndArr( (T*)pArray + arrSize )
|
||||
{};
|
||||
|
||||
ConstVectorset(const ConstVectorset &other)
|
||||
: pStartArr(other.pStartArr)
|
||||
, pEndArr(other.pEndArr)
|
||||
{}
|
||||
|
||||
// ----------------------------------------------------------------- Operators
|
||||
/// Creates a new Vectorset containing all elements of the current Vectorset with all elements
|
||||
/// of the other Vectorset appended on to it.
|
||||
///
|
||||
/// @param other
|
||||
/// The other Vectorset of the same type to use in combination.
|
||||
///
|
||||
/// @returns A new Vectorset containing the contents of both this and other.
|
||||
///
|
||||
/// @note Duplicate entries are not removed.
|
||||
///
|
||||
/// @see operator|
|
||||
Vectorset<T> operator +(const ConstVectorset<T> &other) const
|
||||
{
|
||||
Vectorset<T> vcopy(this->size() + other.size());
|
||||
vcopy.push_back(*this);
|
||||
vcopy.push_back(other);
|
||||
return vcopy;
|
||||
};
|
||||
Vectorset<T> operator +(const T &val) const
|
||||
{
|
||||
Vectorset<T> vcopy(this->size() + 1);
|
||||
vcopy.push_back(*this);
|
||||
vcopy.push_back(val);
|
||||
return vcopy;
|
||||
};
|
||||
|
||||
/// Creates a new Vectorset containing all elements of the current Vectorset and all elements
|
||||
/// of the other Vectorset with duplicates removed.
|
||||
///
|
||||
/// @param other
|
||||
/// The other Vectorset of the same type to use in combination.
|
||||
///
|
||||
/// @returns A new Vectorset containing the contents of both this and other.
|
||||
Vectorset<T> operator |(const ConstVectorset<T> &other) const
|
||||
{
|
||||
Vectorset<T> vcopy(this->size() + other.size());
|
||||
vcopy.push_back(*this);
|
||||
vcopy.insert(other);
|
||||
return vcopy;
|
||||
};
|
||||
Vectorset<T> operator |(const T &val) const
|
||||
{
|
||||
Vectorset<T> vcopy(this->size() + 1);
|
||||
vcopy.push_back(*this);
|
||||
vcopy.insert(val);
|
||||
return vcopy;
|
||||
};
|
||||
|
||||
/// Compares this Vectorset with another Vectorset of the same type.
|
||||
///
|
||||
/// @param other
|
||||
/// A Vectorset of the same type to use for comparison.
|
||||
///
|
||||
/// @retval true if the other Vectorset is exactly the same as this one.
|
||||
/// @retval false if at least one element in this Vectorset is not found in the other, or if
|
||||
/// they are not in the exact same positions.
|
||||
///
|
||||
/// @note This simply calls memcmp.
|
||||
bool operator ==(const ConstVectorset<T> &other) const
|
||||
{
|
||||
if ( this->empty() && other.empty() )
|
||||
return true;
|
||||
|
||||
if ( this->size() != other.size() )
|
||||
return true;
|
||||
|
||||
return memcmp( this->pStartArr, other.pStartArr, this->size()*sizeof(T) ) == 0;
|
||||
};
|
||||
|
||||
/// Retrieves a pointer to the raw data in the Vectorset.
|
||||
///
|
||||
/// @note Vectorset data is simply an array.
|
||||
///
|
||||
/// @returns A pointer to the Vectorset's array data.
|
||||
inline operator void*() const
|
||||
{
|
||||
return this->pStartArr;
|
||||
};
|
||||
|
||||
/// Used as a macro to check if the Vectorset is empty.
|
||||
///
|
||||
/// @retval true if the Vectorset is not empty.
|
||||
/// @retval false if the Vectorset is empty.
|
||||
inline operator bool() const
|
||||
{
|
||||
return !this->empty();
|
||||
};
|
||||
|
||||
/// Array indexing operator.
|
||||
///
|
||||
/// @TODO Needs to be modified
|
||||
///
|
||||
/// @param index
|
||||
/// The array index in the Vectorset to retrieve the value from.
|
||||
inline T operator [](unsigned int index) const
|
||||
{
|
||||
if ( index < this->size() )
|
||||
return this->pStartArr[index];
|
||||
return pStartArr[0];
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------- Custom const functions
|
||||
/// This function checks if an element exists in the Vectorset.
|
||||
///
|
||||
/// @param element
|
||||
/// The value to search for in the Vectorset.
|
||||
///
|
||||
/// @retval true if the element is in the Vectorset.
|
||||
/// @retval false if the element was not found.
|
||||
bool exists(const T &element) const
|
||||
{
|
||||
return this->find(element) != this->end();
|
||||
};
|
||||
|
||||
/// This macro is used to choose a random value from a Vectorset. It returns a default T
|
||||
/// value if the Vectorset is empty.
|
||||
///
|
||||
/// @TODO needs to be modified
|
||||
///
|
||||
/// @note This function calls the rand() function. A call to srand() should be used for
|
||||
/// initialization.
|
||||
///
|
||||
/// @see rand()
|
||||
T rand() const
|
||||
{
|
||||
size_t size = this->size();
|
||||
switch ( size )
|
||||
{
|
||||
case 0:
|
||||
return T();
|
||||
case 1:
|
||||
return this->pStartArr[0];
|
||||
case 2:
|
||||
return this->pStartArr[::rand()%2];
|
||||
case 4:
|
||||
return this->pStartArr[::rand()%4];
|
||||
case 8:
|
||||
return this->pStartArr[::rand()%8];
|
||||
case 16:
|
||||
return this->pStartArr[::rand()%16];
|
||||
case 32:
|
||||
return this->pStartArr[::rand()%32];
|
||||
case 64:
|
||||
return this->pStartArr[::rand()%64];
|
||||
case 128:
|
||||
return this->pStartArr[::rand()%128];
|
||||
case 256:
|
||||
return this->pStartArr[::rand()%256];
|
||||
case 512:
|
||||
return this->pStartArr[::rand()%512];
|
||||
case 1024:
|
||||
return this->pStartArr[::rand()%1024];
|
||||
case 2048:
|
||||
return this->pStartArr[::rand()%2048];
|
||||
}
|
||||
return this->pStartArr[::rand()%size];
|
||||
};
|
||||
|
||||
/// Iterates the Vectorset and retrieves the best entry using two callback procedures. The
|
||||
/// first returning the value to compare, the second being a binary comparison.
|
||||
///
|
||||
/// @param cmpValue
|
||||
/// A functor taking one argument, T, and returning a value to compare.
|
||||
///
|
||||
/// @param cmpProc
|
||||
/// A functor taking two values, (the ones returned by cmpValue), and returns a boolean
|
||||
/// indicating that the first value passed in is the new best value.
|
||||
///
|
||||
/// @retval NULL If the Vectorset is empty.
|
||||
/// @returns A T representing the best in the Vectorset.
|
||||
template < typename _V, typename _C >
|
||||
T getBest(const _V &cmpValue, const _C &cmpProc) const
|
||||
{
|
||||
// Return if empty
|
||||
if ( this->empty() )
|
||||
return NULL;
|
||||
|
||||
// retrieve a value as the placeholder for the "best"
|
||||
T best = this->front();
|
||||
int bestVal = cmpValue(best);
|
||||
|
||||
// Iterate all (remaining) elements
|
||||
for ( auto i = this->begin()+1; i != this->end(); ++i )
|
||||
{
|
||||
// Retrieve new value
|
||||
int newVal = cmpValue(*i);
|
||||
|
||||
// Set as new best if new value > best
|
||||
if ( cmpProc(newVal, bestVal) )
|
||||
{
|
||||
bestVal = newVal;
|
||||
best = *i;
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
};
|
||||
/// @copydoc getBest
|
||||
/// @see getBest
|
||||
template < typename _V >
|
||||
T most(const _V &cmpValue) const
|
||||
{
|
||||
return this->getBest( std::forward<_V>(cmpValue), [](const int &v1, const int &v2)->bool{ return v1 > v2; } );
|
||||
};
|
||||
/// @copydoc getBest
|
||||
/// @see getBest
|
||||
template < typename _V >
|
||||
T least(const _V &cmpValue) const
|
||||
{
|
||||
return this->getBest( std::forward<_V>(cmpValue), [](const int &v1, const int &v2)->bool{ return v1 < v2; } );
|
||||
};
|
||||
|
||||
/// Calculates a total by applying a functor to each element and adding what the functor
|
||||
/// returns.
|
||||
///
|
||||
/// @param valProc
|
||||
/// A unary functor that takes T as a parameter and returns the integer used to add to
|
||||
/// the total.
|
||||
///
|
||||
/// @returns An integer representing the sum of results from \p valProc applied to every
|
||||
/// element in the Vectorset.
|
||||
template < typename _V >
|
||||
int total(const _V &valProc) const
|
||||
{
|
||||
int sum = 0;
|
||||
for ( auto i = this->begin(); i != this->end(); ++i )
|
||||
sum += valProc(*i);
|
||||
return sum;
|
||||
};
|
||||
// ----------------------------------------------------------------- stl spinoff const functions
|
||||
/// Retrieves the number of elements currently in the Vectorset.
|
||||
///
|
||||
/// @returns The number of elements contained in this Vectorset.
|
||||
///
|
||||
/// @note For efficiency it is recommended to use empty() to check if the Vectorset has 0
|
||||
/// elements.
|
||||
///
|
||||
/// @see empty
|
||||
inline size_t size() const
|
||||
{
|
||||
return ((size_t)this->pEndArr - (size_t)this->pStartArr)/sizeof(T);
|
||||
};
|
||||
|
||||
/// Checks if the Vectorset is empty.
|
||||
///
|
||||
/// @retval true if the Vectorset is empty.
|
||||
/// @retval false if the Vectorset contains elements.
|
||||
inline bool empty() const
|
||||
{
|
||||
return this->pEndArr == this->pStartArr;
|
||||
};
|
||||
|
||||
// iterators
|
||||
inline iterator begin() const
|
||||
{
|
||||
return this->pStartArr;
|
||||
};
|
||||
inline reverse_iterator rbegin() const
|
||||
{
|
||||
return this->pEndArr - 1;
|
||||
};
|
||||
inline iterator end() const
|
||||
{
|
||||
return this->pEndArr;
|
||||
};
|
||||
inline reverse_iterator rend() const
|
||||
{
|
||||
return this->pStartArr - 1;
|
||||
};
|
||||
inline T front() const
|
||||
{
|
||||
return *this->begin();
|
||||
};
|
||||
inline T back() const
|
||||
{
|
||||
return *this->rbegin();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------- stl macros
|
||||
inline iterator find(const T &value) const
|
||||
{
|
||||
return std::find(this->begin(), this->end(), value);
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
protected:
|
||||
// Variables
|
||||
T *pStartArr; // ptr to beginning of array
|
||||
T *pEndArr; // ptr to last element + 1
|
||||
};
|
||||
|
||||
}
|
||||
|
6
bwapi4-includes/BWAPI/Constants.h
Normal file
6
bwapi4-includes/BWAPI/Constants.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
namespace BWAPI
|
||||
{
|
||||
/** Used for converting between TilePosition coordinates and Position coordinates. */
|
||||
#define TILE_SIZE 32
|
||||
}
|
14
bwapi4-includes/BWAPI/CoordinateType.h
Normal file
14
bwapi4-includes/BWAPI/CoordinateType.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace CoordinateType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
None = 0, /**< A default value for uninitialized coordinate types. */
|
||||
Screen = 1, /**< (0,0) corresponds to the top left corner of the screen. */
|
||||
Map = 2, /**< (0,0) corresponds to the top left corner of the map. */
|
||||
Mouse = 3, /**< (0,0) corresponds to the tip of the mouse . */
|
||||
};
|
||||
}
|
||||
}
|
52
bwapi4-includes/BWAPI/DamageType.h
Normal file
52
bwapi4-includes/BWAPI/DamageType.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace DamageTypes
|
||||
{
|
||||
/// Enumeration of damage types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of damage types
|
||||
enum Enum
|
||||
{
|
||||
Independent,
|
||||
Explosive,
|
||||
Concussive,
|
||||
Normal,
|
||||
Ignore_Armor,
|
||||
None,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
}
|
||||
}
|
||||
class DamageType : public Type<DamageType, DamageTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
DamageType(int id = DamageTypes::Enum::None);
|
||||
};
|
||||
/// Namespace containing damage types
|
||||
namespace DamageTypes
|
||||
{
|
||||
/// Retrieves the set of all the DamageTypes.
|
||||
///
|
||||
/// @returns Set of DamageTypes.
|
||||
const DamageType::const_set& allDamageTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const DamageType x
|
||||
BWAPI_DECL(Independent);
|
||||
BWAPI_DECL(Explosive);
|
||||
BWAPI_DECL(Concussive);
|
||||
BWAPI_DECL(Normal);
|
||||
BWAPI_DECL(Ignore_Armor);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
103
bwapi4-includes/BWAPI/Error.h
Normal file
103
bwapi4-includes/BWAPI/Error.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
#include <string>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class UnitType;
|
||||
|
||||
namespace Errors
|
||||
{
|
||||
/// Enumeration of Error types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of Error types
|
||||
enum Enum
|
||||
{
|
||||
Unit_Does_Not_Exist,
|
||||
Unit_Not_Visible,
|
||||
Unit_Not_Owned,
|
||||
Unit_Busy,
|
||||
Incompatible_UnitType,
|
||||
Incompatible_TechType,
|
||||
Incompatible_State,
|
||||
Already_Researched,
|
||||
Fully_Upgraded,
|
||||
Currently_Researching,
|
||||
Currently_Upgrading,
|
||||
Insufficient_Minerals,
|
||||
Insufficient_Gas,
|
||||
Insufficient_Supply,
|
||||
Insufficient_Energy,
|
||||
Insufficient_Tech,
|
||||
Insufficient_Ammo,
|
||||
Insufficient_Space,
|
||||
Invalid_Tile_Position,
|
||||
Unbuildable_Location,
|
||||
Unreachable_Location,
|
||||
Out_Of_Range,
|
||||
Unable_To_Hit,
|
||||
Access_Denied,
|
||||
File_Not_Found,
|
||||
Invalid_Parameter,
|
||||
None,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/// The Error object is generally used to determine why certain functions in BWAPI have failed.
|
||||
///
|
||||
/// For example, you may not have enough resources to construct a unit.
|
||||
/// @see Game::getLastError, Game::setLastError
|
||||
class Error : public Type<Error, Errors::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
Error(int id = Errors::Enum::None);
|
||||
};
|
||||
|
||||
/// Namespace containing error codes
|
||||
namespace Errors
|
||||
{
|
||||
/// Retrieves the set of all the error codes.
|
||||
///
|
||||
/// @returns Set of error types.
|
||||
const Error::const_set& allErrors();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const Error x
|
||||
BWAPI_DECL(Unit_Does_Not_Exist);
|
||||
BWAPI_DECL(Unit_Not_Visible);
|
||||
BWAPI_DECL(Unit_Not_Owned);
|
||||
BWAPI_DECL(Unit_Busy);
|
||||
BWAPI_DECL(Incompatible_UnitType);
|
||||
BWAPI_DECL(Incompatible_TechType);
|
||||
BWAPI_DECL(Incompatible_State);
|
||||
BWAPI_DECL(Already_Researched);
|
||||
BWAPI_DECL(Fully_Upgraded);
|
||||
BWAPI_DECL(Currently_Researching);
|
||||
BWAPI_DECL(Currently_Upgrading);
|
||||
BWAPI_DECL(Insufficient_Minerals);
|
||||
BWAPI_DECL(Insufficient_Gas);
|
||||
BWAPI_DECL(Insufficient_Supply);
|
||||
BWAPI_DECL(Insufficient_Energy);
|
||||
BWAPI_DECL(Insufficient_Tech);
|
||||
BWAPI_DECL(Insufficient_Ammo);
|
||||
BWAPI_DECL(Insufficient_Space);
|
||||
BWAPI_DECL(Invalid_Tile_Position);
|
||||
BWAPI_DECL(Unbuildable_Location);
|
||||
BWAPI_DECL(Unreachable_Location);
|
||||
BWAPI_DECL(Out_Of_Range);
|
||||
BWAPI_DECL(Unable_To_Hit);
|
||||
BWAPI_DECL(Access_Denied);
|
||||
BWAPI_DECL(File_Not_Found);
|
||||
BWAPI_DECL(Invalid_Parameter);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
64
bwapi4-includes/BWAPI/Event.h
Normal file
64
bwapi4-includes/BWAPI/Event.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Position.h>
|
||||
#include <BWAPI/EventType.h>
|
||||
#include <BWAPI/Unit.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forward Declarations
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
Event();
|
||||
~Event();
|
||||
Event(const Event& other);
|
||||
Event(Event&& other);
|
||||
Event& operator=(const Event& other);
|
||||
Event& operator=(Event &&other);
|
||||
bool operator==(const Event& other) const;
|
||||
static Event MatchStart();
|
||||
static Event MatchEnd(bool isWinner);
|
||||
static Event MatchFrame();
|
||||
static Event MenuFrame();
|
||||
static Event SendText(const char* text = nullptr);
|
||||
static Event ReceiveText(Player player, const char* text = nullptr);
|
||||
static Event PlayerLeft(Player player);
|
||||
static Event NukeDetect(Position target);
|
||||
static Event UnitDiscover(Unit unit);
|
||||
static Event UnitEvade(Unit unit);
|
||||
static Event UnitShow(Unit unit);
|
||||
static Event UnitHide(Unit unit);
|
||||
static Event UnitCreate(Unit unit);
|
||||
static Event UnitDestroy(Unit unit);
|
||||
static Event UnitMorph(Unit unit);
|
||||
static Event UnitRenegade(Unit unit);
|
||||
static Event SaveGame(const char* gameName = nullptr);
|
||||
static Event UnitComplete(Unit unit);
|
||||
EventType::Enum getType() const;
|
||||
Position getPosition() const;
|
||||
const std::string& getText() const;
|
||||
Unit getUnit() const;
|
||||
Player getPlayer() const;
|
||||
bool isWinner() const;
|
||||
|
||||
Event& setType(EventType::Enum type);
|
||||
Event& setPosition(Position position);
|
||||
Event& setText(const char* text);
|
||||
Event& setUnit(Unit unit);
|
||||
Event& setPlayer(Player player);
|
||||
Event& setWinner(bool isWinner);
|
||||
//static Event TriggerAction();
|
||||
private:
|
||||
Position position;
|
||||
std::string *text;
|
||||
Unit unit;
|
||||
Player player;
|
||||
EventType::Enum type;
|
||||
bool winner;
|
||||
};
|
||||
}
|
30
bwapi4-includes/BWAPI/EventType.h
Normal file
30
bwapi4-includes/BWAPI/EventType.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace EventType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
MatchStart,
|
||||
MatchEnd,
|
||||
MatchFrame,
|
||||
MenuFrame,
|
||||
SendText,
|
||||
ReceiveText,
|
||||
PlayerLeft,
|
||||
NukeDetect,
|
||||
UnitDiscover,
|
||||
UnitEvade,
|
||||
UnitShow,
|
||||
UnitHide,
|
||||
UnitCreate,
|
||||
UnitDestroy,
|
||||
UnitMorph,
|
||||
UnitRenegade,
|
||||
SaveGame,
|
||||
UnitComplete,
|
||||
//TriggerAction,
|
||||
None
|
||||
};
|
||||
}
|
||||
}
|
89
bwapi4-includes/BWAPI/ExplosionType.h
Normal file
89
bwapi4-includes/BWAPI/ExplosionType.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace ExplosionTypes
|
||||
{
|
||||
/// Enumeration of explosion types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of explosion types
|
||||
enum Enum
|
||||
{
|
||||
None = 0,
|
||||
Normal,
|
||||
Radial_Splash,
|
||||
Enemy_Splash,
|
||||
Lockdown,
|
||||
Nuclear_Missile,
|
||||
Parasite,
|
||||
Broodlings,
|
||||
EMP_Shockwave,
|
||||
Irradiate,
|
||||
Ensnare,
|
||||
Plague,
|
||||
Stasis_Field,
|
||||
Dark_Swarm,
|
||||
Consume,
|
||||
Yamato_Gun,
|
||||
Restoration,
|
||||
Disruption_Web,
|
||||
Corrosive_Acid,
|
||||
Mind_Control,
|
||||
Feedback,
|
||||
Optical_Flare,
|
||||
Maelstrom,
|
||||
Unused,
|
||||
Air_Splash,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
};
|
||||
};
|
||||
class ExplosionType : public Type<ExplosionType, ExplosionTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
ExplosionType(int id = ExplosionTypes::Enum::None);
|
||||
};
|
||||
/// Namespace containing explosion types
|
||||
namespace ExplosionTypes
|
||||
{
|
||||
/// Retrieves the set of all ExplosionTypes.
|
||||
///
|
||||
/// @returns Set of ExplosionTypes.
|
||||
const ExplosionType::const_set& allExplosionTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const ExplosionType x
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Normal);
|
||||
BWAPI_DECL(Radial_Splash);
|
||||
BWAPI_DECL(Enemy_Splash);
|
||||
BWAPI_DECL(Lockdown);
|
||||
BWAPI_DECL(Nuclear_Missile);
|
||||
BWAPI_DECL(Parasite);
|
||||
BWAPI_DECL(Broodlings);
|
||||
BWAPI_DECL(EMP_Shockwave);
|
||||
BWAPI_DECL(Irradiate);
|
||||
BWAPI_DECL(Ensnare);
|
||||
BWAPI_DECL(Plague);
|
||||
BWAPI_DECL(Stasis_Field);
|
||||
BWAPI_DECL(Dark_Swarm);
|
||||
BWAPI_DECL(Consume);
|
||||
BWAPI_DECL(Yamato_Gun);
|
||||
BWAPI_DECL(Restoration);
|
||||
BWAPI_DECL(Disruption_Web);
|
||||
BWAPI_DECL(Corrosive_Acid);
|
||||
BWAPI_DECL(Mind_Control);
|
||||
BWAPI_DECL(Feedback);
|
||||
BWAPI_DECL(Optical_Flare);
|
||||
BWAPI_DECL(Maelstrom);
|
||||
BWAPI_DECL(Air_Splash);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
194
bwapi4-includes/BWAPI/Filters.h
Normal file
194
bwapi4-includes/BWAPI/Filters.h
Normal file
|
@ -0,0 +1,194 @@
|
|||
#pragma once
|
||||
#include <BWAPI/UnaryFilter.h>
|
||||
#include <BWAPI/ComparisonFilter.h>
|
||||
#include <BWAPI/BestFilter.h>
|
||||
#include <BWAPI/UnitSizeType.h>
|
||||
#include <BWAPI/UpgradeType.h>
|
||||
#include <BWAPI/WeaponType.h>
|
||||
#include <BWAPI/Order.h>
|
||||
#include <BWAPI/Race.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// forwards
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
class UnitType;
|
||||
class UnitInterface;
|
||||
typedef UnitInterface *Unit;
|
||||
|
||||
// typedefs
|
||||
typedef UnaryFilter<Unit > UnitFilter;
|
||||
typedef UnaryFilter<Unit ,bool (*)(Unit )> PtrUnitFilter;
|
||||
typedef BestFilter<Unit > BestUnitFilter;
|
||||
typedef CompareFilter<Unit ,int,int(*)(Unit )> PtrIntCompareUnitFilter;
|
||||
|
||||
namespace Filter
|
||||
{
|
||||
// presets
|
||||
extern const PtrUnitFilter IsTransport;
|
||||
|
||||
extern const PtrUnitFilter CanProduce;
|
||||
extern const PtrUnitFilter CanAttack;
|
||||
extern const PtrUnitFilter CanMove;
|
||||
extern const PtrUnitFilter IsFlyer;
|
||||
extern const PtrUnitFilter IsFlying;
|
||||
extern const PtrUnitFilter RegeneratesHP;
|
||||
extern const PtrUnitFilter IsSpellcaster;
|
||||
extern const PtrUnitFilter HasPermanentCloak;
|
||||
extern const PtrUnitFilter IsOrganic;
|
||||
extern const PtrUnitFilter IsMechanical;
|
||||
extern const PtrUnitFilter IsRobotic;
|
||||
extern const PtrUnitFilter IsDetector;
|
||||
extern const PtrUnitFilter IsResourceContainer;
|
||||
extern const PtrUnitFilter IsResourceDepot;
|
||||
extern const PtrUnitFilter IsRefinery;
|
||||
extern const PtrUnitFilter IsWorker;
|
||||
extern const PtrUnitFilter RequiresPsi;
|
||||
extern const PtrUnitFilter RequiresCreep;
|
||||
extern const PtrUnitFilter IsBurrowable;
|
||||
extern const PtrUnitFilter IsCloakable;
|
||||
extern const PtrUnitFilter IsBuilding;
|
||||
extern const PtrUnitFilter IsAddon;
|
||||
extern const PtrUnitFilter IsFlyingBuilding;
|
||||
extern const PtrUnitFilter IsNeutral;
|
||||
extern const PtrUnitFilter IsHero;
|
||||
extern const PtrUnitFilter IsPowerup;
|
||||
extern const PtrUnitFilter IsBeacon;
|
||||
extern const PtrUnitFilter IsFlagBeacon;
|
||||
extern const PtrUnitFilter IsSpecialBuilding;
|
||||
extern const PtrUnitFilter IsSpell;
|
||||
extern const PtrUnitFilter ProducesLarva;
|
||||
extern const PtrUnitFilter IsMineralField;
|
||||
extern const PtrUnitFilter IsCritter;
|
||||
extern const PtrUnitFilter CanBuildAddon;
|
||||
|
||||
extern const PtrIntCompareUnitFilter HP;
|
||||
extern const PtrIntCompareUnitFilter MaxHP;
|
||||
extern const PtrIntCompareUnitFilter HP_Percent;
|
||||
|
||||
extern const PtrIntCompareUnitFilter Shields;
|
||||
extern const PtrIntCompareUnitFilter MaxShields;
|
||||
extern const PtrIntCompareUnitFilter Shields_Percent;
|
||||
|
||||
extern const PtrIntCompareUnitFilter Energy;
|
||||
extern const PtrIntCompareUnitFilter MaxEnergy;
|
||||
extern const PtrIntCompareUnitFilter Energy_Percent;
|
||||
|
||||
extern const PtrIntCompareUnitFilter Armor;
|
||||
extern const CompareFilter<Unit ,UpgradeType,UpgradeType (*)(Unit )> ArmorUpgrade;
|
||||
|
||||
extern const PtrIntCompareUnitFilter MineralPrice;
|
||||
extern const PtrIntCompareUnitFilter GasPrice;
|
||||
extern const PtrIntCompareUnitFilter BuildTime;
|
||||
|
||||
extern const PtrIntCompareUnitFilter SupplyRequired;
|
||||
extern const PtrIntCompareUnitFilter SupplyProvided;
|
||||
|
||||
extern const PtrIntCompareUnitFilter SpaceRequired;
|
||||
extern const PtrIntCompareUnitFilter SpaceRemaining;
|
||||
extern const PtrIntCompareUnitFilter SpaceProvided;
|
||||
|
||||
extern const PtrIntCompareUnitFilter BuildScore;
|
||||
extern const PtrIntCompareUnitFilter DestroyScore;
|
||||
|
||||
extern const CompareFilter<Unit ,double,double (*)(Unit )> TopSpeed;
|
||||
extern const PtrIntCompareUnitFilter SightRange;
|
||||
extern const PtrIntCompareUnitFilter WeaponCooldown;
|
||||
extern const CompareFilter<Unit ,UnitSizeType,UnitSizeType (*)(Unit )> SizeType;
|
||||
|
||||
extern const CompareFilter<Unit ,WeaponType,WeaponType (*)(Unit )> GroundWeapon;
|
||||
extern const CompareFilter<Unit ,WeaponType,WeaponType (*)(Unit )> AirWeapon;
|
||||
|
||||
extern const CompareFilter<Unit ,UnitType,UnitType (*)(Unit )> GetType;
|
||||
extern const CompareFilter<Unit ,Race,Race (*)(Unit )> GetRace;
|
||||
extern const CompareFilter<Unit ,Player,Player (*)(Unit )> GetPlayer;
|
||||
|
||||
extern const PtrIntCompareUnitFilter Resources;
|
||||
extern const PtrIntCompareUnitFilter ResourceGroup;
|
||||
extern const PtrIntCompareUnitFilter AcidSporeCount;
|
||||
extern const PtrIntCompareUnitFilter InterceptorCount;
|
||||
extern const PtrIntCompareUnitFilter ScarabCount;
|
||||
extern const PtrIntCompareUnitFilter SpiderMineCount;
|
||||
extern const PtrIntCompareUnitFilter MaxWeaponCooldown;
|
||||
extern const PtrIntCompareUnitFilter SpellCooldown;
|
||||
|
||||
extern const PtrIntCompareUnitFilter DefenseMatrixPoints;
|
||||
extern const PtrIntCompareUnitFilter DefenseMatrixTime;
|
||||
extern const PtrIntCompareUnitFilter EnsnareTime;
|
||||
extern const PtrIntCompareUnitFilter IrradiateTime;
|
||||
extern const PtrIntCompareUnitFilter LockdownTime;
|
||||
extern const PtrIntCompareUnitFilter MaelstromTime;
|
||||
extern const PtrIntCompareUnitFilter OrderTime;
|
||||
extern const PtrIntCompareUnitFilter PlagueTimer;
|
||||
extern const PtrIntCompareUnitFilter RemoveTime;
|
||||
extern const PtrIntCompareUnitFilter StasisTime;
|
||||
extern const PtrIntCompareUnitFilter StimTime;
|
||||
extern const CompareFilter<Unit ,UnitType,UnitType (*)(Unit )> BuildType;
|
||||
extern const PtrIntCompareUnitFilter RemainingBuildTime;
|
||||
extern const PtrIntCompareUnitFilter RemainingTrainTime;
|
||||
extern const CompareFilter<Unit ,Unit ,Unit (*)(Unit )> Target;
|
||||
extern const CompareFilter<Unit ,Order,Order (*)(Unit )> CurrentOrder;
|
||||
extern const CompareFilter<Unit ,Order,Order (*)(Unit )> SecondaryOrder;
|
||||
extern const CompareFilter<Unit ,Unit ,Unit (*)(Unit )> OrderTarget;
|
||||
extern const PtrIntCompareUnitFilter GetLeft;
|
||||
extern const PtrIntCompareUnitFilter GetTop;
|
||||
extern const PtrIntCompareUnitFilter GetRight;
|
||||
extern const PtrIntCompareUnitFilter GetBottom;
|
||||
|
||||
extern const PtrUnitFilter Exists;
|
||||
extern const PtrUnitFilter IsAttacking;
|
||||
extern const PtrUnitFilter IsBeingConstructed;
|
||||
extern const PtrUnitFilter IsBeingGathered;
|
||||
extern const PtrUnitFilter IsBeingHealed;
|
||||
extern const PtrUnitFilter IsBlind;
|
||||
extern const PtrUnitFilter IsBraking;
|
||||
extern const PtrUnitFilter IsBurrowed;
|
||||
extern const PtrUnitFilter IsCarryingGas;
|
||||
extern const PtrUnitFilter IsCarryingMinerals;
|
||||
extern const PtrUnitFilter IsCarryingSomething;
|
||||
extern const PtrUnitFilter IsCloaked;
|
||||
extern const PtrUnitFilter IsCompleted;
|
||||
extern const PtrUnitFilter IsConstructing;
|
||||
extern const PtrUnitFilter IsDefenseMatrixed;
|
||||
extern const PtrUnitFilter IsDetected;
|
||||
extern const PtrUnitFilter IsEnsnared;
|
||||
extern const PtrUnitFilter IsFollowing;
|
||||
extern const PtrUnitFilter IsGatheringGas;
|
||||
extern const PtrUnitFilter IsGatheringMinerals;
|
||||
extern const PtrUnitFilter IsHallucination;
|
||||
extern const PtrUnitFilter IsHoldingPosition;
|
||||
extern const PtrUnitFilter IsIdle;
|
||||
extern const PtrUnitFilter IsInterruptible;
|
||||
extern const PtrUnitFilter IsInvincible;
|
||||
extern const PtrUnitFilter IsIrradiated;
|
||||
extern const PtrUnitFilter IsLifted;
|
||||
extern const PtrUnitFilter IsLoaded;
|
||||
extern const PtrUnitFilter IsLockedDown;
|
||||
extern const PtrUnitFilter IsMaelstrommed;
|
||||
extern const PtrUnitFilter IsMorphing;
|
||||
extern const PtrUnitFilter IsMoving;
|
||||
extern const PtrUnitFilter IsParasited;
|
||||
extern const PtrUnitFilter IsPatrolling;
|
||||
extern const PtrUnitFilter IsPlagued;
|
||||
extern const PtrUnitFilter IsRepairing;
|
||||
extern const PtrUnitFilter IsResearching;
|
||||
extern const PtrUnitFilter IsSieged;
|
||||
extern const PtrUnitFilter IsStartingAttack;
|
||||
extern const PtrUnitFilter IsStasised;
|
||||
extern const PtrUnitFilter IsStimmed;
|
||||
extern const PtrUnitFilter IsStuck;
|
||||
extern const PtrUnitFilter IsTraining;
|
||||
extern const PtrUnitFilter IsUnderAttack;
|
||||
extern const PtrUnitFilter IsUnderDarkSwarm;
|
||||
extern const PtrUnitFilter IsUnderDisruptionWeb;
|
||||
extern const PtrUnitFilter IsUnderStorm;
|
||||
extern const PtrUnitFilter IsPowered;
|
||||
extern const PtrUnitFilter IsVisible;
|
||||
|
||||
extern const PtrUnitFilter IsEnemy;
|
||||
extern const PtrUnitFilter IsAlly;
|
||||
extern const PtrUnitFilter IsOwned;
|
||||
}
|
||||
}
|
||||
|
18
bwapi4-includes/BWAPI/Flag.h
Normal file
18
bwapi4-includes/BWAPI/Flag.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace Flag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/** Enable to get information about all units on the map, not just the visible units. */
|
||||
CompleteMapInformation = 0,
|
||||
|
||||
/** Enable to get information from the user (what units are selected, chat messages the user enters,
|
||||
* etc) */
|
||||
UserInput = 1,
|
||||
|
||||
Max
|
||||
};
|
||||
}
|
||||
}
|
63
bwapi4-includes/BWAPI/Force.h
Normal file
63
bwapi4-includes/BWAPI/Force.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <BWAPI/Interface.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forward Declarations
|
||||
class Playerset;
|
||||
|
||||
class ForceInterface;
|
||||
typedef ForceInterface *Force;
|
||||
|
||||
/// The Force class is used to get information about each force in a match. Normally this is
|
||||
/// considered a team.
|
||||
///
|
||||
/// @note It is not called a team because players on the same force do not necessarily need
|
||||
/// to be allied at the beginning of a match.
|
||||
class ForceInterface : public Interface<ForceInterface>
|
||||
{
|
||||
protected:
|
||||
virtual ~ForceInterface() {};
|
||||
public :
|
||||
/// Retrieves the unique ID that represents this Force.
|
||||
///
|
||||
/// @returns
|
||||
/// An integer containing the ID for the Force.
|
||||
virtual int getID() const = 0;
|
||||
|
||||
/// Retrieves the name of the Force.
|
||||
///
|
||||
/// @returns
|
||||
/// A std::string object containing the name of the force.
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// BWAPI::Force myForce = BWAPI::Broodwar->self()->getForce();
|
||||
/// if ( myForce->getName() == "Observers" )
|
||||
/// BWAPI::Broodwar << "Looks like we're observing a match." << std::endl;
|
||||
/// @endcode
|
||||
///
|
||||
/// @note Don't forget to use std::string::c_str() when passing this parameter to
|
||||
/// Game::sendText and other variadic functions.
|
||||
virtual std::string getName() const = 0;
|
||||
|
||||
/// Retrieves the set of players that belong to this Force.
|
||||
///
|
||||
/// @returns
|
||||
/// A Playerset object containing the players that are part of this Force.
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// // Get the enemy force, but make sure we have an enemy
|
||||
/// BWAPI::Force myEnemyForce = BWAPI::Broodwar->enemy() ? BWAPI::Broodwar->enemy()->getForce() : nullptr;
|
||||
/// if ( myEnemyForce != nullptr )
|
||||
/// {
|
||||
/// Broodwar << "The allies of my enemy are..." << std::endl;
|
||||
/// for ( auto i = myEnemyForce.begin(); i != myEnemyForce.end(); ++i )
|
||||
/// Broodwar << " - " << i->getName() << std::endl;
|
||||
/// }
|
||||
/// @endcode
|
||||
virtual Playerset getPlayers() const = 0;
|
||||
};
|
||||
}
|
25
bwapi4-includes/BWAPI/Forceset.h
Normal file
25
bwapi4-includes/BWAPI/Forceset.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Vectorset.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forward Declarations
|
||||
class ForceInterface;
|
||||
typedef ForceInterface *Force;
|
||||
class Playerset;
|
||||
|
||||
/// A container that holds a group of Forces.
|
||||
///
|
||||
/// @see BWAPI::Force, BWAPI::Vectorset
|
||||
class Forceset : public Vectorset<BWAPI::Force>
|
||||
{
|
||||
public:
|
||||
Forceset(size_t initialSize = 5);
|
||||
Forceset(const Forceset &other);
|
||||
Forceset(Forceset &&other);
|
||||
|
||||
/// @copydoc ForceInterface::getPlayers
|
||||
Playerset getPlayers() const;
|
||||
};
|
||||
}
|
||||
|
1531
bwapi4-includes/BWAPI/Game.h
Normal file
1531
bwapi4-includes/BWAPI/Game.h
Normal file
File diff suppressed because it is too large
Load diff
73
bwapi4-includes/BWAPI/GameType.h
Normal file
73
bwapi4-includes/BWAPI/GameType.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace GameTypes
|
||||
{
|
||||
/// Enumeration of game types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of game types
|
||||
enum Enum
|
||||
{
|
||||
None = 0,
|
||||
Custom, // Warcraft III
|
||||
Melee,
|
||||
Free_For_All,
|
||||
One_on_One,
|
||||
Capture_The_Flag,
|
||||
Greed,
|
||||
Slaughter,
|
||||
Sudden_Death,
|
||||
Ladder,
|
||||
Use_Map_Settings,
|
||||
Team_Melee,
|
||||
Team_Free_For_All,
|
||||
Team_Capture_The_Flag,
|
||||
Unknown_0x0E,
|
||||
Top_vs_Bottom,
|
||||
Iron_Man_Ladder, // Warcraft II
|
||||
|
||||
Pro_Gamer_League = 32, // Not valid
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
};
|
||||
};
|
||||
class GameType : public Type<GameType, GameTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
GameType(int id = GameTypes::Enum::None);
|
||||
};
|
||||
/// Namespace containing game types
|
||||
namespace GameTypes
|
||||
{
|
||||
/// Retrieves the set of all the valid GameTypes.
|
||||
///
|
||||
/// @returns Set of available GameTypes.
|
||||
const GameType::const_set& allGameTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const GameType x
|
||||
BWAPI_DECL(Melee);
|
||||
BWAPI_DECL(Free_For_All);
|
||||
BWAPI_DECL(One_on_One);
|
||||
BWAPI_DECL(Capture_The_Flag);
|
||||
BWAPI_DECL(Greed);
|
||||
BWAPI_DECL(Slaughter);
|
||||
BWAPI_DECL(Sudden_Death);
|
||||
BWAPI_DECL(Ladder);
|
||||
BWAPI_DECL(Use_Map_Settings);
|
||||
BWAPI_DECL(Team_Melee);
|
||||
BWAPI_DECL(Team_Free_For_All);
|
||||
BWAPI_DECL(Team_Capture_The_Flag);
|
||||
BWAPI_DECL(Top_vs_Bottom);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
247
bwapi4-includes/BWAPI/Input.h
Normal file
247
bwapi4-includes/BWAPI/Input.h
Normal file
|
@ -0,0 +1,247 @@
|
|||
#pragma once
|
||||
namespace BWAPI
|
||||
{
|
||||
enum MouseButton
|
||||
{
|
||||
M_LEFT = 0,
|
||||
M_RIGHT,
|
||||
M_MIDDLE,
|
||||
M_MAX,
|
||||
};
|
||||
|
||||
enum Key
|
||||
{
|
||||
K_LBUTTON = 0x01,
|
||||
K_RBUTTON,
|
||||
K_CANCEL,
|
||||
K_MBUTTON,
|
||||
K_XBUTTON1,
|
||||
K_XBUTTON2,
|
||||
__UNDEFINED_7,
|
||||
K_BACK,
|
||||
K_TAB,
|
||||
__RESERVED_A,
|
||||
__RESERVED_B,
|
||||
K_CLEAR,
|
||||
K_RETURN,
|
||||
__UNDEFINED_E,
|
||||
__UNDEFINED_F,
|
||||
K_SHIFT,
|
||||
K_CONTROL,
|
||||
K_MENU,
|
||||
K_PAUSE,
|
||||
K_CAPITAL,
|
||||
K_KANA,
|
||||
K_UNDEFINED_16,
|
||||
K_JUNJA,
|
||||
K_FINAL,
|
||||
K_KANJI,
|
||||
__UNDEFINED_1A,
|
||||
K_ESCAPE,
|
||||
K_CONVERT,
|
||||
K_NONCONVERT,
|
||||
K_ACCEPT,
|
||||
K_MODECHANGE,
|
||||
K_SPACE,
|
||||
K_PRIOR,
|
||||
K_NEXT,
|
||||
K_END,
|
||||
K_HOME,
|
||||
K_LEFT,
|
||||
K_UP,
|
||||
K_RIGHT,
|
||||
K_DOWN,
|
||||
K_SELECT,
|
||||
K_PRINT,
|
||||
K_EXECUTE,
|
||||
K_SNAPSHOT,
|
||||
K_INSERT,
|
||||
K_DELETE,
|
||||
K_HELP,
|
||||
K_0,
|
||||
K_1,
|
||||
K_2,
|
||||
K_3,
|
||||
K_4,
|
||||
K_5,
|
||||
K_6,
|
||||
K_7,
|
||||
K_8,
|
||||
K_9,
|
||||
__UNDEFINED_3A,
|
||||
__UNDEFINED_3B,
|
||||
__UNDEFINED_3C,
|
||||
__UNDEFINED_3D,
|
||||
__UNDEFINED_3E,
|
||||
__UNDEFINED_3F,
|
||||
__UNDEFINED_40,
|
||||
K_A,
|
||||
K_B,
|
||||
K_C,
|
||||
K_D,
|
||||
K_E,
|
||||
K_F,
|
||||
K_G,
|
||||
K_H,
|
||||
K_I,
|
||||
K_J,
|
||||
K_K,
|
||||
K_L,
|
||||
K_M,
|
||||
K_N,
|
||||
K_O,
|
||||
K_P,
|
||||
K_Q,
|
||||
K_R,
|
||||
K_S,
|
||||
K_T,
|
||||
K_U,
|
||||
K_V,
|
||||
K_W,
|
||||
K_X,
|
||||
K_Y,
|
||||
K_Z,
|
||||
K_LWIN,
|
||||
K_RWIN,
|
||||
K_APPS,
|
||||
__RESERVED_5E,
|
||||
K_SLEEP,
|
||||
K_NUMPAD0,
|
||||
K_NUMPAD1,
|
||||
K_NUMPAD2,
|
||||
K_NUMPAD3,
|
||||
K_NUMPAD4,
|
||||
K_NUMPAD5,
|
||||
K_NUMPAD6,
|
||||
K_NUMPAD7,
|
||||
K_NUMPAD8,
|
||||
K_NUMPAD9,
|
||||
K_MULTIPLY,
|
||||
K_ADD,
|
||||
K_SEPARATOR,
|
||||
K_SUBTRACT,
|
||||
K_DECIMAL,
|
||||
K_DIVIDE,
|
||||
K_F1,
|
||||
K_F2,
|
||||
K_F3,
|
||||
K_F4,
|
||||
K_F5,
|
||||
K_F6,
|
||||
K_F7,
|
||||
K_F8,
|
||||
K_F9,
|
||||
K_F10,
|
||||
K_F11,
|
||||
K_F12,
|
||||
K_F13,
|
||||
K_F14,
|
||||
K_F15,
|
||||
K_F16,
|
||||
K_F17,
|
||||
K_F18,
|
||||
K_F19,
|
||||
K_F20,
|
||||
K_F21,
|
||||
K_F22,
|
||||
K_F23,
|
||||
K_F24,
|
||||
__UNASSIGNED_88,
|
||||
__UNASSIGNED_89,
|
||||
__UNASSIGNED_8A,
|
||||
__UNASSIGNED_8B,
|
||||
__UNASSIGNED_8C,
|
||||
__UNASSIGNED_8D,
|
||||
__UNASSIGNED_8E,
|
||||
__UNASSIGNED_8F,
|
||||
K_NUMLOCK,
|
||||
K_SCROLL,
|
||||
|
||||
K_OEM_NEC_EQUAL,
|
||||
K_OEM_FJ_JISHO,
|
||||
K_OEM_FJ_MASSHOU,
|
||||
K_OEM_FJ_TOUROKU,
|
||||
K_OEM_FJ_LOYA,
|
||||
__UNASSIGNED_97,
|
||||
__UNASSIGNED_98,
|
||||
__UNASSIGNED_99,
|
||||
__UNASSIGNED_9A,
|
||||
__UNASSIGNED_9B,
|
||||
__UNASSIGNED_9C,
|
||||
__UNASSIGNED_9D,
|
||||
__UNASSIGNED_9E,
|
||||
__UNASSIGNED_9F,
|
||||
K_LSHIFT,
|
||||
K_RSHIFT,
|
||||
K_LCONTROL,
|
||||
K_RCONTROL,
|
||||
K_LMENU,
|
||||
K_RMENU,
|
||||
K_BROWSER_BACK,
|
||||
K_BROWSER_FORWARD,
|
||||
K_BROWSER_REFRESH,
|
||||
K_BROWSER_STOP,
|
||||
K_BROWSER_SEARCH,
|
||||
K_BROWSER_FAVORITES,
|
||||
K_BROWSER_HOME,
|
||||
K_VOLUME_MUTE,
|
||||
K_VOLUME_DOWN,
|
||||
K_VOLUME_UP,
|
||||
K_MEDIA_NEXT_TRACK,
|
||||
K_MEDIA_PREV_TRACK,
|
||||
K_MEDIA_STOP,
|
||||
K_MEDIA_PLAY_PAUSE,
|
||||
K_LAUNCH_MAIL,
|
||||
K_LAUNCH_MEDIA_SELECT,
|
||||
K_LAUNCH_APP1,
|
||||
K_LAUNCH_APP2,
|
||||
__RESERVED_B8,
|
||||
__RESERVED_B9,
|
||||
K_OEM_1,
|
||||
K_OEM_PLUS,
|
||||
K_OEM_COMMA,
|
||||
K_OEM_MINUS,
|
||||
K_OEM_PERIOD,
|
||||
K_OEM_2,
|
||||
K_OEM_3,
|
||||
|
||||
K_OEM_4 = 0xDB,
|
||||
K_OEM_5,
|
||||
K_OEM_6,
|
||||
K_OEM_7,
|
||||
K_OEM_8,
|
||||
__RESERVED_E0,
|
||||
K_OEM_AX,
|
||||
K_OEM_102,
|
||||
K_ICO_HELP,
|
||||
K_ICO_00,
|
||||
K_PROCESSKEY,
|
||||
K_ICO_CLEAR,
|
||||
K_PACKET,
|
||||
__UNASSIGNED_E8,
|
||||
K_OEM_RESET,
|
||||
K_OEM_JUMP,
|
||||
K_OEM_PA1,
|
||||
K_OEM_PA2,
|
||||
K_OEM_PA3,
|
||||
K_OEM_WSCTRL,
|
||||
K_OEM_CUSEL,
|
||||
K_OEM_ATTN,
|
||||
K_OEM_FINISH,
|
||||
K_OEM_COPY,
|
||||
K_OEM_AUTO,
|
||||
K_OEM_ENLW,
|
||||
K_OEM_BACKTAB,
|
||||
|
||||
K_ATTN,
|
||||
K_CRSEL,
|
||||
K_EXSEL,
|
||||
K_EREOF,
|
||||
K_PLAY,
|
||||
K_ZOOM,
|
||||
K_NONAME,
|
||||
K_PA1,
|
||||
K_OEM_CLEAR,
|
||||
K_MAX
|
||||
};
|
||||
}
|
131
bwapi4-includes/BWAPI/Interface.h
Normal file
131
bwapi4-includes/BWAPI/Interface.h
Normal file
|
@ -0,0 +1,131 @@
|
|||
#pragma once
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include <BWAPI/InterfaceEvent.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
/// This generalized class allows the application of features that are common to all interface
|
||||
/// classes.
|
||||
template < typename T >
|
||||
class Interface
|
||||
{
|
||||
protected:
|
||||
// default ctor
|
||||
Interface() {};
|
||||
// dtor
|
||||
virtual ~Interface()
|
||||
{};
|
||||
|
||||
std::map<int,void*> clientInfo;
|
||||
std::list< InterfaceEvent<T> > interfaceEvents;
|
||||
|
||||
friend class GameImpl;
|
||||
|
||||
// Function manages events and updates it for the given frame
|
||||
void updateEvents()
|
||||
{
|
||||
auto e = interfaceEvents.begin();
|
||||
while ( e != interfaceEvents.end() )
|
||||
{
|
||||
if ( e->isFinished() )
|
||||
{
|
||||
e = interfaceEvents.erase(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
e->execute(static_cast<T*>(this));
|
||||
++e;
|
||||
}
|
||||
}
|
||||
};
|
||||
public:
|
||||
/// Retrieves a pointer or value at an index that was stored for this interface using
|
||||
/// setClientInfo.
|
||||
///
|
||||
/// @param key
|
||||
/// The key containing the value to retrieve. Default is 0.
|
||||
///
|
||||
/// @retval nullptr if index is out of bounds.
|
||||
/// @returns The client info at the given index.
|
||||
/// @see setClientInfo
|
||||
void *getClientInfo(int key = 0) const
|
||||
{
|
||||
// Retrieve iterator to element at index
|
||||
auto result = this->clientInfo.find(key);
|
||||
|
||||
// Return a default value if not found
|
||||
if ( result == this->clientInfo.end() )
|
||||
return nullptr;
|
||||
|
||||
// return the desired value
|
||||
return result->second;
|
||||
};
|
||||
|
||||
template <typename CT>
|
||||
CT getClientInfo(int key = 0) const
|
||||
{
|
||||
return (CT)(int)this->getClientInfo(key);
|
||||
};
|
||||
|
||||
/// Associates one or more pointers or values with any BWAPI interface.
|
||||
///
|
||||
/// This client information is managed entirely by the AI module. It is not modified by BWAPI.
|
||||
/// @warning If a pointer to allocated memory is used, then the AI module is responsible for
|
||||
/// deallocating the memory when the game ends.
|
||||
///
|
||||
/// If client info at the given index has already been set, then it will be overwritten.
|
||||
///
|
||||
/// @param clientInfo
|
||||
/// The data to associate with this interface.
|
||||
/// @param key
|
||||
/// The key to use for this data. Default is 0.
|
||||
///
|
||||
/// @see getClientInfo
|
||||
template < typename V >
|
||||
void setClientInfo(const V &clientInfo, int key = 0)
|
||||
{
|
||||
this->clientInfo[key] = (void*)clientInfo;
|
||||
};
|
||||
|
||||
/// Registers an event and associates it with the current Interface object. Events can be used
|
||||
/// to automate tasks (like train X @Marines until Y of them have been created by the given
|
||||
/// @Barracks) or to create user-defined callbacks.
|
||||
///
|
||||
/// @param action
|
||||
/// The action callback to be executed when the event conditions are true. It is of type
|
||||
/// void fn(T *inst) where fn is the function name and inst is a pointer to the instance of
|
||||
/// the object performing the action.
|
||||
/// @param condition (optional)
|
||||
/// The condition callback which will return true if the action is intended to be executed.
|
||||
/// It is of type bool fn(T *inst) where fn is the function name and inst is a pointer to the
|
||||
/// instance of the object performing the check. The condition will always be true if omitted.
|
||||
/// @param timesToRun (optional)
|
||||
/// The number of times to execute the action before the event is removed. If the value is
|
||||
/// negative, then the event will never be removed. The value will be -1 if omitted, causing
|
||||
/// the event to execute regularly.
|
||||
/// @param framesToCheck (optional)
|
||||
/// The number of frames to skip between checks. If this value is 0, then a condition check is
|
||||
/// made once per frame. If this value is 1, then the condition for this event is only checked
|
||||
/// every other frame. This value is 0 by default, meaning the event's condition is checked
|
||||
/// every frame.
|
||||
void registerEvent(const std::function<void(T*)> &action, const std::function<bool(T*)> &condition = nullptr, int timesToRun = -1, int framesToCheck = 0)
|
||||
{
|
||||
interfaceEvents.push_back( InterfaceEvent<T>(action,condition,timesToRun,framesToCheck) );
|
||||
};
|
||||
/// @overload
|
||||
void registerEvent(const InterfaceEvent<T> &evt)
|
||||
{
|
||||
interfaceEvents.push_back( evt );
|
||||
};
|
||||
/// @overload
|
||||
void registerEvent(InterfaceEvent<T> &&evt)
|
||||
{
|
||||
interfaceEvents.push_back( std::move(evt) );
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
142
bwapi4-includes/BWAPI/InterfaceEvent.h
Normal file
142
bwapi4-includes/BWAPI/InterfaceEvent.h
Normal file
|
@ -0,0 +1,142 @@
|
|||
#pragma once
|
||||
#include <functional>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
template < typename T >
|
||||
class InterfaceEvent
|
||||
{
|
||||
public:
|
||||
// default ctor
|
||||
InterfaceEvent()
|
||||
: condProc(nullptr)
|
||||
, execProc(nullptr)
|
||||
, runCount(0)
|
||||
, runFreq(0)
|
||||
, step(0)
|
||||
{};
|
||||
|
||||
// expected ctor
|
||||
InterfaceEvent(const std::function<void(T*)> &action, const std::function<bool(T*)> &condition = nullptr, int timesToRun = -1, int framesToCheck = 0)
|
||||
: condProc( condition )
|
||||
, execProc( action )
|
||||
, runFreq( framesToCheck )
|
||||
, runCount( timesToRun )
|
||||
, step( framesToCheck )
|
||||
{};
|
||||
// copy ctor
|
||||
InterfaceEvent(const InterfaceEvent<T> &other)
|
||||
: condProc( other.condProc )
|
||||
, execProc( other.execProc )
|
||||
, runFreq( other.runFreq )
|
||||
, runCount( other.runCount )
|
||||
, step( other.step )
|
||||
{};
|
||||
// move ctor
|
||||
InterfaceEvent(InterfaceEvent<T> &&other)
|
||||
: condProc( std::move(other.condProc) )
|
||||
, execProc( std::move(other.execProc) )
|
||||
, runFreq( std::move(other.runFreq) )
|
||||
, runCount( std::move(other.runCount) )
|
||||
, step( std::move(other.step) )
|
||||
{};
|
||||
// copy assignment
|
||||
InterfaceEvent &operator =(InterfaceEvent<T> other)
|
||||
{
|
||||
swap(*this, other);
|
||||
return *this;
|
||||
};
|
||||
// move assignment
|
||||
InterfaceEvent &operator =(InterfaceEvent<T> &&other)
|
||||
{
|
||||
swap(*this, other);
|
||||
return *this;
|
||||
};
|
||||
|
||||
// dtor
|
||||
virtual ~InterfaceEvent()
|
||||
{};
|
||||
|
||||
/// Checks if the event has finished its execution and is marked for removal.
|
||||
///
|
||||
/// @retval true If the event has completed all runs and/or is marked for removal.
|
||||
/// @retval false If the event should continue execution.
|
||||
bool isFinished()
|
||||
{
|
||||
return this->runCount == 0;
|
||||
};
|
||||
|
||||
/// Marks the event for removal.
|
||||
void removeEvent()
|
||||
{
|
||||
this->runCount = 0;
|
||||
};
|
||||
|
||||
friend void swap(InterfaceEvent<T> &a, InterfaceEvent<T> &b);
|
||||
|
||||
protected:
|
||||
template < typename U >
|
||||
friend class Interface;
|
||||
|
||||
// Function that runs the event, checkings its conditions and running its action, then
|
||||
// decrementing the run count.
|
||||
bool execute(T *instance)
|
||||
{
|
||||
// condition check
|
||||
if ( !this->isConditionMet(instance) )
|
||||
return false;
|
||||
|
||||
// There must be an exec proc!
|
||||
if ( !this->execProc )
|
||||
return false;
|
||||
|
||||
// execute
|
||||
this->execProc(instance);
|
||||
|
||||
// Decrement run count (-1 being infinite)
|
||||
if ( this->runCount > 0 )
|
||||
--this->runCount;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Function to check if the condition associated with the event is true. Includes frame and
|
||||
// run count checking.
|
||||
bool isConditionMet(T *instance)
|
||||
{
|
||||
// Validity check
|
||||
if ( this->isFinished() )
|
||||
return false;
|
||||
|
||||
// Frame check
|
||||
--step;
|
||||
if ( step > 0 )
|
||||
return false;
|
||||
this->step = this->runFreq;
|
||||
|
||||
// Conditional check
|
||||
if ( this->condProc )
|
||||
return this->condProc(instance);
|
||||
return true; // always run if there is no conditional function
|
||||
};
|
||||
|
||||
private:
|
||||
// Data members
|
||||
std::function<bool(T*)> condProc;
|
||||
std::function<void(T*)> execProc;
|
||||
int runFreq; // Frequency of runs, in frames (0 means every frame, 1 means every other frame)
|
||||
int runCount; // Number of times that the action can occur (-1 being infinite)
|
||||
int step; // Current step. Executes when reaches 0, then reset to runFreq.
|
||||
};
|
||||
|
||||
// Note: This is down here to prevent intellisense errors
|
||||
template <typename T>
|
||||
inline void swap(InterfaceEvent<T> &a, InterfaceEvent<T> &b)
|
||||
{
|
||||
std::swap(a.condProc, b.condProc);
|
||||
std::swap(a.execProc, b.execProc);
|
||||
std::swap(a.runFreq, b.runFreq);
|
||||
std::swap(a.runCount, b.runCount);
|
||||
std::swap(a.step, b.step);
|
||||
};
|
||||
|
||||
}
|
17
bwapi4-includes/BWAPI/Latency.h
Normal file
17
bwapi4-includes/BWAPI/Latency.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace Latency
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
SinglePlayer = 2,
|
||||
LanLow = 5,
|
||||
LanMedium = 7,
|
||||
LanHigh = 9,
|
||||
BattlenetLow = 14,
|
||||
BattlenetMedium = 19,
|
||||
BattlenetHigh = 24
|
||||
};
|
||||
}
|
||||
}
|
391
bwapi4-includes/BWAPI/Order.h
Normal file
391
bwapi4-includes/BWAPI/Order.h
Normal file
|
@ -0,0 +1,391 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace Orders
|
||||
{
|
||||
/// Enumeration of unit orders
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of unit orders
|
||||
enum Enum
|
||||
{
|
||||
Die,
|
||||
Stop,
|
||||
Guard,
|
||||
PlayerGuard,
|
||||
TurretGuard,
|
||||
BunkerGuard,
|
||||
Move,
|
||||
ReaverStop,
|
||||
Attack1,
|
||||
Attack2,
|
||||
AttackUnit,
|
||||
AttackFixedRange,
|
||||
AttackTile,
|
||||
Hover,
|
||||
AttackMove,
|
||||
InfestedCommandCenter,
|
||||
UnusedNothing,
|
||||
UnusedPowerup,
|
||||
TowerGuard,
|
||||
TowerAttack,
|
||||
VultureMine,
|
||||
StayInRange,
|
||||
TurretAttack,
|
||||
Nothing,
|
||||
Unused_24,
|
||||
DroneStartBuild,
|
||||
DroneBuild,
|
||||
CastInfestation,
|
||||
MoveToInfest,
|
||||
InfestingCommandCenter,
|
||||
PlaceBuilding,
|
||||
PlaceProtossBuilding,
|
||||
CreateProtossBuilding,
|
||||
ConstructingBuilding,
|
||||
Repair,
|
||||
MoveToRepair,
|
||||
PlaceAddon,
|
||||
BuildAddon,
|
||||
Train,
|
||||
RallyPointUnit,
|
||||
RallyPointTile,
|
||||
ZergBirth,
|
||||
ZergUnitMorph,
|
||||
ZergBuildingMorph,
|
||||
IncompleteBuilding,
|
||||
IncompleteMorphing,
|
||||
BuildNydusExit,
|
||||
EnterNydusCanal,
|
||||
IncompleteWarping,
|
||||
Follow,
|
||||
Carrier,
|
||||
ReaverCarrierMove,
|
||||
CarrierStop,
|
||||
CarrierAttack,
|
||||
CarrierMoveToAttack,
|
||||
CarrierIgnore2,
|
||||
CarrierFight,
|
||||
CarrierHoldPosition,
|
||||
Reaver,
|
||||
ReaverAttack,
|
||||
ReaverMoveToAttack,
|
||||
ReaverFight,
|
||||
ReaverHoldPosition,
|
||||
TrainFighter,
|
||||
InterceptorAttack,
|
||||
ScarabAttack,
|
||||
RechargeShieldsUnit,
|
||||
RechargeShieldsBattery,
|
||||
ShieldBattery,
|
||||
InterceptorReturn,
|
||||
DroneLand,
|
||||
BuildingLand,
|
||||
BuildingLiftOff,
|
||||
DroneLiftOff,
|
||||
LiftingOff,
|
||||
ResearchTech,
|
||||
Upgrade,
|
||||
Larva,
|
||||
SpawningLarva,
|
||||
Harvest1,
|
||||
Harvest2,
|
||||
MoveToGas,
|
||||
WaitForGas,
|
||||
HarvestGas,
|
||||
ReturnGas,
|
||||
MoveToMinerals,
|
||||
WaitForMinerals,
|
||||
MiningMinerals,
|
||||
Harvest3,
|
||||
Harvest4,
|
||||
ReturnMinerals,
|
||||
Interrupted,
|
||||
EnterTransport,
|
||||
PickupIdle,
|
||||
PickupTransport,
|
||||
PickupBunker,
|
||||
Pickup4,
|
||||
PowerupIdle,
|
||||
Sieging,
|
||||
Unsieging,
|
||||
WatchTarget,
|
||||
InitCreepGrowth,
|
||||
SpreadCreep,
|
||||
StoppingCreepGrowth,
|
||||
GuardianAspect,
|
||||
ArchonWarp,
|
||||
CompletingArchonSummon,
|
||||
HoldPosition,
|
||||
QueenHoldPosition,
|
||||
Cloak,
|
||||
Decloak,
|
||||
Unload,
|
||||
MoveUnload,
|
||||
FireYamatoGun,
|
||||
MoveToFireYamatoGun,
|
||||
CastLockdown,
|
||||
Burrowing,
|
||||
Burrowed,
|
||||
Unburrowing,
|
||||
CastDarkSwarm,
|
||||
CastParasite,
|
||||
CastSpawnBroodlings,
|
||||
CastEMPShockwave,
|
||||
NukeWait,
|
||||
NukeTrain,
|
||||
NukeLaunch,
|
||||
NukePaint,
|
||||
NukeUnit,
|
||||
CastNuclearStrike,
|
||||
NukeTrack,
|
||||
InitializeArbiter,
|
||||
CloakNearbyUnits,
|
||||
PlaceMine,
|
||||
RightClickAction,
|
||||
SuicideUnit,
|
||||
SuicideLocation,
|
||||
SuicideHoldPosition,
|
||||
CastRecall,
|
||||
Teleport,
|
||||
CastScannerSweep,
|
||||
Scanner,
|
||||
CastDefensiveMatrix,
|
||||
CastPsionicStorm,
|
||||
CastIrradiate,
|
||||
CastPlague,
|
||||
CastConsume,
|
||||
CastEnsnare,
|
||||
CastStasisField,
|
||||
CastHallucination,
|
||||
Hallucination2,
|
||||
ResetCollision,
|
||||
ResetHarvestCollision,
|
||||
Patrol,
|
||||
CTFCOPInit,
|
||||
CTFCOPStarted,
|
||||
CTFCOP2,
|
||||
ComputerAI,
|
||||
AtkMoveEP,
|
||||
HarassMove,
|
||||
AIPatrol,
|
||||
GuardPost,
|
||||
RescuePassive,
|
||||
Neutral,
|
||||
ComputerReturn,
|
||||
InitializePsiProvider,
|
||||
SelfDestructing,
|
||||
Critter,
|
||||
HiddenGun,
|
||||
OpenDoor,
|
||||
CloseDoor,
|
||||
HideTrap,
|
||||
RevealTrap,
|
||||
EnableDoodad,
|
||||
DisableDoodad,
|
||||
WarpIn,
|
||||
Medic,
|
||||
MedicHeal,
|
||||
HealMove,
|
||||
MedicHoldPosition,
|
||||
MedicHealToIdle,
|
||||
CastRestoration,
|
||||
CastDisruptionWeb,
|
||||
CastMindControl,
|
||||
DarkArchonMeld,
|
||||
CastFeedback,
|
||||
CastOpticalFlare,
|
||||
CastMaelstrom,
|
||||
JunkYardDog,
|
||||
Fatal,
|
||||
None,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
}
|
||||
}
|
||||
/// An Order (Order type) represents a Unit's current action and can be retrieved with
|
||||
/// UnitInterface::getOrder. It can also be used to identify the current state of the unit during
|
||||
/// command execution (gathering minerals can consist of Orders::MoveToMinerals,
|
||||
/// Orders::WaitForMinerals, Orders::MiningMinerals, etc.).
|
||||
///
|
||||
/// @see UnitInterface::getOrder
|
||||
class Order : public Type<Order, Orders::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
Order(int id = Orders::Enum::None);
|
||||
};
|
||||
/// Namespace containing unit orders
|
||||
namespace Orders
|
||||
{
|
||||
/// Retrieves the set of all the Orders.
|
||||
///
|
||||
/// @returns Set of all Order types.
|
||||
const Order::const_set& allOrders();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const Order x
|
||||
BWAPI_DECL(Die);
|
||||
BWAPI_DECL(Stop);
|
||||
BWAPI_DECL(Guard);
|
||||
BWAPI_DECL(PlayerGuard);
|
||||
BWAPI_DECL(TurretGuard);
|
||||
BWAPI_DECL(BunkerGuard);
|
||||
BWAPI_DECL(Move);
|
||||
BWAPI_DECL(AttackUnit);
|
||||
BWAPI_DECL(AttackTile);
|
||||
BWAPI_DECL(Hover);
|
||||
BWAPI_DECL(AttackMove);
|
||||
BWAPI_DECL(InfestedCommandCenter);
|
||||
BWAPI_DECL(UnusedNothing);
|
||||
BWAPI_DECL(UnusedPowerup);
|
||||
BWAPI_DECL(TowerGuard);
|
||||
BWAPI_DECL(VultureMine);
|
||||
BWAPI_DECL(Nothing);
|
||||
BWAPI_DECL(CastInfestation);
|
||||
BWAPI_DECL(InfestingCommandCenter);
|
||||
BWAPI_DECL(PlaceBuilding);
|
||||
BWAPI_DECL(CreateProtossBuilding);
|
||||
BWAPI_DECL(ConstructingBuilding);
|
||||
BWAPI_DECL(Repair);
|
||||
BWAPI_DECL(PlaceAddon);
|
||||
BWAPI_DECL(BuildAddon);
|
||||
BWAPI_DECL(Train);
|
||||
BWAPI_DECL(RallyPointUnit);
|
||||
BWAPI_DECL(RallyPointTile);
|
||||
BWAPI_DECL(ZergBirth);
|
||||
BWAPI_DECL(ZergUnitMorph);
|
||||
BWAPI_DECL(ZergBuildingMorph);
|
||||
BWAPI_DECL(IncompleteBuilding);
|
||||
BWAPI_DECL(BuildNydusExit);
|
||||
BWAPI_DECL(EnterNydusCanal);
|
||||
BWAPI_DECL(Follow);
|
||||
BWAPI_DECL(Carrier);
|
||||
BWAPI_DECL(ReaverCarrierMove);
|
||||
BWAPI_DECL(CarrierIgnore2);
|
||||
BWAPI_DECL(Reaver);
|
||||
BWAPI_DECL(TrainFighter);
|
||||
BWAPI_DECL(InterceptorAttack);
|
||||
BWAPI_DECL(ScarabAttack);
|
||||
BWAPI_DECL(RechargeShieldsUnit);
|
||||
BWAPI_DECL(RechargeShieldsBattery);
|
||||
BWAPI_DECL(ShieldBattery);
|
||||
BWAPI_DECL(InterceptorReturn);
|
||||
BWAPI_DECL(BuildingLand);
|
||||
BWAPI_DECL(BuildingLiftOff);
|
||||
BWAPI_DECL(DroneLiftOff);
|
||||
BWAPI_DECL(LiftingOff);
|
||||
BWAPI_DECL(ResearchTech);
|
||||
BWAPI_DECL(Upgrade);
|
||||
BWAPI_DECL(Larva);
|
||||
BWAPI_DECL(SpawningLarva);
|
||||
BWAPI_DECL(Harvest1);
|
||||
BWAPI_DECL(Harvest2);
|
||||
BWAPI_DECL(MoveToGas);
|
||||
BWAPI_DECL(WaitForGas);
|
||||
BWAPI_DECL(HarvestGas);
|
||||
BWAPI_DECL(ReturnGas);
|
||||
BWAPI_DECL(MoveToMinerals);
|
||||
BWAPI_DECL(WaitForMinerals);
|
||||
BWAPI_DECL(MiningMinerals);
|
||||
BWAPI_DECL(Harvest3);
|
||||
BWAPI_DECL(Harvest4);
|
||||
BWAPI_DECL(ReturnMinerals);
|
||||
BWAPI_DECL(Interrupted);
|
||||
BWAPI_DECL(EnterTransport);
|
||||
BWAPI_DECL(PickupIdle);
|
||||
BWAPI_DECL(PickupTransport);
|
||||
BWAPI_DECL(PickupBunker);
|
||||
BWAPI_DECL(Pickup4);
|
||||
BWAPI_DECL(PowerupIdle);
|
||||
BWAPI_DECL(Sieging);
|
||||
BWAPI_DECL(Unsieging);
|
||||
BWAPI_DECL(InitCreepGrowth);
|
||||
BWAPI_DECL(SpreadCreep);
|
||||
BWAPI_DECL(StoppingCreepGrowth);
|
||||
BWAPI_DECL(GuardianAspect);
|
||||
BWAPI_DECL(ArchonWarp);
|
||||
BWAPI_DECL(CompletingArchonSummon);
|
||||
BWAPI_DECL(HoldPosition);
|
||||
BWAPI_DECL(Cloak);
|
||||
BWAPI_DECL(Decloak);
|
||||
BWAPI_DECL(Unload);
|
||||
BWAPI_DECL(MoveUnload);
|
||||
BWAPI_DECL(FireYamatoGun);
|
||||
BWAPI_DECL(CastLockdown);
|
||||
BWAPI_DECL(Burrowing);
|
||||
BWAPI_DECL(Burrowed);
|
||||
BWAPI_DECL(Unburrowing);
|
||||
BWAPI_DECL(CastDarkSwarm);
|
||||
BWAPI_DECL(CastParasite);
|
||||
BWAPI_DECL(CastSpawnBroodlings);
|
||||
BWAPI_DECL(CastEMPShockwave);
|
||||
BWAPI_DECL(NukeWait);
|
||||
BWAPI_DECL(NukeTrain);
|
||||
BWAPI_DECL(NukeLaunch);
|
||||
BWAPI_DECL(NukePaint);
|
||||
BWAPI_DECL(NukeUnit);
|
||||
BWAPI_DECL(CastNuclearStrike);
|
||||
BWAPI_DECL(NukeTrack);
|
||||
BWAPI_DECL(CloakNearbyUnits);
|
||||
BWAPI_DECL(PlaceMine);
|
||||
BWAPI_DECL(RightClickAction);
|
||||
BWAPI_DECL(CastRecall);
|
||||
BWAPI_DECL(Teleport);
|
||||
BWAPI_DECL(CastScannerSweep);
|
||||
BWAPI_DECL(Scanner);
|
||||
BWAPI_DECL(CastDefensiveMatrix);
|
||||
BWAPI_DECL(CastPsionicStorm);
|
||||
BWAPI_DECL(CastIrradiate);
|
||||
BWAPI_DECL(CastPlague);
|
||||
BWAPI_DECL(CastConsume);
|
||||
BWAPI_DECL(CastEnsnare);
|
||||
BWAPI_DECL(CastStasisField);
|
||||
BWAPI_DECL(CastHallucination);
|
||||
BWAPI_DECL(Hallucination2);
|
||||
BWAPI_DECL(ResetCollision);
|
||||
BWAPI_DECL(Patrol);
|
||||
BWAPI_DECL(CTFCOPInit);
|
||||
BWAPI_DECL(CTFCOPStarted);
|
||||
BWAPI_DECL(CTFCOP2);
|
||||
BWAPI_DECL(ComputerAI);
|
||||
BWAPI_DECL(AtkMoveEP);
|
||||
BWAPI_DECL(HarassMove);
|
||||
BWAPI_DECL(AIPatrol);
|
||||
BWAPI_DECL(GuardPost);
|
||||
BWAPI_DECL(RescuePassive);
|
||||
BWAPI_DECL(Neutral);
|
||||
BWAPI_DECL(ComputerReturn);
|
||||
BWAPI_DECL(SelfDestructing);
|
||||
BWAPI_DECL(Critter);
|
||||
BWAPI_DECL(HiddenGun);
|
||||
BWAPI_DECL(OpenDoor);
|
||||
BWAPI_DECL(CloseDoor);
|
||||
BWAPI_DECL(HideTrap);
|
||||
BWAPI_DECL(RevealTrap);
|
||||
BWAPI_DECL(EnableDoodad);
|
||||
BWAPI_DECL(DisableDoodad);
|
||||
BWAPI_DECL(WarpIn);
|
||||
BWAPI_DECL(Medic);
|
||||
BWAPI_DECL(MedicHeal);
|
||||
BWAPI_DECL(HealMove);
|
||||
BWAPI_DECL(MedicHealToIdle);
|
||||
BWAPI_DECL(CastRestoration);
|
||||
BWAPI_DECL(CastDisruptionWeb);
|
||||
BWAPI_DECL(CastMindControl);
|
||||
BWAPI_DECL(DarkArchonMeld);
|
||||
BWAPI_DECL(CastFeedback);
|
||||
BWAPI_DECL(CastOpticalFlare);
|
||||
BWAPI_DECL(CastMaelstrom);
|
||||
BWAPI_DECL(JunkYardDog);
|
||||
BWAPI_DECL(Fatal);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
};
|
||||
}
|
592
bwapi4-includes/BWAPI/Player.h
Normal file
592
bwapi4-includes/BWAPI/Player.h
Normal file
|
@ -0,0 +1,592 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include <BWAPI/Position.h>
|
||||
#include <BWAPI/Race.h>
|
||||
#include <BWAPI/Filters.h>
|
||||
#include <BWAPI/Interface.h>
|
||||
#include <BWAPI/UnitType.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forwards
|
||||
class Color;
|
||||
class ForceInterface;
|
||||
typedef ForceInterface *Force;
|
||||
class PlayerType;
|
||||
class TechType;
|
||||
class Unitset;
|
||||
class UpgradeType;
|
||||
class WeaponType;
|
||||
|
||||
struct PlayerData;
|
||||
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
|
||||
/// The Player represents a unique controller in the game. Each player in a match will have his
|
||||
/// or her own player instance. There is also a neutral player which owns all the neutral units
|
||||
/// (such as mineral patches and vespene geysers).
|
||||
///
|
||||
/// @see Playerset, PlayerType, Race
|
||||
class PlayerInterface : public Interface<PlayerInterface>
|
||||
{
|
||||
protected:
|
||||
virtual ~PlayerInterface() {};
|
||||
public :
|
||||
/// Retrieves a unique ID that represents the player.
|
||||
///
|
||||
/// @returns
|
||||
/// An integer representing the ID of the player.
|
||||
virtual int getID() const = 0;
|
||||
|
||||
/// Retrieves the name of the player.
|
||||
///
|
||||
/// @returns
|
||||
/// A std::string object containing the player's name.
|
||||
///
|
||||
/// @note Don't forget to use std::string::c_str() when passing this parameter to
|
||||
/// Game::sendText and other variadic functions.
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// BWAPI::Player myEnemy = BWAPI::Broodwar->enemy();
|
||||
/// if ( myEnemy != nullptr ) // Make sure there is an enemy!
|
||||
/// BWAPI::Broodwar->sendText("Prepare to be crushed, %s!", myEnemy->getName().c_str());
|
||||
/// @endcode
|
||||
virtual std::string getName() const = 0;
|
||||
|
||||
/// Retrieves the set of all units that the player owns. This also includes incomplete units.
|
||||
///
|
||||
/// @returns Reference to a Unitset containing the units.
|
||||
///
|
||||
/// @note This does not include units that are loaded into transports, @Bunkers, @Refineries,
|
||||
/// @Assimilators, or @Extractors.
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// Unitset myUnits = BWAPI::Broodwar->self()->getUnits();
|
||||
/// for ( auto u = myUnits.begin(); u != myUnits.end(); ++u )
|
||||
/// {
|
||||
/// // Do something with your units
|
||||
/// }
|
||||
/// @endcode
|
||||
virtual const Unitset &getUnits() const = 0;
|
||||
|
||||
/// Retrieves the race of the player. This allows you to change strategies against different
|
||||
/// races, or generalize some commands for yourself.
|
||||
///
|
||||
/// @retval Races::Unknown If the player chose Races::Random when the game started and they
|
||||
/// have not been seen.
|
||||
///
|
||||
/// @returns
|
||||
/// The Race that the player is using.
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// if ( BWAPI::Broodwar->enemy() )
|
||||
/// {
|
||||
/// BWAPI::Race enemyRace = BWAPI::Broodwar->enemy()->getRace();
|
||||
/// if ( enemyRace == Races::Zerg )
|
||||
/// BWAPI::Broodwar->sendText("Do you really think you can beat me with a zergling rush?");
|
||||
/// }
|
||||
/// @endcode
|
||||
virtual Race getRace() const = 0;
|
||||
|
||||
/// Retrieves the player's controller type. This allows you to distinguish betweeen computer
|
||||
/// and human players.
|
||||
///
|
||||
/// @returns
|
||||
/// The PlayerType that identifies who is controlling a player.
|
||||
///
|
||||
/// @note Other players using BWAPI will be treated as a human player and return
|
||||
/// PlayerTypes::Player.
|
||||
///
|
||||
/// @code
|
||||
/// if ( BWAPI::Broodwar->enemy() )
|
||||
/// {
|
||||
/// if ( BWAPI::Broodwar->enemy()->getType() == PlayerTypes::Computer )
|
||||
/// BWAPI::Broodwar << "Looks like something I can abuse!" << std::endl;
|
||||
/// }
|
||||
/// @endcode
|
||||
virtual PlayerType getType() const = 0;
|
||||
|
||||
/// Retrieves the player's force. A force is the team that the player is playing on. This is
|
||||
/// only used in non-melee game types.
|
||||
///
|
||||
/// @returns
|
||||
/// The Force object that the player is part of.
|
||||
virtual Force getForce() const = 0;
|
||||
|
||||
/// Checks if this player is allied to the specified player.
|
||||
///
|
||||
/// @param player
|
||||
/// The player to check alliance with.
|
||||
///
|
||||
/// @retval true if this player is allied with \p player .
|
||||
/// @retval false if this player is not allied with \p player.
|
||||
///
|
||||
/// @note This function will also return false if this player is neutral or an observer, or
|
||||
/// if \p player is neutral or an observer.
|
||||
///
|
||||
/// @see isEnemy
|
||||
virtual bool isAlly(Player player) const = 0;
|
||||
|
||||
/// Checks if this player is unallied to the specified player.
|
||||
///
|
||||
/// @param player
|
||||
/// The player to check alliance with.
|
||||
///
|
||||
/// @retval true if this player is allied with \p player .
|
||||
/// @retval false if this player is not allied with \p player .
|
||||
///
|
||||
/// @note This function will also return false if this player is neutral or an observer, or if
|
||||
/// \p player is neutral or an observer.
|
||||
///
|
||||
/// @see isAlly
|
||||
virtual bool isEnemy(Player player) const = 0;
|
||||
|
||||
/// Checks if this player is the neutral player.
|
||||
///
|
||||
/// @retval true if this player is the neutral player.
|
||||
/// @retval false if this player is any other player.
|
||||
virtual bool isNeutral() const = 0;
|
||||
|
||||
/// Retrieve's the player's starting location.
|
||||
///
|
||||
/// @returns
|
||||
/// A TilePosition containing the position of the start location.
|
||||
///
|
||||
/// @retval TilePositions::None if the player does not have a start location.
|
||||
/// @retval TilePositions::Unknown if an error occured while trying to retrieve the start
|
||||
/// location.
|
||||
///
|
||||
/// @see Game::getStartLocations, Game::getLastError
|
||||
virtual TilePosition getStartLocation() const = 0;
|
||||
|
||||
/// Checks if the player has achieved victory.
|
||||
///
|
||||
/// @returns true if this player has achieved victory, otherwise false
|
||||
virtual bool isVictorious() const = 0;
|
||||
|
||||
/// Checks if the player has been defeated.
|
||||
///
|
||||
/// @returns true if the player is defeated, otherwise false
|
||||
virtual bool isDefeated() const = 0;
|
||||
|
||||
/// Checks if the player has left the game.
|
||||
///
|
||||
/// @returns true if the player has left the game, otherwise false
|
||||
virtual bool leftGame() const = 0;
|
||||
|
||||
/// Retrieves the current amount of minerals/ore that this player has.
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Amount of minerals that the player currently has for spending.
|
||||
virtual int minerals() const = 0;
|
||||
|
||||
/// Retrieves the current amount of vespene gas that this player has.
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Amount of gas that the player currently has for spending.
|
||||
virtual int gas() const = 0;
|
||||
|
||||
/// Retrieves the cumulative amount of minerals/ore that this player has gathered since the
|
||||
/// beginning of the game, including the amount that the player starts the game with (if any).
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Cumulative amount of minerals that the player has gathered.
|
||||
virtual int gatheredMinerals() const = 0;
|
||||
|
||||
/// Retrieves the cumulative amount of vespene gas that this player has gathered since the
|
||||
/// beginning of the game, including the amount that the player starts the game with (if any).
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Cumulative amount of gas that the player has gathered.
|
||||
virtual int gatheredGas() const = 0;
|
||||
|
||||
/// Retrieves the cumulative amount of minerals/ore that this player has spent on repairing
|
||||
/// units since the beginning of the game. This function only applies to @Terran players.
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Cumulative amount of minerals that the player has spent repairing.
|
||||
virtual int repairedMinerals() const = 0;
|
||||
|
||||
/// Retrieves the cumulative amount of vespene gas that this player has spent on repairing
|
||||
/// units since the beginning of the game. This function only applies to @Terran players.
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Cumulative amount of gas that the player has spent repairing.
|
||||
virtual int repairedGas() const = 0;
|
||||
|
||||
/// Retrieves the cumulative amount of minerals/ore that this player has gained from refunding
|
||||
/// (cancelling) units and structures.
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Cumulative amount of minerals that the player has received from refunds.
|
||||
virtual int refundedMinerals() const = 0;
|
||||
|
||||
/// Retrieves the cumulative amount of vespene gas that this player has gained from refunding
|
||||
/// (cancelling) units and structures.
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Cumulative amount of gas that the player has received from refunds.
|
||||
virtual int refundedGas() const = 0;
|
||||
|
||||
/// Retrieves the cumulative amount of minerals/ore that this player has spent, excluding
|
||||
/// repairs.
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Cumulative amount of minerals that the player has spent.
|
||||
virtual int spentMinerals() const = 0;
|
||||
|
||||
/// Retrieves the cumulative amount of vespene gas that this player has spent, excluding
|
||||
/// repairs.
|
||||
///
|
||||
/// @note This function will return 0 if the player is inaccessible.
|
||||
///
|
||||
/// @returns Cumulative amount of gas that the player has spent.
|
||||
virtual int spentGas() const = 0;
|
||||
|
||||
/// Retrieves the total amount of supply the player has available for unit control.
|
||||
///
|
||||
/// @note In Starcraft programming, the managed supply values are double than what they appear
|
||||
/// in the game. The reason for this is because @Zerglings use 0.5 visible supply.
|
||||
///
|
||||
/// @note In Starcraft, the supply for each race is separate. Having a @Pylon and an @Overlord
|
||||
/// will not give you 32 supply. It will instead give you 16 @Protoss supply and 16 @Zerg
|
||||
/// supply.
|
||||
///
|
||||
/// @param race (optional)
|
||||
/// The race to query the total supply for. If this is omitted, then the player's current
|
||||
/// race will be used.
|
||||
///
|
||||
/// @returns The total supply available for this player and the given \p race.
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// if ( BWAPI::Broodwar->self()->supplyUsed() + 8 >= BWAPI::Broodwar->self()->supplyTotal() )
|
||||
/// {
|
||||
/// // Construct pylons, supply depots, or overlords
|
||||
/// }
|
||||
/// @endcode
|
||||
/// @see supplyUsed
|
||||
virtual int supplyTotal(Race race = Races::None) const = 0;
|
||||
|
||||
/// Retrieves the current amount of supply that the player is using for unit control.
|
||||
///
|
||||
/// @param race (optional)
|
||||
/// The race to query the used supply for. If this is omitted, then the player's current
|
||||
/// race will be used.
|
||||
///
|
||||
/// @returns The supply that is in use for this player and the given \p race.
|
||||
/// @see supplyTotal
|
||||
virtual int supplyUsed(Race race = Races::None) const = 0;
|
||||
|
||||
/// Retrieves the total number of units that the player has. If the information about the
|
||||
/// player is limited, then this function will only return the number of visible units.
|
||||
///
|
||||
/// @param unit (optional)
|
||||
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
|
||||
/// then it will use UnitTypes::AllUnits by default.
|
||||
///
|
||||
/// @returns The total number of units of the given type that the player owns.
|
||||
/// @see visibleUnitCount, completedUnitCount, incompleteUnitCount
|
||||
virtual int allUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
|
||||
|
||||
/// Retrieves the total number of strictly visible units that the player has, even if
|
||||
/// information on the player is unrestricted.
|
||||
///
|
||||
/// @param unit (optional)
|
||||
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
|
||||
/// then it will use UnitTypes::AllUnits by default.
|
||||
///
|
||||
/// @returns The total number of units of the given type that the player owns, and is visible
|
||||
/// to the BWAPI player.
|
||||
/// @see allUnitCount, completedUnitCount, incompleteUnitCount
|
||||
virtual int visibleUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
|
||||
|
||||
/// Retrieves the number of completed units that the player has. If the information about the
|
||||
/// player is limited, then this function will only return the number of visible completed
|
||||
/// units.
|
||||
///
|
||||
/// @param unit (optional)
|
||||
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
|
||||
/// then it will use UnitTypes::AllUnits by default.
|
||||
///
|
||||
/// @returns The number of completed units of the given type that the player owns.
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// bool obtainNextUpgrade(BWAPI::UpgradeType upgType)
|
||||
/// {
|
||||
/// BWAPI::Player self = BWAPI::Broodwar->self();
|
||||
/// int maxLvl = self->getMaxUpgradeLevel(upgType);
|
||||
/// int currentLvl = self->getUpgradeLevel(upgType);
|
||||
/// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl &&
|
||||
/// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 &&
|
||||
/// self->completedUnitCount(upgType.whatUpgrades()) > 0 )
|
||||
/// return self->getUnits().upgrade(upgType);
|
||||
/// return false;
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
/// @see allUnitCount, visibleUnitCount, incompleteUnitCount
|
||||
virtual int completedUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
|
||||
|
||||
/// Retrieves the number of incomplete units that the player has. If the information about the
|
||||
/// player is limited, then this function will only return the number of visible incomplete
|
||||
/// units.
|
||||
///
|
||||
/// @note This function is a macro for allUnitCount() - completedUnitCount().
|
||||
///
|
||||
/// @param unit (optional)
|
||||
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
|
||||
/// then it will use UnitTypes::AllUnits by default.
|
||||
///
|
||||
/// @returns The number of incomplete units of the given type that the player owns.
|
||||
/// @see allUnitCount, visibleUnitCount, completedUnitCount
|
||||
int incompleteUnitCount(UnitType unit = UnitTypes::AllUnits) const;
|
||||
|
||||
/// Retrieves the number units that have died for this player.
|
||||
///
|
||||
/// @param unit (optional)
|
||||
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
|
||||
/// then it will use UnitTypes::AllUnits by default.
|
||||
///
|
||||
/// @returns The total number of units that have died throughout the game.
|
||||
virtual int deadUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
|
||||
|
||||
/// Retrieves the number units that the player has killed.
|
||||
///
|
||||
/// @param unit (optional)
|
||||
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
|
||||
/// then it will use UnitTypes::AllUnits by default.
|
||||
///
|
||||
/// @returns The total number of units that the player has killed throughout the game.
|
||||
virtual int killedUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
|
||||
|
||||
/// Retrieves the current upgrade level that the player has attained for a given upgrade type.
|
||||
///
|
||||
/// @param upgrade
|
||||
/// The UpgradeType to query.
|
||||
///
|
||||
/// @returns The number of levels that the \p upgrade has been upgraded for this player.
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// bool obtainNextUpgrade(BWAPI::UpgradeType upgType)
|
||||
/// {
|
||||
/// BWAPI::Player self = BWAPI::Broodwar->self();
|
||||
/// int maxLvl = self->getMaxUpgradeLevel(upgType);
|
||||
/// int currentLvl = self->getUpgradeLevel(upgType);
|
||||
/// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl &&
|
||||
/// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 &&
|
||||
/// self->completedUnitCount(upgType.whatUpgrades()) > 0 )
|
||||
/// return self->getUnits().upgrade(upgType);
|
||||
/// return false;
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
/// @see UnitInterface::upgrade, getMaxUpgradeLevel
|
||||
virtual int getUpgradeLevel(UpgradeType upgrade) const = 0;
|
||||
|
||||
/// Checks if the player has already researched a given technology.
|
||||
///
|
||||
/// @param tech
|
||||
/// The TechType to query.
|
||||
///
|
||||
/// @returns true if the player has obtained the given \p tech, or false if they have not
|
||||
/// @see isResearching, UnitInterface::research, isResearchAvailable
|
||||
virtual bool hasResearched(TechType tech) const = 0;
|
||||
|
||||
/// Checks if the player is researching a given technology type.
|
||||
///
|
||||
/// @param tech
|
||||
/// The TechType to query.
|
||||
///
|
||||
/// @returns true if the player is currently researching the \p tech, or false otherwise
|
||||
/// @see UnitInterface::research, hasResearched
|
||||
virtual bool isResearching(TechType tech) const = 0;
|
||||
|
||||
/// Checks if the player is upgrading a given upgrade type.
|
||||
///
|
||||
/// @param upgrade
|
||||
/// The upgrade type to query.
|
||||
///
|
||||
/// @returns true if the player is currently upgrading the given \p upgrade, false otherwise
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// bool obtainNextUpgrade(BWAPI::UpgradeType upgType)
|
||||
/// {
|
||||
/// BWAPI::Player self = BWAPI::Broodwar->self();
|
||||
/// int maxLvl = self->getMaxUpgradeLevel(upgType);
|
||||
/// int currentLvl = self->getUpgradeLevel(upgType);
|
||||
/// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl &&
|
||||
/// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 &&
|
||||
/// self->completedUnitCount(upgType.whatUpgrades()) > 0 )
|
||||
/// return self->getUnits().upgrade(upgType);
|
||||
/// return false;
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
/// @see UnitInterface::upgrade
|
||||
virtual bool isUpgrading(UpgradeType upgrade) const = 0;
|
||||
|
||||
/// Retrieves the color value of the current player.
|
||||
///
|
||||
/// @returns Color object that represents the color of the current player.
|
||||
virtual BWAPI::Color getColor() const = 0;
|
||||
|
||||
/// Retrieves the control code character that changes the color of text messages to represent
|
||||
/// this player.
|
||||
///
|
||||
/// @returns character code to use for text in Broodwar.
|
||||
char getTextColor() const;
|
||||
|
||||
/// Retrieves the maximum amount of energy that a unit type will have, taking the player's
|
||||
/// energy upgrades into consideration.
|
||||
///
|
||||
/// @param unit
|
||||
/// The UnitType to retrieve the maximum energy for.
|
||||
///
|
||||
/// @returns Maximum amount of energy that the given unit type can have.
|
||||
int maxEnergy(UnitType unit) const;
|
||||
|
||||
/// Retrieves the top speed of a unit type, taking the player's speed upgrades into
|
||||
/// consideration.
|
||||
///
|
||||
/// @param unit
|
||||
/// The UnitType to retrieve the top speed for.
|
||||
///
|
||||
/// @returns Top speed of the provided unit type for this player.
|
||||
double topSpeed(UnitType unit) const;
|
||||
|
||||
/// Retrieves the maximum weapon range of a weapon type, taking the player's weapon upgrades
|
||||
/// into consideration.
|
||||
///
|
||||
/// @param weapon
|
||||
/// The WeaponType to retrieve the maximum range for.
|
||||
///
|
||||
/// @returns Maximum range of the given weapon type for units owned by this player.
|
||||
int weaponMaxRange(WeaponType weapon) const;
|
||||
|
||||
/// Retrieves the sight range of a unit type, taking the player's sight range upgrades into
|
||||
/// consideration.
|
||||
///
|
||||
/// @param unit
|
||||
/// The UnitType to retrieve the sight range for.
|
||||
///
|
||||
/// @returns Sight range of the provided unit type for this player.
|
||||
int sightRange(UnitType unit) const;
|
||||
|
||||
/// Retrieves the weapon cooldown of a unit type, taking the player's attack speed upgrades
|
||||
/// into consideration.
|
||||
///
|
||||
/// @param unit
|
||||
/// The UnitType to retrieve the damage cooldown for.
|
||||
///
|
||||
/// @returns Weapon cooldown of the provided unit type for this player.
|
||||
int weaponDamageCooldown(UnitType unit) const;
|
||||
|
||||
/// Calculates the armor that a given unit type will have, including upgrades.
|
||||
///
|
||||
/// @param unit
|
||||
/// The unit type to calculate armor for, using the current player's upgrades.
|
||||
///
|
||||
/// @returns The amount of armor that the unit will have with the player's upgrades.
|
||||
int armor(UnitType unit) const;
|
||||
|
||||
/// Calculates the damage that a given weapon type can deal, including upgrades.
|
||||
///
|
||||
/// @param wpn
|
||||
/// The weapon type to calculate for.
|
||||
///
|
||||
/// @returns The amount of damage that the weapon deals with this player's upgrades.
|
||||
int damage(WeaponType wpn) const;
|
||||
|
||||
/// Retrieves the total unit score, as seen in the end-game score screen.
|
||||
///
|
||||
/// @returns The player's unit score.
|
||||
virtual int getUnitScore() const = 0;
|
||||
|
||||
/// Retrieves the total kill score, as seen in the end-game score screen.
|
||||
///
|
||||
/// @returns The player's kill score.
|
||||
virtual int getKillScore() const = 0;
|
||||
|
||||
/// Retrieves the total building score, as seen in the end-game score screen.
|
||||
///
|
||||
/// @returns The player's building score.
|
||||
virtual int getBuildingScore() const = 0;
|
||||
|
||||
/// Retrieves the total razing score, as seen in the end-game score screen.
|
||||
///
|
||||
/// @returns The player's razing score.
|
||||
virtual int getRazingScore() const = 0;
|
||||
|
||||
/// Retrieves the player's custom score. This score is used in @UMS game types.
|
||||
///
|
||||
/// @returns The player's custom score.
|
||||
virtual int getCustomScore() const = 0;
|
||||
|
||||
/// Checks if the player is an observer player, typically in a @UMS observer game. An observer
|
||||
/// player does not participate in the game.
|
||||
///
|
||||
/// @returns true if the player is observing, or false if the player is capable of playing in
|
||||
/// the game.
|
||||
virtual bool isObserver() const = 0;
|
||||
|
||||
/// Retrieves the maximum upgrades available specific to the player. This value is only
|
||||
/// different from UpgradeType::maxRepeats in @UMS games.
|
||||
///
|
||||
/// @param upgrade
|
||||
/// The UpgradeType to retrieve the maximum upgrade level for.
|
||||
///
|
||||
/// @returns Maximum upgrade level of the given \p upgrade type.
|
||||
///
|
||||
/// Example usage:
|
||||
/// @code
|
||||
/// bool obtainNextUpgrade(BWAPI::UpgradeType upgType)
|
||||
/// {
|
||||
/// BWAPI::Player self = BWAPI::Broodwar->self();
|
||||
/// int maxLvl = self->getMaxUpgradeLevel(upgType);
|
||||
/// int currentLvl = self->getUpgradeLevel(upgType);
|
||||
/// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl &&
|
||||
/// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 &&
|
||||
/// self->completedUnitCount(upgType.whatUpgrades()) > 0 )
|
||||
/// return self->getUnits().upgrade(upgType);
|
||||
/// return false;
|
||||
/// }
|
||||
/// @endcode
|
||||
virtual int getMaxUpgradeLevel(UpgradeType upgrade) const = 0;
|
||||
|
||||
/// Checks if a technology can be researched by the player. Certain technologies may be
|
||||
/// disabled in @UMS game types.
|
||||
///
|
||||
/// @param tech
|
||||
/// The TechType to query.
|
||||
///
|
||||
/// @returns true if the \p tech type is available to the player for research.
|
||||
virtual bool isResearchAvailable(TechType tech) const = 0;
|
||||
|
||||
/// Checks if a unit type can be created by the player. Certain unit types may be disabled in
|
||||
/// @UMS game types.
|
||||
///
|
||||
/// @param unit
|
||||
/// The UnitType to check.
|
||||
///
|
||||
/// @returns true if the \p unit type is available to the player.
|
||||
virtual bool isUnitAvailable(UnitType unit) const = 0;
|
||||
};
|
||||
};
|
65
bwapi4-includes/BWAPI/PlayerType.h
Normal file
65
bwapi4-includes/BWAPI/PlayerType.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace PlayerTypes
|
||||
{
|
||||
/// Enumeration of player types (player controllers)
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of player types (player controllers)
|
||||
enum Enum
|
||||
{
|
||||
None = 0,
|
||||
Computer,
|
||||
Player,
|
||||
RescuePassive,
|
||||
RescueActive,
|
||||
EitherPreferComputer,
|
||||
EitherPreferHuman,
|
||||
Neutral,
|
||||
Closed,
|
||||
Observer,
|
||||
PlayerLeft,
|
||||
ComputerLeft,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
};
|
||||
};
|
||||
class PlayerType : public Type<PlayerType, PlayerTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
PlayerType(int id = PlayerTypes::Enum::None);
|
||||
|
||||
bool isLobbyType() const;
|
||||
bool isGameType() const;
|
||||
};
|
||||
/// Namespace containing player types (player controllers)
|
||||
namespace PlayerTypes
|
||||
{
|
||||
/// Retrieves the set of all the PlayerTypes.
|
||||
///
|
||||
/// @returns Set consisting of all valid PlayerTypes.
|
||||
const PlayerType::const_set& allPlayerTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const PlayerType x
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Computer);
|
||||
BWAPI_DECL(Player);
|
||||
BWAPI_DECL(RescuePassive);
|
||||
BWAPI_DECL(EitherPreferComputer);
|
||||
BWAPI_DECL(EitherPreferHuman);
|
||||
BWAPI_DECL(Neutral);
|
||||
BWAPI_DECL(Closed);
|
||||
BWAPI_DECL(PlayerLeft);
|
||||
BWAPI_DECL(ComputerLeft);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
47
bwapi4-includes/BWAPI/Playerset.h
Normal file
47
bwapi4-includes/BWAPI/Playerset.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Vectorset.h>
|
||||
|
||||
#include <BWAPI/Race.h>
|
||||
#include <BWAPI/Filters.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forward Declarations
|
||||
class PlayerInterface;
|
||||
typedef PlayerInterface *Player;
|
||||
class Unitset;
|
||||
|
||||
class Playerset : public Vectorset<BWAPI::Player>
|
||||
{
|
||||
public:
|
||||
Playerset(size_t initialSize = 16);
|
||||
Playerset(const Playerset &other);
|
||||
Playerset(Playerset &&other);
|
||||
|
||||
/// Returns the set of all units that every
|
||||
/// player in this set owns.
|
||||
///
|
||||
/// @returns Unitset containing Playerset's units
|
||||
/// @see PlayerInterface::getUnits
|
||||
Unitset getUnits() const;
|
||||
|
||||
/// Returns the list of races that each player
|
||||
/// in the set is.
|
||||
///
|
||||
/// @returns Race::set containing Playerset's races
|
||||
/// @see PlayerInterface::getRace
|
||||
Race::set getRaces() const;
|
||||
|
||||
/// Sets the alliance status with all players
|
||||
/// contained in the Playerset.
|
||||
///
|
||||
/// @param allies Set to true to set the player
|
||||
/// to allied, or false for enemy.
|
||||
/// @param alliedVictory Set to true to turn on
|
||||
/// allied victory, or false to disable it
|
||||
/// @see Game::setAlliance
|
||||
void setAlliance(bool allies = true, bool alliedVictory = true);
|
||||
|
||||
};
|
||||
}
|
||||
|
266
bwapi4-includes/BWAPI/Position.h
Normal file
266
bwapi4-includes/BWAPI/Position.h
Normal file
|
@ -0,0 +1,266 @@
|
|||
#pragma once
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <iosfwd>
|
||||
#include <tuple>
|
||||
|
||||
#include <BWAPI/Vectorset.h>
|
||||
|
||||
#ifndef _MAKE_POSITION_TEMPLATE
|
||||
|
||||
#ifdef SWIG
|
||||
#define _MAKE_POSITION_TEMPLATE(_n,_t,_s) typedef BWAPI::Point<_t,_s> _n;
|
||||
#else
|
||||
#define _MAKE_POSITION_TEMPLATE(_n,_t,_s) typedef BWAPI::Point<_t,_s> _n; \
|
||||
namespace _n ## s \
|
||||
{ const _n Invalid(32000/_s,32000/_s); \
|
||||
const _n None(32000/_s,32032/_s); \
|
||||
const _n Unknown(32000/_s,32064/_s); \
|
||||
const _n Origin(0,0); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define _OPERATOR_OP_PT(op) Point operator op (const Point &pos) const \
|
||||
{ return Point(this->x op pos.x, this->y op pos.y); }; \
|
||||
Point &operator op ## = (const Point &pos) \
|
||||
{ this->x op ## = pos.x; this->y op ## = pos.y; \
|
||||
return *this; };
|
||||
|
||||
#define _OPERATOR_OP_VAL(op) Point operator op (const _T &val) const \
|
||||
{ return Point(this->x op val, this->y op val); }; \
|
||||
Point &operator op ## = (const _T &val) \
|
||||
{ this->x op ## = val; this->y op ## = val; \
|
||||
return *this; };
|
||||
|
||||
#define _OPERATOR_OP_VAL_CHK(op) Point operator op (const _T &val) const \
|
||||
{ if ( val == 0 ) return Point(32000/__Scale,32000/__Scale); \
|
||||
return Point(this->x op val, this->y op val); }; \
|
||||
Point &operator op ## = (const _T &val) \
|
||||
{ if ( val == 0 ) { this->x = 32000/__Scale; this->y = 32000/__Scale; } \
|
||||
else { this->x op ## = val; this->y op ## = val; } \
|
||||
return *this; };
|
||||
|
||||
#endif
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Declaration
|
||||
template<typename _T, int __Scale = 1>
|
||||
class Point;
|
||||
|
||||
// Restrictions (no division by 0 or types too small to contain map positions)
|
||||
template<typename _T> class Point<_T, 0> {};
|
||||
template<int __Scale> class Point<char, __Scale> {};
|
||||
template<int __Scale> class Point<unsigned char, __Scale> {};
|
||||
template<int __Scale> class Point<bool, __Scale> {};
|
||||
|
||||
// ------------------------------------------------------ Point template ----------------
|
||||
template<typename _T, int __Scale>
|
||||
class Point
|
||||
{
|
||||
public:
|
||||
typedef Vectorset< Point<_T,__Scale> > set;
|
||||
|
||||
// Constructors
|
||||
Point(_T _x = 0, _T _y = 0) : x(_x), y(_y) {};
|
||||
template<typename _NT> Point(const Point<_NT, __Scale> &pt) : x( (_T)pt.x ), y( (_T)pt.y ) {};
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4723 )
|
||||
// Conversion constructor
|
||||
template<typename _NT, int __NScale> explicit Point(const Point<_NT, __NScale> &pt)
|
||||
: x( (_T)(__NScale > __Scale ? pt.x*(__NScale/__Scale) : pt.x/(__Scale/__NScale)) )
|
||||
, y( (_T)(__NScale > __Scale ? pt.y*(__NScale/__Scale) : pt.y/(__Scale/__NScale)) ) { };
|
||||
#pragma warning( pop )
|
||||
|
||||
// Conversion restriction constructor
|
||||
template<typename _NT> Point(const Point<_NT, 0> &pt) : x(0), y(0) {};
|
||||
|
||||
// Operators
|
||||
operator bool() const { return this->isValid(); };
|
||||
|
||||
bool operator == (const Point<_T,__Scale> &pos) const
|
||||
{
|
||||
return std::tie(this->x, this->y) == std::tie(pos.x, pos.y);
|
||||
};
|
||||
bool operator != (const Point<_T,__Scale> &pos) const
|
||||
{
|
||||
return !(*this == pos);
|
||||
};
|
||||
|
||||
bool operator < (const Point<_T,__Scale> &position) const
|
||||
{
|
||||
return std::tie(this->x, this->y) < std::tie(position.x, position.y);
|
||||
};
|
||||
|
||||
_OPERATOR_OP_PT(+)
|
||||
_OPERATOR_OP_PT(-)
|
||||
|
||||
_OPERATOR_OP_VAL(*)
|
||||
_OPERATOR_OP_VAL(&)
|
||||
_OPERATOR_OP_VAL(|)
|
||||
_OPERATOR_OP_VAL(^)
|
||||
|
||||
_OPERATOR_OP_VAL_CHK(/)
|
||||
_OPERATOR_OP_VAL_CHK(%)
|
||||
|
||||
/// Ouput stream operator overload. Outputs the Point in the format "(x,y)" without
|
||||
/// quotations.
|
||||
///
|
||||
/// @param out
|
||||
/// Output stream.
|
||||
/// @param pt
|
||||
/// Point to output.
|
||||
/// @returns Output stream \p out.
|
||||
friend std::ostream &operator << (std::ostream &out, const Point<_T,__Scale> &pt)
|
||||
{
|
||||
return out << '(' << pt.x << ',' << pt.y << ')';
|
||||
};
|
||||
|
||||
/// Input stream operator overload. Reads the input in the form "x y" without quotations.
|
||||
/// The x and y values are read as type T(typically int or float) and stored into pt.
|
||||
///
|
||||
/// @param in
|
||||
/// The input stream.
|
||||
/// @param pt
|
||||
/// The receiving variable.
|
||||
/// @returns Input stream \p in.
|
||||
friend std::istream &operator >> (std::istream &in, Point<_T,__Scale> &pt)
|
||||
{
|
||||
return in >> pt.x >> pt.y;
|
||||
};
|
||||
|
||||
/// Checks if this point is within the game's map bounds.
|
||||
///
|
||||
/// @note If the Broodwar pointer is not initialized, this function will check validity
|
||||
/// against the largest (256x256) map size.
|
||||
///
|
||||
/// @retval true If it is a valid position and on the map/playing field.
|
||||
/// @retval false If this is not a valid position.
|
||||
///
|
||||
/// @see makeValid
|
||||
bool isValid() const;
|
||||
|
||||
/// Checks if this point is within the game's map bounds, if not, then it will set the x and y
|
||||
/// values to be within map bounds. (Example: If x is less than 0, then x is set to 0)
|
||||
///
|
||||
/// @note If the Broodwar pointer is not initialized, this function will check validity
|
||||
/// against the largest (256x256) map size.
|
||||
///
|
||||
/// @returns A reference to itself.
|
||||
/// @see isValid
|
||||
Point &makeValid();
|
||||
|
||||
/// Gets an accurate distance measurement from this point to the given position.
|
||||
///
|
||||
/// @note This function impedes performance. In most cases you should use getApproxDistance.
|
||||
///
|
||||
/// @param position
|
||||
/// The target position to get the distance to.
|
||||
///
|
||||
/// @returns A double representing the distance between this point and \p position.
|
||||
/// @see getApproxDistance
|
||||
double getDistance(const Point<_T,__Scale> &position) const
|
||||
{
|
||||
return ((*this) - position).getLength();
|
||||
};
|
||||
|
||||
/// Gets the length of this point from the top left corner of the map.
|
||||
///
|
||||
/// @note This function impedes performance. In most cases you should use getApproxDistance.
|
||||
///
|
||||
/// @returns A double representing the length of this point from (0,0).
|
||||
/// @see getApproxDistance
|
||||
double getLength() const
|
||||
{
|
||||
double x = (double)this->x;
|
||||
double y = (double)this->y;
|
||||
return sqrt(x * x + y * y);
|
||||
};
|
||||
|
||||
/// Retrieves the approximate distance using an algorithm from Starcraft: Broodwar.
|
||||
///
|
||||
/// @note This function is desired because it uses the same "imperfect" algorithm used in
|
||||
/// Broodwar, so that calculations will be consistent with the game. It is also optimized
|
||||
/// for performance.
|
||||
///
|
||||
/// @param position
|
||||
/// The target point to measure the distance to.
|
||||
///
|
||||
/// @returns An integer representing the distance between this point and \p position.
|
||||
/// @see getDistance
|
||||
int getApproxDistance(const Point<_T,__Scale> &position) const
|
||||
{
|
||||
unsigned int min = abs((int)(this->x - position.x));
|
||||
unsigned int max = abs((int)(this->y - position.y));
|
||||
if ( max < min )
|
||||
std::swap(min, max);
|
||||
|
||||
if ( min < (max >> 2) )
|
||||
return max;
|
||||
|
||||
unsigned int minCalc = (3*min) >> 3;
|
||||
return (minCalc >> 5) + minCalc + max - (max >> 4) - (max >> 6);
|
||||
};
|
||||
|
||||
/// Sets the maximum x and y values. If the current x or y values exceed the given maximum,
|
||||
/// then values are set to the maximum.
|
||||
///
|
||||
/// @param max_x
|
||||
/// Maximum x value.
|
||||
/// @param max_y
|
||||
/// Maximum y value.
|
||||
///
|
||||
/// @returns A reference to itself.
|
||||
/// @see setMin
|
||||
Point &setMax(_T max_x, _T max_y)
|
||||
{
|
||||
if ( x > max_x )
|
||||
x = max_x;
|
||||
if ( y > max_y )
|
||||
y = max_y;
|
||||
return *this;
|
||||
};
|
||||
/// @overload
|
||||
Point &setMax(const Point<_T,__Scale> &max)
|
||||
{
|
||||
this->setMax(max.x, max.y);
|
||||
return *this;
|
||||
};
|
||||
|
||||
/// Sets the minimum x and y values. If the current x or y values are below the given minimum,
|
||||
/// then values are set to the minimum.
|
||||
///
|
||||
/// @param min_x
|
||||
/// Minimum x value.
|
||||
/// @param min_y
|
||||
/// Minimum y value.
|
||||
///
|
||||
/// @returns A reference to itself.
|
||||
/// @see setMax
|
||||
Point &setMin(_T min_x, _T min_y)
|
||||
{
|
||||
if ( x < min_x )
|
||||
x = min_x;
|
||||
if ( y < min_y )
|
||||
y = min_y;
|
||||
return *this;
|
||||
};
|
||||
/// @overload
|
||||
Point &setMin(const Point<_T,__Scale> &min)
|
||||
{
|
||||
this->setMin(min.x, min.y);
|
||||
return *this;
|
||||
};
|
||||
|
||||
/// The x and y members for this class.
|
||||
///
|
||||
/// Simply reference these members when retrieving a position's x and y values.
|
||||
_T x, y;
|
||||
};
|
||||
|
||||
_MAKE_POSITION_TEMPLATE(WalkPosition,int,8)
|
||||
_MAKE_POSITION_TEMPLATE(Position,int,1)
|
||||
_MAKE_POSITION_TEMPLATE(TilePosition,int,32)
|
||||
}
|
||||
|
45
bwapi4-includes/BWAPI/PositionUnit.h
Normal file
45
bwapi4-includes/BWAPI/PositionUnit.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Position.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class UnitInterface;
|
||||
typedef UnitInterface *Unit;
|
||||
|
||||
/// PositionOrUnit is a class that is either a Position OR a Unit. The purpose of this class is
|
||||
/// to reduce interface overhead by combining two commonly passed values into one, and to allow
|
||||
/// more function overloads with little effort.
|
||||
class PositionOrUnit
|
||||
{
|
||||
public:
|
||||
// constructors
|
||||
PositionOrUnit(Unit unit = nullptr);
|
||||
PositionOrUnit(Position pos);
|
||||
|
||||
// operators
|
||||
PositionOrUnit &operator =(Unit pUnit);
|
||||
PositionOrUnit &operator =(Position pos);
|
||||
|
||||
// members (unit)
|
||||
bool isUnit() const;
|
||||
Unit getUnit() const;
|
||||
|
||||
// members (position)
|
||||
bool isPosition() const;
|
||||
Position getPosition() const;
|
||||
private:
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
int x, y;
|
||||
} position;
|
||||
struct
|
||||
{
|
||||
Unit pUnit;
|
||||
int y;
|
||||
} unit;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
104
bwapi4-includes/BWAPI/Race.h
Normal file
104
bwapi4-includes/BWAPI/Race.h
Normal file
|
@ -0,0 +1,104 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class UnitType;
|
||||
|
||||
namespace Races
|
||||
{
|
||||
/// Enumeration of races
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of races
|
||||
enum Enum
|
||||
{
|
||||
Zerg = 0,
|
||||
Terran,
|
||||
Protoss,
|
||||
Other,
|
||||
Unused,
|
||||
Select,
|
||||
Random,
|
||||
None,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/// The Race object is used to get information about a particular race. For example, the default
|
||||
/// worker and supply provider UnitType.
|
||||
///
|
||||
/// As you should already know, Starcraft has three races: @Terran , @Protoss , and @Zerg .
|
||||
/// @see UnitType::getRace, PlayerInterface::getRace
|
||||
class Race : public Type<Race, Races::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
Race(int id = Races::Enum::None);
|
||||
|
||||
/// Retrieves the default worker type for this Race.
|
||||
///
|
||||
/// @note In Starcraft, workers are the units that are used to construct structures.
|
||||
///
|
||||
/// @returns UnitType of the worker that this race uses.
|
||||
UnitType getWorker() const;
|
||||
|
||||
/// Retrieves the default resource center UnitType that is used to create expansions for
|
||||
/// this Race.
|
||||
///
|
||||
/// @note In Starcraft, the center is the very first structure of the Race's technology
|
||||
/// tree. Also known as its base of operations or resource depot.
|
||||
///
|
||||
/// @returns UnitType of the center that this race uses.
|
||||
UnitType getCenter() const;
|
||||
|
||||
/// Retrieves the default structure UnitType for this Race that is used to harvest gas from
|
||||
/// @Geysers .
|
||||
///
|
||||
/// @note In Starcraft, you must first construct a structure over a @Geyser in order to
|
||||
/// begin harvesting Vespene Gas.
|
||||
///
|
||||
/// @returns UnitType of the structure used to harvest gas.
|
||||
UnitType getRefinery() const;
|
||||
|
||||
/// Retrieves the default transport UnitType for this race that is used to transport ground
|
||||
/// units across the map.
|
||||
///
|
||||
/// @note In Starcraft, transports will allow you to carry ground units over unpassable
|
||||
/// terrain.
|
||||
///
|
||||
/// @returns UnitType for transportation.
|
||||
UnitType getTransport() const;
|
||||
|
||||
/// Retrieves the default supply provider UnitType for this race that is used to construct
|
||||
/// units.
|
||||
///
|
||||
/// @note In Starcraft, training, morphing, or warping in units requires that the player
|
||||
/// has sufficient supply available for their Race.
|
||||
///
|
||||
/// @returns UnitType that provides the player with supply.
|
||||
UnitType getSupplyProvider() const;
|
||||
};
|
||||
/// Namespace containing all races
|
||||
namespace Races
|
||||
{
|
||||
/// Retrieves the set of all races.
|
||||
///
|
||||
/// @returns Race::set containing all the Race types.
|
||||
const Race::const_set& allRaces();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const Race x
|
||||
BWAPI_DECL(Zerg);
|
||||
BWAPI_DECL(Terran);
|
||||
BWAPI_DECL(Protoss);
|
||||
BWAPI_DECL(Random);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
129
bwapi4-includes/BWAPI/Region.h
Normal file
129
bwapi4-includes/BWAPI/Region.h
Normal file
|
@ -0,0 +1,129 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Position.h>
|
||||
#include <BWAPI/Filters.h>
|
||||
#include <BWAPI/UnaryFilter.h>
|
||||
#include <BWAPI/Interface.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class Regionset;
|
||||
class Unitset;
|
||||
|
||||
class RegionInterface;
|
||||
typedef RegionInterface *Region;
|
||||
|
||||
/// Region objects are created by Starcraft: Broodwar to contain several tiles with the same
|
||||
/// properties, and create a node in pathfinding and other algorithms. Regions may not contain
|
||||
/// detailed information, but have a sufficient amount of data to identify general chokepoints,
|
||||
/// accessibility to neighboring terrain, be used in general pathing algorithms, and used as
|
||||
/// nodes to rally units to.
|
||||
///
|
||||
/// Most parameters that are available are explicitly assigned by Broodwar itself.
|
||||
///
|
||||
/// @see Game::getAllRegions, Game::getRegionAt, UnitInterface::getRegion
|
||||
class RegionInterface : public Interface<RegionInterface>
|
||||
{
|
||||
protected:
|
||||
virtual ~RegionInterface() {};
|
||||
public:
|
||||
/// Retrieves a unique identifier for this region.
|
||||
///
|
||||
/// @note This identifier is explicitly assigned by Broodwar.
|
||||
///
|
||||
/// @returns An integer that represents this region.
|
||||
/// @see Game::getRegion
|
||||
virtual int getID() const = 0;
|
||||
|
||||
/// Retrieves a unique identifier for a group of regions that are all connected and accessible
|
||||
/// by each other. That is, all accessible regions will have the same group ID. This function
|
||||
/// is generally used to check if a path is available between two points in constant time.
|
||||
///
|
||||
/// @note This identifier is explicitly assigned by Broodwar.
|
||||
///
|
||||
/// @returns An integer that represents the group of regions that this one is attached to.
|
||||
virtual int getRegionGroupID() const = 0;
|
||||
|
||||
/// Retrieves the center of the region. This position is used as the node of the region.
|
||||
///
|
||||
/// @returns A Position indicating the center location of the Region, in pixels.
|
||||
virtual BWAPI::Position getCenter() const = 0;
|
||||
|
||||
/// Checks if this region is part of higher ground. Higher ground may be used in strategic
|
||||
/// placement of units and structures.
|
||||
///
|
||||
/// @returns true if this region is part of strategic higher ground, and false otherwise.
|
||||
virtual bool isHigherGround() const = 0;
|
||||
|
||||
/// Retrieves a value that represents the strategic advantage of this region relative to other
|
||||
/// regions. A value of 2 may indicate a possible choke point, and a value of 3 indicates a
|
||||
/// signficant strategic position.
|
||||
///
|
||||
/// @note This value is explicitly assigned by Broodwar.
|
||||
///
|
||||
/// @returns An integer indicating this region's strategic potential.
|
||||
virtual int getDefensePriority() const = 0;
|
||||
|
||||
/// Retrieves the state of accessibility of the region. The region is considered accessible
|
||||
/// if it can be accessed by ground units.
|
||||
///
|
||||
/// @returns true if ground units can traverse this region, and false if the tiles in this
|
||||
/// region are inaccessible or unwalkable.
|
||||
virtual bool isAccessible() const = 0;
|
||||
|
||||
/// Retrieves the set of neighbor Regions that this one is connected to.
|
||||
///
|
||||
/// @returns A reference to a Regionset containing the neighboring Regions.
|
||||
virtual const Regionset &getNeighbors() const = 0;
|
||||
|
||||
/// Retrieves the approximate left boundary of the region.
|
||||
///
|
||||
/// @returns The x coordinate, in pixels, of the approximate left boundary of the region.
|
||||
virtual int getBoundsLeft() const = 0;
|
||||
|
||||
/// Retrieves the approximate top boundary of the region.
|
||||
///
|
||||
/// @returns The y coordinate, in pixels, of the approximate top boundary of the region.
|
||||
virtual int getBoundsTop() const = 0;
|
||||
|
||||
/// Retrieves the approximate right boundary of the region.
|
||||
///
|
||||
/// @returns The x coordinate, in pixels, of the approximate right boundary of the region.
|
||||
virtual int getBoundsRight() const = 0;
|
||||
|
||||
/// Retrieves the approximate bottom boundary of the region.
|
||||
///
|
||||
/// @returns The y coordinate, in pixels, of the approximate bottom boundary of the region.
|
||||
virtual int getBoundsBottom() const = 0;
|
||||
|
||||
/// Retrieves the closest accessible neighbor region.
|
||||
///
|
||||
/// @returns The closest Region that is accessible.
|
||||
virtual BWAPI::Region getClosestAccessibleRegion() const = 0;
|
||||
|
||||
/// Retrieves the closest inaccessible neighbor region.
|
||||
///
|
||||
/// @returns The closest Region that is inaccessible.
|
||||
virtual BWAPI::Region getClosestInaccessibleRegion() const = 0;
|
||||
|
||||
/// Retrieves the center-to-center distance between two regions.
|
||||
///
|
||||
/// @param other
|
||||
/// The target Region to calculate distance to.
|
||||
/// @returns The integer distance from this Region to \p other.
|
||||
int getDistance(BWAPI::Region other) const;
|
||||
|
||||
/// Retrieves a Unitset containing all the units that are in this region. Also has the ability
|
||||
/// to filter the units before the creation of the Unitset.
|
||||
///
|
||||
/// @param pred (optional)
|
||||
/// If this parameter is used, it is a UnitFilter or function predicate that will retrieve
|
||||
/// only the units whose attributes match the given criteria. If omitted, then a default
|
||||
/// value of nullptr is used, in which case there is no filter.
|
||||
///
|
||||
/// @returns A Unitset containing all units in this region that have met the requirements
|
||||
/// of \p pred.
|
||||
///
|
||||
/// @see UnitFilter
|
||||
Unitset getUnits(const UnitFilter &pred = nullptr) const;
|
||||
};
|
||||
};
|
28
bwapi4-includes/BWAPI/Regionset.h
Normal file
28
bwapi4-includes/BWAPI/Regionset.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Vectorset.h>
|
||||
#include <BWAPI/Position.h>
|
||||
#include <BWAPI/Filters.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forward Declarations
|
||||
class RegionInterface;
|
||||
typedef RegionInterface *Region;
|
||||
|
||||
class Unitset;
|
||||
|
||||
class Regionset : public Vectorset<BWAPI::Region>
|
||||
{
|
||||
public:
|
||||
Regionset(size_t initialSize = 16);
|
||||
Regionset(const Regionset &other);
|
||||
Regionset(Regionset &&other);
|
||||
|
||||
/// @copydoc RegionInterface::getCenter
|
||||
Position getCenter() const;
|
||||
|
||||
/// @copydoc RegionInterface::getUnits
|
||||
Unitset getUnits(const UnitFilter &pred = nullptr) const;
|
||||
};
|
||||
}
|
||||
|
185
bwapi4-includes/BWAPI/TechType.h
Normal file
185
bwapi4-includes/BWAPI/TechType.h
Normal file
|
@ -0,0 +1,185 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
#include <BWAPI/UnitType.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class WeaponType;
|
||||
class Order;
|
||||
class Race;
|
||||
|
||||
namespace TechTypes
|
||||
{
|
||||
/// Enumeration of Tech Types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of Tech Types
|
||||
enum Enum
|
||||
{
|
||||
Stim_Packs = 0,
|
||||
Lockdown,
|
||||
EMP_Shockwave,
|
||||
Spider_Mines,
|
||||
Scanner_Sweep,
|
||||
Tank_Siege_Mode,
|
||||
Defensive_Matrix,
|
||||
Irradiate,
|
||||
Yamato_Gun,
|
||||
Cloaking_Field,
|
||||
Personnel_Cloaking,
|
||||
Burrowing,
|
||||
Infestation,
|
||||
Spawn_Broodlings,
|
||||
Dark_Swarm,
|
||||
Plague,
|
||||
Consume,
|
||||
Ensnare,
|
||||
Parasite,
|
||||
Psionic_Storm,
|
||||
Hallucination,
|
||||
Recall,
|
||||
Stasis_Field,
|
||||
Archon_Warp,
|
||||
Restoration,
|
||||
Disruption_Web,
|
||||
Unused_26,
|
||||
Mind_Control,
|
||||
Dark_Archon_Meld,
|
||||
Feedback,
|
||||
Optical_Flare,
|
||||
Maelstrom,
|
||||
Lurker_Aspect,
|
||||
Unused_33,
|
||||
Healing,
|
||||
|
||||
None = 44,
|
||||
Nuclear_Strike,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
};
|
||||
}
|
||||
/// The TechType (or Technology Type, also referred to as an Ability) represents a Unit's ability
|
||||
/// which can be researched with UnitInterface::research or used with UnitInterface::useTech. In order for a Unit
|
||||
/// to use its own specialized ability, it must first be available and researched.
|
||||
class TechType : public Type<TechType, TechTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
TechType(int id = TechTypes::Enum::None);
|
||||
|
||||
/// Retrieves the race that is required to research or use the TechType.
|
||||
///
|
||||
/// @note There is an exception where @Infested_Kerrigan can use @Psi_Storm. This does not
|
||||
/// apply to the behavior of this function.
|
||||
///
|
||||
/// @returns Race object indicating which race is designed to use this technology type.
|
||||
Race getRace() const;
|
||||
|
||||
/// Retrieves the mineral cost of researching this technology.
|
||||
///
|
||||
/// @returns Amount of minerals needed in order to research this technology.
|
||||
int mineralPrice() const;
|
||||
|
||||
/// Retrieves the vespene gas cost of researching this technology.
|
||||
///
|
||||
/// @returns Amount of vespene gas needed in order to research this technology.
|
||||
int gasPrice() const;
|
||||
|
||||
/// Retrieves the number of frames needed to research the tech type.
|
||||
///
|
||||
/// @returns The time, in frames, it will take for the research to complete.
|
||||
/// @see UnitInterface::getRemainingResearchTime
|
||||
int researchTime() const;
|
||||
|
||||
/// Retrieves the amount of energy needed to use this TechType as an ability.
|
||||
///
|
||||
/// @returns Energy cost of the ability.
|
||||
/// @see UnitInterface::getEnergy
|
||||
int energyCost() const;
|
||||
|
||||
/// Retrieves the UnitType that can research this technology.
|
||||
///
|
||||
/// @returns UnitType that is able to research the technology in the game.
|
||||
/// @retval UnitTypes::None If the technology/ability is either provided for free or never
|
||||
/// available.
|
||||
UnitType whatResearches() const;
|
||||
|
||||
/// Retrieves the Weapon that is attached to this tech type. A technology's WeaponType
|
||||
/// is used to indicate the range and behaviour of the ability when used by a Unit.
|
||||
///
|
||||
/// @returns WeaponType containing information about the ability's behavior.
|
||||
/// @retval WeaponTypes::None If there is no corresponding WeaponType.
|
||||
WeaponType getWeapon() const;
|
||||
|
||||
/// Checks if this ability can be used on other units.
|
||||
///
|
||||
/// @returns true if the ability can be used on other units, and false if it can not.
|
||||
bool targetsUnit() const;
|
||||
|
||||
/// Checks if this ability can be used on the terrain (ground).
|
||||
///
|
||||
/// @returns true if the ability can be used on the terrain.
|
||||
bool targetsPosition() const;
|
||||
|
||||
/// Retrieves the set of all UnitTypes that are capable of using this ability.
|
||||
///
|
||||
/// @returns Set of UnitTypes that can use this ability when researched.
|
||||
const UnitType::const_set& whatUses() const;
|
||||
|
||||
/// Retrieves the Order that a Unit uses when using this ability.
|
||||
///
|
||||
/// @returns Order representing the action a Unit uses to perform this ability
|
||||
Order getOrder() const;
|
||||
};
|
||||
/// Namespace containing tech types
|
||||
namespace TechTypes
|
||||
{
|
||||
/// Retrieves the set of all the TechTypes.
|
||||
///
|
||||
/// @returns Set of all available TechTypes.
|
||||
const TechType::const_set& allTechTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const TechType x
|
||||
BWAPI_DECL(Stim_Packs);
|
||||
BWAPI_DECL(Lockdown);
|
||||
BWAPI_DECL(EMP_Shockwave);
|
||||
BWAPI_DECL(Spider_Mines);
|
||||
BWAPI_DECL(Scanner_Sweep);
|
||||
BWAPI_DECL(Tank_Siege_Mode);
|
||||
BWAPI_DECL(Defensive_Matrix);
|
||||
BWAPI_DECL(Irradiate);
|
||||
BWAPI_DECL(Yamato_Gun);
|
||||
BWAPI_DECL(Cloaking_Field);
|
||||
BWAPI_DECL(Personnel_Cloaking);
|
||||
BWAPI_DECL(Burrowing);
|
||||
BWAPI_DECL(Infestation);
|
||||
BWAPI_DECL(Spawn_Broodlings);
|
||||
BWAPI_DECL(Dark_Swarm);
|
||||
BWAPI_DECL(Plague);
|
||||
BWAPI_DECL(Consume);
|
||||
BWAPI_DECL(Ensnare);
|
||||
BWAPI_DECL(Parasite);
|
||||
BWAPI_DECL(Psionic_Storm);
|
||||
BWAPI_DECL(Hallucination);
|
||||
BWAPI_DECL(Recall);
|
||||
BWAPI_DECL(Stasis_Field);
|
||||
BWAPI_DECL(Archon_Warp);
|
||||
BWAPI_DECL(Restoration);
|
||||
BWAPI_DECL(Disruption_Web);
|
||||
BWAPI_DECL(Mind_Control);
|
||||
BWAPI_DECL(Dark_Archon_Meld);
|
||||
BWAPI_DECL(Feedback);
|
||||
BWAPI_DECL(Optical_Flare);
|
||||
BWAPI_DECL(Maelstrom);
|
||||
BWAPI_DECL(Lurker_Aspect);
|
||||
BWAPI_DECL(Healing);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Nuclear_Strike);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
};
|
||||
}
|
25
bwapi4-includes/BWAPI/TournamentAction.h
Normal file
25
bwapi4-includes/BWAPI/TournamentAction.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace Tournament
|
||||
{
|
||||
enum ActionID
|
||||
{
|
||||
EnableFlag,
|
||||
PauseGame,
|
||||
ResumeGame,
|
||||
LeaveGame,
|
||||
SetLocalSpeed,
|
||||
SetTextSize,
|
||||
SetLatCom,
|
||||
SetGUI,
|
||||
SetMap,
|
||||
SetFrameSkip,
|
||||
Printf,
|
||||
SendText,
|
||||
SetCommandOptimizationLevel
|
||||
};
|
||||
|
||||
};
|
||||
};
|
172
bwapi4-includes/BWAPI/Type.h
Normal file
172
bwapi4-includes/BWAPI/Type.h
Normal file
|
@ -0,0 +1,172 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <cctype>
|
||||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
|
||||
#include <BWAPI/Vectorset.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// @TODO Get rid of this eventually.
|
||||
template<class T>
|
||||
class Typeset : public Vectorset<T>
|
||||
{
|
||||
public:
|
||||
// Constructors
|
||||
Typeset() : Vectorset<T>() {};
|
||||
// copy ctor
|
||||
Typeset(const Typeset<T> &other) : Vectorset<T>( other ) {};
|
||||
Typeset(const ConstVectorset<T> &other) : Vectorset<T>( other ) {};
|
||||
|
||||
// move ctor
|
||||
Typeset(Typeset<T> &&other) : Vectorset<T>( std::forward< Typeset<T> >(other) ) {};
|
||||
// type ctor
|
||||
Typeset(const T &val) : Vectorset<T>() { this->push_back(val); };
|
||||
// array ctor
|
||||
Typeset(const T *pArray, size_t size) : Vectorset<T>(pArray, size) {};
|
||||
Typeset(const int *pArray, size_t size) : Vectorset<T>((const T*)pArray, size) {};
|
||||
|
||||
~Typeset() {};
|
||||
|
||||
// Operators (adding elements)
|
||||
Typeset operator |(const T &val) const
|
||||
{
|
||||
Typeset newset(*this);
|
||||
newset.insert(val);
|
||||
return newset;
|
||||
};
|
||||
Typeset &operator |=(const T &val)
|
||||
{
|
||||
this->insert(val);
|
||||
return *this;
|
||||
};
|
||||
Typeset &operator |=(const Typeset<T> &val)
|
||||
{
|
||||
this->insert(val);
|
||||
return *this;
|
||||
};
|
||||
};
|
||||
|
||||
/// Base superclass for all BWAPI Types.
|
||||
template<class T, int UnknownId>
|
||||
class Type
|
||||
{
|
||||
protected:
|
||||
/// Primitive storage unit for the type identifier (t id)
|
||||
int tid;
|
||||
|
||||
/// Array of strings containing the type names.
|
||||
static const std::string typeNames[UnknownId+1];
|
||||
|
||||
typedef std::unordered_map<std::string,T> typeMapT;
|
||||
|
||||
private:
|
||||
static typeMapT typeMapInit()
|
||||
{
|
||||
typeMapT result(UnknownId+1);
|
||||
for ( int i = 0; i < UnknownId + 1; ++i ) // include unknown
|
||||
{
|
||||
std::string n( typeNames[i] );
|
||||
|
||||
// erase-remove idiom, eliminates spaces and underscores from the string
|
||||
n.erase( std::remove_if(n.begin(), n.end(), [](char const &c){ return isspace(c) || c == '_'; }), n.end() );
|
||||
|
||||
// Make lowercase
|
||||
std::transform(n.begin(), n.end(), n.begin(), ::tolower);
|
||||
|
||||
result.insert( typeMapT::value_type(n, T(i)) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public:
|
||||
/// Expected type constructor. If the type is an invalid type, then it becomes Types::Unknown.
|
||||
/// A type is invalid if its value is less than 0 or greater than Types::Unknown.
|
||||
///
|
||||
/// @param id (optional)
|
||||
/// The id that corresponds to this type. It is typically an integer value that corresponds
|
||||
/// to an internal Broodwar type. If the given id is invalid, then it becomes Types::Unknown.
|
||||
/// If it is omitted, then it becomes Types::None.
|
||||
explicit Type(int id) : tid( id < 0 || id > UnknownId ? UnknownId : id ) {};
|
||||
|
||||
/// The set that contains the current type.
|
||||
typedef Typeset<T> set;
|
||||
|
||||
/// The constant set that contains the current type.
|
||||
typedef ConstVectorset<T> const_set;
|
||||
|
||||
/// Conversion/convenience operator to convert this type to its primitive type.
|
||||
inline operator int() const { return this->tid; };
|
||||
|
||||
/// Retrieves this type's identifier.
|
||||
///
|
||||
/// @returns An integer representation of this type.
|
||||
inline int getID() const { return this->tid; };
|
||||
|
||||
/// Checks if the current type has a valid identifier. The purpose of this function is to
|
||||
/// prevent buffer overflows if a type has been handled improperly.
|
||||
///
|
||||
/// A type is valid if it is between 0 and Unknown (inclusive).
|
||||
///
|
||||
/// @returns true If this type is valid and false otherwise.
|
||||
inline bool isValid() const { return this->tid >= 0 && this->tid <= UnknownId; };
|
||||
|
||||
/// Retrieves the variable name of the type.
|
||||
///
|
||||
/// @returns Reference to std::string object containing the name.
|
||||
inline const std::string &getName() const
|
||||
{
|
||||
return typeNames[this->isValid() ? this->tid : UnknownId];
|
||||
};
|
||||
|
||||
/// @copydoc Type::getName
|
||||
inline const std::string &toString() const
|
||||
{
|
||||
return this->getName();
|
||||
};
|
||||
|
||||
/// Retrieves the variable name of the type as a c-style string. Meant to be a convenience
|
||||
/// member.
|
||||
///
|
||||
/// @returns Pointer to constant c-style string containing the name.
|
||||
inline const char *c_str() const
|
||||
{
|
||||
return this->getName().c_str();
|
||||
};
|
||||
|
||||
/// Output stream operator overload. Allows printing of the type without calling
|
||||
/// Type::getName.
|
||||
friend inline std::ostream &operator << (std::ostream &out, const Type<T,UnknownId> &t)
|
||||
{
|
||||
return out << t.getName();
|
||||
};
|
||||
|
||||
/// Searches for the type associated with the given string and returns it.
|
||||
///
|
||||
/// @param name
|
||||
/// A string containing the name of the type.
|
||||
///
|
||||
/// @returns The type that resolves to the given name.
|
||||
static T getType(std::string name)
|
||||
{
|
||||
// Mapping of strings to types
|
||||
static const typeMapT typeMap( typeMapInit() );
|
||||
|
||||
// erase-remove idiom, eliminates spaces and underscores from the string to search
|
||||
name.erase( std::remove_if(name.begin(), name.end(), [](char const &c){ return isspace(c) || c == '_'; }), name.end() );
|
||||
|
||||
// Make lowercase
|
||||
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
|
||||
|
||||
// Find the type
|
||||
auto it = typeMap.find(name);
|
||||
if ( it != typeMap.end() )
|
||||
return it->second;
|
||||
|
||||
// Return unknown if it wasn't found
|
||||
return T(UnknownId);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
68
bwapi4-includes/BWAPI/UnaryFilter.h
Normal file
68
bwapi4-includes/BWAPI/UnaryFilter.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
#pragma once
|
||||
#include <functional>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
/// UnaryFilter allows for logical functor combinations.
|
||||
///
|
||||
/// @code
|
||||
/// Unit myUnit;
|
||||
/// // The following two if statements are equivalent
|
||||
/// if ( myUnit->getType().isWorker() && myUnit->isCompleted() && myUnit->isIdle() )
|
||||
/// {}
|
||||
///
|
||||
/// if ( (IsWorker && IsCompleted && IsIdle)(myUnit) )
|
||||
/// {}
|
||||
/// @endcode
|
||||
///
|
||||
/// @tparam PType
|
||||
/// The type being passed into the predicate, which will be of type bool(PType).
|
||||
/// @tparam Container (optional)
|
||||
/// Storage container for the function predicate. It is std::function<bool(PType)> by default.
|
||||
template <class PType, class Container = std::function<bool(PType)> >
|
||||
class UnaryFilter
|
||||
{
|
||||
private:
|
||||
Container pred;
|
||||
public:
|
||||
// ctor
|
||||
template < typename T >
|
||||
UnaryFilter(const T &predicate) : pred(predicate) {}
|
||||
|
||||
// Default copy/move ctor/assign and dtor
|
||||
|
||||
// logical operators
|
||||
template <typename T>
|
||||
inline UnaryFilter<PType,std::function<bool(PType)> > operator &&(const T& other) const
|
||||
{
|
||||
return [=](PType v){ return (*this)(v) && other(v); };
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline UnaryFilter<PType,std::function<bool(PType)> > operator ||(const T& other) const
|
||||
{
|
||||
return [=](PType v){ return (*this)(v) || other(v); };
|
||||
};
|
||||
|
||||
inline UnaryFilter<PType,std::function<bool(PType)> > operator !() const
|
||||
{
|
||||
if ( !this->pred )
|
||||
return nullptr;
|
||||
return [=](PType v){ return !(*this)(v); };
|
||||
};
|
||||
|
||||
// call
|
||||
inline bool operator()(PType v) const
|
||||
{
|
||||
return pred(v);
|
||||
};
|
||||
|
||||
// operator bool
|
||||
inline bool isValid() const
|
||||
{
|
||||
return (bool)pred;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
2004
bwapi4-includes/BWAPI/Unit.h
Normal file
2004
bwapi4-includes/BWAPI/Unit.h
Normal file
File diff suppressed because it is too large
Load diff
81
bwapi4-includes/BWAPI/UnitCommand.h
Normal file
81
bwapi4-includes/BWAPI/UnitCommand.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Position.h>
|
||||
#include <BWAPI/UnitCommandType.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forwards
|
||||
class UnitType;
|
||||
class TechType;
|
||||
class UpgradeType;
|
||||
class PositionOrUnit;
|
||||
class UnitInterface;
|
||||
typedef UnitInterface *Unit;
|
||||
|
||||
class UnitCommand
|
||||
{
|
||||
public:
|
||||
UnitCommand();
|
||||
UnitCommand(Unit _unit, UnitCommandType _type, Unit _target, int _x, int _y, int _extra);
|
||||
|
||||
static UnitCommand attack(Unit unit, PositionOrUnit target, bool shiftQueueCommand = false);
|
||||
static UnitCommand build(Unit unit, TilePosition target, UnitType type);
|
||||
static UnitCommand buildAddon(Unit unit, UnitType type);
|
||||
static UnitCommand train(Unit unit, UnitType type);
|
||||
static UnitCommand morph(Unit unit, UnitType type);
|
||||
static UnitCommand research(Unit unit, TechType tech);
|
||||
static UnitCommand upgrade(Unit unit, UpgradeType upgrade);
|
||||
static UnitCommand setRallyPoint(Unit unit, PositionOrUnit target);
|
||||
static UnitCommand move(Unit unit, Position target, bool shiftQueueCommand = false);
|
||||
static UnitCommand patrol(Unit unit, Position target, bool shiftQueueCommand = false);
|
||||
static UnitCommand holdPosition(Unit unit, bool shiftQueueCommand = false);
|
||||
static UnitCommand stop(Unit unit, bool shiftQueueCommand = false);
|
||||
static UnitCommand follow(Unit unit, Unit target, bool shiftQueueCommand = false);
|
||||
static UnitCommand gather(Unit unit, Unit target, bool shiftQueueCommand = false);
|
||||
static UnitCommand returnCargo(Unit unit, bool shiftQueueCommand = false);
|
||||
static UnitCommand repair(Unit unit, Unit target, bool shiftQueueCommand = false);
|
||||
static UnitCommand burrow(Unit unit);
|
||||
static UnitCommand unburrow(Unit unit);
|
||||
static UnitCommand cloak(Unit unit);
|
||||
static UnitCommand decloak(Unit unit);
|
||||
static UnitCommand siege(Unit unit);
|
||||
static UnitCommand unsiege(Unit unit);
|
||||
static UnitCommand lift(Unit unit);
|
||||
static UnitCommand land(Unit unit, TilePosition target);
|
||||
static UnitCommand load(Unit unit, Unit target, bool shiftQueueCommand = false);
|
||||
static UnitCommand unload(Unit unit, Unit target);
|
||||
static UnitCommand unloadAll(Unit unit, bool shiftQueueCommand = false);
|
||||
static UnitCommand unloadAll(Unit unit, Position target, bool shiftQueueCommand = false);
|
||||
static UnitCommand rightClick(Unit unit, PositionOrUnit target, bool shiftQueueCommand = false);
|
||||
static UnitCommand haltConstruction(Unit unit);
|
||||
static UnitCommand cancelConstruction(Unit unit);
|
||||
static UnitCommand cancelAddon(Unit unit);
|
||||
static UnitCommand cancelTrain(Unit unit, int slot = -2);
|
||||
static UnitCommand cancelMorph(Unit unit);
|
||||
static UnitCommand cancelResearch(Unit unit);
|
||||
static UnitCommand cancelUpgrade(Unit unit);
|
||||
static UnitCommand useTech(Unit unit,TechType tech);
|
||||
static UnitCommand useTech(Unit unit,TechType tech, PositionOrUnit target);
|
||||
static UnitCommand placeCOP(Unit unit, TilePosition target);
|
||||
|
||||
UnitCommandType getType() const;
|
||||
Unit getUnit() const;
|
||||
Unit getTarget() const;
|
||||
Position getTargetPosition() const;
|
||||
TilePosition getTargetTilePosition() const;
|
||||
UnitType getUnitType() const;
|
||||
TechType getTechType() const;
|
||||
UpgradeType getUpgradeType() const;
|
||||
int getSlot() const;
|
||||
bool isQueued() const;
|
||||
|
||||
bool operator==(const UnitCommand& other) const;
|
||||
bool operator!=(const UnitCommand& other) const;
|
||||
|
||||
Unit unit;
|
||||
UnitCommandType type;
|
||||
Unit target;
|
||||
int x, y;
|
||||
int extra;
|
||||
};
|
||||
}
|
130
bwapi4-includes/BWAPI/UnitCommandType.h
Normal file
130
bwapi4-includes/BWAPI/UnitCommandType.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace UnitCommandTypes
|
||||
{
|
||||
/// Enumeration of unit command types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of unit command types
|
||||
enum Enum
|
||||
{
|
||||
Attack_Move = 0,
|
||||
Attack_Unit,
|
||||
Build,
|
||||
Build_Addon,
|
||||
Train,
|
||||
Morph,
|
||||
Research,
|
||||
Upgrade,
|
||||
Set_Rally_Position,
|
||||
Set_Rally_Unit,
|
||||
Move,
|
||||
Patrol,
|
||||
Hold_Position,
|
||||
Stop,
|
||||
Follow,
|
||||
Gather,
|
||||
Return_Cargo,
|
||||
Repair,
|
||||
Burrow,
|
||||
Unburrow,
|
||||
Cloak,
|
||||
Decloak,
|
||||
Siege,
|
||||
Unsiege,
|
||||
Lift,
|
||||
Land,
|
||||
Load,
|
||||
Unload,
|
||||
Unload_All,
|
||||
Unload_All_Position,
|
||||
Right_Click_Position,
|
||||
Right_Click_Unit,
|
||||
Halt_Construction,
|
||||
Cancel_Construction,
|
||||
Cancel_Addon,
|
||||
Cancel_Train,
|
||||
Cancel_Train_Slot,
|
||||
Cancel_Morph,
|
||||
Cancel_Research,
|
||||
Cancel_Upgrade,
|
||||
Use_Tech,
|
||||
Use_Tech_Position,
|
||||
Use_Tech_Unit,
|
||||
Place_COP,
|
||||
None,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
};
|
||||
};
|
||||
class UnitCommandType : public Type<UnitCommandType, UnitCommandTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
UnitCommandType(int id = UnitCommandTypes::Enum::None);
|
||||
};
|
||||
/// Namespace containing unit command types
|
||||
namespace UnitCommandTypes
|
||||
{
|
||||
/// Retrieves the set of all UnitCommandTypes.
|
||||
///
|
||||
/// @returns Set of UnitCommandTypes.
|
||||
const UnitCommandType::const_set& allUnitCommandTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const UnitCommandType x
|
||||
BWAPI_DECL(Attack_Move);
|
||||
BWAPI_DECL(Attack_Unit);
|
||||
BWAPI_DECL(Build);
|
||||
BWAPI_DECL(Build_Addon);
|
||||
BWAPI_DECL(Train);
|
||||
BWAPI_DECL(Morph);
|
||||
BWAPI_DECL(Research);
|
||||
BWAPI_DECL(Upgrade);
|
||||
BWAPI_DECL(Set_Rally_Position);
|
||||
BWAPI_DECL(Set_Rally_Unit);
|
||||
BWAPI_DECL(Move);
|
||||
BWAPI_DECL(Patrol);
|
||||
BWAPI_DECL(Hold_Position);
|
||||
BWAPI_DECL(Stop);
|
||||
BWAPI_DECL(Follow);
|
||||
BWAPI_DECL(Gather);
|
||||
BWAPI_DECL(Return_Cargo);
|
||||
BWAPI_DECL(Repair);
|
||||
BWAPI_DECL(Burrow);
|
||||
BWAPI_DECL(Unburrow);
|
||||
BWAPI_DECL(Cloak);
|
||||
BWAPI_DECL(Decloak);
|
||||
BWAPI_DECL(Siege);
|
||||
BWAPI_DECL(Unsiege);
|
||||
BWAPI_DECL(Lift);
|
||||
BWAPI_DECL(Land);
|
||||
BWAPI_DECL(Load);
|
||||
BWAPI_DECL(Unload);
|
||||
BWAPI_DECL(Unload_All);
|
||||
BWAPI_DECL(Unload_All_Position);
|
||||
BWAPI_DECL(Right_Click_Position);
|
||||
BWAPI_DECL(Right_Click_Unit);
|
||||
BWAPI_DECL(Halt_Construction);
|
||||
BWAPI_DECL(Cancel_Construction);
|
||||
BWAPI_DECL(Cancel_Addon);
|
||||
BWAPI_DECL(Cancel_Train);
|
||||
BWAPI_DECL(Cancel_Train_Slot);
|
||||
BWAPI_DECL(Cancel_Morph);
|
||||
BWAPI_DECL(Cancel_Research);
|
||||
BWAPI_DECL(Cancel_Upgrade);
|
||||
BWAPI_DECL(Use_Tech);
|
||||
BWAPI_DECL(Use_Tech_Position);
|
||||
BWAPI_DECL(Use_Tech_Unit);
|
||||
BWAPI_DECL(Place_COP);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
52
bwapi4-includes/BWAPI/UnitSizeType.h
Normal file
52
bwapi4-includes/BWAPI/UnitSizeType.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
#define BWAPI_UNITSIZETYPEDEF(x) static const UnitSizeType x(Enum::x) /** ref x */
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
namespace UnitSizeTypes
|
||||
{
|
||||
/// Enumeration of unit size types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of unit size types
|
||||
enum Enum
|
||||
{
|
||||
Independent = 0,
|
||||
Small,
|
||||
Medium,
|
||||
Large,
|
||||
None,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
};
|
||||
};
|
||||
class UnitSizeType : public Type<UnitSizeType, UnitSizeTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
UnitSizeType(int id = UnitSizeTypes::Enum::None);
|
||||
};
|
||||
/// Namespace containing unit size types
|
||||
namespace UnitSizeTypes
|
||||
{
|
||||
/// Retrieves the set of all UnitSizeTypes.
|
||||
///
|
||||
/// @returns Set of all UnitSizeTypes.
|
||||
const UnitSizeType::const_set& allUnitSizeTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const UnitSizeType x
|
||||
BWAPI_DECL(Independent);
|
||||
BWAPI_DECL(Small);
|
||||
BWAPI_DECL(Medium);
|
||||
BWAPI_DECL(Large);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
1025
bwapi4-includes/BWAPI/UnitType.h
Normal file
1025
bwapi4-includes/BWAPI/UnitType.h
Normal file
File diff suppressed because it is too large
Load diff
191
bwapi4-includes/BWAPI/Unitset.h
Normal file
191
bwapi4-includes/BWAPI/Unitset.h
Normal file
|
@ -0,0 +1,191 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Vectorset.h>
|
||||
#include <BWAPI/Position.h>
|
||||
#include <BWAPI/PositionUnit.h>
|
||||
#include <BWAPI/Filters.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
// Forward declarations
|
||||
class UnitType;
|
||||
class Regionset;
|
||||
class UnitCommand;
|
||||
class TechType;
|
||||
|
||||
/// 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.
|
||||
///
|
||||
/// @note Because of the efficiency, it is recommended to use the Unitset over any of the STL
|
||||
/// containers.
|
||||
///
|
||||
/// @see Unit, UnitType, UnitSizeType
|
||||
class Unitset : public Vectorset<BWAPI::Unit >
|
||||
{
|
||||
public:
|
||||
/// A blank Unitset containing no elements. This is typically used as a return value for BWAPI
|
||||
/// interface functions that have encountered an error.
|
||||
static const Unitset none;
|
||||
|
||||
/// The Unitset constructor.
|
||||
///
|
||||
/// @param initialSize The initial maximum size of the Unitset before expanding it is
|
||||
/// necessary.
|
||||
Unitset(size_t initialSize = 16);
|
||||
|
||||
/// The copy constructor.
|
||||
///
|
||||
/// @param other The Unitset to construct this one from.
|
||||
Unitset(const Unitset &other);
|
||||
|
||||
/// The move constructor.
|
||||
///
|
||||
/// @param other The Unitset to move its contents from.
|
||||
Unitset(Unitset &&other);
|
||||
|
||||
/// Calculates the average of all valid Unit positions in this set.
|
||||
///
|
||||
/// @returns Average Position of all units in the set.
|
||||
///
|
||||
/// @see UnitInterface::getPosition
|
||||
Position getPosition() const;
|
||||
|
||||
/// Creates a single set containing all units that are loaded into units of this set.
|
||||
///
|
||||
/// @returns The set of all loaded units.
|
||||
///
|
||||
/// @see UnitInterface::getLoadedUnits
|
||||
Unitset getLoadedUnits() const;
|
||||
|
||||
/// Creates a single set containing all the @Interceptors of all @Carriers in this set.
|
||||
///
|
||||
/// @returns The set of all @Interceptors .
|
||||
///
|
||||
/// @see UnitInterface::getInterceptors
|
||||
Unitset getInterceptors() const;
|
||||
|
||||
/// Creates a single set containing all the @Larvae of all @Hatcheries, @Lairs, and @Hives in
|
||||
/// this set.
|
||||
///
|
||||
/// @returns The set of all @Larvae .
|
||||
///
|
||||
/// @see UnitInterface::getLarva
|
||||
Unitset getLarva() const;
|
||||
|
||||
/// Sets the client info for every unit in this set.
|
||||
///
|
||||
/// @param clientInfo A pointer to client information, managed by the AI module, or nullptr if
|
||||
/// client information is to be cleared.
|
||||
///
|
||||
/// @see UnitInterface::setClientInfo
|
||||
void setClientInfo(void *clientInfo = nullptr, int index = 0) const;
|
||||
|
||||
/// @overload
|
||||
void setClientInfo(int clientInfo = 0, int index = 0) const;
|
||||
|
||||
Unitset getUnitsInRadius(int radius, const UnitFilter &pred = nullptr) const;
|
||||
Unit getClosestUnit(const UnitFilter &pred = nullptr, int radius = 999999) const;
|
||||
|
||||
/// @copydoc UnitInterface::issueCommand
|
||||
bool issueCommand(UnitCommand command) const;
|
||||
|
||||
/// @copydoc UnitInterface::attack
|
||||
bool attack(PositionOrUnit target, bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::build
|
||||
bool build(UnitType type, TilePosition target = TilePositions::None) const;
|
||||
|
||||
/// @copydoc UnitInterface::buildAddon
|
||||
bool buildAddon(UnitType type) const;
|
||||
|
||||
/// @copydoc UnitInterface::train
|
||||
bool train(UnitType type) const;
|
||||
|
||||
/// @copydoc UnitInterface::morph
|
||||
bool morph(UnitType type) const;
|
||||
|
||||
/// @copydoc UnitInterface::setRallyPoint
|
||||
bool setRallyPoint(PositionOrUnit target) const;
|
||||
|
||||
/// @copydoc UnitInterface::move
|
||||
bool move(Position target, bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::patrol
|
||||
bool patrol(Position target, bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::holdPosition
|
||||
bool holdPosition(bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::stop
|
||||
bool stop(bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::follow
|
||||
bool follow(Unit target, bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::gather
|
||||
bool gather(Unit target, bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::returnCargo
|
||||
bool returnCargo(bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::repair
|
||||
bool repair(Unit target, bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::burrow
|
||||
bool burrow() const;
|
||||
|
||||
/// @copydoc UnitInterface::unburrow
|
||||
bool unburrow() const;
|
||||
|
||||
/// @copydoc UnitInterface::cloak
|
||||
bool cloak() const;
|
||||
|
||||
/// @copydoc UnitInterface::decloak
|
||||
bool decloak() const;
|
||||
|
||||
/// @copydoc UnitInterface::siege
|
||||
bool siege() const;
|
||||
|
||||
/// @copydoc UnitInterface::unsiege
|
||||
bool unsiege() const;
|
||||
|
||||
/// @copydoc UnitInterface::lift
|
||||
bool lift() const;
|
||||
|
||||
/// @copydoc UnitInterface::load
|
||||
bool load(Unit target, bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::unloadAll(bool)
|
||||
bool unloadAll(bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::unloadAll(Position,bool)
|
||||
bool unloadAll(Position target, bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::rightClick
|
||||
bool rightClick(PositionOrUnit target, bool shiftQueueCommand = false) const;
|
||||
|
||||
/// @copydoc UnitInterface::haltConstruction
|
||||
bool haltConstruction() const;
|
||||
|
||||
/// @copydoc UnitInterface::cancelConstruction
|
||||
bool cancelConstruction() const;
|
||||
|
||||
/// @copydoc UnitInterface::cancelAddon
|
||||
bool cancelAddon() const;
|
||||
|
||||
/// @copydoc UnitInterface::cancelTrain
|
||||
bool cancelTrain(int slot = -2) const;
|
||||
|
||||
/// @copydoc UnitInterface::cancelMorph
|
||||
bool cancelMorph() const;
|
||||
|
||||
/// @copydoc UnitInterface::cancelResearch
|
||||
bool cancelResearch() const;
|
||||
|
||||
/// @copydoc UnitInterface::cancelUpgrade
|
||||
bool cancelUpgrade() const;
|
||||
|
||||
/// @copydoc UnitInterface::useTech
|
||||
bool useTech(TechType tech, PositionOrUnit target = nullptr) const;
|
||||
};
|
||||
}
|
||||
|
183
bwapi4-includes/BWAPI/UpgradeType.h
Normal file
183
bwapi4-includes/BWAPI/UpgradeType.h
Normal file
|
@ -0,0 +1,183 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
#include <BWAPI/UnitType.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class Race;
|
||||
|
||||
namespace UpgradeTypes
|
||||
{
|
||||
/// Enumeration of upgrade types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of upgrade types
|
||||
enum Enum
|
||||
{
|
||||
Terran_Infantry_Armor = 0,
|
||||
Terran_Vehicle_Plating = 1,
|
||||
Terran_Ship_Plating = 2,
|
||||
Zerg_Carapace = 3,
|
||||
Zerg_Flyer_Carapace = 4,
|
||||
Protoss_Ground_Armor = 5,
|
||||
Protoss_Air_Armor = 6,
|
||||
Terran_Infantry_Weapons = 7,
|
||||
Terran_Vehicle_Weapons = 8,
|
||||
Terran_Ship_Weapons = 9,
|
||||
Zerg_Melee_Attacks = 10,
|
||||
Zerg_Missile_Attacks = 11,
|
||||
Zerg_Flyer_Attacks = 12,
|
||||
Protoss_Ground_Weapons = 13,
|
||||
Protoss_Air_Weapons = 14,
|
||||
Protoss_Plasma_Shields = 15,
|
||||
U_238_Shells = 16,
|
||||
Ion_Thrusters = 17,
|
||||
|
||||
Titan_Reactor = 19,
|
||||
Ocular_Implants = 20,
|
||||
Moebius_Reactor = 21,
|
||||
Apollo_Reactor = 22,
|
||||
Colossus_Reactor = 23,
|
||||
Ventral_Sacs = 24,
|
||||
Antennae = 25,
|
||||
Pneumatized_Carapace = 26,
|
||||
Metabolic_Boost = 27,
|
||||
Adrenal_Glands = 28,
|
||||
Muscular_Augments = 29,
|
||||
Grooved_Spines = 30,
|
||||
Gamete_Meiosis = 31,
|
||||
Metasynaptic_Node = 32,
|
||||
Singularity_Charge = 33,
|
||||
Leg_Enhancements = 34,
|
||||
Scarab_Damage = 35,
|
||||
Reaver_Capacity = 36,
|
||||
Gravitic_Drive = 37,
|
||||
Sensor_Array = 38,
|
||||
Gravitic_Boosters = 39,
|
||||
Khaydarin_Amulet = 40,
|
||||
Apial_Sensors = 41,
|
||||
Gravitic_Thrusters = 42,
|
||||
Carrier_Capacity = 43,
|
||||
Khaydarin_Core = 44,
|
||||
|
||||
Argus_Jewel = 47,
|
||||
|
||||
Argus_Talisman = 49,
|
||||
|
||||
Caduceus_Reactor = 51,
|
||||
Chitinous_Plating = 52,
|
||||
Anabolic_Synthesis = 53,
|
||||
Charon_Boosters = 54,
|
||||
|
||||
Upgrade_60 = 60,
|
||||
None = 61,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
}
|
||||
}
|
||||
class UpgradeType : public Type<UpgradeType, UpgradeTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
UpgradeType(int id = UpgradeTypes::Enum::None);
|
||||
|
||||
/** Returns the race the upgrade is for. For example, UpgradeTypes::Terran_Infantry_Armor.getRace()
|
||||
* will return Races::Terran. */
|
||||
Race getRace() const;
|
||||
|
||||
/** Returns the mineral price for the first upgrade. */
|
||||
int mineralPrice(int level = 1) const;
|
||||
|
||||
/** Returns the amount that the mineral price increases for each additional upgrade. */
|
||||
int mineralPriceFactor() const;
|
||||
|
||||
/** Returns the vespene gas price for the first upgrade. */
|
||||
int gasPrice(int level = 1) const;
|
||||
|
||||
/** Returns the amount that the vespene gas price increases for each additional upgrade. */
|
||||
int gasPriceFactor() const;
|
||||
|
||||
/** Returns the number of frames needed to research the first upgrade. */
|
||||
int upgradeTime(int level = 1) const;
|
||||
|
||||
/** Returns the number of frames that the upgrade time increases for each additional upgrade. */
|
||||
int upgradeTimeFactor() const;
|
||||
|
||||
/** Returns the maximum number of times the upgrade can be researched. */
|
||||
int maxRepeats() const;
|
||||
|
||||
/** Returns the type of unit that researches the upgrade. */
|
||||
UnitType whatUpgrades() const;
|
||||
|
||||
/** Returns the type of unit that is additionally required for the upgrade. */
|
||||
UnitType whatsRequired(int level = 1) const;
|
||||
|
||||
/** Returns the set of units that are affected by this upgrade. */
|
||||
const UnitType::const_set& whatUses() const;
|
||||
};
|
||||
/// Namespace of upgrade types
|
||||
namespace UpgradeTypes
|
||||
{
|
||||
/** Returns the set of all the UpgradeTypes. */
|
||||
const UpgradeType::const_set& allUpgradeTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const UpgradeType x
|
||||
BWAPI_DECL(Terran_Infantry_Armor);
|
||||
BWAPI_DECL(Terran_Vehicle_Plating);
|
||||
BWAPI_DECL(Terran_Ship_Plating);
|
||||
BWAPI_DECL(Zerg_Carapace);
|
||||
BWAPI_DECL(Zerg_Flyer_Carapace);
|
||||
BWAPI_DECL(Protoss_Ground_Armor);
|
||||
BWAPI_DECL(Protoss_Air_Armor);
|
||||
BWAPI_DECL(Terran_Infantry_Weapons);
|
||||
BWAPI_DECL(Terran_Vehicle_Weapons);
|
||||
BWAPI_DECL(Terran_Ship_Weapons);
|
||||
BWAPI_DECL(Zerg_Melee_Attacks);
|
||||
BWAPI_DECL(Zerg_Missile_Attacks);
|
||||
BWAPI_DECL(Zerg_Flyer_Attacks);
|
||||
BWAPI_DECL(Protoss_Ground_Weapons);
|
||||
BWAPI_DECL(Protoss_Air_Weapons);
|
||||
BWAPI_DECL(Protoss_Plasma_Shields);
|
||||
BWAPI_DECL(U_238_Shells);
|
||||
BWAPI_DECL(Ion_Thrusters);
|
||||
BWAPI_DECL(Titan_Reactor);
|
||||
BWAPI_DECL(Ocular_Implants);
|
||||
BWAPI_DECL(Moebius_Reactor);
|
||||
BWAPI_DECL(Apollo_Reactor);
|
||||
BWAPI_DECL(Colossus_Reactor);
|
||||
BWAPI_DECL(Ventral_Sacs);
|
||||
BWAPI_DECL(Antennae);
|
||||
BWAPI_DECL(Pneumatized_Carapace);
|
||||
BWAPI_DECL(Metabolic_Boost);
|
||||
BWAPI_DECL(Adrenal_Glands);
|
||||
BWAPI_DECL(Muscular_Augments);
|
||||
BWAPI_DECL(Grooved_Spines);
|
||||
BWAPI_DECL(Gamete_Meiosis);
|
||||
BWAPI_DECL(Metasynaptic_Node);
|
||||
BWAPI_DECL(Singularity_Charge);
|
||||
BWAPI_DECL(Leg_Enhancements);
|
||||
BWAPI_DECL(Scarab_Damage);
|
||||
BWAPI_DECL(Reaver_Capacity);
|
||||
BWAPI_DECL(Gravitic_Drive);
|
||||
BWAPI_DECL(Sensor_Array);
|
||||
BWAPI_DECL(Gravitic_Boosters);
|
||||
BWAPI_DECL(Khaydarin_Amulet);
|
||||
BWAPI_DECL(Apial_Sensors);
|
||||
BWAPI_DECL(Gravitic_Thrusters);
|
||||
BWAPI_DECL(Carrier_Capacity);
|
||||
BWAPI_DECL(Khaydarin_Core);
|
||||
BWAPI_DECL(Argus_Jewel);
|
||||
BWAPI_DECL(Argus_Talisman);
|
||||
BWAPI_DECL(Caduceus_Reactor);
|
||||
BWAPI_DECL(Chitinous_Plating);
|
||||
BWAPI_DECL(Anabolic_Synthesis);
|
||||
BWAPI_DECL(Charon_Boosters);
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
520
bwapi4-includes/BWAPI/Vectorset.h
Normal file
520
bwapi4-includes/BWAPI/Vectorset.h
Normal file
|
@ -0,0 +1,520 @@
|
|||
#pragma once
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Vectorset_iterator.h"
|
||||
#include "ConstVectorset.h"
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
/// The Vectorset is a class template designed specifically for trivial classes or PODs and
|
||||
/// performance. It mimics the usage of various stl containers (specifically the Vector and Set)
|
||||
/// in order to replace them. The Vectorset is designed for BWAPI usage and is recommended,
|
||||
/// especially if stl containers are causing a bottleneck in your bot's code.
|
||||
///
|
||||
/// @warning The Vectorset should only be used with objects that have a trivial destructor and
|
||||
/// trivial copy constructor. Objects in the Vectorset should not do any memory management
|
||||
/// or the behaviour will be undefined. Use with caution.
|
||||
///
|
||||
/// @note The Vectorset will only free memory when the object is destroyed.
|
||||
///
|
||||
/// @see std::vector, std::set
|
||||
template<typename _T>
|
||||
class Vectorset : public ConstVectorset<_T>
|
||||
{
|
||||
public:
|
||||
typedef typename ConstVectorset<_T>::iterator iterator;
|
||||
// ----------------------------------------------------------------- Constructors
|
||||
/// This is the default constructor. The Vectorset will allocate memory for the given number
|
||||
/// of elements (or 16 by default).
|
||||
///
|
||||
/// @param initialSize
|
||||
/// The number of elements of type _T to allocate memory for.
|
||||
Vectorset(size_t initialSize = 16)
|
||||
: ConstVectorset<_T>( (_T*)malloc(initialSize*sizeof(_T)) )
|
||||
, pEndAlloc( ConstVectorset<_T>::pStartArr + initialSize )
|
||||
{};
|
||||
|
||||
/// This is the copy constructor. The Vectorset will allocate only the necessary space to
|
||||
/// copy the other Vectorset's contents.
|
||||
///
|
||||
/// @param other
|
||||
/// Reference to the Vectorset of the same type whose contents will be copied.
|
||||
///
|
||||
/// @note Duplicate entries are not removed.
|
||||
Vectorset(const Vectorset<_T> &other)
|
||||
: ConstVectorset<_T>( (_T*)malloc( other.size()*sizeof(_T)), other.size() )
|
||||
, pEndAlloc( ConstVectorset<_T>::pEndArr )
|
||||
{
|
||||
memcpy(this->pStartArr, (void*)other, other.size()*sizeof(_T));
|
||||
};
|
||||
/// @overload
|
||||
Vectorset(const ConstVectorset<_T> &other)
|
||||
: ConstVectorset<_T>( (_T*)malloc( other.size()*sizeof(_T)), other.size() )
|
||||
, pEndAlloc( ConstVectorset<_T>::pEndArr )
|
||||
{
|
||||
memcpy(this->pStartArr, (void*)other, other.size()*sizeof(_T));
|
||||
};
|
||||
|
||||
/// This is the move constructor. The Vectorset will steal the data pointer from the other
|
||||
/// Vectorset.
|
||||
///
|
||||
/// @param other
|
||||
/// Reference to the Vectorset of the same type whose contents will be moved.
|
||||
///
|
||||
/// @note Duplicate entries are not removed.
|
||||
Vectorset(Vectorset<_T> &&other)
|
||||
: ConstVectorset<_T>( other.pStartArr, other.size() )
|
||||
, pEndAlloc( other.pEndAlloc )
|
||||
{
|
||||
other.pStartArr = nullptr;
|
||||
};
|
||||
|
||||
/// This constructor uses an existing array of objects and copies them into the vector.
|
||||
/// The Vectorset will allocate only enough memory to copy the array's contents.
|
||||
///
|
||||
/// @param pArray
|
||||
/// Pointer to an array of objects of type _T.
|
||||
/// @param arrSize
|
||||
/// The number of elements contained in the given array.
|
||||
///
|
||||
/// @note Duplicate entries are not removed.
|
||||
Vectorset(const _T *pArray, size_t arrSize)
|
||||
: ConstVectorset<_T>( (_T*)malloc(arrSize*sizeof(_T)), arrSize )
|
||||
, pEndAlloc( ConstVectorset<_T>::pEndArr )
|
||||
{
|
||||
memcpy(this->pStartArr, pArray, arrSize*sizeof(_T) );
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------- Destructor
|
||||
~Vectorset()
|
||||
{
|
||||
if ( this->pStartArr != nullptr )
|
||||
{
|
||||
free(this->pStartArr);
|
||||
this->pStartArr = nullptr;
|
||||
}
|
||||
};
|
||||
// ----------------------------------------------------------------- Operators
|
||||
/// This is the copy assignment operator. The contents of the current container are erased
|
||||
/// and replaced with the contents of other.
|
||||
///
|
||||
/// @returns A reference to the current object.
|
||||
Vectorset<_T> &operator =(const Vectorset<_T> &other)
|
||||
{
|
||||
this->clear();
|
||||
this->push_back(other);
|
||||
return *this;
|
||||
};
|
||||
/// @overload
|
||||
Vectorset<_T> &operator =(const ConstVectorset<_T> &other)
|
||||
{
|
||||
this->clear();
|
||||
this->push_back(other);
|
||||
return *this;
|
||||
};
|
||||
/// This is the move assignment operator. The contents of the current container are discarded,
|
||||
/// and the contents of other moved into this.
|
||||
///
|
||||
/// @returns A reference to the current object.
|
||||
Vectorset &operator =(Vectorset<_T> &&other)
|
||||
{
|
||||
if ( this->pStartArr != nullptr )
|
||||
free(this->pStartArr);
|
||||
|
||||
this->pStartArr = other.pStartArr;
|
||||
other.pStartArr = nullptr;
|
||||
|
||||
this->pEndArr = other.pEndArr;
|
||||
this->pEndAlloc = other.pEndAlloc;
|
||||
|
||||
return *this;
|
||||
};
|
||||
/// @copydoc push_back(const ConstVectorset<_T> &other)
|
||||
///
|
||||
/// @returns A reference to the current object.
|
||||
///
|
||||
/// @see operator|=
|
||||
Vectorset &operator +=(const ConstVectorset<_T> &other)
|
||||
{
|
||||
this->push_back(other);
|
||||
return *this;
|
||||
};
|
||||
/// @copydoc insert(const ConstVectorset<_T> &other)
|
||||
///
|
||||
/// @returns A reference to the current object.
|
||||
///
|
||||
/// @see operator+=
|
||||
Vectorset &operator |=(const ConstVectorset<_T> &other)
|
||||
{
|
||||
this->insert(other);
|
||||
return *this;
|
||||
};
|
||||
// ----------------------------------------------------------------- Custom const functions
|
||||
/// Retrieves the current capacity of the Vectorset.
|
||||
///
|
||||
/// @returns The number of elements this Vectorset can contain before needing to allocate more
|
||||
/// memory.
|
||||
inline size_t max_size() const
|
||||
{
|
||||
return ((size_t)this->pEndAlloc - (size_t)this->pStartArr)/sizeof(_T);
|
||||
};
|
||||
// ----------------------------------------------------------------- erase
|
||||
/// Erases all values found in the Vectorset. When a value is found, it is erased and the
|
||||
/// function continues searching for the same value until it reaches the end of the
|
||||
/// Vectorset.
|
||||
///
|
||||
/// @param val
|
||||
/// The value to search for and erase.
|
||||
///
|
||||
/// @note This function does not preserve order. If you wish to preserve order, see remove.
|
||||
void erase(const _T &val)
|
||||
{
|
||||
// iterate all elements
|
||||
auto i = this->begin();
|
||||
while ( i != this->end() )
|
||||
{
|
||||
if ( val == *i ) // erase if values are equal
|
||||
i = this->erase(i);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
};
|
||||
|
||||
/// Erases the value at an iterator for this Vectorset. The advantage of this function is that
|
||||
/// searching for the value is not necessary.
|
||||
///
|
||||
/// @param iter
|
||||
/// A valid iterator for the position to erase. This iterator must be within the scope of
|
||||
/// the Vectorset or the result will be undefined.
|
||||
///
|
||||
/// @returns
|
||||
/// iterator to next element.
|
||||
///
|
||||
/// @note This function does not preserve order. If you wish to preserve order, see remove.
|
||||
iterator erase(iterator iter)
|
||||
{
|
||||
// Remove the element by replacing it with the last one
|
||||
--this->pEndArr;
|
||||
*(&iter) = *this->pEndArr;
|
||||
|
||||
// Return the same iterator since it is already pointing to the next expected element
|
||||
return iter;
|
||||
};
|
||||
/// Erases the values within a range of iterators for this Vectorset.
|
||||
///
|
||||
/// @param first
|
||||
/// A valid iterator for the starting position to erase. This iterator must be within the
|
||||
/// scope of the Vectorset or the result will be undefined.
|
||||
/// @param last
|
||||
/// A valid iterator for the ending position to erase. This iterator must come after first
|
||||
/// and be within the scope of the Vectorset or the result will be undefined.
|
||||
///
|
||||
/// @note This function does not preserve order. If you wish to preserve order, see remove.
|
||||
iterator erase(iterator first, iterator last)
|
||||
{
|
||||
// Erase all elements until last, unless last == end()
|
||||
while ( last != this->end() && first != last )
|
||||
first = this->erase(first);
|
||||
|
||||
// Optimization so that only one operation is necessary
|
||||
if ( first != last && last == this->end() )
|
||||
this->pEndArr -= (last - first);
|
||||
|
||||
// Return the iterator to the same position
|
||||
return first;
|
||||
};
|
||||
|
||||
/// Works similar to the STL algorithm remove_if. Iterates and calls a function predicate for
|
||||
/// each element in the Vectorset. If the predicate call returns true, then the value is
|
||||
/// erased by calling erase.
|
||||
///
|
||||
/// @param pred
|
||||
/// Function predicate used to determine if a value is removed.
|
||||
///
|
||||
/// @see std::remove_if, remove_if
|
||||
template <typename Func>
|
||||
void erase_if( const Func &pred )
|
||||
{
|
||||
// iterate all elements
|
||||
auto i = this->begin();
|
||||
while ( i != this->end() )
|
||||
{
|
||||
if ( pred(*i) ) // erase if predicate returns true
|
||||
this->erase(i);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
};
|
||||
// ----------------------------------------------------------------- remove
|
||||
/// Removes all values found in the Vectorset. When a value is found, it is removed and the
|
||||
/// function continues searching for the same value until it reaches the end of the Vectorset.
|
||||
///
|
||||
/// @param val
|
||||
/// The value to search for and remove.
|
||||
///
|
||||
/// @note This function preserves order. It is recommended to use erase for performance if
|
||||
/// order is not important.
|
||||
///
|
||||
/// @see erase
|
||||
void remove(const _T &val)
|
||||
{
|
||||
// Find the first instance
|
||||
iterator i = this->begin();
|
||||
while ( i < this->end() && val != *i )
|
||||
++i;
|
||||
|
||||
// Now do iteration with shifting
|
||||
iterator skip = i;
|
||||
while ( skip < this->end() )
|
||||
{
|
||||
while ( skip < this->end() && val == *skip ) // increment remove ptr if equal
|
||||
++skip;
|
||||
|
||||
// if we've not reached the end, then shift the value up,
|
||||
// overwriting the one we removed
|
||||
if ( skip < this->end() )
|
||||
*(&i) = *(&skip);
|
||||
|
||||
// increment our position
|
||||
++i;
|
||||
++skip;
|
||||
}
|
||||
this->pEndArr -= (&skip - &i);
|
||||
};
|
||||
|
||||
/// Erases the value at an iterator for this Vectorset. The advantage of this function
|
||||
/// is that searching for the value is not necessary.
|
||||
///
|
||||
/// @param iter
|
||||
/// A valid iterator for the position to erase. This iterator must be within the scope of
|
||||
/// the Vectorset or the result will be undefined.
|
||||
///
|
||||
/// @note This function preserves order. It is recommended to use erase for performance if
|
||||
/// order is not important.
|
||||
///
|
||||
/// @see erase
|
||||
void remove(const iterator &iter)
|
||||
{
|
||||
// Remove the element by shifting positions
|
||||
iterator t = iter;
|
||||
iterator tnext = t + 1;
|
||||
while ( tnext != this->end() )
|
||||
{
|
||||
*(&t) = *(&tnext);
|
||||
++t;
|
||||
++tnext;
|
||||
}
|
||||
--this->pEndArr;
|
||||
};
|
||||
|
||||
/// Works similar to the STL algorithm remove_if. Iterates and calls a function predicate for
|
||||
/// each element in the Vectorset. If the predicate call returns true, then the value is removed.
|
||||
///
|
||||
/// @param pred Function predicate used to determine if a value is removed.
|
||||
///
|
||||
/// @see std::remove_if, erase_if
|
||||
template <typename Func>
|
||||
void remove_if( const Func &pred )
|
||||
{
|
||||
// Find the first instance
|
||||
iterator i = this->begin();
|
||||
while ( i < this->end() && !pred(*i) )
|
||||
++i;
|
||||
|
||||
// Now do iteration with shifting
|
||||
iterator skip = i;
|
||||
while ( skip < this->end() )
|
||||
{
|
||||
while ( skip < this->end() && pred(*skip) ) // increment remove ptr if equal
|
||||
++skip;
|
||||
|
||||
// if we've not reached the end, then shift the value up,
|
||||
// overwriting the one we removed
|
||||
if ( skip < this->end() )
|
||||
*(&i) = *(&skip);
|
||||
|
||||
// increment our position
|
||||
++i;
|
||||
++skip;
|
||||
}
|
||||
this->pEndArr -= (&skip - &i);
|
||||
};
|
||||
// ----------------------------------------------------------------- stl spinoff functions
|
||||
|
||||
/// Clears the Vectorset, removing all elements. Used the same way as stl containers.
|
||||
///
|
||||
/// @note Because of the restrictions placed on the Vectorset, this function executes a
|
||||
/// single instruction regardless of the number of entries.
|
||||
inline void clear()
|
||||
{
|
||||
this->pEndArr = this->pStartArr;
|
||||
};
|
||||
|
||||
// element insertion
|
||||
/// Inserts a new value into the Vectorset only if it does not already exist.
|
||||
///
|
||||
/// @param val
|
||||
/// The value to insert.
|
||||
///
|
||||
/// @see std::set
|
||||
inline void insert(const _T &val)
|
||||
{
|
||||
if ( !this->exists(val) )
|
||||
this->push_back(val);
|
||||
};
|
||||
/// @copydoc insert(const _T &val)
|
||||
inline void insert(const iterator &val)
|
||||
{
|
||||
this->insert(*val);
|
||||
};
|
||||
|
||||
/// Inserts all elements of another vector only if each element does not already exsist.
|
||||
///
|
||||
/// @param other
|
||||
/// Another Vectorset of the same type whose elements will be inserted into this one.
|
||||
void insert(const ConstVectorset<_T> &other)
|
||||
{
|
||||
for ( iterator i = other.begin(); i != other.end(); ++i )
|
||||
this->insert(i);
|
||||
};
|
||||
|
||||
/// Pushes a value to the back of the Vectorset, expanding it if necessary.
|
||||
///
|
||||
/// @param val
|
||||
/// The value to add to the back of this Vectorset.
|
||||
///
|
||||
/// @note Duplicate entries are not removed.
|
||||
///
|
||||
/// @see push_front
|
||||
inline void push_back(const _T val)
|
||||
{
|
||||
if ( this->expand() )
|
||||
{
|
||||
*this->pEndArr = val;
|
||||
++this->pEndArr;
|
||||
}
|
||||
};
|
||||
/// @copydoc push_back(const _T val)
|
||||
inline void push_back(const iterator &val)
|
||||
{
|
||||
this->push_back(*val);
|
||||
};
|
||||
|
||||
/// Pushes all values of another Vectorset to the back of this one, expanding it to contain
|
||||
/// exactly the number of elements in both Vectorsets if necessary.
|
||||
///
|
||||
/// @param other
|
||||
/// The other Vectorset of the same type whose values will be appended to this one.
|
||||
///
|
||||
/// @note Duplicate entries are not removed.
|
||||
void push_back(const ConstVectorset<_T> &other)
|
||||
{
|
||||
// localize variables
|
||||
size_t nSize = other.size();
|
||||
|
||||
// manage existing set
|
||||
if ( this->expand(nSize) )
|
||||
{
|
||||
// copy the data to this set
|
||||
memcpy( this->pEndArr, other, nSize*sizeof(_T) );
|
||||
|
||||
// update variables in this set
|
||||
this->pEndArr += nSize;
|
||||
}
|
||||
};
|
||||
|
||||
/// Pushes a value to the front of the Vectorset, expanding it if necessary.
|
||||
///
|
||||
/// @param val
|
||||
/// The value to add to the back of this Vectorset.
|
||||
///
|
||||
/// @note Duplicate entries are not removed.
|
||||
/// @note For efficiency, it is recommended to use push_back.
|
||||
///
|
||||
/// @see push_back
|
||||
void push_front(const _T val)
|
||||
{
|
||||
if ( this->expand() )
|
||||
{
|
||||
// @TODO: make front available to reduce cost
|
||||
memmove(this->pStartArr+1, this->pStartArr, this->size()*sizeof(_T));
|
||||
++this->pEndArr;
|
||||
*this->pStartArr = val;
|
||||
}
|
||||
};
|
||||
/// @copydoc push_front(const _T val)
|
||||
inline void push_front(const iterator &val)
|
||||
{
|
||||
this->push_front(*val);
|
||||
};
|
||||
|
||||
/// @TODO change return value to copy of value that was popped
|
||||
/// @see pop_front
|
||||
inline void pop_back()
|
||||
{
|
||||
if ( !this->empty() ) // remove last element if non-empty
|
||||
--this->pEndArr;
|
||||
};
|
||||
|
||||
/// @TODO change return value to copy of value that was popped
|
||||
/// @note For efficiency, it is recommended to use pop_back.
|
||||
/// @see pop_back
|
||||
void pop_front()
|
||||
{
|
||||
if ( this->empty() ) // return if empty
|
||||
return;
|
||||
|
||||
--this->pEndArr; // subtract the last element (not removing it)
|
||||
size_t size = this->size(); // localize the new size
|
||||
switch ( size )
|
||||
{
|
||||
case 0: // just ignore it if it was the only element
|
||||
break;
|
||||
case 1: // if only one element should remain
|
||||
*this->pStartArr = *this->pEndArr;
|
||||
break;
|
||||
default: // otherwise move all elements up
|
||||
// @TODO: make front available to reduce cost
|
||||
memmove(this->pStartArr, this->pStartArr+1, size*sizeof(_T));
|
||||
break;
|
||||
}
|
||||
};
|
||||
// -----------------------------------------------------------------
|
||||
protected:
|
||||
/// Expands the container if it currently does not have the capacity for the number of
|
||||
/// additional elements.
|
||||
///
|
||||
/// @retval true If space is available.
|
||||
/// @retval false If realloc failed.
|
||||
bool expand(size_t additionalElements = 1)
|
||||
{
|
||||
// localize the variables
|
||||
size_t allocSize = this->max_size(), arrSize = this->size();
|
||||
|
||||
// expand to expected size, or ignore of not necessary
|
||||
if ( allocSize >= arrSize + additionalElements )
|
||||
return true;
|
||||
|
||||
// expand to desired size
|
||||
allocSize = ((arrSize + additionalElements)/256 + 1)*256;
|
||||
|
||||
// Reallocate and store the new values
|
||||
_T *pReallocated = (_T*)realloc(this->pStartArr, allocSize*sizeof(_T));
|
||||
if ( pReallocated != nullptr )
|
||||
{
|
||||
this->pStartArr = pReallocated;
|
||||
this->pEndArr = pReallocated + arrSize;
|
||||
this->pEndAlloc = pReallocated + allocSize;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// Variables
|
||||
_T *pEndAlloc; // ptr to end of allocation
|
||||
};
|
||||
|
||||
}
|
||||
|
117
bwapi4-includes/BWAPI/Vectorset_iterator.h
Normal file
117
bwapi4-includes/BWAPI/Vectorset_iterator.h
Normal file
|
@ -0,0 +1,117 @@
|
|||
#pragma once
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#define _ITER_COMPARE(op) friend bool operator op(const VSetIterator<T> &lhs, const VSetIterator<T> &rhs) \
|
||||
{ return lhs.pVal op rhs.pVal; };
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
/// The iterator class template allows the iteration
|
||||
/// of elements of a Vectorset with ease while
|
||||
/// maintaining the compatibility with any familiar
|
||||
/// STL container iteration.
|
||||
///
|
||||
/// @see Vectorset
|
||||
template<typename T>
|
||||
class VSetIterator : public std::iterator<std::random_access_iterator_tag, T>
|
||||
{
|
||||
public:
|
||||
typedef std::iterator<std::random_access_iterator_tag, T> host_type;
|
||||
typedef typename host_type::pointer pointer;
|
||||
typedef typename host_type::difference_type difference_type;
|
||||
typedef typename host_type::reference reference;
|
||||
|
||||
// constructors
|
||||
VSetIterator(pointer ptr = nullptr) : pVal(ptr) {};
|
||||
VSetIterator(const VSetIterator<T> &other) : pVal(&other) {};
|
||||
|
||||
// Copy assignment
|
||||
VSetIterator<T> &operator =(const VSetIterator<T> &other)
|
||||
{
|
||||
this->pVal = other.pVal;
|
||||
return *this;
|
||||
};
|
||||
|
||||
// comparison operators
|
||||
_ITER_COMPARE(==);
|
||||
_ITER_COMPARE(!=);
|
||||
_ITER_COMPARE(<);
|
||||
_ITER_COMPARE(>);
|
||||
_ITER_COMPARE(<=);
|
||||
_ITER_COMPARE(>=);
|
||||
|
||||
// modification operators
|
||||
VSetIterator<T> &operator ++()
|
||||
{
|
||||
++pVal;
|
||||
return *this;
|
||||
};
|
||||
VSetIterator<T> operator ++(int)
|
||||
{
|
||||
VSetIterator<T> copy(*this);
|
||||
++pVal;
|
||||
return copy;
|
||||
};
|
||||
VSetIterator<T> &operator --()
|
||||
{
|
||||
--pVal;
|
||||
return *this;
|
||||
};
|
||||
VSetIterator<T> operator --(int)
|
||||
{
|
||||
VSetIterator<T> copy(*this);
|
||||
--pVal;
|
||||
return copy;
|
||||
};
|
||||
VSetIterator<T> operator +(const difference_type &n) const
|
||||
{
|
||||
return VSetIterator(this->pVal + n);
|
||||
};
|
||||
VSetIterator<T> operator -(const difference_type &n) const
|
||||
{
|
||||
return VSetIterator(this->pVal - n);
|
||||
};
|
||||
friend difference_type operator -(const VSetIterator<T> &lhs, const VSetIterator<T> &rhs)
|
||||
{
|
||||
return lhs.pVal - rhs.pVal;
|
||||
};
|
||||
|
||||
VSetIterator &operator +=(const difference_type &n)
|
||||
{
|
||||
this->pVal += n;
|
||||
return *this;
|
||||
};
|
||||
VSetIterator &operator -=(const difference_type &n)
|
||||
{
|
||||
this->pVal -= n;
|
||||
return *this;
|
||||
};
|
||||
|
||||
// Dereference operators
|
||||
reference operator *() const
|
||||
{
|
||||
return *pVal;
|
||||
};
|
||||
// @TODO: should be "pointer" and "return pVal", need specialization
|
||||
reference operator ->() const
|
||||
{
|
||||
return *pVal;
|
||||
};
|
||||
reference operator [](const difference_type &n) const
|
||||
{
|
||||
return this->pVal[n];
|
||||
};
|
||||
|
||||
|
||||
// @TODO: remove
|
||||
T *operator &() const
|
||||
{
|
||||
return pVal;
|
||||
};
|
||||
protected:
|
||||
pointer pVal;
|
||||
};
|
||||
|
||||
|
||||
}
|
333
bwapi4-includes/BWAPI/WeaponType.h
Normal file
333
bwapi4-includes/BWAPI/WeaponType.h
Normal file
|
@ -0,0 +1,333 @@
|
|||
#pragma once
|
||||
#include <BWAPI/Type.h>
|
||||
|
||||
namespace BWAPI
|
||||
{
|
||||
class TechType;
|
||||
class UpgradeType;
|
||||
class DamageType;
|
||||
class ExplosionType;
|
||||
|
||||
namespace WeaponTypes
|
||||
{
|
||||
/// Enumeration of weapon types
|
||||
namespace Enum
|
||||
{
|
||||
/// Enumeration of weapon types
|
||||
enum Enum
|
||||
{
|
||||
Gauss_Rifle = 0,
|
||||
Gauss_Rifle_Jim_Raynor = 1,
|
||||
C_10_Canister_Rifle = 2,
|
||||
C_10_Canister_Rifle_Sarah_Kerrigan = 3,
|
||||
Fragmentation_Grenade = 4,
|
||||
Fragmentation_Grenade_Jim_Raynor = 5,
|
||||
Spider_Mines = 6,
|
||||
Twin_Autocannons = 7,
|
||||
Hellfire_Missile_Pack = 8,
|
||||
Twin_Autocannons_Alan_Schezar = 9,
|
||||
Hellfire_Missile_Pack_Alan_Schezar = 10,
|
||||
Arclite_Cannon = 11,
|
||||
Arclite_Cannon_Edmund_Duke = 12,
|
||||
Fusion_Cutter = 13,
|
||||
|
||||
Gemini_Missiles = 15,
|
||||
Burst_Lasers = 16,
|
||||
Gemini_Missiles_Tom_Kazansky = 17,
|
||||
Burst_Lasers_Tom_Kazansky = 18,
|
||||
ATS_Laser_Battery = 19,
|
||||
ATA_Laser_Battery = 20,
|
||||
ATS_Laser_Battery_Hero = 21,
|
||||
ATA_Laser_Battery_Hero = 22,
|
||||
ATS_Laser_Battery_Hyperion = 23,
|
||||
ATA_Laser_Battery_Hyperion = 24,
|
||||
Flame_Thrower = 25,
|
||||
Flame_Thrower_Gui_Montag = 26,
|
||||
Arclite_Shock_Cannon = 27,
|
||||
Arclite_Shock_Cannon_Edmund_Duke = 28,
|
||||
Longbolt_Missile = 29,
|
||||
Yamato_Gun = 30,
|
||||
Nuclear_Strike = 31,
|
||||
Lockdown = 32,
|
||||
EMP_Shockwave = 33,
|
||||
Irradiate = 34,
|
||||
Claws = 35,
|
||||
Claws_Devouring_One = 36,
|
||||
Claws_Infested_Kerrigan = 37,
|
||||
Needle_Spines = 38,
|
||||
Needle_Spines_Hunter_Killer = 39,
|
||||
Kaiser_Blades = 40,
|
||||
Kaiser_Blades_Torrasque = 41,
|
||||
Toxic_Spores = 42,
|
||||
Spines = 43,
|
||||
|
||||
Acid_Spore = 46,
|
||||
Acid_Spore_Kukulza = 47,
|
||||
Glave_Wurm = 48,
|
||||
Glave_Wurm_Kukulza = 49,
|
||||
|
||||
Seeker_Spores = 52,
|
||||
Subterranean_Tentacle = 53,
|
||||
Suicide_Infested_Terran = 54,
|
||||
Suicide_Scourge = 55,
|
||||
Parasite = 56,
|
||||
Spawn_Broodlings = 57,
|
||||
Ensnare = 58,
|
||||
Dark_Swarm = 59,
|
||||
Plague = 60,
|
||||
Consume = 61,
|
||||
Particle_Beam = 62,
|
||||
|
||||
Psi_Blades = 64,
|
||||
Psi_Blades_Fenix = 65,
|
||||
Phase_Disruptor = 66,
|
||||
Phase_Disruptor_Fenix = 67,
|
||||
|
||||
Psi_Assault = 69,
|
||||
Psionic_Shockwave = 70,
|
||||
Psionic_Shockwave_TZ_Archon = 71,
|
||||
|
||||
Dual_Photon_Blasters = 73,
|
||||
Anti_Matter_Missiles = 74,
|
||||
Dual_Photon_Blasters_Mojo = 75,
|
||||
Anti_Matter_Missiles_Mojo = 76,
|
||||
Phase_Disruptor_Cannon = 77,
|
||||
Phase_Disruptor_Cannon_Danimoth = 78,
|
||||
Pulse_Cannon = 79,
|
||||
STS_Photon_Cannon = 80,
|
||||
STA_Photon_Cannon = 81,
|
||||
Scarab = 82,
|
||||
Stasis_Field = 83,
|
||||
Psionic_Storm = 84,
|
||||
Warp_Blades_Zeratul = 85,
|
||||
Warp_Blades_Hero = 86,
|
||||
|
||||
Platform_Laser_Battery = 92,
|
||||
Independant_Laser_Battery = 93,
|
||||
|
||||
Twin_Autocannons_Floor_Trap = 96,
|
||||
Hellfire_Missile_Pack_Wall_Trap = 97,
|
||||
Flame_Thrower_Wall_Trap = 98,
|
||||
Hellfire_Missile_Pack_Floor_Trap = 99,
|
||||
|
||||
Neutron_Flare = 100,
|
||||
Disruption_Web = 101,
|
||||
Restoration = 102,
|
||||
Halo_Rockets = 103,
|
||||
Corrosive_Acid = 104,
|
||||
Mind_Control = 105,
|
||||
Feedback = 106,
|
||||
Optical_Flare = 107,
|
||||
Maelstrom = 108,
|
||||
Subterranean_Spines = 109,
|
||||
|
||||
Warp_Blades = 111,
|
||||
C_10_Canister_Rifle_Samir_Duran = 112,
|
||||
C_10_Canister_Rifle_Infested_Duran = 113,
|
||||
Dual_Photon_Blasters_Artanis = 114,
|
||||
Anti_Matter_Missiles_Artanis = 115,
|
||||
C_10_Canister_Rifle_Alexei_Stukov = 116,
|
||||
|
||||
None = 130,
|
||||
Unknown,
|
||||
MAX
|
||||
};
|
||||
}
|
||||
}
|
||||
class WeaponType : public Type<WeaponType, WeaponTypes::Enum::Unknown>
|
||||
{
|
||||
public:
|
||||
/// @copydoc Type::Type(int)
|
||||
WeaponType(int id = WeaponTypes::Enum::None);
|
||||
|
||||
/** Returns the tech type that must be researched before this weapon can be used, or TechTypes::None if
|
||||
* no tech type is required. */
|
||||
TechType getTech() const;
|
||||
|
||||
/** Returns the unit that can use this weapon. */
|
||||
UnitType whatUses() const;
|
||||
|
||||
/** Returns the amount of damage that this weapon deals per attack. */
|
||||
int damageAmount() const;
|
||||
|
||||
// TODO: add doc
|
||||
int damageBonus() const;
|
||||
|
||||
/** Returns the amount of cooldown time between attacks. */
|
||||
int damageCooldown() const;
|
||||
|
||||
/** Returns the amount that the damage increases per upgrade.
|
||||
* \see WeaponType::upgradeType. */
|
||||
int damageFactor() const;
|
||||
|
||||
/** Returns the upgrade type that can be upgraded to increase the attack damage. */
|
||||
UpgradeType upgradeType() const;
|
||||
|
||||
/** Returns the type of damage that this weapon uses (i.e. concussive, normal, explosive, etc). */
|
||||
DamageType damageType() const;
|
||||
|
||||
/** Returns the type of explosion that this weapon uses. */
|
||||
ExplosionType explosionType() const;
|
||||
|
||||
/** Returns the minimum attack range of the weapon, measured in pixels, 0 for most things except
|
||||
* WeaponTypes::Arclite_Shock_Cannon (the weapon of the Terran Siege Tank in Siege Mode). */
|
||||
int minRange() const;
|
||||
|
||||
/** Returns the maximum attack range of the weapon, measured in pixels. */
|
||||
int maxRange() const;
|
||||
|
||||
/** Inner radius used in splash damage calculations. */
|
||||
int innerSplashRadius() const;
|
||||
|
||||
/** Median radius used in splash damage calculations. */
|
||||
int medianSplashRadius() const;
|
||||
|
||||
/** Outer radius used in splash damage calculations. */
|
||||
int outerSplashRadius() const;
|
||||
|
||||
/** Returns true if this weapon can attack air units. */
|
||||
bool targetsAir() const;
|
||||
|
||||
// TODO: group these methods
|
||||
/** Returns true if this weapon can attack ground units. */
|
||||
bool targetsGround() const;
|
||||
bool targetsMechanical() const;
|
||||
bool targetsOrganic() const;
|
||||
bool targetsNonBuilding() const;
|
||||
bool targetsNonRobotic() const;
|
||||
bool targetsTerrain() const;
|
||||
bool targetsOrgOrMech() const;
|
||||
bool targetsOwn() const;
|
||||
};
|
||||
/// namespace containing weapon types
|
||||
namespace WeaponTypes
|
||||
{
|
||||
/// Retrieves the set of all weapon types. This is a union between the normalWeaponTypes and
|
||||
/// specialWeaponTypes.
|
||||
///
|
||||
/// @returns set consisting of all weapon types.
|
||||
const WeaponType::set& allWeaponTypes();
|
||||
|
||||
/// Retrieves the set of all normal weapon types. This set contains all weapons that are
|
||||
/// not used for abilities.
|
||||
///
|
||||
/// @returns constant set consisting of all normal weapon types.
|
||||
const WeaponType::const_set& normalWeaponTypes();
|
||||
|
||||
/// Retrieves the set of all special weapon types. This set contains all weapons that are
|
||||
/// used exclusively for special unit abilities.
|
||||
///
|
||||
/// @returns constant set consisting of all special weapon types.
|
||||
const WeaponType::const_set& specialWeaponTypes();
|
||||
|
||||
#ifdef BWAPI_DECL
|
||||
#undef BWAPI_DECL
|
||||
#endif
|
||||
#define BWAPI_DECL(x) /** x */ extern const WeaponType x
|
||||
BWAPI_DECL(Gauss_Rifle);
|
||||
BWAPI_DECL(Gauss_Rifle_Jim_Raynor);
|
||||
BWAPI_DECL(C_10_Canister_Rifle);
|
||||
BWAPI_DECL(C_10_Canister_Rifle_Sarah_Kerrigan);
|
||||
BWAPI_DECL(C_10_Canister_Rifle_Samir_Duran);
|
||||
BWAPI_DECL(C_10_Canister_Rifle_Infested_Duran);
|
||||
BWAPI_DECL(C_10_Canister_Rifle_Alexei_Stukov);
|
||||
BWAPI_DECL(Fragmentation_Grenade);
|
||||
BWAPI_DECL(Fragmentation_Grenade_Jim_Raynor);
|
||||
BWAPI_DECL(Spider_Mines);
|
||||
BWAPI_DECL(Twin_Autocannons);
|
||||
BWAPI_DECL(Twin_Autocannons_Alan_Schezar);
|
||||
BWAPI_DECL(Hellfire_Missile_Pack);
|
||||
BWAPI_DECL(Hellfire_Missile_Pack_Alan_Schezar);
|
||||
BWAPI_DECL(Arclite_Cannon);
|
||||
BWAPI_DECL(Arclite_Cannon_Edmund_Duke);
|
||||
BWAPI_DECL(Fusion_Cutter);
|
||||
BWAPI_DECL(Gemini_Missiles);
|
||||
BWAPI_DECL(Gemini_Missiles_Tom_Kazansky);
|
||||
BWAPI_DECL(Burst_Lasers);
|
||||
BWAPI_DECL(Burst_Lasers_Tom_Kazansky);
|
||||
BWAPI_DECL(ATS_Laser_Battery);
|
||||
BWAPI_DECL(ATS_Laser_Battery_Hero);
|
||||
BWAPI_DECL(ATS_Laser_Battery_Hyperion);
|
||||
BWAPI_DECL(ATA_Laser_Battery);
|
||||
BWAPI_DECL(ATA_Laser_Battery_Hero);
|
||||
BWAPI_DECL(ATA_Laser_Battery_Hyperion);
|
||||
BWAPI_DECL(Flame_Thrower);
|
||||
BWAPI_DECL(Flame_Thrower_Gui_Montag);
|
||||
BWAPI_DECL(Arclite_Shock_Cannon);
|
||||
BWAPI_DECL(Arclite_Shock_Cannon_Edmund_Duke);
|
||||
BWAPI_DECL(Longbolt_Missile);
|
||||
BWAPI_DECL(Claws);
|
||||
BWAPI_DECL(Claws_Devouring_One);
|
||||
BWAPI_DECL(Claws_Infested_Kerrigan);
|
||||
BWAPI_DECL(Needle_Spines);
|
||||
BWAPI_DECL(Needle_Spines_Hunter_Killer);
|
||||
BWAPI_DECL(Kaiser_Blades);
|
||||
BWAPI_DECL(Kaiser_Blades_Torrasque);
|
||||
BWAPI_DECL(Toxic_Spores);
|
||||
BWAPI_DECL(Spines);
|
||||
BWAPI_DECL(Acid_Spore);
|
||||
BWAPI_DECL(Acid_Spore_Kukulza);
|
||||
BWAPI_DECL(Glave_Wurm);
|
||||
BWAPI_DECL(Glave_Wurm_Kukulza);
|
||||
BWAPI_DECL(Seeker_Spores);
|
||||
BWAPI_DECL(Subterranean_Tentacle);
|
||||
BWAPI_DECL(Suicide_Infested_Terran);
|
||||
BWAPI_DECL(Suicide_Scourge);
|
||||
BWAPI_DECL(Particle_Beam);
|
||||
BWAPI_DECL(Psi_Blades);
|
||||
BWAPI_DECL(Psi_Blades_Fenix);
|
||||
BWAPI_DECL(Phase_Disruptor);
|
||||
BWAPI_DECL(Phase_Disruptor_Fenix);
|
||||
BWAPI_DECL(Psi_Assault);
|
||||
BWAPI_DECL(Psionic_Shockwave);
|
||||
BWAPI_DECL(Psionic_Shockwave_TZ_Archon);
|
||||
BWAPI_DECL(Dual_Photon_Blasters);
|
||||
BWAPI_DECL(Dual_Photon_Blasters_Mojo);
|
||||
BWAPI_DECL(Dual_Photon_Blasters_Artanis);
|
||||
BWAPI_DECL(Anti_Matter_Missiles);
|
||||
BWAPI_DECL(Anti_Matter_Missiles_Mojo);
|
||||
BWAPI_DECL(Anti_Matter_Missiles_Artanis);
|
||||
BWAPI_DECL(Phase_Disruptor_Cannon);
|
||||
BWAPI_DECL(Phase_Disruptor_Cannon_Danimoth);
|
||||
BWAPI_DECL(Pulse_Cannon);
|
||||
BWAPI_DECL(STS_Photon_Cannon);
|
||||
BWAPI_DECL(STA_Photon_Cannon);
|
||||
BWAPI_DECL(Scarab);
|
||||
BWAPI_DECL(Neutron_Flare);
|
||||
BWAPI_DECL(Halo_Rockets);
|
||||
BWAPI_DECL(Corrosive_Acid);
|
||||
BWAPI_DECL(Subterranean_Spines);
|
||||
BWAPI_DECL(Warp_Blades);
|
||||
BWAPI_DECL(Warp_Blades_Hero);
|
||||
BWAPI_DECL(Warp_Blades_Zeratul);
|
||||
BWAPI_DECL(Independant_Laser_Battery);
|
||||
BWAPI_DECL(Twin_Autocannons_Floor_Trap);
|
||||
BWAPI_DECL(Hellfire_Missile_Pack_Wall_Trap);
|
||||
BWAPI_DECL(Flame_Thrower_Wall_Trap);
|
||||
BWAPI_DECL(Hellfire_Missile_Pack_Floor_Trap);
|
||||
|
||||
BWAPI_DECL(Yamato_Gun);
|
||||
BWAPI_DECL(Nuclear_Strike);
|
||||
BWAPI_DECL(Lockdown);
|
||||
BWAPI_DECL(EMP_Shockwave);
|
||||
BWAPI_DECL(Irradiate);
|
||||
BWAPI_DECL(Parasite);
|
||||
BWAPI_DECL(Spawn_Broodlings);
|
||||
BWAPI_DECL(Ensnare);
|
||||
BWAPI_DECL(Dark_Swarm);
|
||||
BWAPI_DECL(Plague);
|
||||
BWAPI_DECL(Consume);
|
||||
BWAPI_DECL(Stasis_Field);
|
||||
BWAPI_DECL(Psionic_Storm);
|
||||
BWAPI_DECL(Disruption_Web);
|
||||
BWAPI_DECL(Restoration);
|
||||
BWAPI_DECL(Mind_Control);
|
||||
BWAPI_DECL(Feedback);
|
||||
BWAPI_DECL(Optical_Flare);
|
||||
BWAPI_DECL(Maelstrom);
|
||||
|
||||
BWAPI_DECL(None);
|
||||
BWAPI_DECL(Unknown);
|
||||
#undef BWAPI_DECL
|
||||
}
|
||||
}
|
261
bwapi4-includes/swig.i
Normal file
261
bwapi4-includes/swig.i
Normal file
|
@ -0,0 +1,261 @@
|
|||
%module BWAPI
|
||||
%{
|
||||
#include "BWAPI.h"
|
||||
%}
|
||||
|
||||
%include "BWAPI/Vectorset.h"
|
||||
%include "BWAPI/Type.h"
|
||||
|
||||
%define VSET_WRAP(t)
|
||||
%template(t ## set_Base) BWAPI::Vectorset<BWAPI::t*>;
|
||||
%enddef
|
||||
|
||||
VSET_WRAP(Bullet)
|
||||
VSET_WRAP(Unit)
|
||||
VSET_WRAP(Player)
|
||||
VSET_WRAP(Region)
|
||||
VSET_WRAP(Force)
|
||||
|
||||
%template(Color_Base) BWAPI::Type<BWAPI::Color,255>;
|
||||
%rename(Text_Enum) BWAPI::Text::Enum;
|
||||
|
||||
%define COLOR_WRAP(n)
|
||||
%rename(Color_ ## n) BWAPI::Colors::n;
|
||||
%enddef
|
||||
|
||||
COLOR_WRAP(Yellow)
|
||||
COLOR_WRAP(White)
|
||||
COLOR_WRAP(Grey)
|
||||
COLOR_WRAP(Red)
|
||||
COLOR_WRAP(Green)
|
||||
COLOR_WRAP(Blue)
|
||||
COLOR_WRAP(Teal)
|
||||
COLOR_WRAP(Purple)
|
||||
COLOR_WRAP(Orange)
|
||||
COLOR_WRAP(Brown)
|
||||
COLOR_WRAP(Cyan)
|
||||
|
||||
|
||||
%rename(CoordinateType_Enum) BWAPI::CoordinateType::Enum;
|
||||
%rename(Flag_Enum) BWAPI::Flag::Enum;
|
||||
%rename(Latency_Enum) BWAPI::Latency::Enum;
|
||||
|
||||
|
||||
%define TYPEVAL_WRAP(t,v)
|
||||
%rename(t ## _ ## v) BWAPI::t ## s::v;
|
||||
%rename(t ## _Enum_ ## v) BWAPI::t ## s::Enum::v;
|
||||
%enddef
|
||||
|
||||
%define TYPE_WRAP(t)
|
||||
%template(t ## _Base) BWAPI::Type<BWAPI::t,BWAPI::t ## s::Enum::Unknown>;
|
||||
TYPEVAL_WRAP(t,None)
|
||||
TYPEVAL_WRAP(t,Unknown)
|
||||
TYPEVAL_WRAP(t,MAX)
|
||||
%rename(t ## _ ## init) BWAPI::t ## s::init;
|
||||
%rename(t ## _ ## Enum) BWAPI::t ## s::Enum::Enum;
|
||||
|
||||
TYPEVAL_WRAP(t,Normal)
|
||||
TYPEVAL_WRAP(t,Ensnare)
|
||||
TYPEVAL_WRAP(t,Yamato_Gun)
|
||||
TYPEVAL_WRAP(t,Consume)
|
||||
TYPEVAL_WRAP(t,Melee)
|
||||
TYPEVAL_WRAP(t,Unused)
|
||||
TYPEVAL_WRAP(t,Neutral)
|
||||
TYPEVAL_WRAP(t,PlayerLeft)
|
||||
TYPEVAL_WRAP(t,RescuePassive)
|
||||
TYPEVAL_WRAP(t,Burrowing)
|
||||
TYPEVAL_WRAP(t,Dark_Swarm)
|
||||
TYPEVAL_WRAP(t,Irradiate)
|
||||
TYPEVAL_WRAP(t,Plague)
|
||||
TYPEVAL_WRAP(t,Psionic_Storm)
|
||||
TYPEVAL_WRAP(t,Parasite)
|
||||
TYPEVAL_WRAP(t,Stasis_Field)
|
||||
TYPEVAL_WRAP(t,Restoration)
|
||||
TYPEVAL_WRAP(t,EMP_Shockwave)
|
||||
TYPEVAL_WRAP(t,Stop)
|
||||
TYPEVAL_WRAP(t,Train)
|
||||
TYPEVAL_WRAP(t,Follow)
|
||||
TYPEVAL_WRAP(t,Patrol)
|
||||
TYPEVAL_WRAP(t,Move)
|
||||
TYPEVAL_WRAP(t,Upgrade)
|
||||
TYPEVAL_WRAP(t,Unload)
|
||||
TYPEVAL_WRAP(t,Cloak)
|
||||
TYPEVAL_WRAP(t,Decloak)
|
||||
TYPEVAL_WRAP(t,Maelstrom)
|
||||
TYPEVAL_WRAP(t,Optical_Flare)
|
||||
TYPEVAL_WRAP(t,Feedback)
|
||||
TYPEVAL_WRAP(t,Mind_Control)
|
||||
TYPEVAL_WRAP(t,Disruption_Web)
|
||||
TYPEVAL_WRAP(t,Lockdown)
|
||||
TYPEVAL_WRAP(t,Nuclear_Strike)
|
||||
TYPEVAL_WRAP(t,Corrosive_Acid)
|
||||
TYPEVAL_WRAP(t,Subterranean_Spines)
|
||||
TYPEVAL_WRAP(t,Halo_Rockets)
|
||||
TYPEVAL_WRAP(t,Neutron_Flare)
|
||||
TYPEVAL_WRAP(t,Pulse_Cannon)
|
||||
TYPEVAL_WRAP(t,Phase_Disruptor)
|
||||
TYPEVAL_WRAP(t,Seeker_Spores)
|
||||
TYPEVAL_WRAP(t,Glave_Wurm)
|
||||
TYPEVAL_WRAP(t,Acid_Spore)
|
||||
TYPEVAL_WRAP(t,Longbolt_Missile)
|
||||
TYPEVAL_WRAP(t,Burst_Lasers)
|
||||
TYPEVAL_WRAP(t,Gemini_Missiles)
|
||||
TYPEVAL_WRAP(t,Spider_Mines)
|
||||
TYPEVAL_WRAP(t,Fragmentation_Grenade)
|
||||
TYPEVAL_WRAP(t,Fusion_Cutter_Hit)
|
||||
TYPEVAL_WRAP(t,Optical_Flare_Grenade)
|
||||
TYPEVAL_WRAP(t,Independent)
|
||||
TYPEVAL_WRAP(t,Unit_Does_Not_Exist)
|
||||
TYPEVAL_WRAP(t,Terran_Marine)
|
||||
TYPEVAL_WRAP(t,Spawn_Broodlings)
|
||||
TYPEVAL_WRAP(t,Hellfire_Missile_Pack)
|
||||
TYPEVAL_WRAP(t,Twin_Autocannons_Floor_Trap)
|
||||
TYPEVAL_WRAP(t,Independant_Laser_Battery)
|
||||
TYPEVAL_WRAP(t,Warp_Blades_Zeratul)
|
||||
TYPEVAL_WRAP(t,Warp_Blades_Hero)
|
||||
TYPEVAL_WRAP(t,Scarab)
|
||||
TYPEVAL_WRAP(t,STS_Photon_Cannon)
|
||||
TYPEVAL_WRAP(t,STA_Photon_Cannon)
|
||||
TYPEVAL_WRAP(t,Phase_Disruptor_Cannon_Danimoth)
|
||||
TYPEVAL_WRAP(t,Phase_Disruptor_Cannon)
|
||||
TYPEVAL_WRAP(t,Anti_Matter_Missiles)
|
||||
TYPEVAL_WRAP(t,Anti_Matter_Missiles_Artanis)
|
||||
TYPEVAL_WRAP(t,Anti_Matter_Missiles_Mojo)
|
||||
TYPEVAL_WRAP(t,Dual_Photon_Blasters)
|
||||
TYPEVAL_WRAP(t,Dual_Photon_Blasters_Artanis)
|
||||
TYPEVAL_WRAP(t,Dual_Photon_Blasters_Mojo)
|
||||
TYPEVAL_WRAP(t,Psionic_Shockwave_TZ_Archon)
|
||||
TYPEVAL_WRAP(t,Psionic_Shockwave)
|
||||
TYPEVAL_WRAP(t,Psi_Assault)
|
||||
TYPEVAL_WRAP(t,Phase_Disruptor_Fenix)
|
||||
TYPEVAL_WRAP(t,Phase_Disruptor)
|
||||
TYPEVAL_WRAP(t,Psi_Blades_Fenix)
|
||||
TYPEVAL_WRAP(t,Psi_Blades)
|
||||
TYPEVAL_WRAP(t,Particle_Beam)
|
||||
TYPEVAL_WRAP(t,Suicide_Scourge)
|
||||
TYPEVAL_WRAP(t,Suicide_Infested_Terran)
|
||||
TYPEVAL_WRAP(t,Subterranean_Tentacle)
|
||||
TYPEVAL_WRAP(t,Glave_Wurm_Kukulza)
|
||||
TYPEVAL_WRAP(t,Glave_Wurm)
|
||||
TYPEVAL_WRAP(t,Acid_Spore_Kukulza)
|
||||
TYPEVAL_WRAP(t,Acid_Spore)
|
||||
TYPEVAL_WRAP(t,Spines)
|
||||
TYPEVAL_WRAP(t,Toxic_Spores)
|
||||
TYPEVAL_WRAP(t,Kaiser_Blades_Torrasque)
|
||||
TYPEVAL_WRAP(t,Needle_Spines_Hunter_Killer)
|
||||
TYPEVAL_WRAP(t,Kaiser_Blades)
|
||||
TYPEVAL_WRAP(t,Needle_Spines)
|
||||
TYPEVAL_WRAP(t,Claws_Infested_Kerrigan)
|
||||
TYPEVAL_WRAP(t,Claws_Devouring_One)
|
||||
TYPEVAL_WRAP(t,Claws)
|
||||
TYPEVAL_WRAP(t,Arclite_Shock_Cannon_Edmund_Duke)
|
||||
TYPEVAL_WRAP(t,Arclite_Shock_Cannon)
|
||||
TYPEVAL_WRAP(t,Flame_Thrower_Gui_Montag)
|
||||
TYPEVAL_WRAP(t,Flame_Thrower)
|
||||
TYPEVAL_WRAP(t,ATA_Laser_Battery)
|
||||
TYPEVAL_WRAP(t,ATA_Laser_Battery_Hero)
|
||||
TYPEVAL_WRAP(t,ATA_Laser_Battery_Hyperion)
|
||||
TYPEVAL_WRAP(t,ATS_Laser_Battery)
|
||||
TYPEVAL_WRAP(t,ATS_Laser_Battery_Hero)
|
||||
TYPEVAL_WRAP(t,ATS_Laser_Battery_Hyperion)
|
||||
TYPEVAL_WRAP(t,Burst_Lasers_Tom_Kazansky)
|
||||
TYPEVAL_WRAP(t,Burst_Lasers)
|
||||
TYPEVAL_WRAP(t,Gemini_Missiles_Tom_Kazansky)
|
||||
TYPEVAL_WRAP(t,Gemini_Missiles)
|
||||
TYPEVAL_WRAP(t,Fusion_Cutter)
|
||||
TYPEVAL_WRAP(t,Arclite_Cannon_Edmund_Duke)
|
||||
TYPEVAL_WRAP(t,Arclite_Cannon)
|
||||
TYPEVAL_WRAP(t,Hellfire_Missile_Pack_Alan_Schezar)
|
||||
TYPEVAL_WRAP(t,Hellfire_Missile_Pack)
|
||||
TYPEVAL_WRAP(t,C_10_Canister_Rifle)
|
||||
TYPEVAL_WRAP(t,C_10_Canister_Rifle_Sarah_Kerrigan)
|
||||
TYPEVAL_WRAP(t,C_10_Canister_Rifle_Samir_Duran)
|
||||
TYPEVAL_WRAP(t,C_10_Canister_Rifle_Infested_Duran)
|
||||
TYPEVAL_WRAP(t,C_10_Canister_Rifle_Alexei_Stukov)
|
||||
TYPEVAL_WRAP(t,Gauss_Rifle)
|
||||
TYPEVAL_WRAP(t,Gauss_Rifle_Jim_Raynor)
|
||||
TYPEVAL_WRAP(t,Hellfire_Missile_Pack_Floor_Trap)
|
||||
TYPEVAL_WRAP(t,Flame_Thrower_Wall_Trap)
|
||||
TYPEVAL_WRAP(t,Hellfire_Missile_Pack_Wall_Trap)
|
||||
TYPEVAL_WRAP(t,Warp_Blades)
|
||||
TYPEVAL_WRAP(t,Twin_Autocannons_Alan_Schezar)
|
||||
TYPEVAL_WRAP(t,Twin_Autocannons)
|
||||
TYPEVAL_WRAP(t,Fragmentation_Grenade_Jim_Raynor)
|
||||
TYPEVAL_WRAP(t,Fragmentation_Grenade)
|
||||
TYPEVAL_WRAP(t,Charon_Boosters)
|
||||
TYPEVAL_WRAP(t,Anabolic_Synthesis)
|
||||
TYPEVAL_WRAP(t,Chitinous_Plating)
|
||||
TYPEVAL_WRAP(t,Caduceus_Reactir)
|
||||
TYPEVAL_WRAP(t,Argus_Talisman)
|
||||
TYPEVAL_WRAP(t,Argus_Jewel)
|
||||
TYPEVAL_WRAP(t,Khaydarin_Core)
|
||||
TYPEVAL_WRAP(t,Carrier_Capacity)
|
||||
TYPEVAL_WRAP(t,Gravitic_Thrusters)
|
||||
TYPEVAL_WRAP(t,Apial_Sensors)
|
||||
TYPEVAL_WRAP(t,Khaydarin_Amulet)
|
||||
TYPEVAL_WRAP(t,Gravitic_Boosters)
|
||||
TYPEVAL_WRAP(t,Sensor_Array)
|
||||
TYPEVAL_WRAP(t,Gravitic_Drive)
|
||||
TYPEVAL_WRAP(t,Reaver_Capacity)
|
||||
TYPEVAL_WRAP(t,Scarab_Damage)
|
||||
TYPEVAL_WRAP(t,Leg_Enhancements)
|
||||
TYPEVAL_WRAP(t,Singularity_Charge)
|
||||
TYPEVAL_WRAP(t,Metasynaptic_Node)
|
||||
TYPEVAL_WRAP(t,Gamete_Meiosis)
|
||||
TYPEVAL_WRAP(t,Grooved_Spines)
|
||||
TYPEVAL_WRAP(t,Muscular_Augments)
|
||||
TYPEVAL_WRAP(t,Adrenal_Glands)
|
||||
TYPEVAL_WRAP(t,Metabolic_Boost)
|
||||
TYPEVAL_WRAP(t,Antennae)
|
||||
TYPEVAL_WRAP(t,Ventral_Sacs)
|
||||
TYPEVAL_WRAP(t,Colossus_Reactor)
|
||||
TYPEVAL_WRAP(t,Apollo_Reactor)
|
||||
TYPEVAL_WRAP(t,Moebius_Reactor)
|
||||
TYPEVAL_WRAP(t,Ocular_Implants)
|
||||
TYPEVAL_WRAP(t,Titan_Reactor)
|
||||
TYPEVAL_WRAP(t,Ion_Thrusters)
|
||||
TYPEVAL_WRAP(t,U_238_Shells)
|
||||
TYPEVAL_WRAP(t,Protoss_Plasma_Shields)
|
||||
TYPEVAL_WRAP(t,Protoss_Air_Weapons)
|
||||
TYPEVAL_WRAP(t,Protoss_Ground_Weapons)
|
||||
TYPEVAL_WRAP(t,Zerg_Flyer_Attacks)
|
||||
TYPEVAL_WRAP(t,Zerg_Missile_Attacks)
|
||||
TYPEVAL_WRAP(t,Zerg_Melee_Attacks)
|
||||
TYPEVAL_WRAP(t,Terran_Ship_Weapons)
|
||||
TYPEVAL_WRAP(t,Terran_Vehicle_Weapons)
|
||||
TYPEVAL_WRAP(t,Terran_Infantry_Weapons)
|
||||
TYPEVAL_WRAP(t,Protoss_Air_Armor)
|
||||
TYPEVAL_WRAP(t,Protoss_Ground_Armor)
|
||||
TYPEVAL_WRAP(t,Zerg_Flyer_Carapace)
|
||||
TYPEVAL_WRAP(t,Zerg_Carapace)
|
||||
TYPEVAL_WRAP(t,Terran_Ship_Plating)
|
||||
TYPEVAL_WRAP(t,Terran_Vehicle_Plating)
|
||||
TYPEVAL_WRAP(t,Terran_Infantry_Armor)
|
||||
TYPEVAL_WRAP(t,Repair)
|
||||
TYPEVAL_WRAP(t,Attack_Move)
|
||||
TYPEVAL_WRAP(t,Stim_Packs)
|
||||
TYPEVAL_WRAP(t,Zerg)
|
||||
TYPEVAL_WRAP(t,Pneumatized_Carapace)
|
||||
TYPEVAL_WRAP(t,Caduceus_Reactor)
|
||||
TYPEVAL_WRAP(t,Player)
|
||||
%enddef
|
||||
|
||||
TYPE_WRAP(BulletType)
|
||||
TYPE_WRAP(DamageType)
|
||||
TYPE_WRAP(Error)
|
||||
TYPE_WRAP(ExplosionType)
|
||||
TYPE_WRAP(GameType)
|
||||
TYPE_WRAP(Order)
|
||||
TYPE_WRAP(PlayerType)
|
||||
TYPE_WRAP(Race)
|
||||
TYPE_WRAP(TechType)
|
||||
TYPE_WRAP(UnitCommandType)
|
||||
TYPE_WRAP(UnitSizeType)
|
||||
TYPE_WRAP(UnitType)
|
||||
TYPE_WRAP(UpgradeType)
|
||||
TYPE_WRAP(WeaponType)
|
||||
|
||||
%rename(Text_Invisible) BWAPI::Text::Invisible;
|
||||
|
||||
|
||||
%include "BWAPI.h"
|
133
bwapi4/AIModule.java
Normal file
133
bwapi4/AIModule.java
Normal file
|
@ -0,0 +1,133 @@
|
|||
package bwapi4;
|
||||
|
||||
import bwapi4.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class AIModule {
|
||||
|
||||
public void onStart() {
|
||||
onStart_native(pointer);
|
||||
}
|
||||
|
||||
public void onEnd(boolean isWinner) {
|
||||
onEnd_native(pointer, isWinner);
|
||||
}
|
||||
|
||||
public void onFrame() {
|
||||
onFrame_native(pointer);
|
||||
}
|
||||
|
||||
public void onSendText(String text) {
|
||||
onSendText_native(pointer, text);
|
||||
}
|
||||
|
||||
public void onReceiveText(Player player, String text) {
|
||||
onReceiveText_native(pointer, player, text);
|
||||
}
|
||||
|
||||
public void onPlayerLeft(Player player) {
|
||||
onPlayerLeft_native(pointer, player);
|
||||
}
|
||||
|
||||
public void onNukeDetect(Position target) {
|
||||
onNukeDetect_native(pointer, target);
|
||||
}
|
||||
|
||||
public void onUnitDiscover(Unit unit) {
|
||||
onUnitDiscover_native(pointer, unit);
|
||||
}
|
||||
|
||||
public void onUnitEvade(Unit unit) {
|
||||
onUnitEvade_native(pointer, unit);
|
||||
}
|
||||
|
||||
public void onUnitShow(Unit unit) {
|
||||
onUnitShow_native(pointer, unit);
|
||||
}
|
||||
|
||||
public void onUnitHide(Unit unit) {
|
||||
onUnitHide_native(pointer, unit);
|
||||
}
|
||||
|
||||
public void onUnitCreate(Unit unit) {
|
||||
onUnitCreate_native(pointer, unit);
|
||||
}
|
||||
|
||||
public void onUnitDestroy(Unit unit) {
|
||||
onUnitDestroy_native(pointer, unit);
|
||||
}
|
||||
|
||||
public void onUnitMorph(Unit unit) {
|
||||
onUnitMorph_native(pointer, unit);
|
||||
}
|
||||
|
||||
public void onUnitRenegade(Unit unit) {
|
||||
onUnitRenegade_native(pointer, unit);
|
||||
}
|
||||
|
||||
public void onSaveGame(String gameName) {
|
||||
onSaveGame_native(pointer, gameName);
|
||||
}
|
||||
|
||||
public void onUnitComplete(Unit unit) {
|
||||
onUnitComplete_native(pointer, unit);
|
||||
}
|
||||
|
||||
|
||||
private static Map<Long, AIModule> instances = new HashMap<Long, AIModule>();
|
||||
|
||||
private AIModule(long pointer) {
|
||||
this.pointer = pointer;
|
||||
}
|
||||
|
||||
private static AIModule get(long pointer) {
|
||||
AIModule instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new AIModule(pointer);
|
||||
instances.put(pointer, instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private long pointer;
|
||||
|
||||
private native void onStart_native(long pointer);
|
||||
|
||||
private native void onEnd_native(long pointer, boolean isWinner);
|
||||
|
||||
private native void onFrame_native(long pointer);
|
||||
|
||||
private native void onSendText_native(long pointer, String text);
|
||||
|
||||
private native void onReceiveText_native(long pointer, Player player, String text);
|
||||
|
||||
private native void onPlayerLeft_native(long pointer, Player player);
|
||||
|
||||
private native void onNukeDetect_native(long pointer, Position target);
|
||||
|
||||
private native void onUnitDiscover_native(long pointer, Unit unit);
|
||||
|
||||
private native void onUnitEvade_native(long pointer, Unit unit);
|
||||
|
||||
private native void onUnitShow_native(long pointer, Unit unit);
|
||||
|
||||
private native void onUnitHide_native(long pointer, Unit unit);
|
||||
|
||||
private native void onUnitCreate_native(long pointer, Unit unit);
|
||||
|
||||
private native void onUnitDestroy_native(long pointer, Unit unit);
|
||||
|
||||
private native void onUnitMorph_native(long pointer, Unit unit);
|
||||
|
||||
private native void onUnitRenegade_native(long pointer, Unit unit);
|
||||
|
||||
private native void onSaveGame_native(long pointer, String gameName);
|
||||
|
||||
private native void onUnitComplete_native(long pointer, Unit unit);
|
||||
|
||||
|
||||
}
|
31
bwapi4/BestFilter.java
Normal file
31
bwapi4/BestFilter.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package bwapi4;
|
||||
|
||||
import bwapi4.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class BestFilter {
|
||||
|
||||
|
||||
private static Map<Long, BestFilter> instances = new HashMap<Long, BestFilter>();
|
||||
|
||||
private BestFilter(long pointer) {
|
||||
this.pointer = pointer;
|
||||
}
|
||||
|
||||
private static BestFilter get(long pointer) {
|
||||
BestFilter instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new BestFilter(pointer);
|
||||
instances.put(pointer, instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private long pointer;
|
||||
|
||||
|
||||
}
|
31
bwapi4/BestUnitFilter.java
Normal file
31
bwapi4/BestUnitFilter.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package bwapi4;
|
||||
|
||||
import bwapi4.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class BestUnitFilter {
|
||||
|
||||
|
||||
private static Map<Long, BestUnitFilter> instances = new HashMap<Long, BestUnitFilter>();
|
||||
|
||||
private BestUnitFilter(long pointer) {
|
||||
this.pointer = pointer;
|
||||
}
|
||||
|
||||
private static BestUnitFilter get(long pointer) {
|
||||
BestUnitFilter instance = instances.get(pointer);
|
||||
if (instance == null ) {
|
||||
instance = new BestUnitFilter(pointer);
|
||||
instances.put(pointer, instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private long pointer;
|
||||
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue