initial commit

This commit is contained in:
vjurenka 2014-08-05 10:43:14 +02:00
commit dbddde4ff5
473 changed files with 8623526 additions and 0 deletions

22
.gitattributes vendored Normal file
View file

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

220
.gitignore vendored Normal file
View file

@ -0,0 +1,220 @@
.idea/**
javadoc/**
*.pdb
*.zip
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

13
InvokeGenerator.iml Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="compiled" level="project" />
</component>
</module>

167
LICENSE.md Normal file
View file

@ -0,0 +1,167 @@
<!-- saved from url=(0063)https://raw.githubusercontent.com/bwapi/bwapi/master/LICENSE.md -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css"></style></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">GNU Lesser General Public License
=================================
Version 3, 29 June 2007
Copyright &amp;copy; 2007 Free Software Foundation, Inc. &amp;lt;&lt;http://fsf.org/&gt;&amp;gt;
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
### 0. Additional Definitions.
As used herein, &amp;ldquo;this License&amp;rdquo; refers to version 3 of the GNU Lesser
General Public License, and the &amp;ldquo;GNU GPL&amp;rdquo; refers to version 3 of the GNU
General Public License.
&amp;ldquo;The Library&amp;rdquo; refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An &amp;ldquo;Application&amp;rdquo; is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A &amp;ldquo;Combined Work&amp;rdquo; is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the &amp;ldquo;Linked
Version&amp;rdquo;.
The &amp;ldquo;Minimal Corresponding Source&amp;rdquo; for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The &amp;ldquo;Corresponding Application Code&amp;rdquo; for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
### 1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
### 2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
* a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
* b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
### 3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
* a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
* b) Accompany the object code with a copy of the GNU GPL and this license
document.
### 4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
* a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
* b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
* c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
* d) Do one of the following:
- 0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
- 1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
* e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
### 5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
* a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
* b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
### 6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License &amp;ldquo;or any later version&amp;rdquo;
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
</pre></body></html>

2
META-INF/MANIFEST.MF Normal file
View file

@ -0,0 +1,2 @@
Manifest-Version: 1.0

4
README.md Normal file
View file

@ -0,0 +1,4 @@
BWMirror API
=========
BWMirror API allows you to treat native BWAPI C/C++ objects as if they were Java objects.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

111
bwapi-master/AIModule.h Normal file
View file

@ -0,0 +1,111 @@
#pragma once
#include <string>
#include <BWAPI/Position.h>
#include <BWAPI/Color.h>
namespace BWAPI
{
class Unit;
class Player;
/** AIModule is a virtual class that is intended to be implemented or inherited by a custom AI class.
*
* \note
* Using BWAPI in a different thread than the default one will produce unexpected results and possibly crash
* the program. Multi-threaded AIs are possible so long as all BWAPI interaction is limited to the default
* thread (during one of the call-backs). */
class AIModule
{
public:
AIModule();
virtual ~AIModule();
/** BWAPI calls this at the start of a match. Typically an AI will execute set up code in this method
* (initialize data structures, load build orders, etc). */
virtual void onStart();
/** BWAPI calls this at the end of the match. isWinner will be true if the AIModule won the game. If the
* game is a replay, isWinner will always be false. */
virtual void onEnd(bool isWinner);
/** BWAPI calls this on every logical frame in the game. */
virtual void onFrame();
/** If Flag::UserInput is enabled, BWAPI will call this each time a user enters a message into the chat.
* */
virtual void onSendText(std::string text);
/** BWAPI calls this when another player sends a message. */
virtual void onReceiveText(Player* player, std::string text);
/** BWAPI calls this when a player leaves the game. */
virtual void onPlayerLeft(Player* player);
/** BWAPI calls this when a nuclear launch has been detected. If the target position is visible, or if
* Complete Map Information is enabled, the target position will also be provided. If Complete Map
* Information is disabled and the target position is not visible, target will be set to
* Positions::Unknown. */
virtual void onNukeDetect(Position target);
/** BWAPI calls this when a unit becomes accessible. */
virtual void onUnitDiscover(Unit* unit);
/** BWAPI calls this when a unit becomes inaccessible. */
virtual void onUnitEvade(Unit* unit);
/** BWAPI calls this the instant a previously invisible unit becomes visible. The complete map
* information flag has no effect on this callback. */
virtual void onUnitShow(Unit* unit);
/** BWAPI calls this right before a unit becomes invisible, so if you want your non-cheating AI to
* remember where it last saw a unit, this callback would be a good place to implement it. The complete
* map information flag has no effect on this callback. */
virtual void onUnitHide(Unit* unit);
/** BWAPI calls this when a unit is created. Note that this is NOT called when a unit changes type
* (such as larva into egg or egg into drone). Building a refinery/assimilator/extractor will not
* produce an onUnitCreate call since the vespene geyser changes to the unit type of the
* refinery/assimilator/extractor. If Complete Map Information is enabled, this will also be called for
* new units that are hidden by the fog of war. If the unit is visible upon creation, onUnitShow will be
* called shortly after onUnitCreate is called. */
virtual void onUnitCreate(Unit* unit);
/** BWAPI calls this when a unit dies or otherwise removed from the game (i.e. a mined out mineral
* patch). When a zerg drone becomes an extractor, the Vespene geyser changes to the Zerg Extractor type
* and the drone is removed. If Complete Map Information is enabled, this will also be called for units
* that are hidden by the fog of war. If a unit that was visible gets destroyed, onUnitHide will be
* called right before onUnitDestroy is called. */
virtual void onUnitDestroy(Unit* unit);
/** BWAPI calls this when a unit changes type, such as from a Zerg Drone to a Zerg Hatchery, or from a
* Terran Siege Tank Tank Mode to Terran Siege Tank Siege Mode. This is not called when the type changes
* to or from UnitTypes::Unknown (which happens when a unit becomes visible or invisible). */
virtual void onUnitMorph(Unit* unit);
/** BWAPI calls this when an accessible unit changes ownership. */
virtual void onUnitRenegade(Unit* unit);
// TODO: Add Doxygen documentation
virtual void onSaveGame(std::string gameName);
/** */
virtual void onUnitComplete(Unit *unit);
virtual void onPlayerDropped(Player *player);
};
class TournamentModule
{
public:
TournamentModule();
virtual ~TournamentModule();
/** BWAPI calls this any time some Game-related functions are called.
Return true to allow them, or false to disallow them.
This includes functions like Game::pauseGame and Game::enableFlag. */
virtual bool onAction(int actionType, void *parameter = NULL);
/** BWAPI calls this when this module was the first to send out its
tournament advertisement. It can prevent both modules from performing
the same task if it's necessary. */
virtual void onFirstAdvertisement();
};
}

30
bwapi-master/Bullet.h Normal file
View file

@ -0,0 +1,30 @@
#pragma once
#include <BWAPI/BulletType.h>
#include <BWAPI/Position.h>
namespace BWAPI
{
class Player;
class Unit;
class Bullet
{
protected:
virtual ~Bullet() {};
public:
virtual int getID() const = 0;
virtual Player* getPlayer() const = 0;
virtual BulletType getType() const = 0;
virtual Unit* getSource() const = 0;
virtual Position getPosition() const = 0;
virtual double getAngle() const = 0;
virtual double getVelocityX() const = 0;
virtual double getVelocityY() const = 0;
virtual Unit* getTarget() const = 0;
virtual Position getTargetPosition() const = 0;
virtual int getRemoveTimer() const = 0;
virtual bool exists() const = 0;
virtual bool isVisible() const = 0;
virtual bool isVisible(Player* player) const = 0;
};
}

65
bwapi-master/BulletType.h Normal file
View file

@ -0,0 +1,65 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
class BulletType : public Type
{
public:
BulletType();
BulletType(int id);
/** Returns the name of this bullet type. */
const std::string &getName() const;
const char *c_str() const;
};
namespace BulletTypes
{
/** Given the name of an bullet type, getBulletType() will return the corresponding BulletType object. */
BulletType getBulletType(std::string name);
/** Returns the set of all the BulletTypes. */
const std::set<BulletType>& allBulletTypes();
void init();
extern const BulletType Melee;
extern const BulletType Fusion_Cutter_Hit;
extern const BulletType Gauss_Rifle_Hit;
extern const BulletType C_10_Canister_Rifle_Hit;
extern const BulletType Gemini_Missiles;
extern const BulletType Fragmentation_Grenade;
extern const BulletType Longbolt_Missile;
extern const BulletType ATS_ATA_Laser_Battery;
extern const BulletType Burst_Lasers;
extern const BulletType Arclite_Shock_Cannon_Hit;
extern const BulletType EMP_Missile;
extern const BulletType Dual_Photon_Blasters_Hit;
extern const BulletType Particle_Beam_Hit;
extern const BulletType Anti_Matter_Missile;
extern const BulletType Pulse_Cannon;
extern const BulletType Psionic_Shockwave_Hit;
extern const BulletType Psionic_Storm;
extern const BulletType Yamato_Gun;
extern const BulletType Phase_Disruptor;
extern const BulletType STA_STS_Cannon_Overlay;
extern const BulletType Sunken_Colony_Tentacle;
extern const BulletType Acid_Spore;
extern const BulletType Glave_Wurm;
extern const BulletType Seeker_Spores;
extern const BulletType Queen_Spell_Carrier;
extern const BulletType Plague_Cloud;
extern const BulletType Consume;
extern const BulletType Ensnare;
extern const BulletType Needle_Spine_Hit;
extern const BulletType Invisible;
extern const BulletType Optical_Flare_Grenade;
extern const BulletType Halo_Rockets;
extern const BulletType Subterranean_Spines;
extern const BulletType Corrosive_Acid_Shot;
extern const BulletType Neutron_Flare;
extern const BulletType None;
extern const BulletType Unknown;
};
}

17
bwapi-master/Client.h Normal file
View 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>

View 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];
};
}

View file

@ -0,0 +1,34 @@
#pragma once
#include <BWAPI.h>
#include "BulletData.h"
#include <set>
#include <string>
namespace BWAPI
{
class Player;
class Unit;
class BulletImpl : public Bullet
{
private:
const BulletData* self;
int index;
public:
BulletImpl(int index);
virtual int getID() const;
virtual Player* getPlayer() const;
virtual BulletType getType() const;
virtual Unit* getSource() const;
virtual Position getPosition() const;
virtual double getAngle() const;
virtual double getVelocityX() const;
virtual double getVelocityY() const;
virtual Unit* getTarget() const;
virtual Position getTargetPosition() const;
virtual int getRemoveTimer() const;
virtual bool exists() const;
virtual bool isVisible() const;
virtual bool isVisible(Player* player) const;
};
}

View 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();
GameData* data;
bool isConnected();
bool connect();
void disconnect();
void update();
private:
HANDLE pipeObjectHandle;
HANDLE mapFileHandle;
HANDLE gameTableFileHandle;
GameTable* gameTable;
bool connected;
bool showedErrorBox;
};
extern Client BWAPIClient;
}

View file

@ -0,0 +1,22 @@
#pragma once
#include "CommandType.h"
namespace BWAPIC
{
struct Command
{
Command()
{
type = CommandType::None;
}
Command(CommandType::Enum _commandType, int _value1=0, int _value2=0)
{
type = _commandType;
value1 = _value1;
value2 = _value2;
}
CommandType::Enum type;
int value1;
int value2;
};
}

View file

@ -0,0 +1,36 @@
#pragma once
/**
* Used in UnitCommand
*/
namespace BWAPIC
{
namespace CommandType
{
enum Enum
{
None,
SetScreenPosition,
PingMinimap,
EnableFlag,
Printf,
SendText,
ChangeRace,
StartGame,
PauseGame,
ResumeGame,
LeaveGame,
RestartGame,
SetLocalSpeed,
SetLatCom,
SetGui,
SetFrameSkip,
SetMap,
SetAllies,
SetVision,
SetCommandOptimizerLevel,
SetReplayVision,
SetRevealAll
};
}
}

View 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;
};
}

View file

@ -0,0 +1,9 @@
#pragma once
namespace BWAPI
{
struct ForceData
{
char name[32];
};
}

View file

@ -0,0 +1,23 @@
#pragma once
#include <BWAPI.h>
#include "ForceData.h"
#include <set>
#include <string>
namespace BWAPI
{
class Game;
class Player;
class Unit;
class ForceImpl : public Force
{
private:
const ForceData* self;
int id;
public:
ForceImpl(int id);
virtual int getID() const;
virtual std::string getName() const;
virtual std::set<Player*> getPlayers() const;
};
}

View file

@ -0,0 +1,162 @@
#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];
unitFinder xUnitSearch[1700*2];
unitFinder yUnitSearch[1700*2];
};
}

View file

@ -0,0 +1,247 @@
#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 <map>
#include <set>
#include <vector>
namespace BWAPI
{
class Force;
class Player;
class Unit;
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 clearAll();
GameData* data;
std::vector<ForceImpl> forceVector;
std::vector<PlayerImpl> playerVector;
std::vector<UnitImpl> unitVector;
std::vector<BulletImpl> bulletVector;
RegionImpl *regionArray[5000];
std::set<Force*> forces;
std::set<Player*> playerSet;
std::set<Unit*> accessibleUnits;//all units that are accessible (and definitely alive)
//notDestroyedUnits - accessibleUnits = all units that may or may not be alive (status unknown)
std::set<Unit*> minerals;
std::set<Unit*> geysers;
std::set<Unit*> neutralUnits;
std::set<Unit*> staticMinerals;
std::set<Unit*> staticGeysers;
std::set<Unit*> staticNeutralUnits;
std::set<Bullet*> bullets;
std::set<Position> nukeDots;
std::set<Unit*> selectedUnits;
std::set<Unit*> pylons;
std::set<Unit*> unitsOnTileData[256][256];
std::set<Region*> regionsList;
std::set< TilePosition > startLocations;
std::list< Event > events;
bool flagEnabled[2];
Player* thePlayer;
Player* theEnemy;
Player* theNeutral;
std::set<Player*> _allies;
std::set<Player*> _enemies;
std::set<Player*> _observers;
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 std::set< Force* >& getForces();
virtual std::set< Player* >& getPlayers();
virtual std::set< Unit* >& getAllUnits();
virtual std::set< Unit* >& getMinerals();
virtual std::set< Unit* >& getGeysers();
virtual std::set< Unit* >& getNeutralUnits();
virtual std::set< Unit* >& getStaticMinerals();
virtual std::set< Unit* >& getStaticGeysers();
virtual std::set< Unit* >& getStaticNeutralUnits();
virtual std::set< Bullet* >& getBullets();
virtual std::set< Position >& getNukeDots();
virtual std::list< Event>& getEvents();
virtual Force* getForce(int forceID);
virtual Player* getPlayer(int playerID);
virtual Unit* getUnit(int unitID);
virtual Unit* indexToUnit(int unitIndex);
virtual Region* getRegion(int regionID);
virtual GameType getGameType();
virtual int getLatency();
virtual int getFrameCount();
virtual int getReplayFrameCount();
virtual int getFPS();
virtual double getAverageFPS();
virtual BWAPI::Position getMousePosition();
virtual bool getMouseState(MouseButton button);
virtual bool getMouseState(int button);
virtual bool getKeyState(Key key);
virtual bool getKeyState(int key);
virtual BWAPI::Position getScreenPosition();
virtual void setScreenPosition(int x, int y);
virtual void setScreenPosition(BWAPI::Position p);
virtual void pingMinimap(int x, int y);
virtual void pingMinimap(BWAPI::Position p);
virtual bool isFlagEnabled(int flag);
virtual void enableFlag(int flag);
virtual std::set<Unit*>& getUnitsOnTile(int x, int y);
virtual std::set<Unit*>& getUnitsInRectangle(int left, int top, int right, int bottom) const;
virtual std::set<Unit*>& getUnitsInRectangle(BWAPI::Position topLeft, BWAPI::Position bottomRight) const;
virtual std::set<Unit*>& getUnitsInRadius(BWAPI::Position center, int radius) const;
virtual Error getLastError() const;
virtual bool setLastError(BWAPI::Error e);
virtual int mapWidth();
virtual int mapHeight();
virtual std::string mapFileName();
virtual std::string mapPathName();
virtual std::string mapName();
virtual std::string mapHash();
virtual bool isWalkable(int x, int y);
virtual int getGroundHeight(int x, int y);
virtual int getGroundHeight(TilePosition position);
virtual bool isBuildable(int x, int y, bool includeBuildings = false);
virtual bool isBuildable(TilePosition position, bool includeBuildings = false);
virtual bool isVisible(int x, int y);
virtual bool isVisible(TilePosition position);
virtual bool isExplored(int x, int y);
virtual bool isExplored(TilePosition position);
virtual bool hasCreep(int x, int y);
virtual bool hasCreep(TilePosition position);
virtual bool hasPower(int tileX, int tileY, UnitType unitType = UnitTypes::None) const;
virtual bool hasPower(TilePosition position, UnitType unitType = UnitTypes::None) const;
virtual bool hasPower(int tileX, int tileY, int tileWidth, int tileHeight, UnitType unitType = UnitTypes::None) const;
virtual bool hasPower(TilePosition position, int tileWidth, int tileHeight, UnitType unitType = UnitTypes::None) const;
virtual bool hasPowerPrecise(int x, int y, UnitType unitType = UnitTypes::None ) const;
virtual bool hasPowerPrecise(Position position, UnitType unitType = UnitTypes::None) const;
virtual bool canBuildHere(const Unit* builder, TilePosition position, UnitType type, bool checkExplored = false);
virtual bool canMake(const Unit* builder, UnitType type);
virtual bool canResearch(const Unit* unit, TechType type);
virtual bool canUpgrade(const Unit* unit, UpgradeType type);
virtual std::set< TilePosition >& getStartLocations();
virtual void printf(const char* format, ...);
virtual void sendText(const char* format, ...);
virtual void sendTextEx(bool toAllies, const char *format, ...);
virtual void changeRace(BWAPI::Race race);
virtual bool isInGame();
virtual bool isMultiplayer();
virtual bool isBattleNet();
virtual bool isPaused();
virtual bool isReplay();
virtual void startGame();
virtual void pauseGame();
virtual void resumeGame();
virtual void leaveGame();
virtual void restartGame();
virtual void setLocalSpeed(int speed = -1);
virtual bool issueCommand(const std::set<BWAPI::Unit*>& units, UnitCommand command);
virtual std::set<BWAPI::Unit*>& getSelectedUnits();
virtual Player* self();
virtual Player* enemy();
virtual Player* neutral();
virtual std::set<BWAPI::Player*>& allies();
virtual std::set<BWAPI::Player*>& enemies();
virtual std::set<BWAPI::Player*>& observers();
virtual void setTextSize(int size = 1);
virtual void drawText(int ctype, int x, int y, const char *format, ...);
virtual void drawTextMap(int x, int y, const char *format, ...);
virtual void drawTextMouse(int x, int y, const char *format, ...);
virtual void drawTextScreen(int x, int y, const char *format, ...);
virtual void drawBox(int ctype, int left, int top, int right, int bottom, Color color, bool isSolid = false);
virtual void drawBoxMap(int left, int top, int right, int bottom, Color color, bool isSolid = false);
virtual void drawBoxMouse(int left, int top, int right, int bottom, Color color, bool isSolid = false);
virtual void drawBoxScreen(int left, int top, int right, int bottom, Color color, bool isSolid = false);
virtual void drawTriangle(int ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false);
virtual void drawTriangleMap(int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false);
virtual void drawTriangleMouse(int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false);
virtual void drawTriangleScreen(int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false);
virtual void drawCircle(int ctype, int x, int y, int radius, Color color, bool isSolid = false);
virtual void drawCircleMap(int x, int y, int radius, Color color, bool isSolid = false);
virtual void drawCircleMouse(int x, int y, int radius, Color color, bool isSolid = false);
virtual void drawCircleScreen(int x, int y, int radius, Color color, bool isSolid = false);
virtual void drawEllipse(int ctype, int x, int y, int xrad, int yrad, Color color, bool isSolid = false);
virtual void drawEllipseMap(int x, int y, int xrad, int yrad, Color color, bool isSolid = false);
virtual void drawEllipseMouse(int x, int y, int xrad, int yrad, Color color, bool isSolid = false);
virtual void drawEllipseScreen(int x, int y, int xrad, int yrad, Color color, bool isSolid = false);
virtual void drawDot(int ctype, int x, int y, Color color);
virtual void drawDotMap(int x, int y, Color color);
virtual void drawDotMouse(int x, int y, Color color);
virtual void drawDotScreen(int x, int y, Color color);
virtual void drawLine(int ctype, int x1, int y1, int x2, int y2, Color color);
virtual void drawLineMap(int x1, int y1, int x2, int y2, Color color);
virtual void drawLineMouse(int x1, int y1, int x2, int y2, Color color);
virtual void drawLineScreen(int x1, int y1, int x2, int y2, Color color);
virtual void *getScreenBuffer();
virtual int getLatencyFrames();
virtual int getLatencyTime();
virtual int getRemainingLatencyFrames();
virtual int getRemainingLatencyTime();
virtual int getRevision();
virtual bool isDebug();
virtual bool isLatComEnabled();
virtual void setLatCom(bool isEnabled);
virtual bool isGUIEnabled();
virtual void setGUI(bool enabled = true);
virtual int getInstanceNumber();
virtual int getAPM(bool includeSelects = false);
virtual bool setMap(const char *mapFileName);
virtual void setFrameSkip(int frameSkip = 1);
virtual bool hasPath(Position source, Position destination) const;
virtual bool setAlliance(BWAPI::Player *player, bool allied = true, bool alliedVictory = true);
virtual bool setVision(BWAPI::Player *player, bool enabled = true);
virtual int elapsedTime() const;
virtual void setCommandOptimizationLevel(int level = 2);
virtual int countdownTimer() const;
virtual const std::set<BWAPI::Region*> &getAllRegions() const;
virtual BWAPI::Region *getRegionAt(int x, int y) const;
virtual BWAPI::Region *getRegionAt(BWAPI::Position position) const;
virtual int getLastEventTime() const;
virtual bool setReplayVision(BWAPI::Player *player, bool enabled = true);
virtual bool setRevealAll(bool reveal = true);
};
}

View file

@ -0,0 +1,18 @@
#pragma once
namespace BWAPI
{
struct GameInstance
{
DWORD serverProcessID;
bool isConnected;
//time_t lastKeepAliveTime;
DWORD lastKeepAliveTime;
};
struct GameTable
{
GameTable() {}
static const int MAX_GAME_INSTANCES = 8;
GameInstance gameInstances[MAX_GAME_INSTANCES];
};
}

View file

@ -0,0 +1,56 @@
#pragma once
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[BWAPI_UNIT_TYPE_MAX_COUNT];
int visibleUnitCount[BWAPI_UNIT_TYPE_MAX_COUNT];
int completedUnitCount[BWAPI_UNIT_TYPE_MAX_COUNT];
int deadUnitCount[BWAPI_UNIT_TYPE_MAX_COUNT];
int killedUnitCount[BWAPI_UNIT_TYPE_MAX_COUNT];
int upgradeLevel[63];
bool hasResearched[47];
bool isResearching[47];
bool isUpgrading[63];
int colorByte;
int color;
int totalUnitScore;
int totalKillScore;
int totalBuildingScore;
int totalRazingScore;
int customScore;
int maxUpgradeLevel[61];
bool isResearchAvailable[44];
bool isUnitAvailable[228];
};
}

View file

@ -0,0 +1,86 @@
#pragma once
#include <BWAPI.h>
#include "PlayerData.h"
#include <set>
#include <string>
namespace BWAPI
{
class Unit;
class Force;
class PlayerImpl : public Player
{
private:
int id;
public:
PlayerData* self;
std::set<Unit*> units;
void clear();
PlayerImpl(int id);
virtual int getID() const;
virtual std::string getName() const;
virtual const std::set<Unit*>& getUnits() const;
virtual Race getRace() const;
virtual PlayerType getType() const;
virtual Force* getForce() const;
virtual bool isAlly(Player* player) const;
virtual bool isEnemy(Player* player) const;
virtual bool isNeutral() const;
virtual TilePosition getStartLocation() const;
virtual bool isVictorious() const;
virtual bool isDefeated() const;
virtual bool leftGame() const;
virtual int minerals() const;
virtual int gas() const;
virtual int gatheredMinerals() const;
virtual int gatheredGas() const;
virtual int repairedMinerals() const;
virtual int repairedGas() const;
virtual int refundedMinerals() const;
virtual int refundedGas() const;
virtual int spentMinerals() const;
virtual int spentGas() const;
virtual int supplyTotal() const;
virtual int supplyUsed() const;
virtual int supplyTotal(Race race) const;
virtual int supplyUsed(Race race) const;
virtual int allUnitCount(UnitType unit) const;
virtual int visibleUnitCount(UnitType unit) const;
virtual int completedUnitCount(UnitType unit) const;
virtual int incompleteUnitCount(UnitType unit) const;
virtual int deadUnitCount(UnitType unit) const;
virtual int killedUnitCount(UnitType unit) const;
virtual int getUpgradeLevel(UpgradeType upgrade) const;
virtual bool hasResearched(TechType tech) const;
virtual bool isResearching(TechType tech) const;
virtual bool isUpgrading(UpgradeType upgrade) const;
virtual BWAPI::Color getColor() const;
virtual int getTextColor() const;
virtual int maxEnergy(UnitType unit) const;
virtual double topSpeed(UnitType unit) const;
virtual int groundWeaponMaxRange(UnitType unit) const;
virtual int airWeaponMaxRange(UnitType unit) const;
virtual int weaponMaxRange(WeaponType weapon) const;
virtual int sightRange(UnitType unit) const;
virtual int groundWeaponDamageCooldown(UnitType unit) const;
virtual int armor(UnitType unit) const;
virtual int getUnitScore() const;
virtual int getKillScore() const;
virtual int getBuildingScore() const;
virtual int getRazingScore() const;
virtual int getCustomScore() const;
virtual bool isObserver() const;
virtual int getMaxUpgradeLevel(UpgradeType upgrade) const;
virtual bool isResearchAvailable(TechType tech) const;
virtual bool isUnitAvailable(UnitType unit) const;
};
};

View file

@ -0,0 +1,25 @@
#pragma once
namespace BWAPI
{
struct RegionData
{
int id;
int islandID;
int center_x;
int center_y;
int priority;
// region boundry
int leftMost;
int rightMost;
int topMost;
int bottomMost;
int neighborCount;
int neighbors[256];
bool isWalkable;
bool isHigherGround;
};
};

View file

@ -0,0 +1,39 @@
#pragma once
#include <BWAPI/Region.h>
#include <BWAPI/Position.h>
#include <BWAPI/Client/RegionData.h>
namespace BWAPI
{
class RegionImpl : public Region
{
private:
RegionData *self;
std::set<BWAPI::Region*> neighbors;
BWAPI::Region *closestAccessibleRgn;
BWAPI::Region *closestInaccessibleRgn;
public:
RegionImpl(int index);
void setNeighbors();
virtual int getID() const;
virtual int getRegionGroupID() const;
virtual BWAPI::Position getCenter() const;
virtual bool isHigherGround() const;
virtual int getDefensePriority() const;
virtual bool isWalkable() const;
virtual const std::set<BWAPI::Region*> &getNeighbors() const;
virtual int getBoundsLeft() const;
virtual int getBoundsTop() const;
virtual int getBoundsRight() const;
virtual int getBoundsBottom() const;
virtual BWAPI::Region *getClosestAccessibleRegion() const;
virtual BWAPI::Region *getClosestInaccessibleRegion() const;
virtual int getDistance(BWAPI::Region *other) const;
};
};

View file

@ -0,0 +1,47 @@
#pragma once
#include "ShapeType.h"
namespace BWAPIC
{
struct Shape
{
Shape()
:type(ShapeType::None)
,ctype(0)
,x1(0)
,y1(0)
,x2(0)
,y2(0)
,extra1(0)
,extra2(0)
,color(0)
,isSolid(false)
{
}
Shape(ShapeType::Enum _shapeType, int _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;
int ctype;
int x1;
int y1;
int x2;
int y2;
int extra1;
int extra2;
int color;
bool isSolid;
};
}

View file

@ -0,0 +1,22 @@
#pragma once
/**
* Used in UnitCommand
*/
namespace BWAPIC
{
namespace ShapeType
{
enum Enum
{
None,
Text,
Box,
Triangle,
Circle,
Ellipse,
Dot,
Line
};
}
}

View 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;
};
}

View 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 isUnpowered;
bool isVisible[9];
int buttonset;
int lastAttackerPlayer;
bool recentlyAttacked;
int replayID;
};
}

View file

@ -0,0 +1,223 @@
#pragma once
#include <BWAPI.h>
#include "UnitData.h"
#include <set>
#include <string>
namespace BWAPI
{
class Player;
class UnitImpl : public Unit
{
private:
int id;
UnitType initialType;
int initialResources;
int initialHitPoints;
Position initialPosition;
int lastCommandFrame;
UnitCommand lastCommand;
void* clientInfo;
public:
UnitData* self;
std::set<Unit*> connectedUnits;
std::set<Unit*> loadedUnits;
void clear();
void saveInitialState();
UnitImpl(int id);
virtual int getID() const;
virtual int getReplayID() const;
virtual Player* getPlayer() const;
virtual UnitType getType() const;
virtual Position getPosition() const;
virtual TilePosition getTilePosition() const;
virtual double getAngle() const;
virtual double getVelocityX() const;
virtual double getVelocityY() const;
virtual BWAPI::Region *getRegion() const;
virtual int getLeft() const;
virtual int getTop() const;
virtual int getRight() const;
virtual int getBottom() const;
virtual int getHitPoints() const;
virtual int getShields() const;
virtual int getEnergy() const;
virtual int getResources() const;
virtual int getResourceGroup() const;
virtual int getDistance(Unit* target) const;
virtual int getDistance(Position target) const;
virtual bool hasPath(Unit* target) const;
virtual bool hasPath(Position target) const;
virtual int getLastCommandFrame() const;
virtual UnitCommand getLastCommand() const;
virtual BWAPI::Player *getLastAttackingPlayer() const;
virtual int getUpgradeLevel(UpgradeType upgrade) const;
virtual UnitType getInitialType() const;
virtual Position getInitialPosition() const;
virtual TilePosition getInitialTilePosition() const;
virtual int getInitialHitPoints() const;
virtual int getInitialResources() const;
virtual int getKillCount() const;
virtual int getAcidSporeCount() const;
virtual int getInterceptorCount() const;
virtual int getScarabCount() const;
virtual int getSpiderMineCount() const;
virtual int getGroundWeaponCooldown() const;
virtual int getAirWeaponCooldown() const;
virtual int getSpellCooldown() const;
virtual int getDefenseMatrixPoints() const;
virtual int getDefenseMatrixTimer() const;
virtual int getEnsnareTimer() const;
virtual int getIrradiateTimer() const;
virtual int getLockdownTimer() const;
virtual int getMaelstromTimer() const;
virtual int getOrderTimer() const;
virtual int getPlagueTimer() const;
virtual int getRemoveTimer() const;
virtual int getStasisTimer() const;
virtual int getStimTimer() const;
virtual UnitType getBuildType() const;
virtual std::list<UnitType> getTrainingQueue() const;
virtual TechType getTech() const;
virtual UpgradeType getUpgrade() const;
virtual int getRemainingBuildTime() const;
virtual int getRemainingTrainTime() const;
virtual int getRemainingResearchTime() const;
virtual int getRemainingUpgradeTime() const;
virtual Unit* getBuildUnit() const;
virtual Unit* getTarget() const;
virtual Position getTargetPosition() const;
virtual Order getOrder() const;
virtual Unit* getOrderTarget() const;
virtual Position getOrderTargetPosition() const;
virtual Order getSecondaryOrder() const;
virtual Position getRallyPosition() const;
virtual Unit* getRallyUnit() const;
virtual Unit* getAddon() const;
virtual Unit* getNydusExit() const;
virtual Unit* getPowerUp() const;
virtual Unit* getTransport() const;
virtual std::set<Unit*> getLoadedUnits() const;
virtual Unit* getCarrier() const;
virtual std::set<Unit*> getInterceptors() const;
virtual Unit* getHatchery() const;
virtual std::set<Unit*> getLarva() const;
virtual std::set<Unit*>& getUnitsInRadius(int radius) const;
virtual std::set<Unit*>& getUnitsInWeaponRange(WeaponType weapon) const;
virtual void *getClientInfo() const;
virtual void setClientInfo(void* clientinfo);
virtual bool exists() const;
virtual bool hasNuke() const;
virtual bool isAccelerating() const;
virtual bool isAttackFrame() const;
virtual bool isAttacking() const;
virtual bool isBeingConstructed() const;
virtual bool isBeingGathered() const;
virtual bool isBeingHealed() const;
virtual bool isBlind() const;
virtual bool isBraking() const;
virtual bool isBurrowed() const;
virtual bool isCarryingGas() const;
virtual bool isCarryingMinerals() const;
virtual bool isCloaked() const;
virtual bool isCompleted() const;
virtual bool isConstructing() const;
virtual bool isDefenseMatrixed() const;
virtual bool isDetected() const;
virtual bool isEnsnared() const;
virtual bool isFollowing() const;
virtual bool isGatheringGas() const;
virtual bool isGatheringMinerals() const;
virtual bool isHallucination() const;
virtual bool isHoldingPosition() const;
virtual bool isIdle() const;
virtual bool isInWeaponRange(Unit *target) const;
virtual bool isInterruptible() const;
virtual bool isInvincible() const;
virtual bool isIrradiated() const;
virtual bool isLifted() const;
virtual bool isLoaded() const;
virtual bool isLockedDown() const;
virtual bool isMaelstrommed() const;
virtual bool isMorphing() const;
virtual bool isMoving() const;
virtual bool isParasited() const;
virtual bool isPatrolling() const;
virtual bool isPlagued() const;
virtual bool isRepairing() const;
virtual bool isResearching() const;
virtual bool isSelected() const;
virtual bool isSieged() const;
virtual bool isStartingAttack() const;
virtual bool isStasised() const;
virtual bool isStimmed() const;
virtual bool isStuck() const;
virtual bool isTraining() const;
virtual bool isUnderAttack() const;
virtual bool isUnderDarkSwarm() const;
virtual bool isUnderDisruptionWeb() const;
virtual bool isUnderStorm() const;
virtual bool isUnpowered() const;
virtual bool isUpgrading() const;
virtual bool isVisible() const;
virtual bool isVisible(Player* player) const;
virtual bool canIssueCommand(UnitCommand command) const;
virtual bool issueCommand(UnitCommand command);
virtual bool attack(Position target, bool shiftQueueCommand = false);
virtual bool attack(Unit* target, bool shiftQueueCommand = false);
virtual bool build(TilePosition target, UnitType type);
virtual bool buildAddon(UnitType type);
virtual bool train(UnitType type);
virtual bool morph(UnitType type);
virtual bool research(TechType tech);
virtual bool upgrade(UpgradeType upgrade);
virtual bool setRallyPoint(Position target);
virtual bool setRallyPoint(Unit* target);
virtual bool move(Position target, bool shiftQueueCommand = false);
virtual bool patrol(Position target, bool shiftQueueCommand = false);
virtual bool holdPosition(bool shiftQueueCommand = false);
virtual bool stop(bool shiftQueueCommand = false);
virtual bool follow(Unit* target, bool shiftQueueCommand = false);
virtual bool gather(Unit* target, bool shiftQueueCommand = false);
virtual bool returnCargo(bool shiftQueueCommand = false);
virtual bool repair(Unit* target, bool shiftQueueCommand = false);
virtual bool burrow();
virtual bool unburrow();
virtual bool cloak();
virtual bool decloak();
virtual bool siege();
virtual bool unsiege();
virtual bool lift();
virtual bool land(TilePosition target);
virtual bool load(Unit* target, bool shiftQueueCommand = false);
virtual bool unload(Unit* target);
virtual bool unloadAll(bool shiftQueueCommand = false);
virtual bool unloadAll(Position target, bool shiftQueueCommand = false);
virtual bool rightClick(Position target, bool shiftQueueCommand = false);
virtual bool rightClick(Unit* target, bool shiftQueueCommand = false);
virtual bool haltConstruction();
virtual bool cancelConstruction();
virtual bool cancelAddon();
virtual bool cancelTrain(int slot = -2);
virtual bool cancelMorph();
virtual bool cancelResearch();
virtual bool cancelUpgrade();
virtual bool useTech(TechType tech);
virtual bool useTech(TechType tech, Position target);
virtual bool useTech(TechType tech, Unit* target);
virtual bool placeCOP(TilePosition target);
};
}

48
bwapi-master/Color.h Normal file
View file

@ -0,0 +1,48 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
// TODO: Add color palette image and info about text color
/** StarCraft uses a 256 color palette to render everything, so the colors we can use to draw shapes using
* BWAPI is limited to the colors available in the Palette. */
class Color : public Type
{
public:
Color();
/** Create a color using the specified index from the Broodwar color palette. */
Color(int id);
/** Create a color using the color in the palette that is closest to the RGB color specified. */
Color(int red, int green, int blue);
/** Return the red component of the color. */
int red() const;
/** Return the green component of the color. */
int green() const;
/** Return the blue component of the color. */
int blue() const;
};
/** While any color from the palette can be used, the following colors are available as short cuts. */
namespace Colors
{
void init();
extern const Color Red;
extern const Color Blue;
extern const Color Teal;
extern const Color Purple;
extern const Color Orange;
extern const Color Brown;
extern const Color White;
extern const Color Yellow;
extern const Color Green;
extern const Color Cyan;
extern const Color Black;
extern const Color Grey;
}
}

6
bwapi-master/Constants.h Normal file
View file

@ -0,0 +1,6 @@
#pragma once
namespace BWAPI
{
/** Used for converting between TilePosition coordinates and Position coordinates. */
#define TILE_SIZE 32
}

View file

@ -0,0 +1,13 @@
#pragma once
namespace BWAPI
{
namespace CoordinateType
{
enum Enum
{
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 . */
};
}
}

36
bwapi-master/DamageType.h Normal file
View file

@ -0,0 +1,36 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
class DamageType : public Type
{
public:
DamageType();
DamageType(int id);
/** Returns the name of this damage type. For example DamageTypes::Explosive.getName() will return
* std::string("Explosive"). */
const std::string &getName() const;
const char *c_str() const;
};
namespace DamageTypes
{
/** Given the name of a damage type, this will return a corresponding DamageType object. For example,
* DamageTypes::getDamageType("Concussive") will return DamageTypes::Concussive. */
DamageType getDamageType(std::string name);
/** Returns the set of all the DamageTypes. */
const std::set<DamageType>& allDamageTypes();
void init();
extern const DamageType Independent;
extern const DamageType Explosive;
extern const DamageType Concussive;
extern const DamageType Normal;
extern const DamageType Ignore_Armor;
extern const DamageType None;
extern const DamageType Unknown;
}
}

129
bwapi-master/Error.h Normal file
View file

@ -0,0 +1,129 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
class UnitType;
/** Functions in BWAPI may set an error code. To retrieve the error code, call Game::getLastError. */
class Error : public Type
{
public:
Error();
Error(int id);
/** Returns the name of the error. For example Errors::Insufficient_Minerals?.toString() will return a
* std::string object containing "Insufficient Minerals". */
std::string toString() const;
const char *c_str() const;
};
namespace Errors
{
/** Given the name of an error, this function will return the error code. For example:
* Errors::getError("Unbuildable Location") will return Errors::Unbuildable_Location?. */
Error getError(std::string name);
/** The set of all the error codes. */
const std::set<Error>& allErrors();
void init();
/** Returned if you try to order a unit or get information from a unit that no longer exists. */
extern const Error Unit_Does_Not_Exist;
/** Returned if you try to retrieve information about a unit that is not currently visible or is dead. */
extern const Error Unit_Not_Visible;
/** Returned when attempting to order a unit that BWAPI does not own (i.e. can't order enemy army to go
* away) */
extern const Error Unit_Not_Owned;
/** Returned when trying to order a unit to do something when it is performing another order or is in a
* state which prevents it from performing the desired order. For example, ordering a Terran Engineering
* Bay to upgrade something while it is already upgrading something else will return this error.
* Similarly, trying to train units from a factory that is lifted will return this error. */
extern const Error Unit_Busy;
/** Returned if you do something weird like try to build a Pylon with an SCV, or train Vultures in a
* Barracks, or order a Hydralisk to lay a spider mine. */
extern const Error Incompatible_UnitType;
/** Returned when trying to use a tech type with the wrong Unit::useTech method. */
extern const Error Incompatible_TechType;
/** Returned if you to do something like try to cancel an upgrade when the unit isn't upgrading. */
extern const Error Incompatible_State;
/** Returned if you try to research something that is already researched. */
extern const Error Already_Researched;
/** Returned if you try to upgrade something that is already fully upgraded. */
extern const Error Fully_Upgraded;
/** Returned if you try to research something that is already being researched. */
extern const Error Currently_Researching;
/** Returned if you try to upgrade something that is already being upgraded. */
extern const Error Currently_Upgrading;
/** Returned if you try to train or build something without enough minerals. */
extern const Error Insufficient_Minerals;
/** Returned if you try to train or build something without enough vespene gas. */
extern const Error Insufficient_Gas;
/** Returned if you try to train something without enough supply. */
extern const Error Insufficient_Supply;
/** Returned if you to do something like try to order a Defiler to cast a Dark Swarm without enough
* energy. */
extern const Error Insufficient_Energy;
/** Returned if you do something like try to train Medics when you don't have an Academy, or try to lay
* Spider Mines before spider mines have been researched. */
extern const Error Insufficient_Tech;
/** Returned if you do something like try to lay Spider Mines when your Vulture is out of Spider Mines.
* Same thing with Reavers and Scarabs. */
extern const Error Insufficient_Ammo;
/** Returned if you try to train more Interceptors than the Carrier can hold, try to train more Scarabs
* than a Reaver can hold, or try to load more units into a transport than there is space. */
extern const Error Insufficient_Space;
/** Returned if you try to build a barracks at TilePositions::None or something similar */
extern const Error Invalid_Tile_Position;
/** Returned if you try to construct a building on an unbuildable location */
extern const Error Unbuildable_Location;
/** Returned if you try to construct a building where the worker cannot reach based on static map data. */
extern const Error Unreachable_Location;
/** Returned if you order an immovable unit, like a Protoss Photon Cannon, to attack a unit that is out of
* range.*/
extern const Error Out_Of_Range;
/** Returned if you do something like order a Vulture to attack a flying unit. */
extern const Error Unable_To_Hit;
/** Returned if you try to get information that is not allowed with the given flag settings. For example,
* trying to read the enemy's resource counts while the CompleteMapInformation? flag is not enabled will
* return this error. Similarly, trying to read the coordinates of the screen or mouse while the UserInput
* flag is not enabled will also return this error. */
extern const Error Access_Denied;
/** Used when a file can't be found. */
extern const Error File_Not_Found;
/** Used for bad parameters, like passing NULL or an empty string. */
extern const Error Invalid_Parameter;
/** Used when no error has been encountered. */
extern const Error None;
/** Used when the error code is not recognized or can not be determined. */
extern const Error Unknown;
}
}

59
bwapi-master/Event.h Normal file
View file

@ -0,0 +1,59 @@
#pragma once
#include <BWAPI/EventType.h>
#include <BWAPI/Player.h>
#include <BWAPI/Unit.h>
#include <BWAPI/Position.h>
#include <string>
namespace BWAPI
{
class Event
{
public:
Event();
~Event();
Event(const Event& other);
Event& operator=(const 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 = NULL);
static Event ReceiveText(Player* player, const char* text = NULL);
static Event PlayerLeft(Player* player);
static Event PlayerDropped(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 = NULL);
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:
EventType::Enum type;
Position position;
std::string* text;
Unit* unit;
Player* player;
bool winner;
};
}

31
bwapi-master/EventType.h Normal file
View file

@ -0,0 +1,31 @@
#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,
PlayerDropped,
None
};
}
}

View file

@ -0,0 +1,52 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
class ExplosionType : public Type
{
public:
ExplosionType();
ExplosionType(int id);
/** Returns the name of this explosion type. */
const std::string &getName() const;
const char *c_str() const;
};
namespace ExplosionTypes
{
/** Given a name of an explosion type, this will return the corresponding ExplosionType object. */
ExplosionType getExplosionType(std::string name);
/** Returns the set of all ExplosionTypes. */
const std::set<ExplosionType>& allExplosionTypes();
void init();
extern const ExplosionType None;
extern const ExplosionType Normal;
extern const ExplosionType Radial_Splash;
extern const ExplosionType Enemy_Splash;
extern const ExplosionType Lockdown;
extern const ExplosionType Nuclear_Missile;
extern const ExplosionType Parasite;
extern const ExplosionType Broodlings;
extern const ExplosionType EMP_Shockwave;
extern const ExplosionType Irradiate;
extern const ExplosionType Ensnare;
extern const ExplosionType Plague;
extern const ExplosionType Stasis_Field;
extern const ExplosionType Dark_Swarm;
extern const ExplosionType Consume;
extern const ExplosionType Yamato_Gun;
extern const ExplosionType Restoration;
extern const ExplosionType Disruption_Web;
extern const ExplosionType Corrosive_Acid;
extern const ExplosionType Mind_Control;
extern const ExplosionType Feedback;
extern const ExplosionType Optical_Flare;
extern const ExplosionType Maelstrom;
extern const ExplosionType Air_Splash;
extern const ExplosionType Unknown;
}
}

18
bwapi-master/Flag.h Normal file
View 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
};
}
}

25
bwapi-master/Force.h Normal file
View file

@ -0,0 +1,25 @@
#pragma once
#include <set>
#include <string>
namespace BWAPI
{
class Player;
/** 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. */
class Force
{
protected:
virtual ~Force() {};
public :
/** Returns a unique ID for the force. */
virtual int getID() const = 0;
/** Returns the name of the force. */
virtual std::string getName() const = 0;
/** Returns the set of players in the force. */
virtual std::set<Player*> getPlayers() const = 0;
};
}

475
bwapi-master/Game.h Normal file
View file

@ -0,0 +1,475 @@
#pragma once
#include <list>
#include <map>
#include <set>
#include <vector>
#include <BWAPI/Color.h>
#include <BWAPI/CoordinateType.h>
#include <BWAPI/Error.h>
#include <BWAPI/Event.h>
#include <BWAPI/Flag.h>
#include <BWAPI/GameType.h>
#include <BWAPI/Race.h>
#include <BWAPI/Region.h>
#include <BWAPI/Order.h>
#include <BWAPI/Latency.h>
#include <BWAPI/TilePosition.h>
#include <BWAPI/UnitType.h>
#include <BWAPI/TechType.h>
#include <BWAPI/UpgradeType.h>
#include <BWAPI/Input.h>
namespace BWAPI
{
class Force;
class Player;
class Unit;
class Bullet;
/** 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. */
class Game
{
protected:
virtual ~Game() {};
public :
/** Returns the set of all forces in the match. */
virtual std::set< Force* >& getForces() = 0;
/** 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. */
virtual std::set< Player* >& getPlayers() = 0;
/** 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. */
virtual std::set< Unit* >& getAllUnits() = 0;
/** Returns the set of all accessible mineral patches. */
virtual std::set< Unit* >& getMinerals() = 0;
/** Returns the set of all accessible vespene geysers. */
virtual std::set< Unit* >& getGeysers() = 0;
/** Returns the set of all accessible neutral units. */
virtual std::set< Unit* >& getNeutralUnits() = 0;
/** Returns the set of all mineral patches (including mined out and other inaccessible ones). */
virtual std::set< Unit* >& getStaticMinerals() = 0;
/** Returns the set of all vespene geysers (including mined out and other inaccessible ones). */
virtual std::set< Unit* >& getStaticGeysers() = 0;
/** Returns the set of all neutral units (including mined out and other inaccessible ones). */
virtual std::set< Unit* >& getStaticNeutralUnits() = 0;
/** Returns all visible bullets. If Flag::CompleteMapInformation is enabled, the set of all bullets is
* returned, not just visible ones. */
virtual std::set< Bullet* >& getBullets() = 0;
/** Returns all visible nuke dots. If Flag::CompleteMapInformation is enabled, the set of all nuke dots
* is returned, not just visible ones. */
virtual std::set< Position >& getNukeDots() = 0;
/** Returns the list of events */
virtual std::list< Event >& getEvents() = 0;
/** Returns the force with the given ID, or NULL if no force has the given ID */
virtual Force* getForce(int forceID) = 0;
/** Returns the player with the given ID, or NULL if no player has the given ID */
virtual Player* getPlayer(int playerID) = 0;
/** Returns the unit with the given ID, or NULL if no unit has the given ID */
virtual Unit* getUnit(int unitID) = 0;
/** Returns a pointer to a Unit given an index. */
virtual Unit* indexToUnit(int unitIndex) = 0;
/** Returns the Region with the given ID, or NULL if no region has the given ID */
virtual Region* getRegion(int regionID) = 0;
/** Returns the game type */
virtual GameType getGameType() = 0;
/** Returns the amount of latency the current game has. Currently only returns Latency::SinglePlayer,
* Latency::LanLow, Latency::LanMedium, or Latency::LanHigh. */
virtual int getLatency() = 0;
/** 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. */
virtual int getFrameCount() = 0;
/** Returns the Frames Per Second (FPS) that the game is currently running at */
virtual int getFPS() = 0;
virtual double getAverageFPS() = 0;
/** Returns the position of the mouse on the screen. Returns Positions::Unknown if Flag::UserInput is
* disabled. */
virtual BWAPI::Position getMousePosition() = 0;
/** Returns true if the specified mouse button is pressed. Returns false if Flag::UserInput is
* disabled. */
virtual bool getMouseState(MouseButton button) = 0;
/** \copydoc getMouseState(MouseButton) */
virtual bool getMouseState(int button) = 0;
/** 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. */
virtual bool getKeyState(Key key) = 0;
/** \copydoc getKeyState(Key) */
virtual bool getKeyState(int key) = 0;
/** Returns the position of the top left corner of the screen on the map. Returns Positions::Unknown if
* Flag::UserInput is disabled. */
virtual BWAPI::Position getScreenPosition() = 0;
/** Moves the screen to the given position on the map. The position specified where the top left corner
* of the screen will be. */
virtual void setScreenPosition(int x, int y) = 0;
/** \copydoc setScreenPosition(int, int) */
virtual void setScreenPosition(BWAPI::Position p) = 0;
/** Pings the given position on the minimap. */
virtual void pingMinimap(int x, int y) = 0;
/** \copydoc pingMinimap(int, int) */
virtual void pingMinimap(BWAPI::Position p) = 0;
/** 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. */
virtual bool isFlagEnabled(int flag) = 0;
/** Enables the specified flag. Note that flags can only be enabled at the beginning of a match, during
* the AIModule::onStart callback. */
virtual void enableFlag(int flag) = 0;
/** Returns the set of accessible units that are on the given build tile. */
virtual std::set<Unit*>& getUnitsOnTile(int tileX, int tileY) = 0;
/** Returns the set of accessible units that are in or overlapping the given rectangle. */
virtual std::set<Unit*>& getUnitsInRectangle(int left, int top, int right, int bottom) const = 0;
virtual std::set<Unit*>& getUnitsInRectangle(BWAPI::Position topLeft, BWAPI::Position bottomRight) const = 0;
/** Returns the set of accessible units within or overlapping a circle at the given point with the given radius. */
virtual std::set<Unit*>& getUnitsInRadius(BWAPI::Position center, int radius) const = 0;
/** 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. */
virtual Error getLastError() const = 0;
/** Sets the last error code. */
virtual bool setLastError(BWAPI::Error e) = 0;
/** 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). */
virtual int mapWidth() = 0;
/** 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). */
virtual int mapHeight() = 0;
/** Returns the file name of the current map. */
virtual std::string mapFileName() = 0;
/** Returns the full path name of the current map. */
virtual std::string mapPathName() = 0;
/** Returns the name/title of the current map. */
virtual std::string mapName() = 0;
/** Returns the SHA-1 hash of the map file. */
virtual std::string mapHash() = 0;
/** 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. */
virtual bool isWalkable(int walkX, int walkY) = 0;
/** Returns the ground height of the given build tile. 0 = normal, 1 = high ground. 2 = very high ground. */
virtual int getGroundHeight(int tileX, int tileY) = 0;
/** Returns the ground height of the given build tile. 0 = normal, 1 = high ground. 2 = very high ground. */
virtual int getGroundHeight(TilePosition position) = 0;
/** Returns true if the specified build tile is buildable. Note that this just uses the static map data.
* You will also need to make sure no ground units on the tile to see if its currently buildable. To do
* this, see unitsOnTile. */
virtual bool isBuildable(int tileX, int tileY, bool includeBuildings = false) = 0;
/** \copydoc isBuildable(int, int) */
virtual bool isBuildable(TilePosition position, bool includeBuildings = false) = 0;
/** Returns true if the specified build tile is visible. If the tile is concealed by fog of war, the
* function will return false. */
virtual bool isVisible(int tileX, int tileY) = 0;
/** \copydoc isVisible(int, int) */
virtual bool isVisible(TilePosition position) = 0;
/** Returns true if the specified build tile has been explored (i.e. was visible at some point in the
* match). */
virtual bool isExplored(int tileX, int tileY) = 0;
/** \copydoc isExplored(int, int) */
virtual bool isExplored(TilePosition position) = 0;
/** 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. */
virtual bool hasCreep(int tileX, int tileY) = 0;
/** \copydoc hasCreep(int, int) */
virtual bool hasCreep(TilePosition position) = 0;
/** Returns true if the given build location is powered by a nearby friendly pylon. */
virtual bool hasPower(int tileX, int tileY, UnitType unitType = UnitTypes::None) const = 0;
/** Returns true if the given build location is powered by a nearby friendly pylon. */
virtual bool hasPower(TilePosition position, UnitType unitType = UnitTypes::None) const = 0;
/** Returns true if the given build location is powered by a nearby friendly pylon. */
virtual bool hasPower(int tileX, int tileY, int tileWidth, int tileHeight, UnitType unitType = UnitTypes::None) const = 0;
/** Returns true if the given build location is powered by a nearby friendly pylon. */
virtual bool hasPower(TilePosition position, int tileWidth, int tileHeight, UnitType unitType = UnitTypes::None) const = 0;
/** Returns true if the given pixel location is powered by a nearby friendly pylon. */
virtual bool hasPowerPrecise(int x, int y, UnitType unitType = UnitTypes::None ) const = 0;
/** Returns true if the given pixel location is powered by a nearby friendly pylon. */
virtual bool hasPowerPrecise(Position position, UnitType unitType = UnitTypes::None) const = 0;
/** 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. */
virtual bool canBuildHere(const Unit *builder, TilePosition position, UnitType type, bool checkExplored = false) = 0;
/** 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. */
virtual bool canMake(const Unit *builder, UnitType type) = 0;
/** 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. */
virtual bool canResearch(const Unit *unit, TechType type) = 0;
/** 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. */
virtual bool canUpgrade(const Unit *unit, UpgradeType type) = 0;
/** 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. */
virtual std::set< TilePosition >& getStartLocations() = 0;
/** Prints text on the screen. Text is not sent to other players in multiplayer games. */
virtual void printf(const char *format, ...) = 0;
/** 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"). */
virtual void sendText(const char *format, ...) = 0;
virtual void sendTextEx(bool toAllies, const char *format, ...) = 0;
/** 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. */
virtual void changeRace(Race race) = 0;
/** Returns true if Broodwar is in a game. Returns false for lobby and menu screens */
virtual bool isInGame() = 0;
/** Returns true if Broodwar is in a multiplayer game. Returns false for single player games and
* replays. */
virtual bool isMultiplayer() = 0;
/** Returns true if Broodwar is in a BNet multiplayer game.
*/
virtual bool isBattleNet() = 0;
/** 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. */
virtual bool isPaused() = 0;
/** Returns true if Broodwar is in a replay. */
virtual bool isReplay() = 0;
/** 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. */
virtual void startGame() = 0;
/** Pauses the game. If the game is paused, Game::getFrameCount will not increase however
* AIModule::onFrame will still be called while paused. */
virtual void pauseGame() = 0;
/** Resumes the game. */
virtual void resumeGame() = 0;
/** Leaves the current match and goes to the after-game stats screen. */
virtual void leaveGame() = 0;
/** Restarts the match. Works the same way as if you restarted the match from the menu screen. Only
* available in single player mode. */
virtual void restartGame() = 0;
/** 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. */
virtual void setLocalSpeed(int speed = -1) = 0;
/** Issues a command to a group of units */
virtual bool issueCommand(const std::set<BWAPI::Unit*>& units, UnitCommand command) = 0;
/** 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. */
virtual std::set<Unit*>& getSelectedUnits() = 0;
/** Returns a pointer to the player that BWAPI controls. In replays this will return null. */
virtual Player* self() = 0;
/** 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. */
virtual Player* enemy() = 0;
/** Returns a pointer to the neutral player. */
virtual Player* neutral() = 0;
/** Returns a set of all the ally players that have not left or been defeated. Does not include self. */
virtual std::set<BWAPI::Player*>& allies() = 0;
/** Returns a set of all the enemy players that have not left or been defeated. */
virtual std::set<BWAPI::Player*>& enemies() = 0;
/** Returns a set of all the observer players that have not left. */
virtual std::set<BWAPI::Player*>& observers() = 0;
virtual void setTextSize(int size = 1) = 0;
/** 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.*/
virtual void drawText(int ctype, int x, int y, const char *format, ...) = 0;
virtual void drawTextMap(int x, int y, const char *format, ...) = 0;
virtual void drawTextMouse(int x, int y, const char *format, ...) = 0;
virtual void drawTextScreen(int x, int y, const char *format, ...) = 0;
/** 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. */
virtual void drawBox(int ctype, int left, int top, int right, int bottom, Color color, bool isSolid = false) = 0;
virtual void drawBoxMap(int left, int top, int right, int bottom, Color color, bool isSolid = false) = 0;
virtual void drawBoxMouse(int left, int top, int right, int bottom, Color color, bool isSolid = false) = 0;
virtual void drawBoxScreen(int left, int top, int right, int bottom, Color color, bool isSolid = false) = 0;
/** 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. */
virtual void drawTriangle(int ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false) = 0;
virtual void drawTriangleMap(int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false) = 0;
virtual void drawTriangleMouse(int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false) = 0;
virtual void drawTriangleScreen(int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false) = 0;
/** 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. */
virtual void drawCircle(int ctype, int x, int y, int radius, Color color, bool isSolid = false) = 0;
virtual void drawCircleMap(int x, int y, int radius, Color color, bool isSolid = false) = 0;
virtual void drawCircleMouse(int x, int y, int radius, Color color, bool isSolid = false) = 0;
virtual void drawCircleScreen(int x, int y, int radius, Color color, bool isSolid = false) = 0;
/** 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. */
virtual void drawEllipse(int ctype, int x, int y, int xrad, int yrad, Color color, bool isSolid = false) = 0;
virtual void drawEllipseMap(int x, int y, int xrad, int yrad, Color color, bool isSolid = false) = 0;
virtual void drawEllipseMouse(int x, int y, int xrad, int yrad, Color color, bool isSolid = false) = 0;
virtual void drawEllipseScreen(int x, int y, int xrad, int yrad, Color color, bool isSolid = false) = 0;
/** Draws a dot on the screen at the given position with the given color. */
virtual void drawDot(int ctype, int x, int y, Color color) = 0;
virtual void drawDotMap(int x, int y, Color color) = 0;
virtual void drawDotMouse(int x, int y, Color color) = 0;
virtual void drawDotScreen(int x, int y, Color color) = 0;
/** Draws a line on the screen from (x1,y1) to (x2,y2) with the given color. */
virtual void drawLine(int ctype, int x1, int y1, int x2, int y2, Color color) = 0;
virtual void drawLineMap(int x1, int y1, int x2, int y2, Color color) = 0;
virtual void drawLineMouse(int x1, int y1, int x2, int y2, Color color) = 0;
virtual void drawLineScreen(int x1, int y1, int x2, int y2, Color color) = 0;
/** Retrieves the screen buffer for the game (excluding the HUD) */
virtual void *getScreenBuffer() = 0;
/** Retrieves latency values for the game. Includes latency, speed, and mode */
virtual int getLatencyFrames() = 0;
virtual int getLatencyTime() = 0;
virtual int getRemainingLatencyFrames() = 0;
virtual int getRemainingLatencyTime() = 0;
/** Retrieves the current revision of BWAPI. */
virtual int getRevision() = 0;
/** Retrieves the debug state of the BWAPI build. */
virtual bool isDebug() = 0;
/** Returns true if latency compensation is enabled */
virtual bool isLatComEnabled() = 0;
/** Use to enable or disable latency compensation. Default: Enabled */
virtual void setLatCom(bool isEnabled) = 0;
/** Retrieves the number of frames in the replay */
virtual int getReplayFrameCount() = 0;
/** Sets the rendering state of the Starcraft GUI */
virtual void setGUI(bool enabled = true) = 0;
/** Retrieves the instance number recorded by BWAPI to identify which instance an AI module belongs to */
virtual int getInstanceNumber() = 0;
/** Retrieves the bot's APM. Can include or exclude select commands. */
virtual int getAPM(bool includeSelects = false) = 0;
/** Changes the map to the one specified. Changes do not take effect unless the game is restarted. */
virtual bool setMap(const char *mapFileName) = 0;
/** Sets the frame skip value. 1 = normal */
virtual void setFrameSkip(int frameSkip = 1) = 0;
/** Returns true if Starcraft can find a path from the source to the destination. */
virtual bool hasPath(Position source, Position destination) const = 0;
/** Sets the BWAPI player's alliance with another player. */
virtual bool setAlliance(BWAPI::Player *player, bool allied = true, bool alliedVictory = true) = 0;
/** Sets the BWAPI player's vision with another player. */
virtual bool setVision(BWAPI::Player *player, bool enabled = true) = 0;
/** Returns the elapsed game time in seconds. */
virtual int elapsedTime() const = 0;
/** Sets the level of command optimizations.
0 = No optimization.
1 = Some optimization (Stop, Hold Position, Siege, Burrow, etc.).
2 = More optimization (Train, Set Rally, Lift, [multi-select buildings]).
3 = Maximum optimization (Attack/Move to position, use ability at position, etc.).*/
virtual void setCommandOptimizationLevel(int level = 2) = 0;
/** Returns the remaining countdown time in seconds. */
virtual int countdownTimer() const = 0;
/** Returns the set of all map regions. */
virtual const std::set<BWAPI::Region*> &getAllRegions() const = 0;
/** Returns the region at a position. */
virtual BWAPI::Region *getRegionAt(int x, int y) const = 0;
virtual BWAPI::Region *getRegionAt(BWAPI::Position position) const = 0;
/** Returns the time taken to perform the previous event call. Used for tournament management. */
virtual int getLastEventTime() const = 0;
/** Hides or reveals a player in a replay. */
virtual bool setReplayVision(BWAPI::Player *player, bool enabled = true) = 0;
/** Enables or disables the Fog of War in a replay. */
virtual bool setRevealAll(bool reveal = true) = 0;
};
extern Game* Broodwar;
}

44
bwapi-master/GameType.h Normal file
View file

@ -0,0 +1,44 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
class GameType : public Type
{
public:
GameType();
GameType(int id);
/** Returns the name of the game type. For example GameTypes::Melee.getName() will return an
* std::string object containing "Melee". */
const std::string &getName() const;
const char *c_str() const;
};
namespace GameTypes
{
/** Given the name of a game type, this function will return the GameType. For example:
* GameTypes::getGameType("Free For All") will return GameTypes::Free_For_All. */
GameType getGameType(std::string name);
/** Returns the set of all the GameTypes. */
const std::set<GameType>& allGameTypes();
void init();
extern const GameType Melee;
extern const GameType Free_For_All;
extern const GameType One_on_One;
extern const GameType Capture_The_Flag;
extern const GameType Greed;
extern const GameType Slaughter;
extern const GameType Sudden_Death;
extern const GameType Ladder;
extern const GameType Use_Map_Settings;
extern const GameType Team_Melee;
extern const GameType Team_Free_For_All;
extern const GameType Team_Capture_The_Flag;
extern const GameType Top_vs_Bottom;
extern const GameType Pro_Gamer_League;
extern const GameType None;
extern const GameType Unknown;
}
}

212
bwapi-master/Input.h Normal file
View file

@ -0,0 +1,212 @@
#pragma once
namespace BWAPI
{
enum MouseButton
{
M_LEFT = 0,
M_RIGHT = 1,
M_MIDDLE = 2,
M_MAX
};
enum Key
{
K_LBUTTON = 0x01,
K_RBUTTON = 0x02,
K_CANCEL = 0x03,
K_MBUTTON = 0x04,
K_XBUTTON1 = 0x05,
K_XBUTTON2 = 0x06,
K_BACK = 0x08,
K_TAB = 0x09,
K_CLEAR = 0x0C,
K_RETURN = 0x0D,
K_SHIFT = 0x10,
K_CONTROL = 0x11,
K_MENU = 0x12,
K_PAUSE = 0x13,
K_CAPITAL = 0x14,
K_KANA = 0x15,
K_HANGEUL = 0x15,
K_HANGUL = 0x15,
K_JUNJA = 0x17,
K_FINAL = 0x18,
K_HANJA = 0x19,
K_KANJI = 0x19,
K_ESCAPE = 0x1B,
K_CONVERT = 0x1C,
K_NONCONVERT = 0x1D,
K_ACCEPT = 0x1E,
K_MODECHANGE = 0x1F,
K_SPACE = 0x20,
K_PRIOR = 0x21,
K_NEXT = 0x22,
K_END = 0x23,
K_HOME = 0x24,
K_LEFT = 0x25,
K_UP = 0x26,
K_RIGHT = 0x27,
K_DOWN = 0x28,
K_SELECT = 0x29,
K_PRINT = 0x2A,
K_EXECUTE = 0x2B,
K_SNAPSHOT = 0x2C,
K_INSERT = 0x2D,
K_DELETE = 0x2E,
K_HELP = 0x2F,
K_0 = 0x30,
K_1 = 0x31,
K_2 = 0x32,
K_3 = 0x33,
K_4 = 0x34,
K_5 = 0x35,
K_6 = 0x36,
K_7 = 0x37,
K_8 = 0x38,
K_9 = 0x39,
K_A = 0x41,
K_B = 0x42,
K_C = 0x43,
K_D = 0x44,
K_E = 0x45,
K_F = 0x46,
K_G = 0x47,
K_H = 0x48,
K_I = 0x49,
K_J = 0x4A,
K_K = 0x4B,
K_L = 0x4C,
K_M = 0x4D,
K_N = 0x4E,
K_O = 0x4F,
K_P = 0x50,
K_Q = 0x51,
K_R = 0x52,
K_S = 0x53,
K_T = 0x54,
K_U = 0x55,
K_V = 0x56,
K_W = 0x57,
K_X = 0x58,
K_Y = 0x59,
K_Z = 0x5A,
K_LWIN = 0x5B,
K_RWIN = 0x5C,
K_APPS = 0x5D,
K_SLEEP = 0x5F,
K_NUMPAD0 = 0x60,
K_NUMPAD1 = 0x61,
K_NUMPAD2 = 0x62,
K_NUMPAD3 = 0x63,
K_NUMPAD4 = 0x64,
K_NUMPAD5 = 0x65,
K_NUMPAD6 = 0x66,
K_NUMPAD7 = 0x67,
K_NUMPAD8 = 0x68,
K_NUMPAD9 = 0x69,
K_MULTIPLY = 0x6A,
K_ADD = 0x6B,
K_SEPARATOR = 0x6C,
K_SUBTRACT = 0x6D,
K_DECIMAL = 0x6E,
K_DIVIDE = 0x6F,
K_F1 = 0x70,
K_F2 = 0x71,
K_F3 = 0x72,
K_F4 = 0x73,
K_F5 = 0x74,
K_F6 = 0x75,
K_F7 = 0x76,
K_F8 = 0x77,
K_F9 = 0x78,
K_F10 = 0x79,
K_F11 = 0x7A,
K_F12 = 0x7B,
K_F13 = 0x7C,
K_F14 = 0x7D,
K_F15 = 0x7E,
K_F16 = 0x7F,
K_F17 = 0x80,
K_F18 = 0x81,
K_F19 = 0x82,
K_F20 = 0x83,
K_F21 = 0x84,
K_F22 = 0x85,
K_F23 = 0x86,
K_F24 = 0x87,
K_NUMLOCK = 0x90,
K_SCROLL = 0x91,
K_OEM_NEC_EQUAL = 0x92,
K_OEM_FJ_JISHO = 0x92,
K_OEM_FJ_MASSHOU = 0x93,
K_OEM_FJ_TOUROKU = 0x94,
K_OEM_FJ_LOYA = 0x95,
K_OEM_FJ_ROYA = 0x96,
K_LSHIFT = 0xA0,
K_RSHIFT = 0xA1,
K_LCONTROL = 0xA2,
K_RCONTROL = 0xA3,
K_LMENU = 0xA4,
K_RMENU = 0xA5,
K_BROWSER_BACK = 0xA6,
K_BROWSER_FORWARD = 0xA7,
K_BROWSER_REFRESH = 0xA8,
K_BROWSER_STOP = 0xA9,
K_BROWSER_SEARCH = 0xAA,
K_BROWSER_FAVORITES = 0xAB,
K_BROWSER_HOME = 0xAC,
K_VOLUME_MUTE = 0xAD,
K_VOLUME_DOWN = 0xAE,
K_VOLUME_UP = 0xAF,
K_MEDIA_NEXT_TRACK = 0xB0,
K_MEDIA_PREV_TRACK = 0xB1,
K_MEDIA_STOP = 0xB2,
K_MEDIA_PLAY_PAUSE = 0xB3,
K_LAUNCH_MAIL = 0xB4,
K_LAUNCH_MEDIA_SELECT = 0xB5,
K_LAUNCH_APP1 = 0xB6,
K_LAUNCH_APP2 = 0xB7,
K_OEM_1 = 0xBA,
K_OEM_PLUS = 0xBB,
K_OEM_COMMA = 0xBC,
K_OEM_MINUS = 0xBD,
K_OEM_PERIOD = 0xBE,
K_OEM_2 = 0xBF,
K_OEM_3 = 0xC0,
K_OEM_4 = 0xDB,
K_OEM_5 = 0xDC,
K_OEM_6 = 0xDD,
K_OEM_7 = 0xDE,
K_OEM_8 = 0xDF,
K_OEM_AX = 0xE1,
K_OEM_102 = 0xE2,
K_ICO_HELP = 0xE3,
K_ICO_00 = 0xE4,
K_PROCESSKEY = 0xE5,
K_ICO_CLEAR = 0xE6,
K_PACKET = 0xE7,
K_OEM_RESET = 0xE9,
K_OEM_JUMP = 0xEA,
K_OEM_PA1 = 0xEB,
K_OEM_PA2 = 0xEC,
K_OEM_PA3 = 0xED,
K_OEM_WSCTRL = 0xEE,
K_OEM_CUSEL = 0xEF,
K_OEM_ATTN = 0xF0,
K_OEM_FINISH = 0xF1,
K_OEM_COPY = 0xF2,
K_OEM_AUTO = 0xF3,
K_OEM_ENLW = 0xF4,
K_OEM_BACKTAB = 0xF5,
K_ATTN = 0xF6,
K_CRSEL = 0xF7,
K_EXSEL = 0xF8,
K_EREOF = 0xF9,
K_PLAY = 0xFA,
K_ZOOM = 0xFB,
K_NONAME = 0xFC,
K_PA1 = 0xFD,
K_OEM_CLEAR = 0xFE,
K_MAX
};
}

17
bwapi-master/Latency.h Normal file
View 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
};
}
}

189
bwapi-master/Order.h Normal file
View file

@ -0,0 +1,189 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
/** 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. */
class Order : public Type
{
public:
Order();
Order(int id);
/** Returns the name of this order. */
const std::string &getName() const;
const char *c_str() const;
};
namespace Orders
{
/** Given the name of an order, getOrder() will return the corresponding order object. */
Order getOrder(std::string name);
/** Returns the set of all the Orders. */
const std::set<Order>& allOrders();
void init();
extern const Order Die;
extern const Order Stop;
extern const Order Guard;
extern const Order PlayerGuard;
extern const Order TurretGuard;
extern const Order BunkerGuard;
extern const Order Move;
extern const Order AttackUnit;
extern const Order AttackTile;
extern const Order Hover;
extern const Order AttackMove;
extern const Order InfestedCommandCenter;
extern const Order UnusedNothing;
extern const Order UnusedPowerup;
extern const Order TowerGuard;
extern const Order VultureMine;
extern const Order Nothing;
extern const Order Nothing3;
extern const Order CastInfestation;
extern const Order InfestingCommandCenter;
extern const Order PlaceBuilding;
extern const Order BuildProtoss2;
extern const Order ConstructingBuilding;
extern const Order Repair;
extern const Order PlaceAddon;
extern const Order BuildAddon;
extern const Order Train;
extern const Order RallyPointUnit;
extern const Order RallyPointTile;
extern const Order ZergBirth;
extern const Order ZergUnitMorph;
extern const Order ZergBuildingMorph;
extern const Order IncompleteBuilding;
extern const Order BuildNydusExit;
extern const Order EnterNydusCanal;
extern const Order Follow;
extern const Order Carrier;
extern const Order ReaverCarrierMove;
extern const Order CarrierIgnore2;
extern const Order Reaver;
extern const Order TrainFighter;
extern const Order InterceptorAttack;
extern const Order ScarabAttack;
extern const Order RechargeShieldsUnit;
extern const Order RechargeShieldsBattery;
extern const Order ShieldBattery;
extern const Order InterceptorReturn;
extern const Order BuildingLand;
extern const Order BuildingLiftOff;
extern const Order DroneLiftOff;
extern const Order LiftingOff;
extern const Order ResearchTech;
extern const Order Upgrade;
extern const Order Larva;
extern const Order SpawningLarva;
extern const Order Harvest1;
extern const Order Harvest2;
extern const Order MoveToGas;
extern const Order WaitForGas;
extern const Order HarvestGas;
extern const Order ReturnGas;
extern const Order MoveToMinerals;
extern const Order WaitForMinerals;
extern const Order MiningMinerals;
extern const Order Harvest3;
extern const Order Harvest4;
extern const Order ReturnMinerals;
extern const Order Interrupted;
extern const Order EnterTransport;
extern const Order PickupIdle;
extern const Order PickupTransport;
extern const Order PickupBunker;
extern const Order Pickup4;
extern const Order PowerupIdle;
extern const Order Sieging;
extern const Order Unsieging;
extern const Order InitCreepGrowth;
extern const Order SpreadCreep;
extern const Order StoppingCreepGrowth;
extern const Order GuardianAspect;
extern const Order ArchonWarp;
extern const Order CompletingArchonsummon;
extern const Order HoldPosition;
extern const Order Cloak;
extern const Order Decloak;
extern const Order Unload;
extern const Order MoveUnload;
extern const Order FireYamatoGun;
extern const Order CastLockdown;
extern const Order Burrowing;
extern const Order Burrowed;
extern const Order Unburrowing;
extern const Order CastDarkSwarm;
extern const Order CastParasite;
extern const Order CastSpawnBroodlings;
extern const Order CastEMPShockwave;
extern const Order NukeWait;
extern const Order NukeTrain;
extern const Order NukeLaunch;
extern const Order NukePaint;
extern const Order NukeUnit;
extern const Order CastNuclearStrike;
extern const Order NukeTrack;
extern const Order CloakNearbyUnits;
extern const Order PlaceMine;
extern const Order RightClickAction;
extern const Order CastRecall;
extern const Order TeleporttoLocation;
extern const Order CastScannerSweep;
extern const Order Scanner;
extern const Order CastDefensiveMatrix;
extern const Order CastPsionicStorm;
extern const Order CastIrradiate;
extern const Order CastPlague;
extern const Order CastConsume;
extern const Order CastEnsnare;
extern const Order CastStasisField;
extern const Order CastHallucination;
extern const Order Hallucination2;
extern const Order ResetCollision;
extern const Order Patrol;
extern const Order CTFCOPInit;
extern const Order CTFCOPStarted;
extern const Order CTFCOP2;
extern const Order ComputerAI;
extern const Order AtkMoveEP;
extern const Order HarassMove;
extern const Order AIPatrol;
extern const Order GuardPost;
extern const Order RescuePassive;
extern const Order Neutral;
extern const Order ComputerReturn;
extern const Order SelfDestrucing;
extern const Order Critter;
extern const Order HiddenGun;
extern const Order OpenDoor;
extern const Order CloseDoor;
extern const Order HideTrap;
extern const Order RevealTrap;
extern const Order Enabledoodad;
extern const Order Disabledoodad;
extern const Order Warpin;
extern const Order Medic;
extern const Order MedicHeal1;
extern const Order HealMove;
extern const Order MedicHeal2;
extern const Order CastRestoration;
extern const Order CastDisruptionWeb;
extern const Order CastMindControl;
extern const Order DarkArchonMeld;
extern const Order CastFeedback;
extern const Order CastOpticalFlare;
extern const Order CastMaelstrom;
extern const Order JunkYardDog;
extern const Order Fatal;
extern const Order None;
extern const Order Unknown;
};
}

205
bwapi-master/Player.h Normal file
View file

@ -0,0 +1,205 @@
#pragma once
#include <set>
#include <string>
#include <BWAPI/TilePosition.h>
#include <BWAPI/Race.h>
#include <BWAPI/TechType.h>
#include <BWAPI/UpgradeType.h>
#include <BWAPI/PlayerType.h>
#include <BWAPI/UnitType.h>
#include <BWAPI/Client/PlayerData.h>
#include <BWAPI/Color.h>
namespace BWAPI
{
class Unit;
class Force;
/** 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. */
class Player
{
protected:
virtual ~Player() {};
public :
/** Returns a unique ID for the player. */
virtual int getID() const = 0;
/** Returns the name of the player. */
virtual std::string getName() const = 0;
/** 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. */
virtual const std::set<Unit*>& getUnits() const = 0;
/** Returns the race of the player. */
virtual Race getRace() const = 0;
/** Returns the type of the player. */
virtual PlayerType getType() const = 0;
/** Returns the force the player is on. */
virtual Force* getForce() const = 0;
/** Returns true if other player is an ally of this player. */
virtual bool isAlly(Player* player) const = 0;
/** Returns true if other player is an enemy of this player. */
virtual bool isEnemy(Player* player) const = 0;
/** Returns true if the player is the neutral player. */
virtual bool isNeutral() const = 0;
/** 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. */
virtual TilePosition getStartLocation() const = 0;
/** Returns true if the player has achieved victory. */
virtual bool isVictorious() const = 0;
/** Returns true if the player has been defeated. */
virtual bool isDefeated() const = 0;
/** Returns true if the player left the game. */
virtual bool leftGame() const = 0;
/** Returns the amount of minerals the player has. */
virtual int minerals() const = 0;
/** Returns the amount of vespene gas the player has. */
virtual int gas() const = 0;
/** Returns the cumulative amount of minerals the player has mined up to this point (including the 50
* minerals at the start of the game). */
virtual int gatheredMinerals() const = 0;
/** Returns the cumulative amount of gas the player has harvested up to this point. */
virtual int gatheredGas() const = 0;
/** Returns the cumulative amount of minerals the player has spent on repairs up to this point. */
virtual int repairedMinerals() const = 0;
/** Returns the cumulative amount of gas the player has spent on repairs up to this point. */
virtual int repairedGas() const = 0;
/** Returns the cumulative amount of minerals the player has gained from refunded units up to this point. */
virtual int refundedMinerals() const = 0;
/** Returns the cumulative amount of gas the player has gained from refunded units up to this point. */
virtual int refundedGas() const = 0;
/** Returns the cumulative amount of minerals the player has spent up to this point (not including repairs). */
virtual int spentMinerals() const = 0;
/** Returns the cumulative amount of gas the player has spent up to this point (not including repairs). */
virtual int spentGas() const = 0;
// TODO: ground methods
/** 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. */
virtual int supplyTotal() const = 0;
virtual int supplyTotal(Race race) const = 0;
/** 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. */
virtual int supplyUsed() const = 0;
virtual int supplyUsed(Race race) const = 0;
/** Returns the number of all accessible units of the given type. */
virtual int allUnitCount(UnitType unit) const = 0;
/** Returns the number of visible units of the given type. */
virtual int visibleUnitCount(UnitType unit) const = 0;
/** Returns the number of completed units of the given type. */
virtual int completedUnitCount(UnitType unit) const = 0;
/** Returns the number of incomplete units of the given type. */
virtual int incompleteUnitCount(UnitType unit) const = 0;
/** Returns the number of dead units of the given type. */
virtual int deadUnitCount(UnitType unit) const = 0;
/** Returns the number of killed units of the given type. */
virtual int killedUnitCount(UnitType unit) const = 0;
/** Returns the player's current upgrade level of the given upgrade. To order a unit to upgrade a given
* upgrade type, see Unit::upgrade. */
virtual int getUpgradeLevel(UpgradeType upgrade) const = 0;
/** Returns true if the player has finished researching the given tech. To order a unit to research a
* given tech type, see Unit::research. */
virtual bool hasResearched(TechType tech) const = 0;
/** Returns true if the player is researching the given tech. To order a unit to research a given tech
* type, see Unit::reseach. */
virtual bool isResearching(TechType tech) const = 0;
/** Returns true if the player is upgrading the given upgrade. To order a unit to upgrade a given
* upgrade type, see Unit::upgrade. */
virtual bool isUpgrading(UpgradeType upgrade) const = 0;
/** Returns the color of the player for drawing */
virtual BWAPI::Color getColor() const = 0;
/** Returns the color of the player for text messages */
virtual int getTextColor() const = 0;
/** Returns the max energy of the given unit type, taking into account upgrades */
virtual int maxEnergy(UnitType unit) const = 0;
/** Returns the top speed of the given unit type, includes upgrades */
virtual double topSpeed(UnitType unit) const = 0;
/** Returns the max ground weapon range of the given unit type, includes upgrades */
virtual int groundWeaponMaxRange(UnitType unit) const = 0;
/** Returns the max air weapon range of the given unit type, includes upgrades */
virtual int airWeaponMaxRange(UnitType unit) const = 0;
/** Returns the max range of the given weapon with upgrades */
virtual int weaponMaxRange(WeaponType weapon) const = 0;
/** Returns the sight range of the given unit type, includes upgrades */
virtual int sightRange(UnitType unit) const = 0 ;
/** Returns the ground weapon cooldown of the given unit type, includes upgrades */
virtual int groundWeaponDamageCooldown(UnitType unit) const = 0;
/** Returns the armor of the given unit type, includes upgrades */
virtual int armor(UnitType unit) const = 0;
/** Returns the Player's Total Unit Score */
virtual int getUnitScore() const = 0;
/** Returns the Player's Total Kill Score */
virtual int getKillScore() const = 0;
/** Returns the Player's Total Buildings Score */
virtual int getBuildingScore() const = 0;
/** Returns the Player's Total Razings Score */
virtual int getRazingScore() const = 0;
/** Returns the Player's Custom Score */
virtual int getCustomScore() const = 0;
/** Returns true if the Player is only observing the game, and not participating */
virtual bool isObserver() const = 0;
/** Returns the maximum upgrades available specific to the player (Use Map Settings). */
virtual int getMaxUpgradeLevel(UpgradeType upgrade) const = 0;
/** Returns true if the research is available for the player to research (Use Map Settings). */
virtual bool isResearchAvailable(TechType tech) const = 0;
/** Returns true if the unit is available for the player to build (Use Map Settings). */
virtual bool isUnitAvailable(UnitType unit) const = 0;
};
};

38
bwapi-master/PlayerType.h Normal file
View file

@ -0,0 +1,38 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
class PlayerType : public Type
{
public:
PlayerType();
PlayerType(int id);
/** Returns the name of the player type. For example PlayerTypes::Computer.getName() will return an
* std::string object containing "Computer". */
const std::string &getName() const;
const char *c_str() const;
};
namespace PlayerTypes
{
/** Given the name of a player type, this function will return the playertype. For example:
* PlayerTypes::getPlayerType("Human") will return PlayerTypes::Human. */
PlayerType getPlayerType(std::string name);
/** Returns the set of all the PlayerTypes. */
const std::set<PlayerType>& allPlayerTypes();
void init();
extern const PlayerType None;
extern const PlayerType Computer;
extern const PlayerType Player;
extern const PlayerType RescuePassive;
extern const PlayerType EitherPreferComputer;
extern const PlayerType EitherPreferHuman;
extern const PlayerType Neutral;
extern const PlayerType Closed;
extern const PlayerType PlayerLeft;
extern const PlayerType ComputerLeft;
extern const PlayerType Unknown;
}
}

43
bwapi-master/Position.h Normal file
View file

@ -0,0 +1,43 @@
#pragma once
namespace BWAPI
{
class TilePosition;
// TODO: Add doxygen documentation
class Position
{
public :
Position();
explicit Position(const TilePosition& position);
Position(int x, int y);
bool operator == (const Position& position) const;
bool operator != (const Position& position) const;
bool operator < (const Position& position) const;
operator bool() const;
bool isValid() const;
Position operator+(const Position& position) const;
Position operator-(const Position& position) const;
Position& makeValid();
Position& operator+=(const Position& position);
Position& operator-=(const Position& position);
double getDistance(const Position& position) const;
int getApproxDistance(const Position& position) const;
double getLength() const;
bool hasPath(const Position& destination) const;
int& x();
int& y();
int x() const;
int y() const;
private :
int _x;
int _y;
};
namespace Positions
{
extern const Position Invalid;
extern const Position None;
extern const Position Unknown;
}
};

58
bwapi-master/Race.h Normal file
View file

@ -0,0 +1,58 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
class UnitType;
class Race : public Type
{
public:
Race();
Race(int id);
/** Returns the name of the race. For example Races::Terran.getName() will return a std::string object
* containing "Terran". */
const std::string &getName() const;
const char *c_str() const;
/** Returns the worker unit type for the given race. For example Races::Protoss.getWorker() will return
* a pointer to UnitTypes::Protoss_Probe. */
UnitType getWorker() const;
/** 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. */
UnitType getCenter() const;
/** Returns the refinery unit type for the given race. For example: Races::Zerg.getRefinery() will
* return a pointer to UnitTypes::Zerg_Extractor?. */
UnitType getRefinery() const;
/** Returns the transport unit type for the given race. For example: Races::Protoss.getTransport() will
* return a pointer to UnitTypes::Protoss_Shuttle. */
UnitType getTransport() const;
/** 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?. */
UnitType getSupplyProvider() const;
};
namespace Races
{
/** Given the name of a race, this function will return the race type. For example:
* Races::getRace("Zerg") will return Races::Zerg. */
Race getRace(std::string name);
/** Returns the set of all the races, which are listed below. */
const std::set<Race>& allRaces();
void init();
extern const Race Zerg;
extern const Race Terran;
extern const Race Protoss;
extern const Race Random;
extern const Race Other;
extern const Race None;
extern const Race Unknown;
}
}

49
bwapi-master/Region.h Normal file
View file

@ -0,0 +1,49 @@
#pragma once
#include <set>
#include <BWAPI/Position.h>
namespace BWAPI
{
class Region
{
protected:
virtual ~Region() {};
public:
/** Returns the unique ID for this region assigned by Broodwar. */
virtual int getID() const = 0;
/** Returns an ID for the body of land that this region belongs to. */
virtual int getRegionGroupID() const = 0;
/** Retrieves the center of the region. */
virtual BWAPI::Position getCenter() const = 0;
/** Returns true if this region belongs to strategic higher ground, assigned by Broodwar. */
virtual bool isHigherGround() const = 0;
/** Returns a value representing the strategic advantage of this region according to Broodwar. */
virtual int getDefensePriority() const = 0;
/** Returns true if the region can be walked on by ground units. */
virtual bool isWalkable() const = 0;
/** Retrieves the set of neighbors that this region is connected to. */
virtual const std::set<Region*> &getNeighbors() const = 0;
/** Retrieves the approximate region boundry as specified by Broodwar. */
virtual int getBoundsLeft() const = 0;
virtual int getBoundsTop() const = 0;
virtual int getBoundsRight() const = 0;
virtual int getBoundsBottom() const = 0;
/** Retrieves the closest accessable neighbor region. */
virtual BWAPI::Region *getClosestAccessibleRegion() const = 0;
/** Retrieves the closest inaccessable neighbor region. */
virtual BWAPI::Region *getClosestInaccessibleRegion() const = 0;
/** Retrieves the center-to-center distance between two regions. */
virtual int getDistance(BWAPI::Region *other) const = 0;
};
};

105
bwapi-master/TechType.h Normal file
View file

@ -0,0 +1,105 @@
#pragma once
#include <string>
#include <set>
#include <BWAPI/Race.h>
#include <BWAPI/Order.h>
#include "Type.h"
namespace BWAPI
{
class UnitType;
class WeaponType;
class TechType : public Type
{
public:
TechType();
TechType(int id);
/** Returns the name of the tech type. */
const std::string &getName() const;
const char *c_str() const;
/** Returns the race that uses the TechType. For example, TechTypes::Scanner_Sweep?.getRace() will
* return Races::Terran. */
Race getRace() const;
/** Returns the mineral cost of the tech type. */
int mineralPrice() const;
/** Returns the vespene gas price of the tech type. */
int gasPrice() const;
/** Returns the number of frames needed to research the tech type. */
int researchTime() const;
/** Returns the amount of energy used each time this tech type is used. */
int energyUsed() const;
/** 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. */
UnitType whatResearches() const;
/** 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. */
WeaponType getWeapon() const;
/** Returns true if this tech type must be used on another unit (i.e. Irradiate) */
bool targetsUnit() const;
/** Returns true if this tech type must be specified a position (i.e. Dark Swarm) */
bool targetsPosition() const;
/** 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. */
const std::set<UnitType>& whatUses() const;
/** Returns the order used to execute this tech type as an action. */
Order getOrder() const;
};
namespace TechTypes
{
/** Given a string, this will return the tech type. */
TechType getTechType(std::string name);
/** Returns the set of all the TechTypes. */
const std::set<TechType>& allTechTypes();
void init();
extern const TechType Stim_Packs;
extern const TechType Lockdown;
extern const TechType EMP_Shockwave;
extern const TechType Spider_Mines;
extern const TechType Scanner_Sweep;
extern const TechType Tank_Siege_Mode;
extern const TechType Defensive_Matrix;
extern const TechType Irradiate;
extern const TechType Yamato_Gun;
extern const TechType Cloaking_Field;
extern const TechType Personnel_Cloaking;
extern const TechType Burrowing;
extern const TechType Infestation;
extern const TechType Spawn_Broodlings;
extern const TechType Dark_Swarm;
extern const TechType Plague;
extern const TechType Consume;
extern const TechType Ensnare;
extern const TechType Parasite;
extern const TechType Psionic_Storm;
extern const TechType Hallucination;
extern const TechType Recall;
extern const TechType Stasis_Field;
extern const TechType Archon_Warp;
extern const TechType Restoration;
extern const TechType Disruption_Web;
extern const TechType Mind_Control;
extern const TechType Dark_Archon_Meld;
extern const TechType Feedback;
extern const TechType Optical_Flare;
extern const TechType Maelstrom;
extern const TechType Lurker_Aspect;
extern const TechType Healing;
extern const TechType None;
extern const TechType Unknown;
extern const TechType Nuclear_Strike;
};
}

View file

@ -0,0 +1,42 @@
#pragma once
namespace BWAPI
{
class Position;
// TODO: Add doxygen documentation
class TilePosition
{
public :
TilePosition();
explicit TilePosition(const Position& position);
TilePosition(int x, int y);
bool operator == (const TilePosition& TilePosition) const;
bool operator != (const TilePosition& TilePosition) const;
bool operator < (const TilePosition& TilePosition) const;
bool isValid() const;
operator bool() const;
TilePosition operator+(const TilePosition& position) const;
TilePosition operator-(const TilePosition& position) const;
TilePosition& makeValid();
TilePosition& operator+=(const TilePosition& position);
TilePosition& operator-=(const TilePosition& position);
double getDistance(const TilePosition& position) const;
double getLength() const;
bool hasPath(const TilePosition& destination) const;
int& x();
int& y();
int x() const;
int y() const;
private :
int _x;
int _y;
};
namespace TilePositions
{
extern const TilePosition Invalid;
extern const TilePosition None;
extern const TilePosition Unknown;
}
};

View file

@ -0,0 +1,28 @@
#pragma once
namespace BWAPI
{
namespace Tournament
{
enum ActionID
{
EnableFlag,
ChangeRace,
StartGame,
PauseGame,
ResumeGame,
LeaveGame,
RestartGame,
SetLocalSpeed,
SetTextSize,
SetLatCom,
SetGUI,
SetMap,
SetFrameSkip,
Printf,
SendText,
SetCommandOptimizationLevel
};
};
};

15
bwapi-master/Type.h Normal file
View file

@ -0,0 +1,15 @@
#pragma once
#include <string>
namespace BWAPI
{
class Type
{
private:
int _id;
public:
Type(int id);
operator int() const;
int getID() const;
};
}

727
bwapi-master/Unit.h Normal file
View file

@ -0,0 +1,727 @@
#pragma once
#include <list>
#include <BWAPI/Order.h>
#include <BWAPI/TechType.h>
#include <BWAPI/UpgradeType.h>
#include <BWAPI/UnitType.h>
#include <BWAPI/Position.h>
#include <BWAPI/Region.h>
#include <BWAPI/TilePosition.h>
#include <BWAPI/UnitCommand.h>
#include <BWAPI/Client/UnitData.h>
namespace BWAPI
{
class Player;
/** The Unit class is used to get information about individual units as well as issue orders to units. Each
* unit in the game has a unique Unit object, and Unit objects are not deleted until the end of the match
* (so you don't need to worry about unit pointers becoming invalid).
*
* Every Unit in the game is either accessible or inaccessible. To determine if an AI can access a
* particular unit, BWAPI checks to see if Flag::CompleteMapInformation? is enabled. So there are two cases
* to consider - either the flag is enabled, or it is disabled:
*
* If Flag::CompleteMapInformation? is disabled, then a unit is accessible if and only if it is visible.
* Note also that some properties of visible enemy units will not be made available to the AI (such as the
* contents of visible enemy dropships). If a unit is not visible, Unit::exists will return false,
* regardless of whether or not the unit exists. This is because absolutely no state information on
* invisible enemy units is made available to the AI. To determine if an enemy unit has been destroyed, the
* AI must watch for AIModule::onUnitDestroy messages from BWAPI, which is only called for visible units
* which get destroyed.
*
* If Flag::CompleteMapInformation? is enabled, then all units that exist in the game are accessible, and
* Unit::exists is accurate for all units. Similarly AIModule::onUnitDestroy messages are generated for all
* units that get destroyed, not just visible ones.
*
* If a Unit is not accessible, in general the only the getInitial__ functions will be available to the AI.
* However for units that were owned by the player, getPlayer and getType will continue to work for units
* that have been destroyed. */
class Unit
{
protected:
virtual ~Unit() {};
public:
/** Returns a unique ID for this unit. It simply casts the unit's address as an integer, since each unit
* has a unique address. */
virtual int getID() const = 0;
/** Returns the unit ID that is used in a replay (*.rep) file's action recordings. */
virtual int getReplayID() const = 0;
/** Returns a pointer to the player that owns this unit. */
virtual Player* getPlayer() const = 0;
/** Returns the current type of the unit. */
virtual UnitType getType() const = 0;
/** Returns the position of the unit on the map. */
virtual Position getPosition() const = 0;
/** Returns the build tile position of the unit on the map. Useful if the unit is a building. The tile
* position is of the top left corner of the building. */
virtual TilePosition getTilePosition() const = 0;
/** Returns the direction the unit is facing, measured in radians. An angle of 0 means the unit is
* facing east. */
virtual double getAngle() const = 0;
/** Returns the x component of the unit's velocity, measured in pixels per frame. */
virtual double getVelocityX() const = 0;
/** Returns the y component of the unit's velocity, measured in pixels per frame. */
virtual double getVelocityY() const = 0;
/** Returns the region that this unit is currently in. */
virtual BWAPI::Region *getRegion() const = 0;
/** Returns the X coordinate of the left side of the unit. */
virtual int getLeft() const = 0;
/** Returns the Y coordinate of the top side of the unit. */
virtual int getTop() const = 0;
/** Returns the X coordinate of the right side of the unit. */
virtual int getRight() const = 0;
/** Returns the Y coordinate of the bottom side of the unit. */
virtual int getBottom() const = 0;
/** Returns the unit's current amount of hit points. */
virtual int getHitPoints() const = 0;
/** Returns the unit's current amount of shields. */
virtual int getShields() const = 0;
/** Returns the unit's current amount of energy. */
virtual int getEnergy() const = 0;
/** Returns the unit's current amount of containing resources. Useful for determining how much minerals
* are left in a mineral patch, or how much gas is left in a geyser
* (can also be called on a refinery/assimilator/extractor). */
virtual int getResources() const = 0;
/** Retrieves the group ID of a resource. Can be used to identify which resources belong to an expansion. */
virtual int getResourceGroup() const = 0;
/** Returns the edge-to-edge distance between the current unit and the target unit. */
virtual int getDistance(Unit* target) const = 0;
/** Returns the distance from the edge of the current unit to the target position. */
virtual int getDistance(Position target) const = 0;
/** Returns true if the unit is able to move to the target unit */
virtual bool hasPath(Unit* target) const = 0;
/** Returns true if the unit is able to move to the target position */
virtual bool hasPath(Position target) const = 0;
/** Returns the frame of the last successful command. Frame is comparable to Game::getFrameCount(). */
virtual int getLastCommandFrame() const = 0;
/** Returns the last successful command. */
virtual UnitCommand getLastCommand() const = 0;
/** Returns the player that last attacked this unit. */
virtual BWAPI::Player *getLastAttackingPlayer() const = 0;
/** Returns the player's current upgrade level for the given upgrade, if the unit is affected by this
* upgrade.*/
virtual int getUpgradeLevel(UpgradeType upgrade) const = 0;
/** Returns the initial type of the unit or Unknown if it wasn't a neutral unit at the beginning of the
* game. */
virtual UnitType getInitialType() const = 0;
/** Returns the initial position of the unit on the map, or Positions::Unknown if the unit wasn't a
* neutral unit at the beginning of the game. */
virtual Position getInitialPosition() const = 0;
/** Returns the initial build tile position of the unit on the map, or TilePositions::Unknown if the
* unit wasn't a neutral unit at the beginning of the game. The tile position is of the top left corner
* of the building. */
virtual TilePosition getInitialTilePosition() const = 0;
/** Returns the unit's initial amount of hit points, or 0 if it wasn't a neutral unit at the beginning
* of the game. */
virtual int getInitialHitPoints() const = 0;
/** Returns the unit's initial amount of containing resources, or 0 if the unit wasn't a neutral unit
* at the beginning of the game. */
virtual int getInitialResources() const = 0;
/** Returns the unit's current kill count. */
virtual int getKillCount() const = 0;
/** Returns the unit's acid spore count. */
virtual int getAcidSporeCount() const = 0;
/** Returns the number of interceptors the Protoss Carrier has. */
virtual int getInterceptorCount() const = 0;
/** Returns the number of scarabs in the Protoss Reaver. */
virtual int getScarabCount() const = 0;
/** Returns the number of spider mines in the Terran Vulture. */
virtual int getSpiderMineCount() const = 0;
/** Returns unit's ground weapon cooldown. It is 0 if the unit is ready to attack. */
virtual int getGroundWeaponCooldown() const = 0;
/** Returns unit's air weapon cooldown. It is 0 if the unit is ready to attack. */
virtual int getAirWeaponCooldown() const = 0;
/** Returns unit's ground weapon cooldown. It is 0 if the unit is ready cast a spell. */
virtual int getSpellCooldown() const = 0;
/** Returns the remaining hit points of the defense matrix. Initially a defense Matrix has 250 points.
* \see Unit::getDefenseMatrixTimer, Unit::isDefenseMatrixed. */
virtual int getDefenseMatrixPoints() const = 0;
/** Returns the time until the defense matrix wears off. 0 -> No defense Matrix present. */
virtual int getDefenseMatrixTimer() const = 0;
/** Returns the time until the ensnare effect wears off. 0 -> No ensnare effect present. */
virtual int getEnsnareTimer() const = 0;
/** Returns the time until the radiation wears off. 0 -> No radiation present. */
virtual int getIrradiateTimer() const = 0;
/** Returns the time until the lockdown wears off. 0 -> No lockdown present. */
virtual int getLockdownTimer() const = 0;
/** Returns the time until the maelstrom wears off. 0 -> No maelstrom present. */
virtual int getMaelstromTimer() const = 0;
// TODO: add doc
virtual int getOrderTimer() const = 0;
/** Returns the time until the plague wears off. 0 -> No plague present. */
virtual int getPlagueTimer() const = 0;
/** Returns the amount of time until the unit is removed, or 0 if the unit does not have a remove timer.
* Used to determine how much time remains before hallucinated units, dark swarm, etc have until they
* are removed. */
virtual int getRemoveTimer() const = 0;
/** Returns the time until the stasis field wears off. 0 -> No stasis field present. */
virtual int getStasisTimer() const = 0;
/** Returns the time until the stimpack wears off. 0 -> No stimpack boost present. */
virtual int getStimTimer() const = 0;
/** Returns the building type a worker is about to construct. If the unit is a morphing Zerg unit or an
* incomplete building, this returns the UnitType the unit is about to become upon completion.*/
virtual UnitType getBuildType() const = 0;
/** Returns the list of units queued up to be trained.
* \see Unit::train, Unit::cancelTrain, Unit::isTraining. */
virtual std::list<UnitType > getTrainingQueue() const = 0;
/** Returns the tech that the unit is currently researching. If the unit is not researching anything,
* TechTypes::None is returned.
* \see Unit::research, Unit::cancelResearch, Unit::isResearching, Unit::getRemainingResearchTime. */
virtual TechType getTech() const = 0;
/** Returns the upgrade that the unit is currently upgrading. If the unit is not upgrading anything,
* UpgradeTypes::None is returned.
* \see Unit::upgrade, Unit::cancelUpgrade, Unit::isUpgrading, Unit::getRemainingUpgradeTime. */
virtual UpgradeType getUpgrade() const = 0;
/** Returns the remaining build time of a unit/building that is being constructed. */
virtual int getRemainingBuildTime() const = 0;
/** Returns the remaining time of the unit that is currently being trained. If the unit is a Hatchery,
* Lair, or Hive, this returns the amount of time until the next larva spawns, or 0 if the unit already
* has 3 larva. */
virtual int getRemainingTrainTime() const = 0;
/** Returns the amount of time until the unit is done researching its current tech. If the unit is not
* researching anything, 0 is returned.
* \see Unit::research, Unit::cancelResearch, Unit::isResearching, Unit::getTech. */
virtual int getRemainingResearchTime() const = 0;
/** Returns the amount of time until the unit is done upgrading its current upgrade. If the unit is not
* upgrading anything, 0 is returned.
* \see Unit::upgrade, Unit::cancelUpgrade, Unit::isUpgrading, Unit::getUpgrade. */
virtual int getRemainingUpgradeTime() const = 0;
/** If the unit is an SCV that is constructing a building, this will return the building it is
* constructing. If the unit is a Terran building that is being constructed, this will return the SCV
* that is constructing it. */
virtual Unit* getBuildUnit() const = 0;
/** Generally returns the appropriate target unit after issuing an order that accepts a target unit
* (i.e. attack, repair, gather, follow, etc.). To check for a target that has been acquired
* automatically (without issuing an order) see getOrderTarget. */
virtual Unit* getTarget() const = 0;
/** Returns the target position the unit is moving to (provided a valid path to the target position
* exists). */
virtual Position getTargetPosition() const = 0;
// TODO: add doc
virtual Order getOrder() const = 0;
virtual Order getSecondaryOrder() const = 0;
/** This is usually set when the low level unit AI acquires a new target automatically. For example if
* an enemy probe comes in range of your marine, the marine will start attacking it, and getOrderTarget
* will be set in this case, but not getTarget. */
virtual Unit* getOrderTarget() const = 0;
/** Returns the target position for the units order. For example for the move order getTargetPosition
* returns the end of the units path but this returns the location the unit is trying to move to. */
virtual Position getOrderTargetPosition() const = 0;
/** Returns the position the building is rallied to. If the building does not produce units,
* Positions::None is returned.
* \see Unit::setRallyPoint, Unit::getRallyUnit. */
virtual Position getRallyPosition() const = 0;
/** Returns the unit the building is rallied to. If the building is not rallied to any unit, NULL is
* returned.
* \see Unit::setRallyPoint, Unit::getRallyPosition. */
virtual Unit* getRallyUnit() const = 0;
/** Returns the add-on of this unit, or NULL if the unit doesn't have an add-on. */
virtual Unit* getAddon() const = 0;
/** Returns the corresponding connected nydus canal of this unit, or NULL if the unit does not have a
* connected nydus canal. */
virtual Unit* getNydusExit() const = 0;
/** Returns the power up the unit is holding, or NULL if the unit is not holding a power up */
virtual Unit* getPowerUp() const = 0;
/** Returns the dropship, shuttle, overlord, or bunker that is this unit is loaded in to. */
virtual Unit* getTransport() const = 0;
/** Returns a list of the units loaded into a Terran Bunker, Terran Dropship, Protoss Shuttle, or Zerg
* Overlord. */
virtual std::set<Unit*> getLoadedUnits() const = 0;
/** For Protoss Interceptors, this returns the Carrier unit this Interceptor is controlled by. For all
* other unit types this function returns NULL. */
virtual Unit* getCarrier() const = 0;
/** Returns the set of interceptors controlled by this unit. If the unit has no interceptors, or is not
* a Carrier, this function returns an empty set. */
virtual std::set<Unit*> getInterceptors() const = 0;
/** For Zerg Larva, this returns the Hatchery, Lair, or Hive unit this Larva was spawned from. For all
* other unit types this function returns NULL. */
virtual Unit* getHatchery() const = 0;
/** Returns the set of larva spawned by this unit. If the unit has no larva, or is not a Hatchery, Lair,
* or Hive, this function returns an empty set. Equivalent to clicking "Select Larva" from the Starcraft
* GUI. */
virtual std::set<Unit*> getLarva() const = 0;
/** Returns the set of units within the given radius of this unit */
virtual std::set<Unit*>& getUnitsInRadius(int radius) const = 0;
/** Returns the set of units within weapon range of this unit. */
virtual std::set<Unit*>& getUnitsInWeaponRange(WeaponType weapon) const = 0;
/** Returns the unit's custom client info. The client is responsible for deallocation. */
virtual void* getClientInfo() const = 0;
/** Sets the unit's custom client info. The client is responsible for deallocation. */
virtual void setClientInfo(void* clientinfo) = 0;
/**
* 3 cases to consider:
*
* - If exists() returns true, the unit exists.
* - If exists() returns false and the unit is owned by self(), then the unit does not exist.
* - If exists() returns false and the unit is not owned by self(), then the unit may or may not exist.
*
* \see Unit::isVisible.
* */
virtual bool exists() const = 0;
/* Returns true if the Nuclear Missile Silo has a nuke */
virtual bool hasNuke() const = 0;
/** Returns true if the unit is currently accelerating. */
virtual bool isAccelerating() const = 0;
// TODO: add doc
virtual bool isAttacking() const = 0;
virtual bool isAttackFrame() const = 0;
/** Returns true if the unit is being constructed. Always true for incomplete Protoss and Zerg
* buildings, and true for incomplete Terran buildings that have an SCV constructing them. If the SCV
* halts construction, isBeingConstructed will return false.
*
* \see Unit::build, Unit::cancelConstruction, Unit::haltConstruction, Unit::isConstructing. */
virtual bool isBeingConstructed() const = 0;
/** Returns true if the unit is a mineral patch or refinery that is being gathered. */
virtual bool isBeingGathered() const = 0;
/** Returns true if the unit is currently being healed by a Terran Medic, or repaired by a Terran SCV. */
virtual bool isBeingHealed() const = 0;
/** Returns true if the unit is currently blind from a Medic's Optical Flare. */
virtual bool isBlind() const = 0;
/** Returns true if the unit is currently braking/slowing down. */
virtual bool isBraking() const = 0;
/** Returns true if the unit is a Zerg unit that is current burrowed.
* \see Unit::burrow, Unit::unburrow. */
virtual bool isBurrowed() const = 0;
/** Returns true if the unit is a worker that is carrying gas.
* \see Unit::returnCargo, Unit::isGatheringGas. */
virtual bool isCarryingGas() const = 0;
/** Returns true if the unit is a worker that is carrying minerals.
* \see Unit::returnCargo, Unit::isGatheringMinerals. */
virtual bool isCarryingMinerals() const = 0;
/** Returns true if the unit is cloaked.
* \see Unit::cloak, Unit::decloak. */
virtual bool isCloaked() const = 0;
/** Returns true if the unit has been completed. */
virtual bool isCompleted() const = 0;
/** Returns true when a unit has been issued an order to build a structure and is moving to the build
* location. Also returns true for Terran SCVs while they construct a building.
* \see Unit::build, Unit::cancelConstruction, Unit::haltConstruction, Unit::isBeingConstructed. */
virtual bool isConstructing() const = 0;
/** Returns true if the unit has a defense matrix from a Terran Science Vessel. */
virtual bool isDefenseMatrixed() const = 0;
/** Returns true if the unit is detected. */
virtual bool isDetected() const = 0;
/** Returns true if the unit has been ensnared by a Zerg Queen. */
virtual bool isEnsnared() const = 0;
/** Returns true if the unit is following another unit.
* \see Unit::follow, Unit::getTarget. */
virtual bool isFollowing() const = 0;
/** Returns true if the unit is in one of the four states for gathering gas (MoveToGas, WaitForGas,
* HarvestGas, ReturnGas).
* \see Unit::isCarryingGas. */
virtual bool isGatheringGas() const = 0;
/** Returns true if the unit is in one of the four states for gathering minerals (MoveToMinerals,
* WaitForMinerals, MiningMinerals, ReturnMinerals).
* \see Unit::isCarryingMinerals. */
virtual bool isGatheringMinerals() const = 0;
/** Returns true for hallucinated units, false for normal units. Returns true for hallucinated enemy
* units only if Complete Map Information is enabled.
* \see Unit::getRemoveTimer. */
virtual bool isHallucination() const = 0;
/** Returns true if the unit is holding position
* \see Unit::holdPosition. */
virtual bool isHoldingPosition() const = 0;
/** Returns true if the unit is not doing anything.
* \see Unit::stop. */
virtual bool isIdle() const = 0;
/** Returns true if the unit can be interrupted. */
virtual bool isInterruptible() const = 0;
/** Returns true if the unit is invincible. */
virtual bool isInvincible() const = 0;
/** Returns true if the unit can attack a specified target from its current position. */
virtual bool isInWeaponRange(Unit *target) const = 0;
/** Returns true if the unit is being irradiated by a Terran Science Vessel.
* \see Unit::getIrradiateTimer. */
virtual bool isIrradiated() const = 0;
/** Returns true if the unit is a Terran building that is currently lifted off the ground.
* \see Unit::lift,Unit::land. */
virtual bool isLifted() const = 0;
/** Return true if the unit is loaded into a Terran Bunker, Terran Dropship, Protoss Shuttle, or Zerg
* Overlord.
* \see Unit::load, Unit::unload, Unit::unloadAll. */
virtual bool isLoaded() const = 0;
/** Returns true if the unit is locked down by a Terran Ghost.
* \see Unit::getLockdownTimer. */
virtual bool isLockedDown() const = 0;
/** Returns true if the unit is being maelstrommed.
* \see Unit::getMaelstromTimer. */
virtual bool isMaelstrommed() const = 0;
/** Returns true if the unit is a zerg unit that is morphing.
* \see Unit::morph, Unit::cancelMorph, Unit::getBuildType, Unit::getRemainingBuildTime. */
virtual bool isMorphing() const = 0;
/** Returns true if the unit is moving.
* \see Unit::attack, Unit::stop. */
virtual bool isMoving() const = 0;
/** Returns true if the unit has been parasited by some other player. */
virtual bool isParasited() const = 0;
/** Returns true if the unit is patrolling between two positions.
* \see Unit::patrol. */
virtual bool isPatrolling() const = 0;
/** Returns true if the unit has been plagued by a Zerg Defiler.
* \see Unit::getPlagueTimer. */
virtual bool isPlagued() const = 0;
/** Returns true if the unit is a Terran SCV that is repairing or moving to repair another unit. */
virtual bool isRepairing() const = 0;
/** Returns true if the unit is a building that is researching tech. See TechTypes for the complete list
* of available techs in Broodwar.
* \see Unit::research, Unit::cancelResearch, Unit::getTech, Unit::getRemainingResearchTime. */
virtual bool isResearching() const = 0;
/** Returns true if the unit has been selected by the user via the starcraft GUI. Only available if you
* enable Flag::UserInput during AIModule::onStart.
* \see Game::getSelectedUnits. */
virtual bool isSelected() const = 0;
/** Returns true if the unit is a Terran Siege Tank that is currently in Siege mode.
* \see Unit::siege, Unit::unsiege. */
virtual bool isSieged() const = 0;
/** Returns true if the unit is starting to attack.
* \see Unit::attackUnit, Unit::getGroundWeaponCooldown, Unit::getAirWeaponCooldown. */
virtual bool isStartingAttack() const = 0;
/** Returns true if the unit has been stasised by a Protoss Arbiter.
* \see Unit::getStasisTimer. */
virtual bool isStasised() const = 0;
/** Returns true if the unit is currently stimmed.
* \see Unit::getStimTimer. */
virtual bool isStimmed() const = 0;
/** Returns true if the unit is being pushed off of another unit */
virtual bool isStuck() const = 0;
/** Returns true if the unit is training units (i.e. a Barracks training Marines).
* \see Unit::train, Unit::getTrainingQueue, Unit::cancelTrain, Unit::getRemainingTrainTime. */
virtual bool isTraining() const = 0;
/** Returns true if the unit was recently attacked. */
virtual bool isUnderAttack() const = 0;
/** Returns true if the unit is under a Dark Swarm. */
virtual bool isUnderDarkSwarm() const = 0;
/** Returns true if the unit is under a Disruption Web. */
virtual bool isUnderDisruptionWeb() const = 0;
/** Returns true if the unit is under a Protoss Psionic Storm. */
virtual bool isUnderStorm() const = 0;
/** Returns true if the unit is a Protoss building that is unpowered because no pylons are in range. */
virtual bool isUnpowered() const = 0;
/** Returns true if the unit is a building that is upgrading. See UpgradeTypes for the complete list
* of available upgrades in Broodwar.
* \see Unit::upgrade, Unit::cancelUpgrade, Unit::getUpgrade, Unit::getRemainingUpgradeTime. */
virtual bool isUpgrading() const = 0;
/** Returns true if the unit is visible. If the CompleteMapInformation? cheat flag is enabled, existing
* units hidden by the fog of war will be accessible, but isVisible will still return false.
* \see Unit::exists. */
virtual bool isVisible() const = 0;
virtual bool isVisible(Player* player) const = 0;
/** Returns true if the unit is able to execute the given command, or false if there is an error */
virtual bool canIssueCommand(UnitCommand command) const = 0;
/** Issues the give unit command, or returns false if there is an error */
virtual bool issueCommand(UnitCommand command) = 0;
/** Orders the unit to attack move to the specified location. */
virtual bool attack(Position target, bool shiftQueueCommand = false) = 0;
/** Orders the unit to attack the specified unit. */
virtual bool attack(Unit* target, bool shiftQueueCommand = false) = 0;
/** Orders the unit to build the given unit type at the given position. Note that if the player does not
* have enough resources when the unit attempts to place the building down, the order will fail. The
* tile position specifies where the top left corner of the building will be placed. */
virtual bool build(TilePosition target, UnitType type) = 0;
/** Orders the unit to build the given addon. The unit must be a Terran building that can have an addon
* and the specified unit type must be an addon unit type. */
virtual bool buildAddon(UnitType type) = 0;
/** Orders this unit to add the specified unit type to the training queue. Note that the player must
* have sufficient resources to train. If you wish to make units from a hatchery, use getLarva to get
* the larva associated with the hatchery and then call morph on the larva you want to morph. This
* command can also be used to make interceptors and scarabs. */
virtual bool train(UnitType type) = 0;
/** Orders the unit to morph into the specified unit type. Returns false if given a wrong type.
* \see Unit::cancelMorph, Unit::isMorphing. */
virtual bool morph(UnitType type) = 0;
/** Orders the unit to research the given tech type.
* \see Unit::cancelResearch, Unit::Unit#isResearching, Unit::getRemainingResearchTime, Unit::getTech. */
virtual bool research(TechType tech) = 0;
/** Orders the unit to upgrade the given upgrade type.
* \see Unit::cancelUpgrade, Unit::Unit#isUpgrading, Unit::getRemainingUpgradeTime, Unit::getUpgrade. */
virtual bool upgrade(UpgradeType upgrade) = 0;
/** Orders the unit to set its rally position to the specified position.
* \see Unit::getRallyPosition, Unit::getRallyUnit. */
virtual bool setRallyPoint(Position target) = 0;
/** Orders the unit to set its rally unit to the specified unit.
* \see Unit::setRallyPosition, Unit::getRallyPosition, Unit::getRallyUnit. */
virtual bool setRallyPoint(Unit* target) = 0;
/** Orders the unit to move from its current position to the specified position.
* \see Unit::isMoving. */
virtual bool move(Position target, bool shiftQueueCommand = false) = 0;
/** Orders the unit to patrol between its current position and the specified position.
* \see Unit::isPatrolling. */
virtual bool patrol(Position target, bool shiftQueueCommand = false) = 0;
/** Orders the unit to hold its position.*/
virtual bool holdPosition(bool shiftQueueCommand = false) = 0;
/** Orders the unit to stop. */
virtual bool stop(bool shiftQueueCommand = false) = 0;
/** Orders the unit to follow the specified unit.
* \see Unit::isFollowing. */
virtual bool follow(Unit* target, bool shiftQueueCommand = false) = 0;
/** Orders the unit to gather the specified unit (must be mineral or refinery type).
* \see Unit::isGatheringGas, Unit::isGatheringMinerals. */
virtual bool gather(Unit* target, bool shiftQueueCommand = false) = 0;
/** Orders the unit to return its cargo to a nearby resource depot such as a Command Center. Only
* workers that are carrying minerals or gas can be ordered to return cargo.
* \see Unit::isCarryingGas, Unit::isCarryingMinerals. */
virtual bool returnCargo(bool shiftQueueCommand = false) = 0;
/** Orders the unit to repair the specified unit. Only Terran SCVs can be ordered to repair, and the
* target must be a mechanical Terran unit or building.
* \see Unit::isRepairing. */
virtual bool repair(Unit* target, bool shiftQueueCommand = false) = 0;
/** Orders the unit to burrow. Either the unit must be a Zerg Lurker, or the unit must be a Zerg ground
* unit and burrow tech must be researched.
* \see: Unit::unburrow, Unit::isBurrowed. */
virtual bool burrow() = 0;
/** Orders the burrowed unit to unburrow.
* \see: Unit::burrow, Unit::isBurrowed.
* */
virtual bool unburrow() = 0;
/** Orders the unit to cloak.
* \see: Unit::decloak, Unit::isCloaked. */
virtual bool cloak() = 0;
/** Orders the unit to decloak.
* \see: Unit::cloak, Unit::isCloaked. */
virtual bool decloak() = 0;
/** Orders the unit to siege. Note: unit must be a Terran siege tank.
* \see Unit::unsiege, Unit::isSieged. */
virtual bool siege() = 0;
/** Orders the unit to unsiege. Note: unit must be a Terran siege tank.
* \see: Unit::unsiege, Unit::isSieged. */
virtual bool unsiege() = 0;
/** Orders the unit to lift. Note: unit must be a Terran building that can be lifted.
* \see Unit::land, Unit::isLifted. */
virtual bool lift() = 0;
/** Orders the unit to land. Note: unit must be a Terran building that is currently lifted.
* \see Unit::lift, Unit::isLifted. */
virtual bool land(TilePosition target) = 0;
/** Orders the unit to load the target unit.
* \see Unit::unload, Unit::unloadAll, Unit::getLoadedUnits, Unit:isLoaded. */
virtual bool load(Unit* target, bool shiftQueueCommand = false) = 0;
/** Orders the unit to unload the target unit.
* \see Unit::load, Unit::unloadAll, Unit::getLoadedUnits, Unit:isLoaded. */
virtual bool unload(Unit* target) = 0;
/** Orders the unit to unload all loaded units at the unit's current position.
* \see Unit::load, Unit::unload, Unit::unloadAll, Unit::getLoadedUnits, Unit:isLoaded. */
virtual bool unloadAll(bool shiftQueueCommand = false) = 0;
/** Orders the unit to unload all loaded units at the specified location. Unit should be a Terran
* Dropship, Protoss Shuttle, or Zerg Overlord. If the unit is a Terran Bunker, the units will be
* unloaded right outside the bunker, like in the first version of unloadAll.
* \see Unit::load, Unit::unload, Unit::unloadAll, Unit::getLoadedUnits, Unit:isLoaded. */
virtual bool unloadAll(Position target, bool shiftQueueCommand = false) = 0;
/** Works like the right click in the GUI. */
virtual bool rightClick(Position target, bool shiftQueueCommand = false) = 0;
/** Works like the right click in the GUI. Right click on a mineral patch to order a worker to mine,
* right click on an enemy to attack it. */
virtual bool rightClick(Unit* target, bool shiftQueueCommand = false) = 0;
/** Orders the SCV to stop constructing the building, and the building is left in a partially complete
* state until it is canceled, destroyed, or completed.
* \see Unit::isConstructing. */
virtual bool haltConstruction() = 0;
/** Orders the building to stop being constructed.
* \see Unit::beingConstructed. */
virtual bool cancelConstruction() = 0;
/** Orders the unit to stop making the addon. */
virtual bool cancelAddon() = 0;
/** Orders the unit to remove the specified unit from its training queue.
* \see Unit::train, Unit::cancelTrain, Unit::isTraining, Unit::getTrainingQueue. */
virtual bool cancelTrain(int slot = -2) = 0;
/** Orders the unit to stop morphing.
* \see Unit::morph, Unit::isMorphing. */
virtual bool cancelMorph() = 0;
/** Orders the unit to cancel a research in progress.
* \see Unit::research, Unit::isResearching, Unit::getTech. */
virtual bool cancelResearch() = 0;
/** Orders the unit to cancel an upgrade in progress.
* \see Unit::upgrade, Unit::isUpgrading, Unit::getUpgrade. */
virtual bool cancelUpgrade() = 0;
/** Orders the unit to use a tech not requiring a target (ie Stim Pack). Returns true if it is a valid
* tech. */
virtual bool useTech(TechType tech) = 0;
/** Orders the unit to use a tech requiring a position target (ie Dark Swarm). Returns true if it is a
* valid tech.*/
virtual bool useTech(TechType tech, Position target) = 0;
/** Orders the unit to use a tech requiring a unit target (ie Irradiate). Returns true if it is a valid
* tech.*/
virtual bool useTech(TechType tech, Unit* target) = 0;
/** Moves a Flag Beacon to the target location. */
virtual bool placeCOP(TilePosition target) = 0;
};
}

View file

@ -0,0 +1,85 @@
#pragma once
#include <BWAPI/UnitCommandType.h>
#include <BWAPI/Position.h>
#include <BWAPI/TilePosition.h>
#include <BWAPI/TechType.h>
#include <BWAPI/UpgradeType.h>
#include <BWAPI/UnitType.h>
namespace BWAPI
{
class Unit;
class UnitCommand
{
public:
UnitCommand();
UnitCommand(Unit* _unit, UnitCommandType _type, Unit* _target, int _x, int _y, int _extra);
static UnitCommand attack(Unit* unit, Position target, bool shiftQueueCommand = false);
static UnitCommand attack(Unit* unit, Unit* 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, Position target);
static UnitCommand setRallyPoint(Unit* unit, Unit* 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, Position target, bool shiftQueueCommand = false);
static UnitCommand rightClick(Unit* unit, Unit* 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, Position target);
static UnitCommand useTech(Unit* unit,TechType tech, Unit* 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;
bool operator<(const UnitCommand& other) const;
bool operator>(const UnitCommand& other) const;
Unit* unit;
UnitCommandType type;
Unit* target;
int x;
int y;
int extra;
};
}

View file

@ -0,0 +1,75 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
#define BWAPI_UNIT_COMMAND_TYPE_COUNT 46
namespace BWAPI
{
class UnitCommandType : public Type
{
public:
UnitCommandType();
UnitCommandType(int id);
/** Returns the string corresponding to the UnitCommandType object. For example,
* UnitCommandTypes::Set_Rally_Position.getName() returns std::string("Set Rally Position")*/
const std::string &getName() const;
const char *c_str() const;
};
namespace UnitCommandTypes
{
/** Given a string, this function returns the command type it refers to. For example,
* UnitCommandTypes::getUnitCommandType("Attack Position") returns UnitCommandTypes::Attack_Position. */
UnitCommandType getUnitCommandType(std::string name);
/** Returns the set of all the sizes, which are listed below: */
const std::set<UnitCommandType>& allUnitCommandTypes();
void init();
extern const UnitCommandType Attack_Move;
extern const UnitCommandType Attack_Unit;
extern const UnitCommandType Build;
extern const UnitCommandType Build_Addon;
extern const UnitCommandType Train;
extern const UnitCommandType Morph;
extern const UnitCommandType Research;
extern const UnitCommandType Upgrade;
extern const UnitCommandType Set_Rally_Position;
extern const UnitCommandType Set_Rally_Unit;
extern const UnitCommandType Move;
extern const UnitCommandType Patrol;
extern const UnitCommandType Hold_Position;
extern const UnitCommandType Stop;
extern const UnitCommandType Follow;
extern const UnitCommandType Gather;
extern const UnitCommandType Return_Cargo;
extern const UnitCommandType Repair;
extern const UnitCommandType Burrow;
extern const UnitCommandType Unburrow;
extern const UnitCommandType Cloak;
extern const UnitCommandType Decloak;
extern const UnitCommandType Siege;
extern const UnitCommandType Unsiege;
extern const UnitCommandType Lift;
extern const UnitCommandType Land;
extern const UnitCommandType Load;
extern const UnitCommandType Unload;
extern const UnitCommandType Unload_All;
extern const UnitCommandType Unload_All_Position;
extern const UnitCommandType Right_Click_Position;
extern const UnitCommandType Right_Click_Unit;
extern const UnitCommandType Halt_Construction;
extern const UnitCommandType Cancel_Construction;
extern const UnitCommandType Cancel_Addon;
extern const UnitCommandType Cancel_Train;
extern const UnitCommandType Cancel_Train_Slot;
extern const UnitCommandType Cancel_Morph;
extern const UnitCommandType Cancel_Research;
extern const UnitCommandType Cancel_Upgrade;
extern const UnitCommandType Use_Tech;
extern const UnitCommandType Use_Tech_Position;
extern const UnitCommandType Use_Tech_Unit;
extern const UnitCommandType Place_COP;
extern const UnitCommandType None;
extern const UnitCommandType Unknown;
}
}

View file

@ -0,0 +1,33 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
class UnitSizeType : public Type
{
public:
UnitSizeType();
UnitSizeType(int id);
/** Returns the string corresponding to the UnitSizeType object. For example,
* UnitSizeTypes::Medium.getName() returns std::string("Medium")*/
const std::string &getName() const;
const char *c_str() const;
};
namespace UnitSizeTypes
{
/** Given a string, this function returns the size type it refers to. For example,
* UnitSizeTypes::getUnitSizeType("Small") returns UnitSizeTypes::Small. */
UnitSizeType getUnitSizeType(std::string name);
/** Returns the set of all the sizes, which are listed below: */
const std::set<UnitSizeType>& allUnitSizeTypes();
void init();
extern const UnitSizeType Independent;
extern const UnitSizeType Small;
extern const UnitSizeType Medium;
extern const UnitSizeType Large;
extern const UnitSizeType None;
extern const UnitSizeType Unknown;
}
}

513
bwapi-master/UnitType.h Normal file
View file

@ -0,0 +1,513 @@
#pragma once
#include <string>
#include <map>
#include <set>
#include <BWAPI/Race.h>
#include <BWAPI/UnitSizeType.h>
#include "Type.h"
#define BWAPI_UNIT_TYPE_MAX_COUNT 234
namespace BWAPI
{
class TechType;
class UpgradeType;
class WeaponType;
/** 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*/
class UnitType : public Type
{
public:
UnitType();
UnitType(int id);
/** Returns the name of the unit. */
const std::string &getName() const;
const char *c_str() const;
/** Returns the race that the unit belongs to. For example UnitTypes::Terran_SCV.getRace() will return
* Races::Terran. */
Race getRace() const;
/** 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.
*
* Example: UnitTypes::Terran_Marine.whatBuilds() will return an std::pair, where the first component
* is UnitTypes::Terran_Barracks. */
const std::pair< UnitType, int > whatBuilds() const;
/** Returns the units the player is required to have before it can train or build the given unit type.
*
* Example: UnitTypes::Terran_Battlecruiser.requiredUnits() will return a map of three keys:
* UnitTypes::Terran_Starport, UnitTypes::Terran_Control_Tower, and UnitTypes::Terran_Physics_Lab. */
const std::map< UnitType, int >& requiredUnits() const;
/** Included in the API for completeness, since the only units that actually needs tech to be trained
* are the Zerg_Lurker and Zerg_Lurker_Egg. The tech type needed is TechTypes::Lurker_Aspect. */
TechType requiredTech() const;
/** Returns the tech used to cloak the unit, or TechTypes::None if the unit cannot cloak or is
permanently cloaked */
TechType cloakingTech() const;
/** Returns the set of tech types this unit can use, provided the tech types have been researched and
* the unit has enough energy. */
const std::set< TechType >& abilities() const;
/** Returns the set of upgrade types that can affect this unit. */
const std::set< UpgradeType >& upgrades() const;
/** 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. */
UpgradeType armorUpgrade() const;
/** Returns the maximum amount of hit points the unit type can have. */
int maxHitPoints() const;
/** Returns the maximum amount of shields the unit type can have. */
int maxShields() const;
/** Returns the maximum amount of energy the unit type can have. */
int maxEnergy() const;
/** Returns the amount of armor the non-upgraded unit type has. */
int armor() const;
/** Returns the mineral price of the unit.
*
* Example: UnitTypes::Siege_Tank_Tank_Mode.mineralPrice() returns 150. */
int mineralPrice() const;
/** UnitTypes::Siege_Tank_Tank_Mode.gasPrice() returns 100. */
int gasPrice() const;
/** Returns the number of frames needed to make this unit type. */
int buildTime() const;
/** 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. */
int supplyRequired() const;
/** 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. */
int supplyProvided() const;
/** Returns the amount of space this unit type takes up inside a bunker or transport unit. */
int spaceRequired() const;
/** Returns the amount of space this unit type provides. */
int spaceProvided() const;
/** Returns the score which is used to determine the total scores in the after-game stats screen. */
int buildScore() const;
/** Returns the score which is used to determine the total scores in the after-game stats screen. */
int destroyScore() const;
/** Returns the size of the unit - either Small, Medium, Large, or Independent. */
UnitSizeType size() const;
/** Returns the tile width of the unit. Useful for determining the size of buildings. For example
* UnitTypes::Terran_Supply_Depot.tileWidth() will return 3. */
int tileWidth() const;
/** Returns the tile height of the unit. Useful for determining the size of buildings. For example
* UnitTypes::Terran_Supply_Depot.tileHeight() will return 2. */
int tileHeight() const;
/** Distance from the center of the unit to the left edge of the unit, measured in pixels. */
int dimensionLeft() const;
/** Distance from the center of the unit to the top edge of the unit, measured in pixels. */
int dimensionUp() const;
/** Distance from the center of the unit to the right edge of the unit, measured in pixels. */
int dimensionRight() const;
/** Distance from the center of the unit to the bottom edge of the unit, measured in pixels. */
int dimensionDown() const;
/** Returns the range at which the unit will start targeting enemy units, measured in pixels. */
int seekRange() const;
/** Returns how far the un-upgraded unit type can see into the fog of war, measured in pixels. */
int sightRange() const;
/** Returns the unit's ground weapon. */
WeaponType groundWeapon() const;
// TODO: add doc
int maxGroundHits() const;
/** Returns the unit's air weapon. */
WeaponType airWeapon() const;
// TODO: add doc
int maxAirHits() const;
/** 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. */
double topSpeed() const;
/** Returns how fast the unit can accelerate to its top speed. What units this quantity is measured in
* is currently unknown. */
int acceleration() const;
/** Related to how fast the unit can halt. What units this quantity is measured in is currently
* unknown. */
int haltDistance() const;
/** Related to how fast the unit can turn. What units this quantity is measured in is currently
* unknown. */
int turnRadius() const;
/** 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). */
bool canProduce() const;
/** 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). */
bool canAttack() const;
/** Returns true if the unit can move. Note that buildings will return false, even Terran buildings
* which can move once lifted. */
bool canMove() const;
/** Returns true for flying/air units. */
bool isFlyer() const;
/** Returns true for units that regenerate health (i.e. zerg units). */
bool regeneratesHP() const;
/** Returns true if the unit type is capable of casting spells / using technology. */
bool isSpellcaster() const;
/** Returns true for the two units that are permanently cloaked - Protoss Observer and Protoss Dark
* Templar. */
bool hasPermanentCloak() const;
/** Returns true for units that cannot be destroyed (i.e. Terran Nuclear Missile, Mineral Field,
* Vespene Geyser, etc) */
bool isInvincible() const;
/** Returns true if the unit is organic, such as a Terran Marine. */
bool isOrganic() const;
/** Returns true if the unit is mechanical such as a Terran Vulture. */
bool isMechanical() const;
/** Returns true for the four robotic Protoss units - Probe, Shuttle, Reaver, and Observer. */
bool isRobotic() const;
/** 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. */
bool isDetector() const;
/** Returns true for the five units that hold resources - Mineral Field, Vespene Geyser,
* Terran Refinery, Zerg Extractor, and Protoss Assimilator. */
bool isResourceContainer() const;
/** Returns true for the five units that can accept resources - Terran Command Center, Protoss Nexus,
* Zerg Hatchery, Zerg Lair, and Zerg Hive. */
bool isResourceDepot() const;
/** Returns true for Terran Refinery, Zerg Extractor, and Protoss Assimilator. */
bool isRefinery() const;
/** Returns true for Protoss Probe, Terran SCV, and Zerg Drone. */
bool isWorker() const;
/** Returns true for buildings that must be near a pylon to be constructed. */
bool requiresPsi() const;
/** Returns true for buildings that can only be built on zerg creep. */
bool requiresCreep() const;
/** Returns true for Zergling and Scourge. */
bool isTwoUnitsInOneEgg() const;
/** Returns true for Zerg Lurker and units that can burrow when burrow tech is researched. */
bool isBurrowable() const;
/** 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). */
bool isCloakable() const;
/** Returns true if the unit is a building (also true for mineral field and vespene geyser). */
bool isBuilding() const;
/** Returns true if the unit is an add-on, such as a Terran Comsat Station. */
bool isAddon() const;
/** Returns true for Terran buildings that can lift off (i.e. Barracks). */
bool isFlyingBuilding() const;
/** Returns true if the unit is neutral, such as a critter or mineral field. */
bool isNeutral() const;
/** Returns true if the unit is a Hero unit. */
bool isHero() const;
/** Returns true if the unit is a Powerup unit. */
bool isPowerup() const;
/** Returns true if the unit is a regular Beacon. */
bool isBeacon() const;
/** Returns true if the unit is a flag Beacon. */
bool isFlagBeacon() const;
/** Returns true if the unit is a special building. */
bool isSpecialBuilding() const;
/** Returns true if the unit is a spell unit. */
bool isSpell() const;
/** Returns true if the unit produces larva. */
bool producesLarva() const;
/** Returns true if the unit is one of the three mineral field types. */
bool isMineralField() const;
/** Returns true if the unit is capable of constructing an addon.
This consists of Command Center, Factory, Starport, and Science Facility. */
bool canBuildAddon() const;
};
namespace UnitTypes
{
/** Given the name of a unit type, this function will return the unit type.
* For example, UnitTypes::getUnitType("Terran Marine") will return UnitTypes::Terran_Marine. */
UnitType getUnitType(std::string name);
int maxUnitWidth();
int maxUnitHeight();
/** Returns the set of all the UnitTypes. */
const std::set<UnitType>& allUnitTypes();
/** Returns the set of all the MacroTypes. */
const std::set<UnitType>& allMacroTypes();
void init();
extern const UnitType Terran_Marine;
extern const UnitType Hero_Jim_Raynor_Marine;
extern const UnitType Terran_Ghost;
extern const UnitType Hero_Sarah_Kerrigan;
extern const UnitType Hero_Samir_Duran;
extern const UnitType Hero_Infested_Duran;
extern const UnitType Hero_Alexei_Stukov;
extern const UnitType Terran_Vulture;
extern const UnitType Hero_Jim_Raynor_Vulture;
extern const UnitType Terran_Goliath;
extern const UnitType Hero_Alan_Schezar;
extern const UnitType Terran_Siege_Tank_Tank_Mode;
extern const UnitType Hero_Edmund_Duke_Tank_Mode;
extern const UnitType Terran_SCV;
extern const UnitType Terran_Wraith;
extern const UnitType Hero_Tom_Kazansky;
extern const UnitType Terran_Science_Vessel;
extern const UnitType Hero_Magellan;
extern const UnitType Terran_Dropship;
extern const UnitType Terran_Battlecruiser;
extern const UnitType Hero_Arcturus_Mengsk;
extern const UnitType Hero_Hyperion;
extern const UnitType Hero_Norad_II;
extern const UnitType Hero_Gerard_DuGalle;
extern const UnitType Terran_Vulture_Spider_Mine;
extern const UnitType Terran_Nuclear_Missile;
extern const UnitType Terran_Siege_Tank_Siege_Mode;
extern const UnitType Hero_Edmund_Duke_Siege_Mode;
extern const UnitType Terran_Firebat;
extern const UnitType Hero_Gui_Montag;
extern const UnitType Spell_Scanner_Sweep;
extern const UnitType Terran_Medic;
extern const UnitType Terran_Civilian;
extern const UnitType Zerg_Larva;
extern const UnitType Zerg_Egg;
extern const UnitType Zerg_Zergling;
extern const UnitType Hero_Devouring_One;
extern const UnitType Hero_Infested_Kerrigan;
extern const UnitType Zerg_Hydralisk;
extern const UnitType Hero_Hunter_Killer;
extern const UnitType Zerg_Ultralisk;
extern const UnitType Hero_Torrasque;
extern const UnitType Zerg_Broodling;
extern const UnitType Zerg_Drone;
extern const UnitType Zerg_Overlord;
extern const UnitType Hero_Yggdrasill;
extern const UnitType Zerg_Mutalisk;
extern const UnitType Hero_Kukulza_Mutalisk;
extern const UnitType Zerg_Guardian;
extern const UnitType Hero_Kukulza_Guardian;
extern const UnitType Zerg_Queen;
extern const UnitType Hero_Matriarch;
extern const UnitType Zerg_Defiler;
extern const UnitType Hero_Unclean_One;
extern const UnitType Zerg_Scourge;
extern const UnitType Zerg_Infested_Terran;
extern const UnitType Terran_Valkyrie;
extern const UnitType Zerg_Cocoon;
extern const UnitType Protoss_Corsair;
extern const UnitType Hero_Raszagal;
extern const UnitType Protoss_Dark_Templar;
extern const UnitType Hero_Dark_Templar;
extern const UnitType Hero_Zeratul;
extern const UnitType Zerg_Devourer;
extern const UnitType Protoss_Dark_Archon;
extern const UnitType Protoss_Probe;
extern const UnitType Protoss_Zealot;
extern const UnitType Hero_Fenix_Zealot;
extern const UnitType Protoss_Dragoon;
extern const UnitType Hero_Fenix_Dragoon;
extern const UnitType Protoss_High_Templar;
extern const UnitType Hero_Tassadar;
extern const UnitType Hero_Aldaris;
extern const UnitType Protoss_Archon;
extern const UnitType Hero_Tassadar_Zeratul_Archon;
extern const UnitType Protoss_Shuttle;
extern const UnitType Protoss_Scout;
extern const UnitType Hero_Mojo;
extern const UnitType Hero_Artanis;
extern const UnitType Protoss_Arbiter;
extern const UnitType Hero_Danimoth;
extern const UnitType Protoss_Carrier;
extern const UnitType Hero_Gantrithor;
extern const UnitType Protoss_Interceptor;
extern const UnitType Protoss_Reaver;
extern const UnitType Hero_Warbringer;
extern const UnitType Protoss_Observer;
extern const UnitType Protoss_Scarab;
extern const UnitType Critter_Rhynadon;
extern const UnitType Critter_Bengalaas;
extern const UnitType Special_Cargo_Ship;
extern const UnitType Special_Mercenary_Gunship;
extern const UnitType Critter_Scantid;
extern const UnitType Critter_Kakaru;
extern const UnitType Critter_Ragnasaur;
extern const UnitType Critter_Ursadon;
extern const UnitType Zerg_Lurker_Egg;
extern const UnitType Zerg_Lurker;
extern const UnitType Spell_Disruption_Web;
extern const UnitType Terran_Command_Center;
extern const UnitType Terran_Comsat_Station;
extern const UnitType Terran_Nuclear_Silo;
extern const UnitType Terran_Supply_Depot;
extern const UnitType Terran_Refinery;
extern const UnitType Terran_Barracks;
extern const UnitType Terran_Academy;
extern const UnitType Terran_Factory;
extern const UnitType Terran_Starport;
extern const UnitType Terran_Control_Tower;
extern const UnitType Terran_Science_Facility;
extern const UnitType Terran_Covert_Ops;
extern const UnitType Terran_Physics_Lab;
extern const UnitType Terran_Machine_Shop;
extern const UnitType Terran_Engineering_Bay;
extern const UnitType Terran_Armory;
extern const UnitType Terran_Missile_Turret;
extern const UnitType Terran_Bunker;
extern const UnitType Special_Crashed_Norad_II;
extern const UnitType Special_Ion_Cannon;
extern const UnitType Zerg_Infested_Command_Center;
extern const UnitType Zerg_Hatchery;
extern const UnitType Zerg_Lair;
extern const UnitType Zerg_Hive;
extern const UnitType Zerg_Nydus_Canal;
extern const UnitType Zerg_Hydralisk_Den;
extern const UnitType Zerg_Defiler_Mound;
extern const UnitType Zerg_Greater_Spire;
extern const UnitType Zerg_Queens_Nest;
extern const UnitType Zerg_Evolution_Chamber;
extern const UnitType Zerg_Ultralisk_Cavern;
extern const UnitType Zerg_Spire;
extern const UnitType Zerg_Spawning_Pool;
extern const UnitType Zerg_Creep_Colony;
extern const UnitType Zerg_Spore_Colony;
extern const UnitType Zerg_Sunken_Colony;
extern const UnitType Special_Overmind_With_Shell;
extern const UnitType Special_Overmind;
extern const UnitType Zerg_Extractor;
extern const UnitType Special_Mature_Chrysalis;
extern const UnitType Special_Cerebrate;
extern const UnitType Special_Cerebrate_Daggoth;
extern const UnitType Protoss_Nexus;
extern const UnitType Protoss_Robotics_Facility;
extern const UnitType Protoss_Pylon;
extern const UnitType Protoss_Assimilator;
extern const UnitType Protoss_Observatory;
extern const UnitType Protoss_Gateway;
extern const UnitType Protoss_Photon_Cannon;
extern const UnitType Protoss_Citadel_of_Adun;
extern const UnitType Protoss_Cybernetics_Core;
extern const UnitType Protoss_Templar_Archives;
extern const UnitType Protoss_Forge;
extern const UnitType Protoss_Stargate;
extern const UnitType Special_Stasis_Cell_Prison;
extern const UnitType Protoss_Fleet_Beacon;
extern const UnitType Protoss_Arbiter_Tribunal;
extern const UnitType Protoss_Robotics_Support_Bay;
extern const UnitType Protoss_Shield_Battery;
extern const UnitType Special_Khaydarin_Crystal_Form;
extern const UnitType Special_Protoss_Temple;
extern const UnitType Special_XelNaga_Temple;
extern const UnitType Resource_Mineral_Field;
extern const UnitType Resource_Mineral_Field_Type_2;
extern const UnitType Resource_Mineral_Field_Type_3;
extern const UnitType Special_Independant_Starport;
extern const UnitType Resource_Vespene_Geyser;
extern const UnitType Special_Warp_Gate;
extern const UnitType Special_Psi_Disrupter;
extern const UnitType Special_Power_Generator;
extern const UnitType Special_Overmind_Cocoon;
extern const UnitType Special_Zerg_Beacon;
extern const UnitType Special_Terran_Beacon;
extern const UnitType Special_Protoss_Beacon;
extern const UnitType Special_Zerg_Flag_Beacon;
extern const UnitType Special_Terran_Flag_Beacon;
extern const UnitType Special_Protoss_Flag_Beacon;
extern const UnitType Spell_Dark_Swarm;
extern const UnitType Powerup_Uraj_Crystal;
extern const UnitType Powerup_Khalis_Crystal;
extern const UnitType Powerup_Flag;
extern const UnitType Powerup_Young_Chrysalis;
extern const UnitType Powerup_Psi_Emitter;
extern const UnitType Powerup_Data_Disk;
extern const UnitType Powerup_Khaydarin_Crystal;
extern const UnitType Powerup_Mineral_Cluster_Type_1;
extern const UnitType Powerup_Mineral_Cluster_Type_2;
extern const UnitType Powerup_Protoss_Gas_Orb_Type_1;
extern const UnitType Powerup_Protoss_Gas_Orb_Type_2;
extern const UnitType Powerup_Zerg_Gas_Sac_Type_1;
extern const UnitType Powerup_Zerg_Gas_Sac_Type_2;
extern const UnitType Powerup_Terran_Gas_Tank_Type_1;
extern const UnitType Powerup_Terran_Gas_Tank_Type_2;
extern const UnitType Special_Map_Revealer;
extern const UnitType Special_Floor_Missile_Trap;
extern const UnitType Special_Floor_Hatch;
extern const UnitType Special_Upper_Level_Door;
extern const UnitType Special_Right_Upper_Level_Door;
extern const UnitType Special_Pit_Door;
extern const UnitType Special_Right_Pit_Door;
extern const UnitType Special_Floor_Gun_Trap;
extern const UnitType Special_Wall_Missile_Trap;
extern const UnitType Special_Wall_Flame_Trap;
extern const UnitType Special_Right_Wall_Missile_Trap;
extern const UnitType Special_Right_Wall_Flame_Trap;
extern const UnitType Special_Start_Location;
extern const UnitType None;
extern const UnitType AllUnits;
extern const UnitType Men;
extern const UnitType Buildings;
extern const UnitType Factories;
extern const UnitType Unknown;
}
}

114
bwapi-master/UpgradeType.h Normal file
View file

@ -0,0 +1,114 @@
#pragma once
#include <string>
#include <set>
#include <BWAPI/Race.h>
#include "Type.h"
namespace BWAPI
{
class UnitType;
class UpgradeType : public Type
{
public:
UpgradeType();
UpgradeType(int id);
/** Returns the name for the upgrade type. */
const std::string &getName() const;
const char *c_str() const;
/** 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 std::set<UnitType>& whatUses() const;
};
namespace UpgradeTypes
{
/** Given a string, this will return the upgrade type. */
UpgradeType getUpgradeType(std::string name);
/** Returns the set of all the UpgradeTypes. */
const std::set<UpgradeType>& allUpgradeTypes();
void init();
extern const UpgradeType Terran_Infantry_Armor;
extern const UpgradeType Terran_Vehicle_Plating;
extern const UpgradeType Terran_Ship_Plating;
extern const UpgradeType Zerg_Carapace;
extern const UpgradeType Zerg_Flyer_Carapace;
extern const UpgradeType Protoss_Ground_Armor;
extern const UpgradeType Protoss_Air_Armor;
extern const UpgradeType Terran_Infantry_Weapons;
extern const UpgradeType Terran_Vehicle_Weapons;
extern const UpgradeType Terran_Ship_Weapons;
extern const UpgradeType Zerg_Melee_Attacks;
extern const UpgradeType Zerg_Missile_Attacks;
extern const UpgradeType Zerg_Flyer_Attacks;
extern const UpgradeType Protoss_Ground_Weapons;
extern const UpgradeType Protoss_Air_Weapons;
extern const UpgradeType Protoss_Plasma_Shields;
extern const UpgradeType U_238_Shells;
extern const UpgradeType Ion_Thrusters;
extern const UpgradeType Titan_Reactor;
extern const UpgradeType Ocular_Implants;
extern const UpgradeType Moebius_Reactor;
extern const UpgradeType Apollo_Reactor;
extern const UpgradeType Colossus_Reactor;
extern const UpgradeType Ventral_Sacs;
extern const UpgradeType Antennae;
extern const UpgradeType Pneumatized_Carapace;
extern const UpgradeType Metabolic_Boost;
extern const UpgradeType Adrenal_Glands;
extern const UpgradeType Muscular_Augments;
extern const UpgradeType Grooved_Spines;
extern const UpgradeType Gamete_Meiosis;
extern const UpgradeType Metasynaptic_Node;
extern const UpgradeType Singularity_Charge;
extern const UpgradeType Leg_Enhancements;
extern const UpgradeType Scarab_Damage;
extern const UpgradeType Reaver_Capacity;
extern const UpgradeType Gravitic_Drive;
extern const UpgradeType Sensor_Array;
extern const UpgradeType Gravitic_Boosters;
extern const UpgradeType Khaydarin_Amulet;
extern const UpgradeType Apial_Sensors;
extern const UpgradeType Gravitic_Thrusters;
extern const UpgradeType Carrier_Capacity;
extern const UpgradeType Khaydarin_Core;
extern const UpgradeType Argus_Jewel;
extern const UpgradeType Argus_Talisman;
extern const UpgradeType Caduceus_Reactor;
extern const UpgradeType Chitinous_Plating;
extern const UpgradeType Anabolic_Synthesis;
extern const UpgradeType Charon_Boosters;
extern const UpgradeType None;
extern const UpgradeType Unknown;
}
}

199
bwapi-master/WeaponType.h Normal file
View file

@ -0,0 +1,199 @@
#pragma once
#include <string>
#include <set>
#include "Type.h"
namespace BWAPI
{
class TechType;
class UpgradeType;
class DamageType;
class ExplosionType;
class WeaponType : public Type
{
public:
WeaponType();
WeaponType(int id);
/** Returns the name of the weapon. */
const std::string &getName() const;
const char *c_str() const;
/** 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 WeaponTypes
{
/** Given the name of a weapon, this will return the corresponding weapon type object. */
WeaponType getWeaponType(std::string name);
/** Returns the set of all the WeaponTypes. */
const std::set<WeaponType>& allWeaponTypes();
/** Returns the set of all normal weapons in WeaponTypes. */
const std::set<WeaponType>& normalWeaponTypes();
/** Returns the set of all special weapons in WeaponTypes. */
const std::set<WeaponType>& specialWeaponTypes();
void init();
extern const WeaponType Gauss_Rifle;
extern const WeaponType Gauss_Rifle_Jim_Raynor;
extern const WeaponType C_10_Canister_Rifle;
extern const WeaponType C_10_Canister_Rifle_Sarah_Kerrigan;
extern const WeaponType C_10_Canister_Rifle_Samir_Duran;
extern const WeaponType C_10_Canister_Rifle_Infested_Duran;
extern const WeaponType C_10_Canister_Rifle_Alexei_Stukov;
extern const WeaponType Fragmentation_Grenade;
extern const WeaponType Fragmentation_Grenade_Jim_Raynor;
extern const WeaponType Spider_Mines;
extern const WeaponType Twin_Autocannons;
extern const WeaponType Twin_Autocannons_Alan_Schezar;
extern const WeaponType Hellfire_Missile_Pack;
extern const WeaponType Hellfire_Missile_Pack_Alan_Schezar;
extern const WeaponType Arclite_Cannon;
extern const WeaponType Arclite_Cannon_Edmund_Duke;
extern const WeaponType Fusion_Cutter;
extern const WeaponType Gemini_Missiles;
extern const WeaponType Gemini_Missiles_Tom_Kazansky;
extern const WeaponType Burst_Lasers;
extern const WeaponType Burst_Lasers_Tom_Kazansky;
extern const WeaponType ATS_Laser_Battery;
extern const WeaponType ATS_Laser_Battery_Hero;
extern const WeaponType ATS_Laser_Battery_Hyperion;
extern const WeaponType ATA_Laser_Battery;
extern const WeaponType ATA_Laser_Battery_Hero;
extern const WeaponType ATA_Laser_Battery_Hyperion;
extern const WeaponType Flame_Thrower;
extern const WeaponType Flame_Thrower_Gui_Montag;
extern const WeaponType Arclite_Shock_Cannon;
extern const WeaponType Arclite_Shock_Cannon_Edmund_Duke;
extern const WeaponType Longbolt_Missile;
extern const WeaponType Claws;
extern const WeaponType Claws_Devouring_One;
extern const WeaponType Claws_Infested_Kerrigan;
extern const WeaponType Needle_Spines;
extern const WeaponType Needle_Spines_Hunter_Killer;
extern const WeaponType Kaiser_Blades;
extern const WeaponType Kaiser_Blades_Torrasque;
extern const WeaponType Toxic_Spores;
extern const WeaponType Spines;
extern const WeaponType Acid_Spore;
extern const WeaponType Acid_Spore_Kukulza;
extern const WeaponType Glave_Wurm;
extern const WeaponType Glave_Wurm_Kukulza;
extern const WeaponType Seeker_Spores;
extern const WeaponType Subterranean_Tentacle;
extern const WeaponType Suicide_Infested_Terran;
extern const WeaponType Suicide_Scourge;
extern const WeaponType Particle_Beam;
extern const WeaponType Psi_Blades;
extern const WeaponType Psi_Blades_Fenix;
extern const WeaponType Phase_Disruptor;
extern const WeaponType Phase_Disruptor_Fenix;
extern const WeaponType Psi_Assault;
extern const WeaponType Psionic_Shockwave;
extern const WeaponType Psionic_Shockwave_TZ_Archon;
extern const WeaponType Dual_Photon_Blasters;
extern const WeaponType Dual_Photon_Blasters_Mojo;
extern const WeaponType Dual_Photon_Blasters_Artanis;
extern const WeaponType Anti_Matter_Missiles;
extern const WeaponType Anti_Matter_Missiles_Mojo;
extern const WeaponType Anti_Matter_Missiles_Artanis;
extern const WeaponType Phase_Disruptor_Cannon;
extern const WeaponType Phase_Disruptor_Cannon_Danimoth;
extern const WeaponType Pulse_Cannon;
extern const WeaponType STS_Photon_Cannon;
extern const WeaponType STA_Photon_Cannon;
extern const WeaponType Scarab;
extern const WeaponType Neutron_Flare;
extern const WeaponType Halo_Rockets;
extern const WeaponType Corrosive_Acid;
extern const WeaponType Subterranean_Spines;
extern const WeaponType Warp_Blades;
extern const WeaponType Warp_Blades_Hero;
extern const WeaponType Warp_Blades_Zeratul;
extern const WeaponType Independant_Laser_Battery;
extern const WeaponType Twin_Autocannons_Floor_Trap;
extern const WeaponType Hellfire_Missile_Pack_Wall_Trap;
extern const WeaponType Flame_Thrower_Wall_Trap;
extern const WeaponType Hellfire_Missile_Pack_Floor_Trap;
extern const WeaponType Yamato_Gun;
extern const WeaponType Nuclear_Strike;
extern const WeaponType Lockdown;
extern const WeaponType EMP_Shockwave;
extern const WeaponType Irradiate;
extern const WeaponType Parasite;
extern const WeaponType Spawn_Broodlings;
extern const WeaponType Ensnare;
extern const WeaponType Dark_Swarm;
extern const WeaponType Plague;
extern const WeaponType Consume;
extern const WeaponType Stasis_Field;
extern const WeaponType Psionic_Storm;
extern const WeaponType Disruption_Web;
extern const WeaponType Restoration;
extern const WeaponType Mind_Control;
extern const WeaponType Feedback;
extern const WeaponType Optical_Flare;
extern const WeaponType Maelstrom;
extern const WeaponType None;
extern const WeaponType Unknown;
}
}

130
bwapi/AIModule.java Normal file
View file

@ -0,0 +1,130 @@
package bwapi;
import bwapi.BWEventListener;
/**
* This class receives all events from Broodwar.
* To process them, receive an AIModule's instance from {@link bwapi.Mirror} and call {@link #setEventListener(BWEventListener)}
* to set you own {@link bwapi.BWEventListener listener}.
* There's also a stub class ({@link bwapi.DefaultBWListener}) provided, so you don't have to implement all of the methods.
*/
public class AIModule {
AIModule(){}
private BWEventListener eventListener;
public void setEventListener(BWEventListener eventListener) {
this.eventListener = eventListener;
}
public void onStart() {
if (eventListener != null) {
eventListener.onStart();
}
}
public void onEnd(boolean isWinner) {
if (eventListener != null) {
eventListener.onEnd(isWinner);
}
}
public void onFrame() {
if (eventListener != null) {
eventListener.onFrame();
}
}
public void onSendText(String text) {
if (eventListener != null)
{
eventListener.onSendText(text);
}
}
public void onReceiveText(Player player, String text) {
if (eventListener != null) {
eventListener.onReceiveText(player, text);
}
}
public void onPlayerLeft(Player player) {
if (eventListener != null) {
eventListener.onPlayerLeft(player);
}
}
public void onNukeDetect(Position target) {
if (eventListener != null) {
eventListener.onNukeDetect(target);
}
}
public void onUnitDiscover(Unit unit) {
if (eventListener != null) {
eventListener.onUnitDiscover(unit);
}
}
public void onUnitEvade(Unit unit) {
if (eventListener != null) {
eventListener.onUnitEvade(unit);
}
}
public void onUnitShow(Unit unit) {
if (eventListener != null) {
eventListener.onUnitShow(unit);
}
}
public void onUnitHide(Unit unit) {
if (eventListener != null) {
eventListener.onUnitHide(unit);
}
}
public void onUnitCreate(Unit unit) {
if (eventListener != null) {
eventListener.onUnitCreate(unit);
}
}
public void onUnitDestroy(Unit unit) {
if (eventListener != null) {
eventListener.onUnitDestroy(unit);
}
}
public void onUnitMorph(Unit unit) {
if (eventListener != null) {
eventListener.onUnitMorph(unit);
}
}
public void onUnitRenegade(Unit unit) {
if (eventListener != null) {
eventListener.onUnitRenegade(unit);
}
}
public void onSaveGame(String gameName) {
if (eventListener != null) {
eventListener.onSaveGame(gameName);
}
}
public void onUnitComplete(Unit unit) {
if (eventListener != null) {
eventListener.onUnitComplete(unit);
}
}
public void onPlayerDropped(Player player) {
if (eventListener != null) {
eventListener.onPlayerDropped(player);
}
}
}

View file

@ -0,0 +1,53 @@
package bwapi;
import bwapi.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
/**
* Implement this interface and call {@link bwapi.AIModule#setEventListener(bwapi.BWEventListener)} to receive all of the in game events.
*/
public interface BWEventListener {
public void onStart();
public void onEnd(boolean isWinner);
public void onFrame();
public void onSendText(String text);
public void onReceiveText(Player player, String text);
public void onPlayerLeft(Player player);
public void onNukeDetect(Position target);
public void onUnitDiscover(Unit unit);
public void onUnitEvade(Unit unit);
public void onUnitShow(Unit unit);
public void onUnitHide(Unit unit);
public void onUnitCreate(Unit unit);
public void onUnitDestroy(Unit unit);
public void onUnitMorph(Unit unit);
public void onUnitRenegade(Unit unit);
public void onSaveGame(String gameName);
public void onUnitComplete(Unit unit);
public void onPlayerDropped(Player player);
}

183
bwapi/Bullet.java Normal file
View file

@ -0,0 +1,183 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
private static Map<Long, Bullet> instances = new HashMap<Long, Bullet>();
private Bullet(long pointer) {
this.pointer = pointer;
}
private static Bullet get(long pointer) {
Bullet instance = instances.get(pointer);
if (instance == null ) {
instance = new Bullet(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native int getID_native(long pointer);
private native Player getPlayer_native(long pointer);
private native BulletType getType_native(long pointer);
private native Unit getSource_native(long pointer);
private native Position getPosition_native(long pointer);
private native double getAngle_native(long pointer);
private native double getVelocityX_native(long pointer);
private native double getVelocityY_native(long pointer);
private native Unit getTarget_native(long pointer);
private native Position getTargetPosition_native(long pointer);
private native int getRemoveTimer_native(long pointer);
private native boolean exists_native(long pointer);
private native boolean isVisible_native(long pointer);
private native boolean isVisible_native(long pointer, Player player);
}

121
bwapi/BulletType.java Normal file
View file

@ -0,0 +1,121 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
public String toString(){
return c_str();
}
public static BulletType Melee;
public static BulletType Fusion_Cutter_Hit;
public static BulletType Gauss_Rifle_Hit;
public static BulletType C_10_Canister_Rifle_Hit;
public static BulletType Gemini_Missiles;
public static BulletType Fragmentation_Grenade;
public static BulletType Longbolt_Missile;
public static BulletType ATS_ATA_Laser_Battery;
public static BulletType Burst_Lasers;
public static BulletType Arclite_Shock_Cannon_Hit;
public static BulletType EMP_Missile;
public static BulletType Dual_Photon_Blasters_Hit;
public static BulletType Particle_Beam_Hit;
public static BulletType Anti_Matter_Missile;
public static BulletType Pulse_Cannon;
public static BulletType Psionic_Shockwave_Hit;
public static BulletType Psionic_Storm;
public static BulletType Yamato_Gun;
public static BulletType Phase_Disruptor;
public static BulletType STA_STS_Cannon_Overlay;
public static BulletType Sunken_Colony_Tentacle;
public static BulletType Acid_Spore;
public static BulletType Glave_Wurm;
public static BulletType Seeker_Spores;
public static BulletType Queen_Spell_Carrier;
public static BulletType Plague_Cloud;
public static BulletType Consume;
public static BulletType Ensnare;
public static BulletType Needle_Spine_Hit;
public static BulletType Invisible;
public static BulletType Optical_Flare_Grenade;
public static BulletType Halo_Rockets;
public static BulletType Subterranean_Spines;
public static BulletType Corrosive_Acid_Shot;
public static BulletType Neutron_Flare;
public static BulletType None;
public static BulletType Unknown;
private static Map<Long, BulletType> instances = new HashMap<Long, BulletType>();
private BulletType(long pointer) {
this.pointer = pointer;
}
private static BulletType get(long pointer) {
BulletType instance = instances.get(pointer);
if (instance == null ) {
instance = new BulletType(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native String c_str_native(long pointer);
}

78
bwapi/Client.java Normal file
View file

@ -0,0 +1,78 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
private static Map<Long, Client> instances = new HashMap<Long, Client>();
private Client(long pointer) {
this.pointer = pointer;
}
private static Client get(long pointer) {
Client instance = instances.get(pointer);
if (instance == null ) {
instance = new Client(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native boolean isConnected_native(long pointer);
private native boolean connect_native(long pointer);
private native void disconnect_native(long pointer);
private native void update_native(long pointer);
}

73
bwapi/Color.java Normal file
View file

@ -0,0 +1,73 @@
package bwapi;
import java.lang.Override;
import java.util.HashMap;
import java.util.Map;
/**
* Starcraft uses a 256 color palette to render everything,
* so the colors available for draw shapes using BWAPI is limited to the colors available in the <a href="http://bwapi.googlecode.com/svn/wiki/colorPalette.gif" target="_blank">Pallete</a>.
* Several predefined colors from the pallete are provided.
*/
public class Color {
private int r, g, b;
/**
* Create a color using the color in the palette that is closest to the RGB color specified. This will check a number of colors in the pallet to see which is closest to the specified color so this function is relatively slow.
* @param r
* @param g
* @param b
*/
public Color(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
}
public static Color Red;
public static Color Blue;
public static Color Teal;
public static Color Purple;
public static Color Orange;
public static Color Brown;
public static Color White;
public static Color Yellow;
public static Color Green;
public static Color Cyan;
public static Color Black;
public static Color Grey;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Color)) return false;
Color color = (Color) o;
if (b != color.b) return false;
if (g != color.g) return false;
if (r != color.r) return false;
return true;
}
@Override
public int hashCode() {
int result = r;
result = 31 * result + g;
result = 31 * result + b;
return result;
}
}

View file

@ -0,0 +1,47 @@
package bwapi.CommandType;
import bwapi.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
/**<br/><br/>
* Used in UnitCommand
*/
public enum Enum {
None(0),
SetScreenPosition(1),
PingMinimap(2),
EnableFlag(3),
Printf(4),
SendText(5),
ChangeRace(6),
StartGame(7),
PauseGame(8),
ResumeGame(9),
LeaveGame(10),
RestartGame(11),
SetLocalSpeed(12),
SetLatCom(13),
SetGui(14),
SetFrameSkip(15),
SetMap(16),
SetAllies(17),
SetVision(18),
SetCommandOptimizerLevel(19),
SetReplayVision(20);
private int value;
public int getValue(){
return value;
}
Enum(int value){
this.value = value;
}
}

View file

@ -0,0 +1,26 @@
package bwapi.CoordinateType;
import bwapi.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
public enum Enum {
Screen(1),
Map(2),
Mouse(3);
private int value;
public int getValue(){
return value;
}
Enum(int value){
this.value = value;
}
}

62
bwapi/DamageType.java Normal file
View file

@ -0,0 +1,62 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
public String toString(){
return c_str();
}
public static DamageType Independent;
public static DamageType Explosive;
public static DamageType Concussive;
public static DamageType Normal;
public static DamageType Ignore_Armor;
public static DamageType None;
public static DamageType Unknown;
private static Map<Long, DamageType> instances = new HashMap<Long, DamageType>();
private DamageType(long pointer) {
this.pointer = pointer;
}
private static DamageType get(long pointer) {
DamageType instance = instances.get(pointer);
if (instance == null ) {
instance = new DamageType(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native String c_str_native(long pointer);
}

View file

@ -0,0 +1,103 @@
package bwapi;
import bwapi.BWEventListener;
import bwapi.Player;
import bwapi.Position;
import bwapi.Unit;
/**
* A utility stub class providing a default implementation of {@link bwapi.BWEventListener},
* override it's methods if you want to handle only some events.
*/
public class DefaultBWListener implements BWEventListener {
@Override
public void onStart() {
}
@Override
public void onEnd(boolean b) {
}
@Override
public void onFrame() {
}
@Override
public void onSendText(String s) {
}
@Override
public void onReceiveText(Player player, String s) {
}
@Override
public void onPlayerLeft(Player player) {
}
@Override
public void onNukeDetect(Position position) {
}
@Override
public void onUnitDiscover(Unit unit) {
}
@Override
public void onUnitEvade(Unit unit) {
}
@Override
public void onUnitShow(Unit unit) {
}
@Override
public void onUnitHide(Unit unit) {
}
@Override
public void onUnitCreate(Unit unit) {
}
@Override
public void onUnitDestroy(Unit unit) {
}
@Override
public void onUnitMorph(Unit unit) {
}
@Override
public void onUnitRenegade(Unit unit) {
}
@Override
public void onSaveGame(String s) {
}
@Override
public void onUnitComplete(Unit unit) {
}
@Override
public void onPlayerDropped(Player player) {
}
}

100
bwapi/Error.java Normal file
View file

@ -0,0 +1,100 @@
package bwapi;
import java.util.HashMap;
import java.util.Map;
/**
* Functions in BWAPI may set an error code. To retrieve the error code, call Game::getLastError.
*/
public class Error {
private int id;
private Error(int id) {
this.id = id;
}
public static Error Unit_Does_Not_Exist;
public static Error Unit_Not_Visible;
public static Error Unit_Not_Owned;
public static Error Unit_Busy;
public static Error Incompatible_UnitType;
public static Error Incompatible_TechType;
public static Error Incompatible_State;
public static Error Already_Researched;
public static Error Fully_Upgraded;
public static Error Currently_Researching;
public static Error Currently_Upgrading;
public static Error Insufficient_Minerals;
public static Error Insufficient_Gas;
public static Error Insufficient_Supply;
public static Error Insufficient_Energy;
public static Error Insufficient_Tech;
public static Error Insufficient_Ammo;
public static Error Insufficient_Space;
public static Error Invalid_Tile_Position;
public static Error Unbuildable_Location;
public static Error Unreachable_Location;
public static Error Out_Of_Range;
public static Error Unable_To_Hit;
public static Error Access_Denied;
public static Error File_Not_Found;
public static Error Invalid_Parameter;
public static Error None;
public static Error Unknown;
private static Map<Long, Error> instances = new HashMap<Long, Error>();
private Error(long pointer) {
this.pointer = pointer;
}
private static Error get(long pointer) {
Error instance = instances.get(pointer);
if (instance == null) {
instance = new Error(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
public String c_str() {
return c_str_native(pointer);
}
public String toString(){
return c_str();
}
private native String c_str_native(long pointer);
}

86
bwapi/Event.java Normal file
View file

@ -0,0 +1,86 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
private static Map<Long, Event> instances = new HashMap<Long, Event>();
private Event(long pointer) {
this.pointer = pointer;
}
private static Event get(long pointer) {
Event instance = instances.get(pointer);
if (instance == null ) {
instance = new Event(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native Position getPosition_native(long pointer);
private native String getText_native(long pointer);
private native Unit getUnit_native(long pointer);
private native Player getPlayer_native(long pointer);
private native boolean isWinner_native(long pointer);
}

42
bwapi/EventType/Enum.java Normal file
View file

@ -0,0 +1,42 @@
package bwapi.EventType;
import bwapi.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
public enum Enum {
MatchStart(0),
MatchEnd(1),
MatchFrame(2),
MenuFrame(3),
SendText(4),
ReceiveText(5),
PlayerLeft(6),
NukeDetect(7),
UnitDiscover(8),
UnitEvade(9),
UnitShow(10),
UnitHide(11),
UnitCreate(12),
UnitDestroy(13),
UnitMorph(14),
UnitRenegade(15),
SaveGame(16),
UnitComplete(17),
PlayerDropped(18);
private int value;
public int getValue(){
return value;
}
Enum(int value){
this.value = value;
}
}

97
bwapi/ExplosionType.java Normal file
View file

@ -0,0 +1,97 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
public String toString(){
return c_str();
}
public static ExplosionType None;
public static ExplosionType Normal;
public static ExplosionType Radial_Splash;
public static ExplosionType Enemy_Splash;
public static ExplosionType Lockdown;
public static ExplosionType Nuclear_Missile;
public static ExplosionType Parasite;
public static ExplosionType Broodlings;
public static ExplosionType EMP_Shockwave;
public static ExplosionType Irradiate;
public static ExplosionType Ensnare;
public static ExplosionType Plague;
public static ExplosionType Stasis_Field;
public static ExplosionType Dark_Swarm;
public static ExplosionType Consume;
public static ExplosionType Yamato_Gun;
public static ExplosionType Restoration;
public static ExplosionType Disruption_Web;
public static ExplosionType Corrosive_Acid;
public static ExplosionType Mind_Control;
public static ExplosionType Feedback;
public static ExplosionType Optical_Flare;
public static ExplosionType Maelstrom;
public static ExplosionType Air_Splash;
public static ExplosionType Unknown;
private static Map<Long, ExplosionType> instances = new HashMap<Long, ExplosionType>();
private ExplosionType(long pointer) {
this.pointer = pointer;
}
private static ExplosionType get(long pointer) {
ExplosionType instance = instances.get(pointer);
if (instance == null ) {
instance = new ExplosionType(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native String c_str_native(long pointer);
}

25
bwapi/Flag/Enum.java Normal file
View file

@ -0,0 +1,25 @@
package bwapi.Flag;
import bwapi.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
public enum Enum {
CompleteMapInformation(0),
UserInput(1);
private int value;
public int getValue(){
return value;
}
Enum(int value){
this.value = value;
}
}

54
bwapi/Force.java Normal file
View file

@ -0,0 +1,54 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
private static Map<Long, Force> instances = new HashMap<Long, Force>();
private Force(long pointer) {
this.pointer = pointer;
}
private static Force get(long pointer) {
Force instance = instances.get(pointer);
if (instance == null ) {
instance = new Force(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native int getID_native(long pointer);
private native String getName_native(long pointer);
private native List<Player> getPlayers_native(long pointer);
}

1267
bwapi/Game.java Normal file

File diff suppressed because it is too large Load diff

80
bwapi/GameType.java Normal file
View file

@ -0,0 +1,80 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
public String toString(){
return c_str();
}
public static GameType Melee;
public static GameType Free_For_All;
public static GameType One_on_One;
public static GameType Capture_The_Flag;
public static GameType Greed;
public static GameType Slaughter;
public static GameType Sudden_Death;
public static GameType Ladder;
public static GameType Use_Map_Settings;
public static GameType Team_Melee;
public static GameType Team_Free_For_All;
public static GameType Team_Capture_The_Flag;
public static GameType Top_vs_Bottom;
public static GameType Pro_Gamer_League;
public static GameType None;
public static GameType Unknown;
private static Map<Long, GameType> instances = new HashMap<Long, GameType>();
private GameType(long pointer) {
this.pointer = pointer;
}
private static GameType get(long pointer) {
GameType instance = instances.get(pointer);
if (instance == null ) {
instance = new GameType(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native String c_str_native(long pointer);
}

219
bwapi/Key.java Normal file
View file

@ -0,0 +1,219 @@
package bwapi;
import bwapi.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
public enum Key {
K_LBUTTON(1),
K_RBUTTON(2),
K_CANCEL(3),
K_MBUTTON(4),
K_XBUTTON1(5),
K_XBUTTON2(6),
K_BACK(8),
K_TAB(9),
K_CLEAR(12),
K_RETURN(13),
K_SHIFT(16),
K_CONTROL(17),
K_MENU(18),
K_PAUSE(19),
K_CAPITAL(20),
K_KANA(21),
K_HANGEUL(21),
K_HANGUL(21),
K_JUNJA(23),
K_FINAL(24),
K_HANJA(25),
K_KANJI(25),
K_ESCAPE(27),
K_CONVERT(28),
K_NONCONVERT(29),
K_ACCEPT(30),
K_MODECHANGE(31),
K_SPACE(32),
K_PRIOR(33),
K_NEXT(34),
K_END(35),
K_HOME(36),
K_LEFT(37),
K_UP(38),
K_RIGHT(39),
K_DOWN(40),
K_SELECT(41),
K_PRINT(42),
K_EXECUTE(43),
K_SNAPSHOT(44),
K_INSERT(45),
K_DELETE(46),
K_HELP(47),
K_0(48),
K_1(49),
K_2(50),
K_3(51),
K_4(52),
K_5(53),
K_6(54),
K_7(55),
K_8(56),
K_9(57),
K_A(65),
K_B(66),
K_C(67),
K_D(68),
K_E(69),
K_F(70),
K_G(71),
K_H(72),
K_I(73),
K_J(74),
K_K(75),
K_L(76),
K_M(77),
K_N(78),
K_O(79),
K_P(80),
K_Q(81),
K_R(82),
K_S(83),
K_T(84),
K_U(85),
K_V(86),
K_W(87),
K_X(88),
K_Y(89),
K_Z(90),
K_LWIN(91),
K_RWIN(92),
K_APPS(93),
K_SLEEP(95),
K_NUMPAD0(96),
K_NUMPAD1(97),
K_NUMPAD2(98),
K_NUMPAD3(99),
K_NUMPAD4(100),
K_NUMPAD5(101),
K_NUMPAD6(102),
K_NUMPAD7(103),
K_NUMPAD8(104),
K_NUMPAD9(105),
K_MULTIPLY(106),
K_ADD(107),
K_SEPARATOR(108),
K_SUBTRACT(109),
K_DECIMAL(110),
K_DIVIDE(111),
K_F1(112),
K_F2(113),
K_F3(114),
K_F4(115),
K_F5(116),
K_F6(117),
K_F7(118),
K_F8(119),
K_F9(120),
K_F10(121),
K_F11(122),
K_F12(123),
K_F13(124),
K_F14(125),
K_F15(126),
K_F16(127),
K_F17(128),
K_F18(129),
K_F19(130),
K_F20(131),
K_F21(132),
K_F22(133),
K_F23(134),
K_F24(135),
K_NUMLOCK(144),
K_SCROLL(145),
K_OEM_NEC_EQUAL(146),
K_OEM_FJ_JISHO(146),
K_OEM_FJ_MASSHOU(147),
K_OEM_FJ_TOUROKU(148),
K_OEM_FJ_LOYA(149),
K_OEM_FJ_ROYA(150),
K_LSHIFT(160),
K_RSHIFT(161),
K_LCONTROL(162),
K_RCONTROL(163),
K_LMENU(164),
K_RMENU(165),
K_BROWSER_BACK(166),
K_BROWSER_FORWARD(167),
K_BROWSER_REFRESH(168),
K_BROWSER_STOP(169),
K_BROWSER_SEARCH(170),
K_BROWSER_FAVORITES(171),
K_BROWSER_HOME(172),
K_VOLUME_MUTE(173),
K_VOLUME_DOWN(174),
K_VOLUME_UP(175),
K_MEDIA_NEXT_TRACK(176),
K_MEDIA_PREV_TRACK(177),
K_MEDIA_STOP(178),
K_MEDIA_PLAY_PAUSE(179),
K_LAUNCH_MAIL(180),
K_LAUNCH_MEDIA_SELECT(181),
K_LAUNCH_APP1(182),
K_LAUNCH_APP2(183),
K_OEM_1(186),
K_OEM_PLUS(187),
K_OEM_COMMA(188),
K_OEM_MINUS(189),
K_OEM_PERIOD(190),
K_OEM_2(191),
K_OEM_3(192),
K_OEM_4(219),
K_OEM_5(220),
K_OEM_6(221),
K_OEM_7(222),
K_OEM_8(223),
K_OEM_AX(225),
K_OEM_102(226),
K_ICO_HELP(227),
K_ICO_00(228),
K_PROCESSKEY(229),
K_ICO_CLEAR(230),
K_PACKET(231),
K_OEM_RESET(233),
K_OEM_JUMP(234),
K_OEM_PA1(235),
K_OEM_PA2(236),
K_OEM_PA3(237),
K_OEM_WSCTRL(238),
K_OEM_CUSEL(239),
K_OEM_ATTN(240),
K_OEM_FINISH(241),
K_OEM_COPY(242),
K_OEM_AUTO(243),
K_OEM_ENLW(244),
K_OEM_BACKTAB(245),
K_ATTN(246),
K_CRSEL(247),
K_EXSEL(248),
K_EREOF(249),
K_PLAY(250),
K_ZOOM(251),
K_NONAME(252),
K_PA1(253),
K_OEM_CLEAR(254);
private int value;
public int getValue(){
return value;
}
Key(int value){
this.value = value;
}
}

29
bwapi/Latency/Enum.java Normal file
View file

@ -0,0 +1,29 @@
package bwapi.Latency;
import bwapi.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
public enum Enum {
SinglePlayer(2),
LanLow(5),
LanMedium(7),
LanHigh(9),
BattlenetLow(14),
BattlenetMedium(19);
private int value;
public int getValue(){
return value;
}
Enum(int value){
this.value = value;
}
}

262
bwapi/Mirror.java Normal file
View file

@ -0,0 +1,262 @@
package bwapi;
import bwapi.AIModule;
import bwapi.BWEventListener;
import java.io.*;
import java.io.File;
import java.lang.Exception;
import java.lang.UnsupportedOperationException;
import java.util.*;
import java.util.zip.*;
/**
* <p>The API entry point. Standard use case:</p>
* <ul>
* <li>Create a Mirror object and use {@link #getModule()} and then set an {@link bwapi.AIModule}'s {@link bwapi.BWEventListener}<br/>
* <li>Call {@link #startGame()} to init the API and connect to Broodwar, then launch Broodwar from ChaosLauncher.</li>
* <li>In you {@link bwapi.BWEventListener#onStart()} method, receive the Game object by calling {@link #getGame()}</li>
* </ul>
* <br/>
* <b>Example</b>
* <pre>
* {@code
*
* mirror.getModule().setEventListener(new DefaultBWListener()
* {
* public void onStart() {
* game = mirror.getGame();
* self = game.self();
* //initialization
* ....
* }
*
* public void onUpdate() {
* for (Unit myUnit : self.getUnits()) {
* //give orders to unit
* ...
* }
* }
* });
* }
* mirror.startGame();
* </pre>
* <p><b>Note:</b> The Game object is initialized during the {@link #startGame()} as well as other BWMirror API's constants.
* Do not use any API releated methods/fields prior to {@link #startGame()}.</p>
*/
public class Mirror {
private Game game;
private AIModule module = new AIModule();
private FrameCallback frameCallback;
private static final boolean EXTRACT_JAR = true;
private static final String VERSION = "1_0";
static {
String arch = System.getProperty("os.arch");
String dllNames[] = {"bwapi_bridge", "gmp-vc90-mt", "mpfr-vc90-mt"};
if(!arch.equals("x86")){
throw new UnsupportedOperationException("BWMirror API supports only x86 architecture.");
}
try {
if (EXTRACT_JAR) {
System.setProperty("java.library.path", ".");
java.lang.reflect.Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
fieldSysPath.setAccessible(true);
fieldSysPath.set(null, null);
String path = Mirror.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = java.net.URLDecoder.decode(path, "UTF-8");
for (String dllName : dllNames) {
String dllNameExt = dllName + ".dll";
if (!new File(dllNameExt).exists()) {
JarResources jar = new JarResources(path);
byte[] correctDllData = jar.getResource(dllNameExt);
FileOutputStream funnyStream = new FileOutputStream(dllNameExt);
funnyStream.write(correctDllData);
funnyStream.close();
}
}
}
} catch (Exception e) {
System.err.println("Failed to extract native libraries.\n" + e);
}
System.loadLibrary(dllNames[0]);
File dataDir = new File("bwapi-data/BWTA");
if(!dataDir.exists()){
try {
dataDir.mkdirs();
} catch (Exception e) {
System.err.println("Unable to create /bwapi-data/BWTA folder, BWTA analysis will not be saved.");
}
}
}
public Game getGame() {
return game;
}
public AIModule getModule() {
return module;
}
/**
* Starts the API, initializes all constants ( {@link bwapi.UnitType}, {@link bwapi.WeaponType} ) and the {@link bwapi.Game} object.
* This method blocks until the end of game.
*/
public native void startGame();
private void update() {
if (frameCallback != null) {
frameCallback.update();
}
}
/*public void setFrameCallback(bwapi.Mirror.FrameCallback frameCallback) {
this.frameCallback = frameCallback;
} */
/**
* The simplest interface to receive update event from Broodwar. The {@link #update()} method is called once each frame.
* For a simple bot and implementation of this interface is enough, to receive all in game events, implement {@link bwapi.BWEventListener}.
*/
/*public*/ private interface FrameCallback {
public void update();
}
@SuppressWarnings({"unchecked"})
private static class JarResources {
// external debug flag
public boolean debugOn = false;
// jar resource mapping tables
private Hashtable htSizes = new Hashtable();
private Hashtable htJarContents = new Hashtable();
// a jar file
private String jarFileName;
/**
* creates a javabot.JarResources. It extracts all resources from a Jar
* into an internal hashtable, keyed by resource names.
*
* @param jarFileName a jar or zip file
*/
public JarResources(String jarFileName) {
this.jarFileName = jarFileName;
init();
}
/**
* Extracts a jar resource as a blob.
*
* @param name a resource name.
*/
public byte[] getResource(String name) {
return (byte[]) htJarContents.get(name);
}
/**
* initializes internal hash tables with Jar file resources.
*/
private void init() {
try {
// extracts just sizes only.
ZipFile zf = new ZipFile(jarFileName);
Enumeration e = zf.entries();
while (e.hasMoreElements()) {
ZipEntry ze = (ZipEntry) e.nextElement();
if (debugOn) {
System.out.println(dumpZipEntry(ze));
}
htSizes.put(ze.getName(), new Integer((int) ze.getSize()));
}
zf.close();
// extract resources and put them into the hashtable.
FileInputStream fis = new FileInputStream(jarFileName);
BufferedInputStream bis = new BufferedInputStream(fis);
ZipInputStream zis = new ZipInputStream(bis);
ZipEntry ze = null;
while ((ze = zis.getNextEntry()) != null) {
if (ze.isDirectory()) {
continue;
}
if (debugOn) {
System.out.println(
"ze.getName()=" + ze.getName() + "," + "getSize()=" + ze.getSize()
);
}
int size = (int) ze.getSize();
// -1 means unknown size.
if (size == -1) {
size = ((Integer) htSizes.get(ze.getName())).intValue();
}
byte[] b = new byte[(int) size];
int rb = 0;
int chunk = 0;
while (((int) size - rb) > 0) {
chunk = zis.read(b, rb, (int) size - rb);
if (chunk == -1) {
break;
}
rb += chunk;
}
// add to internal resource hashtable
htJarContents.put(ze.getName(), b);
if (debugOn) {
System.out.println(
ze.getName() + " rb=" + rb +
",size=" + size +
",csize=" + ze.getCompressedSize()
);
}
}
} catch (NullPointerException e) {
System.out.println("done.");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Dumps a zip entry into a string.
*
* @param ze a ZipEntry
*/
private String dumpZipEntry(ZipEntry ze) {
StringBuffer sb = new StringBuffer();
if (ze.isDirectory()) {
sb.append("d ");
} else {
sb.append("f ");
}
if (ze.getMethod() == ZipEntry.STORED) {
sb.append("stored ");
} else {
sb.append("defalted ");
}
sb.append(ze.getName());
sb.append("\t");
sb.append("" + ze.getSize());
if (ze.getMethod() == ZipEntry.DEFLATED) {
sb.append("/" + ze.getCompressedSize());
}
return (sb.toString());
}
}
}

26
bwapi/MouseButton.java Normal file
View file

@ -0,0 +1,26 @@
package bwapi;
import bwapi.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
public enum MouseButton {
M_LEFT(0),
M_RIGHT(1),
M_MIDDLE(2);
private int value;
public int getValue(){
return value;
}
MouseButton(int value){
this.value = value;
}
}

361
bwapi/Order.java Normal file
View file

@ -0,0 +1,361 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
public String toString(){
return c_str();
}
public static Order Die;
public static Order Stop;
public static Order Guard;
public static Order PlayerGuard;
public static Order TurretGuard;
public static Order BunkerGuard;
public static Order Move;
public static Order AttackUnit;
public static Order AttackTile;
public static Order Hover;
public static Order AttackMove;
public static Order InfestedCommandCenter;
public static Order UnusedNothing;
public static Order UnusedPowerup;
public static Order TowerGuard;
public static Order VultureMine;
public static Order Nothing;
public static Order Nothing3;
public static Order CastInfestation;
public static Order InfestingCommandCenter;
public static Order PlaceBuilding;
public static Order BuildProtoss2;
public static Order ConstructingBuilding;
public static Order Repair;
public static Order PlaceAddon;
public static Order BuildAddon;
public static Order Train;
public static Order RallyPointUnit;
public static Order RallyPointTile;
public static Order ZergBirth;
public static Order ZergUnitMorph;
public static Order ZergBuildingMorph;
public static Order IncompleteBuilding;
public static Order BuildNydusExit;
public static Order EnterNydusCanal;
public static Order Follow;
public static Order Carrier;
public static Order ReaverCarrierMove;
public static Order CarrierIgnore2;
public static Order Reaver;
public static Order TrainFighter;
public static Order InterceptorAttack;
public static Order ScarabAttack;
public static Order RechargeShieldsUnit;
public static Order RechargeShieldsBattery;
public static Order ShieldBattery;
public static Order InterceptorReturn;
public static Order BuildingLand;
public static Order BuildingLiftOff;
public static Order DroneLiftOff;
public static Order LiftingOff;
public static Order ResearchTech;
public static Order Upgrade;
public static Order Larva;
public static Order SpawningLarva;
public static Order Harvest1;
public static Order Harvest2;
public static Order MoveToGas;
public static Order WaitForGas;
public static Order HarvestGas;
public static Order ReturnGas;
public static Order MoveToMinerals;
public static Order WaitForMinerals;
public static Order MiningMinerals;
public static Order Harvest3;
public static Order Harvest4;
public static Order ReturnMinerals;
public static Order Interrupted;
public static Order EnterTransport;
public static Order PickupIdle;
public static Order PickupTransport;
public static Order PickupBunker;
public static Order Pickup4;
public static Order PowerupIdle;
public static Order Sieging;
public static Order Unsieging;
public static Order InitCreepGrowth;
public static Order SpreadCreep;
public static Order StoppingCreepGrowth;
public static Order GuardianAspect;
public static Order ArchonWarp;
public static Order CompletingArchonsummon;
public static Order HoldPosition;
public static Order Cloak;
public static Order Decloak;
public static Order Unload;
public static Order MoveUnload;
public static Order FireYamatoGun;
public static Order CastLockdown;
public static Order Burrowing;
public static Order Burrowed;
public static Order Unburrowing;
public static Order CastDarkSwarm;
public static Order CastParasite;
public static Order CastSpawnBroodlings;
public static Order CastEMPShockwave;
public static Order NukeWait;
public static Order NukeTrain;
public static Order NukeLaunch;
public static Order NukePaint;
public static Order NukeUnit;
public static Order CastNuclearStrike;
public static Order NukeTrack;
public static Order CloakNearbyUnits;
public static Order PlaceMine;
public static Order RightClickAction;
public static Order CastRecall;
public static Order TeleporttoLocation;
public static Order CastScannerSweep;
public static Order Scanner;
public static Order CastDefensiveMatrix;
public static Order CastPsionicStorm;
public static Order CastIrradiate;
public static Order CastPlague;
public static Order CastConsume;
public static Order CastEnsnare;
public static Order CastStasisField;
public static Order CastHallucination;
public static Order Hallucination2;
public static Order ResetCollision;
public static Order Patrol;
public static Order CTFCOPInit;
public static Order CTFCOPStarted;
public static Order CTFCOP2;
public static Order ComputerAI;
public static Order AtkMoveEP;
public static Order HarassMove;
public static Order AIPatrol;
public static Order GuardPost;
public static Order RescuePassive;
public static Order Neutral;
public static Order ComputerReturn;
public static Order SelfDestrucing;
public static Order Critter;
public static Order HiddenGun;
public static Order OpenDoor;
public static Order CloseDoor;
public static Order HideTrap;
public static Order RevealTrap;
public static Order Enabledoodad;
public static Order Disabledoodad;
public static Order Warpin;
public static Order Medic;
public static Order MedicHeal1;
public static Order HealMove;
public static Order MedicHeal2;
public static Order CastRestoration;
public static Order CastDisruptionWeb;
public static Order CastMindControl;
public static Order DarkArchonMeld;
public static Order CastFeedback;
public static Order CastOpticalFlare;
public static Order CastMaelstrom;
public static Order JunkYardDog;
public static Order Fatal;
public static Order None;
public static Order Unknown;
private static Map<Long, Order> instances = new HashMap<Long, Order>();
private Order(long pointer) {
this.pointer = pointer;
}
private static Order get(long pointer) {
Order instance = instances.get(pointer);
if (instance == null ) {
instance = new Order(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native String c_str_native(long pointer);
}

423
bwapi/Player.java Normal file
View file

@ -0,0 +1,423 @@
package bwapi;
import bwapi.*;
import java.util.Map;
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);
}
public int supplyTotal(Race race) {
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);
}
public int supplyUsed(Race race) {
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);
}
private static Map<Long, Player> instances = new HashMap<Long, Player>();
private Player(long pointer) {
this.pointer = pointer;
}
private static Player get(long pointer) {
Player instance = instances.get(pointer);
if (instance == null ) {
instance = new Player(pointer);
instances.put(pointer, instance);
}
return instance;
}
private long pointer;
private native int getID_native(long pointer);
private native String getName_native(long pointer);
private native List<Unit> getUnits_native(long pointer);
private native Race getRace_native(long pointer);
private native PlayerType getType_native(long pointer);
private native Force getForce_native(long pointer);
private native boolean isAlly_native(long pointer, Player player);
private native boolean isEnemy_native(long pointer, Player player);
private native boolean isNeutral_native(long pointer);
private native TilePosition getStartLocation_native(long pointer);
private native boolean isVictorious_native(long pointer);
private native boolean isDefeated_native(long pointer);
private native boolean leftGame_native(long pointer);
private native int minerals_native(long pointer);
private native int gas_native(long pointer);
private native int gatheredMinerals_native(long pointer);
private native int gatheredGas_native(long pointer);
private native int repairedMinerals_native(long pointer);
private native int repairedGas_native(long pointer);
private native int refundedMinerals_native(long pointer);
private native int refundedGas_native(long pointer);
private native int spentMinerals_native(long pointer);
private native int spentGas_native(long pointer);
private native int supplyTotal_native(long pointer);
private native int supplyTotal_native(long pointer, Race race);
private native int supplyUsed_native(long pointer);
private native int supplyUsed_native(long pointer, Race race);
private native int allUnitCount_native(long pointer, UnitType unit);
private native int visibleUnitCount_native(long pointer, UnitType unit);
private native int completedUnitCount_native(long pointer, UnitType unit);
private native int incompleteUnitCount_native(long pointer, UnitType unit);
private native int deadUnitCount_native(long pointer, UnitType unit);
private native int killedUnitCount_native(long pointer, UnitType unit);
private native boolean hasResearched_native(long pointer, TechType tech);
private native boolean isResearching_native(long pointer, TechType tech);
private native boolean isUpgrading_native(long pointer, UpgradeType upgrade);
private native Color getColor_native(long pointer);
private native int getTextColor_native(long pointer);
private native int maxEnergy_native(long pointer, UnitType unit);
private native double topSpeed_native(long pointer, UnitType unit);
private native int groundWeaponMaxRange_native(long pointer, UnitType unit);
private native int airWeaponMaxRange_native(long pointer, UnitType unit);
private native int weaponMaxRange_native(long pointer, WeaponType weapon);
private native int sightRange_native(long pointer, UnitType unit);
private native int groundWeaponDamageCooldown_native(long pointer, UnitType unit);
private native int armor_native(long pointer, UnitType unit);
private native int getUnitScore_native(long pointer);
private native int getKillScore_native(long pointer);
private native int getBuildingScore_native(long pointer);
private native int getRazingScore_native(long pointer);
private native int getCustomScore_native(long pointer);
private native boolean isObserver_native(long pointer);
private native boolean isResearchAvailable_native(long pointer, TechType tech);
private native boolean isUnitAvailable_native(long pointer, UnitType unit);
}

Some files were not shown because too many files have changed in this diff Show more