diff --git a/bwapi-includes/BWAPI.h b/bwapi-includes/BWAPI.h deleted file mode 100644 index 71be5e0..0000000 --- a/bwapi-includes/BWAPI.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once -#ifndef __BWAPI_H__ -#define __BWAPI_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/// The primary namespace for the BWAPI interface. Everything that is BWAPI is -/// contained within it. -namespace BWAPI -{ - /// Retrieves the revision of the BWAPILIB module currently being used. - /// - /// @returns - /// An integer representing the revision number of the library. - /// - /// @threadsafe - int BWAPI_getRevision(); - - /// Checks if the BWAPILIB module was compiled in DEBUG mode. - /// - /// @retval true if this is a DEBUG build - /// @retval false if this is a RELEASE build - /// - /// @threadsafe - bool BWAPI_isDebug(); -} - -#endif diff --git a/bwapi-includes/BWAPI/AIModule.h b/bwapi-includes/BWAPI/AIModule.h deleted file mode 100644 index b906b9f..0000000 --- a/bwapi-includes/BWAPI/AIModule.h +++ /dev/null @@ -1,252 +0,0 @@ -#pragma once -#include -#include -#include -#include - -namespace BWAPI -{ - // Forward declarations - class PlayerInterface; - typedef PlayerInterface *Player; - class Color; - - /// AIModule is a virtual class that is intended to be implemented or inherited by a - /// custom AI class. The Broodwar interface is guaranteed to be initialized if any of - /// these predefined interface functions are invoked by BWAPI. - /// - /// @warning - /// Using BWAPI in any thread other than the thread that invokes these functions can produce - /// unexpected behaviour and possibly crash your bot. Multi-threaded AIs are possible so - /// long as all BWAPI interaction is limited to the calling thread. - /// - /// @note - /// Replays are considered games and call all of the same callbacks as a standard game would. - /// - /// @ingroup Interface - class AIModule - { - public: - AIModule(); - virtual ~AIModule(); - - /// Called only once at the beginning of a game. It is intended that the - /// AI module do any data initialization in this function. - /// - /// @warning - /// Using the Broodwar interface before this function is called can produce undefined - /// behaviour and crash your bot. (During static initialization of a class for example) - virtual void onStart(); - - /// Called once at the end of a game. - /// - /// - /// A boolean value to determine if the current player has won the match. This value will - /// be true if the current player has won, and false if either the player has lost or the - /// game is actually a replay. - /// - virtual void onEnd(bool isWinner); - - /// Called once for every execution of a logical frame in Broodwar. - /// Users will generally put most of their code in this function. - virtual void onFrame(); - - /// Called when the user attempts to send a text message. This function - /// can be used to make the bot execute text commands entered by the user for debugging - /// purposes. - /// - /// - /// A string containing the exact text message that was sent by the user. - /// - /// - /// @note - /// If Flag::UserInput is disabled, then this function is not called. - virtual void onSendText(std::string text); - - /// Called when the client receives a message from another Player. This - /// function can be used to retrieve information from allies in team games, or just to - /// respond to other players. - /// - /// - /// The Player interface object representing the owner of the text message. - /// - /// - /// The text message that the \p player sent. - /// - /// - /// @note - /// Messages sent by the current player will never invoke this function. - virtual void onReceiveText(Player player, std::string text); - - /// Called when a Player leaves the game. All of their units are - /// automatically given to the neutral player with their colour and alliance parameters - /// preserved. - /// - /// - /// The Player interface object representing the player that left the game. - /// - virtual void onPlayerLeft(Player player); - - /// Called when a @Nuke has been launched somewhere on the map. - /// - /// - /// A Position object containing the target location of the @Nuke. If the target location - /// is not visible and Flag::CompleteMapInformation is disabled, then target will be - /// Positions::Unknown. - /// - virtual void onNukeDetect(Position target); - - /// Called when a Unit becomes accessible. - /// - /// - /// The Unit interface object representing the unit that has just become accessible. - /// - /// - /// @note - /// This function INCLUDES the state of Flag::CompleteMapInformation. - /// - /// @see onUnitShow - virtual void onUnitDiscover(Unit unit); - - /// Called when a Unit becomes inaccessible. - /// - /// - /// The Unit interface object representing the unit that has just become inaccessible. - /// - /// - /// @note - /// This function INCLUDES the state of Flag::CompleteMapInformation. - /// - /// @see onUnitHide - virtual void onUnitEvade(Unit unit); - - /// Called when a previously invisible unit becomes visible. - /// - /// - /// The Unit interface object representing the unit that has just become visible. - /// - /// - /// @note - /// This function EXCLUDES the state of Flag::CompleteMapInformation. - /// - /// @see onUnitDiscover - virtual void onUnitShow(Unit unit); - - /// Called just as a visible unit is becoming invisible. - /// - /// - /// The Unit interface object representing the unit that is about to go out of scope. - /// - /// - /// @note - /// This function EXCLUDES the state of Flag::CompleteMapInformation. - /// - /// @see onUnitEvade - virtual void onUnitHide(Unit unit); - - /// Called when any unit is created. - /// - /// - /// The Unit interface object representing the unit that has just been created. - /// - /// - /// @note - /// Due to the internal workings of Broodwar, this function excludes Zerg morphing and - /// the construction of structures over a @Geyser . - /// - /// @see onUnitMorph - virtual void onUnitCreate(Unit unit); - - /// Called when a unit is removed from the game either through death or other means. - /// - /// - /// Unit object representing the unit that has just been destroyed or otherwise completely - /// removed from the game. - /// - /// - /// @note - /// When a @Drone morphs into an @Extractor, the @Drone is removed from the game and the - /// @Geyser morphs into an @Extractor. - /// - /// @note - /// If a unit is visible and destroyed, then onUnitHide is called just before this. - virtual void onUnitDestroy(Unit unit); - - /// Called when a unit changes its UnitType. For example, when a @Drone - /// transforms into a @Hatchery, a @SiegeTank uses @SiegeMode, or a @Geyser receives a - /// @Refinery. - /// - /// - /// Unit object representing the unit that had its UnitType change. - /// - /// - /// @note - /// This is NOT called if the unit type changes to or from UnitTypes::Unknown. - virtual void onUnitMorph(Unit unit); - - /// Called when a unit changes ownership. This occurs when the @Protoss - /// ability @MindControl is used, or if a unit changes ownership in @UseMapSettings . - /// - /// - /// Unit interface object pertaining to the unit that has just changed ownership. - /// - virtual void onUnitRenegade(Unit unit); - - /// Called when the state of the Broodwar game is saved to file. - /// - /// - /// A String object containing the file name that the game was saved as. - /// - virtual void onSaveGame(std::string gameName); - - /// Called when the state of a unit changes from incomplete to complete. - /// - /// - /// The Unit object representing the Unit that has just finished training or constructing. - /// - virtual void onUnitComplete(Unit unit); - }; - - /// TournamentModule is a virtual class that is intended to be implemented or inherited - /// by a custom Tournament class. Like AIModule, the Broodwar interface is guaranteed - /// to be initialized if any of these predefined interface functions are invoked by BWAPI. - /// - /// @note - /// The TournamentModule is to be implemented by Tournament Modules ONLY. A standard AI module - /// should never implement it. The Tournament Module is invoked only if it is explicitly - /// defined in the configuration file. Tournament Modules also contain an AI Module interface - /// so that it can monitor the time an AI module spent during its calls using - /// Game::getLastEventTime. - /// - /// @ingroup Interface - class TournamentModule - { - public: - TournamentModule(); - virtual ~TournamentModule(); - - /// This function regulates the functions involving game settings that an AI module - /// is allowed to execute. For example, if the tournament forbids the enabling of - /// Flag::CompleteMapInformation, then this function can deny the request. - /// - /// - /// An ActionID containing the action that the AI module is requesting. - /// - /// - /// - /// An optional parameter that pertains to certain action requests. For example, if - /// \p actionType is Tournament::ActionID::SendText, then \p parameter is a pointer to a - /// null-terminated character array containing the message. If \p actionType is - /// Tournament::ActionID::SetLocalSpeed, then parameter is a pointer to an integer. - /// - /// - /// @see BWAPI::Tournament::ActionID - virtual bool onAction(BWAPI::Tournament::ActionID actionType, void *parameter = nullptr); - - /// This function is called if the current player is chosen to advertise the BWAPI - /// revision. When tournament mode is enabled, to reduce spam, only one bot sends - /// the revision message. The bot that is chosen depends on its player ID. Only one of the - /// bots can call this function during a tournament game. - virtual void onFirstAdvertisement(); - }; -} diff --git a/bwapi-includes/BWAPI/ArithmaticFilter.h b/bwapi-includes/BWAPI/ArithmaticFilter.h deleted file mode 100644 index e69de29..0000000 diff --git a/bwapi-includes/BWAPI/BestFilter.h b/bwapi-includes/BWAPI/BestFilter.h deleted file mode 100644 index b32a244..0000000 --- a/bwapi-includes/BWAPI/BestFilter.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once -#include -#include "ComparisonFilter.h" - -namespace BWAPI -{ - /// The BestFilter is used to compare two objects with each other. Each - /// function object compares two of the same object and returns the most desirable one. - /// - /// @note: A function object should return one of the two given parameters, never nullptr. Both - /// parameters being given should never be nullptr. - template - class BestFilter - { - private: - std::function<_PARAM(_PARAM,_PARAM)> pred; - public: - // Constructor - template - BestFilter(const _T &predicate) : pred(predicate) - {}; - - // Assignment - template - BestFilter<_PARAM> &operator =(const _T &other) - { - this->pred = other; - return *this; - }; - - // Bitwise operators - template - inline BestFilter<_PARAM> operator &&(const _T &other) const - { - return [=](_PARAM p1, _PARAM p2)->_PARAM{ return other( (*this)(p1, p2) ); }; - }; - - // call - inline _PARAM operator()(const _PARAM &p1, const _PARAM &p2) const - { - return this->pred(p1, p2); - }; - - }; - - template - BestFilter<_PARAM> Lowest(const CompareFilter<_PARAM,int> &filter) - { - return [=](_PARAM p1, _PARAM p2)->_PARAM{ return filter(p2) < filter(p1) ? p2 : p1; }; - }; - template - BestFilter<_PARAM> Highest(const CompareFilter<_PARAM,int> &filter) - { - return [=](_PARAM p1, _PARAM p2)->_PARAM{ return filter(p2) > filter(p1) ? p2 : p1; }; - }; - -} - diff --git a/bwapi-includes/BWAPI/Bullet.h b/bwapi-includes/BWAPI/Bullet.h deleted file mode 100644 index 6bf3d68..0000000 --- a/bwapi-includes/BWAPI/Bullet.h +++ /dev/null @@ -1,169 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - // Forward declarations - class PlayerInterface; - typedef PlayerInterface *Player; - class BulletType; - - class BulletInterface; - typedef BulletInterface *Bullet; - - /// An interface object representing a bullet or missile spawned from an attack. - /// - /// The Bullet interface allows you to detect bullets, missiles, and other types - /// of non-melee attacks or special abilities that would normally be visible through - /// human eyes (A lurker spike or a Queen's flying parasite), allowing quicker reaction - /// to unavoidable consequences. - /// - /// For example, ordering medics to restore units that are about to receive a lockdown - /// to compensate for latency and minimize its effects. You can't know entirely which unit - /// will be receiving a lockdown unless you can detect the lockdown missile using the - /// Bullet class. - /// - /// Bullet objects are re-used after they are destroyed, however their ID is updated when it - /// represents a new Bullet. - /// - /// If Flag::CompleteMapInformation is disabled, then a Bullet is accessible if and only if - /// it is visible. Otherwise if Flag::CompleteMapInformation is enabled, then all Bullets - /// in the game are accessible. - /// @see Game::getBullets, BulletInterface::exists - /// @ingroup Interface - class BulletInterface : public Interface - { - protected: - virtual ~BulletInterface() {}; - public: - /// Retrieves a unique identifier for the current Bullet. - /// - /// @returns - /// An integer value containing the identifier. - virtual int getID() const = 0; - - /// Checks if the Bullet exists in the view of the BWAPI player. - /// - /// @retval true If the bullet exists or is visible. - /// @retval false If the bullet was destroyed or has gone out of scope. - /// - /// If Flag::CompleteMapInformation is disabled, and a Bullet is not visible, then the - /// return value will be false regardless of the Bullet's true existence. This is because - /// absolutely no state information on invisible enemy bullets is made available to the AI. - /// - /// If Flag::CompleteMapInformation is enabled, then this function is accurate for all - /// Bullet information. - /// @see isVisible, UnitInterface::exists - virtual bool exists() const = 0; - - /// Retrieves the Player interface that owns the Bullet. - /// - /// @retval nullptr If the Player object for this Bullet is inaccessible. - /// - /// @returns - /// The owning Player interface object. - virtual Player getPlayer() const = 0; - - /// Retrieves the type of this Bullet. - /// - /// @retval BulletTypes::Unknown if the Bullet is inaccessible. - /// - /// @returns - /// A BulletType representing the Bullet's type. - virtual BulletType getType() const = 0; - - /// Retrieves the Unit interface that the Bullet spawned from. - /// - /// @retval nullptr If the source can not be identified or is inaccessible. - /// - /// @returns - /// The owning Unit interface object. - /// @see getTarget - virtual Unit getSource() const = 0; - - /// Retrieves the Bullet's current position. - /// - /// @retval Positions::Unknown If the Bullet is inaccessible. - /// - /// @returns - /// A Position containing the Bullet's current coordinates. - /// @see getTargetPosition - virtual Position getPosition() const = 0; - - /// Retrieve's the direction the Bullet is facing. If the angle is 0, then - /// the Bullet is facing right. - /// - /// @retval 0.0 If the bullet is inaccessible. - /// - /// @returns - /// A double representing the direction the Bullet is facing. - virtual double getAngle() const = 0; - - /// Retrieves the X component of the Bullet's velocity, measured in pixels per frame. - /// - /// @retval 0.0 if the Bullet is inaccessible. - /// - /// @returns - /// A double representing the number of pixels moved on the X axis per frame. - /// - /// @see getVelocityY, getAngle - virtual double getVelocityX() const = 0; - - /// Retrieves the Y component of the Bullet's velocity, measured in pixels per frame. - /// - /// @retval 0.0 if the Bullet is inaccessible. - /// - /// @returns - /// A double representing the number of pixels moved on the Y axis per frame. - /// - /// @see getVelocityX, getAngle - virtual double getVelocityY() const = 0; - - /// Retrieves the Unit interface that the Bullet is heading to. - /// - /// @retval nullptr If the Bullet's target Unit is inaccessible, the Bullet is targetting the - /// ground, or if the Bullet itself is inaccessible. - /// - /// @returns - /// The target Unit interface object, if one exists. - /// @see getTargetPosition, getSource - virtual Unit getTarget() const = 0; - - /// Retrieves the target position that the Bullet is heading to. - /// - /// @retval Positions::Unknown If the bullet is inaccessible. - /// - /// @returns - /// A Position indicating where the Bullet is headed. - /// @see getTarget, getPosition - virtual Position getTargetPosition() const = 0; - - /// Retrieves the timer that indicates the Bullet's life span. - /// - /// Bullets are not permanent objects, so they will often have a limited life span. - /// This life span is measured in frames. Normally a Bullet will reach its target - /// before being removed. - /// - /// @retval 0 If the Bullet is inaccessible. - /// - /// @returns - /// An integer representing the remaining number of frames until the Bullet self-destructs. - virtual int getRemoveTimer() const = 0; - - /// Retrieves the visibility state of the Bullet. - /// - /// (optional) - /// If this parameter is specified, then the Bullet's visibility to the given player is - /// checked. If this parameter is omitted, then a default value of nullptr is used, which - /// will check if the BWAPI player has vision of the Bullet. - /// - /// - /// @note If \c player is nullptr and Broodwar->self() is also nullptr, then the visibility of - /// the Bullet is determined by checking if at least one other player has vision of the - /// Bullet. - /// - /// @retval true If the Bullet is visible to the specified player. - /// @retval false If the Bullet is not visible to the specified player. - virtual bool isVisible(Player player = nullptr) const = 0; - }; -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/BulletType.h b/bwapi-includes/BWAPI/BulletType.h deleted file mode 100644 index 236b742..0000000 --- a/bwapi-includes/BWAPI/BulletType.h +++ /dev/null @@ -1,127 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// Namespace containing bullet types. - /// @see BulletType - namespace BulletTypes - { - /// Enumeration of bullet types. - /// @see BulletType - namespace Enum - { - /// Enumeration of bullet types. - /// @see BulletType - enum Enum - { - Melee = 0, - - Fusion_Cutter_Hit = 141, - Gauss_Rifle_Hit, - C_10_Canister_Rifle_Hit, - Gemini_Missiles, - Fragmentation_Grenade, - Longbolt_Missile, - Unused_Lockdown, - ATS_ATA_Laser_Battery, - Burst_Lasers, - Arclite_Shock_Cannon_Hit, - EMP_Missile, - Dual_Photon_Blasters_Hit, - Particle_Beam_Hit, - Anti_Matter_Missile, - Pulse_Cannon, - Psionic_Shockwave_Hit, - Psionic_Storm, - Yamato_Gun, - Phase_Disruptor, - STA_STS_Cannon_Overlay, - Sunken_Colony_Tentacle, - Venom_Unused, - Acid_Spore, - Plasma_Drip_Unused, - Glave_Wurm, - Seeker_Spores, - Queen_Spell_Carrier, - Plague_Cloud, - Consume, - Ensnare, - Needle_Spine_Hit, - Invisible, - - Optical_Flare_Grenade = 201, - Halo_Rockets, - Subterranean_Spines, - Corrosive_Acid_Shot, - Corrosive_Acid_Hit, - Neutron_Flare, - - None = 209, - Unknown, - MAX - }; - } - } - /// This class represents a type of bullet. - /// - /// @note Internally, these are the same IDs as flingy types in Broodwar. - /// - /// @see BulletTypes - /// @ingroup TypeClasses - class BulletType : public Type - { - public: - /// @copydoc Type::Type(int) - BulletType(int id = BulletTypes::Enum::None); - }; - - /// @ingroup Types - namespace BulletTypes - { - /// Retrieves the set of all the BulletTypes. - /// - /// @returns Set of BulletTypes. - const BulletType::set& allBulletTypes(); - - 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; - }; - - static_assert(sizeof(BulletType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/Bulletset.h b/bwapi-includes/BWAPI/Bulletset.h deleted file mode 100644 index 2f0566e..0000000 --- a/bwapi-includes/BWAPI/Bulletset.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "SetContainer.h" - -namespace BWAPI -{ - // Forward Declarations - class BulletInterface; - typedef BulletInterface *Bullet; - - /// A container for a set of Bullet objects. - class Bulletset : public SetContainer> - { - public: - }; -} - diff --git a/bwapi-includes/BWAPI/Client.h b/bwapi-includes/BWAPI/Client.h deleted file mode 100644 index a55dd7a..0000000 --- a/bwapi-includes/BWAPI/Client.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/bwapi-includes/BWAPI/Client/BulletData.h b/bwapi-includes/BWAPI/Client/BulletData.h deleted file mode 100644 index 25e41e3..0000000 --- a/bwapi-includes/BWAPI/Client/BulletData.h +++ /dev/null @@ -1,23 +0,0 @@ -#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]; - }; -} diff --git a/bwapi-includes/BWAPI/Client/BulletImpl.h b/bwapi-includes/BWAPI/Client/BulletImpl.h deleted file mode 100644 index 48ca297..0000000 --- a/bwapi-includes/BWAPI/Client/BulletImpl.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include -#include "BulletData.h" -#include - -namespace BWAPI -{ - class PlayerInterface; - typedef PlayerInterface *Player; - - class BulletImpl : public BulletInterface - { - private: - const BulletData* self; - int index; - public: - - BulletImpl(int index); - virtual int getID() const override; - virtual bool exists() const override; - virtual Player getPlayer() const override; - virtual BulletType getType() const override; - virtual Unit getSource() const override; - virtual Position getPosition() const override; - virtual double getAngle() const override; - virtual double getVelocityX() const override; - virtual double getVelocityY() const override; - virtual Unit getTarget() const override; - virtual Position getTargetPosition() const override; - virtual int getRemoveTimer() const override; - virtual bool isVisible(Player player = nullptr) const override; - }; -} diff --git a/bwapi-includes/BWAPI/Client/Client.h b/bwapi-includes/BWAPI/Client/Client.h deleted file mode 100644 index 2de8ba2..0000000 --- a/bwapi-includes/BWAPI/Client/Client.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "GameData.h" -#include "GameImpl.h" -#include "ForceImpl.h" -#include "PlayerImpl.h" -#include "UnitImpl.h" -#include "GameTable.h" - -#include "../WindowsTypes.h" - - -namespace BWAPI -{ - class Client - { - public: - Client(); - ~Client(); - - bool isConnected() const; - bool connect(); - void disconnect(); - void update(); - - GameData* data = nullptr; - private: - HANDLE pipeObjectHandle; - HANDLE mapFileHandle; - HANDLE gameTableFileHandle; - GameTable* gameTable = nullptr; - - bool connected = false; - }; - extern Client BWAPIClient; -} diff --git a/bwapi-includes/BWAPI/Client/Command.h b/bwapi-includes/BWAPI/Client/Command.h deleted file mode 100644 index e0d0f88..0000000 --- a/bwapi-includes/BWAPI/Client/Command.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "CommandType.h" - -namespace BWAPIC -{ - struct Command - { - Command() - : type( CommandType::None ) - , value1( 0 ) - , value2( 0 ) - { } - Command(CommandType::Enum _commandType, int _value1=0, int _value2=0) - : type( _commandType ) - , value1( _value1 ) - , value2( _value2 ) - { } - - CommandType::Enum type; - int value1; - int value2; - }; -} diff --git a/bwapi-includes/BWAPI/Client/CommandType.h b/bwapi-includes/BWAPI/Client/CommandType.h deleted file mode 100644 index 25a33e9..0000000 --- a/bwapi-includes/BWAPI/Client/CommandType.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -/** - * Used in UnitCommand - */ - -namespace BWAPIC -{ - namespace CommandType - { - enum Enum - { - None, - SetScreenPosition, - PingMinimap, - EnableFlag, - Printf, - SendText, - PauseGame, - ResumeGame, - LeaveGame, - RestartGame, - SetLocalSpeed, - SetLatCom, - SetGui, - SetFrameSkip, - SetMap, - SetAllies, - SetVision, - SetCommandOptimizerLevel, - SetRevealAll - }; - } -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/Client/Event.h b/bwapi-includes/BWAPI/Client/Event.h deleted file mode 100644 index 7abfccc..0000000 --- a/bwapi-includes/BWAPI/Client/Event.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include -#include - -namespace BWAPIC -{ - struct Event - { - BWAPI::EventType::Enum type; - int v1; - int v2; - }; -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/Client/ForceData.h b/bwapi-includes/BWAPI/Client/ForceData.h deleted file mode 100644 index 6480914..0000000 --- a/bwapi-includes/BWAPI/Client/ForceData.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -namespace BWAPI -{ - struct ForceData - { - char name[32]; - }; -} diff --git a/bwapi-includes/BWAPI/Client/ForceImpl.h b/bwapi-includes/BWAPI/Client/ForceImpl.h deleted file mode 100644 index 640107a..0000000 --- a/bwapi-includes/BWAPI/Client/ForceImpl.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include -#include "ForceData.h" -#include - -namespace BWAPI -{ - class ForceImpl : public ForceInterface - { - private: - const ForceData* self; - int id; - public: - ForceImpl(int id); - virtual int getID() const override; - virtual std::string getName() const override; - virtual Playerset getPlayers() const override; - }; -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/Client/GameData.h b/bwapi-includes/BWAPI/Client/GameData.h deleted file mode 100644 index 5b2745b..0000000 --- a/bwapi-includes/BWAPI/Client/GameData.h +++ /dev/null @@ -1,163 +0,0 @@ -#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][1024]; - - //shapes, commands, unitCommands, from client to server - int shapeCount; - BWAPIC::Shape shapes[MAX_SHAPES]; - - int commandCount; - BWAPIC::Command commands[MAX_COMMANDS]; - - int unitCommandCount; - BWAPIC::UnitCommand unitCommands[MAX_UNIT_COMMANDS]; - - int unitSearchSize; - unitFinder xUnitSearch[1700*2]; - unitFinder yUnitSearch[1700*2]; - }; -} diff --git a/bwapi-includes/BWAPI/Client/GameImpl.h b/bwapi-includes/BWAPI/Client/GameImpl.h deleted file mode 100644 index 87a4440..0000000 --- a/bwapi-includes/BWAPI/Client/GameImpl.h +++ /dev/null @@ -1,200 +0,0 @@ -#pragma once -#include - -#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 -#include -#include - -namespace BWAPI -{ - class ForceInterface; - typedef ForceInterface *Force; - class PlayerInterface; - typedef PlayerInterface *Player; - - class GameImpl : public Game - { - private : - int addShape(const BWAPIC::Shape &s); - int addString(const char* text); - int addText(BWAPIC::Shape &s, const char* text); - int addCommand(const BWAPIC::Command &c); - void processInterfaceEvents(); - void clearAll(); - - GameData* data; - std::vector forceVector; - std::vector playerVector; - std::vector unitVector; - std::vector bulletVector; - std::array regionArray; - - Forceset forces; - Playerset playerSet; - Unitset accessibleUnits;//all units that are accessible (and definitely alive) - //notDestroyedUnits - accessibleUnits = all units that may or may not be alive (status unknown) - Unitset minerals; - Unitset geysers; - Unitset neutralUnits; - Unitset staticMinerals; - Unitset staticGeysers; - Unitset staticNeutralUnits; - Bulletset bullets; - Position::list nukeDots; - Unitset selectedUnits; - Unitset pylons; - Regionset regionsList; - - TilePosition::list startLocations; - std::list< Event > events; - Player thePlayer; - Player theEnemy; - Player theNeutral; - Playerset _allies; - Playerset _enemies; - Playerset _observers; - mutable Error lastError; - Text::Size::Enum textSize; - - public : - Event makeEvent(BWAPIC::Event e); - int addUnitCommand(BWAPIC::UnitCommand& c); - bool inGame; - GameImpl(GameData* data); - void onMatchStart(); - void onMatchEnd(); - void onMatchFrame(); - const GameData* getGameData() const; - Unit _unitFromIndex(int index); - - virtual const Forceset& getForces() const override; - virtual const Playerset& getPlayers() const override; - virtual const Unitset& getAllUnits() const override; - virtual const Unitset& getMinerals() const override; - virtual const Unitset& getGeysers() const override; - virtual const Unitset& getNeutralUnits() const override; - - virtual const Unitset& getStaticMinerals() const override; - virtual const Unitset& getStaticGeysers() const override; - virtual const Unitset& getStaticNeutralUnits() const override; - - virtual const Bulletset& getBullets() const override; - virtual const Position::list& getNukeDots() const override; - virtual const std::list< Event>& getEvents() const override; - - virtual Force getForce(int forceID) const override; - virtual Player getPlayer(int playerID) const override; - virtual Unit getUnit(int unitID) const override; - virtual Unit indexToUnit(int unitIndex) const override; - virtual Region getRegion(int regionID) const override; - - virtual GameType getGameType() const override; - virtual int getLatency() const override; - virtual int getFrameCount() const override; - virtual int getReplayFrameCount() const override; - virtual int getFPS() const override; - virtual double getAverageFPS() const override; - virtual BWAPI::Position getMousePosition() const override; - virtual bool getMouseState(MouseButton button) const override; - virtual bool getKeyState(Key key) const override; - virtual BWAPI::Position getScreenPosition() const override; - virtual void setScreenPosition(int x, int y) override; - virtual void pingMinimap(int x, int y) override; - - virtual bool isFlagEnabled(int flag) const override; - virtual void enableFlag(int flag) override; - virtual Unitset getUnitsInRectangle(int left, int top, int right, int bottom, const UnitFilter &pred = nullptr) const override; - virtual Unit getClosestUnitInRectangle(Position center, const UnitFilter &pred = nullptr, int left = 0, int top = 0, int right = 999999, int bottom = 999999) const override; - virtual Unit getBestUnit(const BestUnitFilter &best, const UnitFilter &pred, Position center = Positions::None, int radius = 999999) const override; - virtual Error getLastError() const override; - virtual bool setLastError(BWAPI::Error e = Errors::None) const override; - - virtual int mapWidth() const override; - virtual int mapHeight() const override; - virtual std::string mapFileName() const override; - virtual std::string mapPathName() const override; - virtual std::string mapName() const override; - virtual std::string mapHash() const override; - - virtual bool isWalkable(int x, int y) const override; - virtual int getGroundHeight(int x, int y) const override; - virtual bool isBuildable(int x, int y, bool includeBuildings = false) const override; - virtual bool isVisible(int x, int y) const override; - virtual bool isExplored(int x, int y) const override; - virtual bool hasCreep(int x, int y) const override; - virtual bool hasPowerPrecise(int x, int y, UnitType unitType = UnitTypes::None ) const override; - - virtual bool canBuildHere(TilePosition position, UnitType type, Unit builder = nullptr, bool checkExplored = false) override; - virtual bool canMake(UnitType type, Unit builder = nullptr) const override; - virtual bool canResearch(TechType type, Unit unit = nullptr, bool checkCanIssueCommandType = true) override; - virtual bool canUpgrade(UpgradeType type, Unit unit = nullptr, bool checkCanIssueCommandType = true) override; - virtual const TilePosition::list& getStartLocations() const override; - - virtual void vPrintf(const char* format, va_list arg) override; - virtual void vSendTextEx(bool toAllies, const char *format, va_list arg) override; - - virtual bool isInGame() const override; - virtual bool isMultiplayer() const override; - virtual bool isBattleNet() const override; - virtual bool isPaused() const override; - virtual bool isReplay() const override; - - virtual void pauseGame() override; - virtual void resumeGame() override; - virtual void leaveGame() override; - virtual void restartGame() override; - virtual void setLocalSpeed(int speed = -1) override; - virtual bool issueCommand(const Unitset& units, UnitCommand command) override; - virtual const Unitset& getSelectedUnits() const override; - virtual Player self() const override; - virtual Player enemy() const override; - virtual Player neutral() const override; - virtual Playerset& allies() override; - virtual Playerset& enemies() override; - virtual Playerset& observers() override; - - virtual void setTextSize(Text::Size::Enum size = Text::Size::Default) override; - virtual void vDrawText(CoordinateType::Enum ctype, int x, int y, const char *format, va_list arg) override; - virtual void drawBox(CoordinateType::Enum ctype, int left, int top, int right, int bottom, Color color, bool isSolid = false) override; - virtual void drawTriangle(CoordinateType::Enum ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false) override; - virtual void drawCircle(CoordinateType::Enum ctype, int x, int y, int radius, Color color, bool isSolid = false) override; - virtual void drawEllipse(CoordinateType::Enum ctype, int x, int y, int xrad, int yrad, Color color, bool isSolid = false) override; - virtual void drawDot(CoordinateType::Enum ctype, int x, int y, Color color) override; - virtual void drawLine(CoordinateType::Enum ctype, int x1, int y1, int x2, int y2, Color color) override; - - virtual int getLatencyFrames() const override; - virtual int getLatencyTime() const override; - virtual int getRemainingLatencyFrames() const override; - virtual int getRemainingLatencyTime() const override; - virtual int getRevision() const override; - virtual bool isDebug() const override; - virtual bool isLatComEnabled() const override; - virtual void setLatCom(bool isEnabled) override; - virtual bool isGUIEnabled() const override; - virtual void setGUI(bool enabled) override; - virtual int getInstanceNumber() const override; - virtual int getAPM(bool includeSelects = false) const override; - virtual bool setMap(const char *mapFileName) override; - virtual void setFrameSkip(int frameSkip) override; - virtual bool setAlliance(BWAPI::Player player, bool allied = true, bool alliedVictory = true) override; - virtual bool setVision(BWAPI::Player player, bool enabled = true) override; - virtual int elapsedTime() const override; - virtual void setCommandOptimizationLevel(int level) override; - virtual int countdownTimer() const override; - virtual const Regionset &getAllRegions() const override; - virtual BWAPI::Region getRegionAt(int x, int y) const override; - virtual int getLastEventTime() const override; - virtual bool setRevealAll(bool reveal = true) override; - }; -} diff --git a/bwapi-includes/BWAPI/Client/GameTable.h b/bwapi-includes/BWAPI/Client/GameTable.h deleted file mode 100644 index 14a0863..0000000 --- a/bwapi-includes/BWAPI/Client/GameTable.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -namespace BWAPI -{ - struct GameInstance - { - GameInstance() - : serverProcessID(0) - , isConnected(false) - , lastKeepAliveTime(0) - {}; - GameInstance(unsigned int servID, bool connected, unsigned int lastAliveTime) - : serverProcessID(servID) - , isConnected(connected) - , lastKeepAliveTime(lastAliveTime) - {}; - - unsigned int serverProcessID; - bool isConnected; - //time_t lastKeepAliveTime; - unsigned int lastKeepAliveTime; - }; - struct GameTable - { - GameTable() - {} - static const int MAX_GAME_INSTANCES = 8; - GameInstance gameInstances[MAX_GAME_INSTANCES]; - }; -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/Client/PlayerData.h b/bwapi-includes/BWAPI/Client/PlayerData.h deleted file mode 100644 index 073d991..0000000 --- a/bwapi-includes/BWAPI/Client/PlayerData.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace BWAPI -{ - struct PlayerData - { - char name[25]; - int race; - int type; - int force; - bool isAlly[12]; - bool isEnemy[12]; - bool isNeutral; - int startLocationX; - int startLocationY; - bool isVictorious; - bool isDefeated; - bool leftGame; - bool isParticipating; - - int minerals; - int gas; - int gatheredMinerals; - int gatheredGas; - int repairedMinerals; - int repairedGas; - int refundedMinerals; - int refundedGas; - int supplyTotal[3]; - int supplyUsed[3]; - - int allUnitCount[UnitTypes::Enum::MAX]; - int visibleUnitCount[UnitTypes::Enum::MAX]; - int completedUnitCount[UnitTypes::Enum::MAX]; - int deadUnitCount[UnitTypes::Enum::MAX]; - int killedUnitCount[UnitTypes::Enum::MAX]; - - int upgradeLevel[UpgradeTypes::Enum::MAX]; - bool hasResearched[TechTypes::Enum::MAX]; - bool isResearching[TechTypes::Enum::MAX]; - bool isUpgrading[UpgradeTypes::Enum::MAX]; - - int color; - - int totalUnitScore; - int totalKillScore; - int totalBuildingScore; - int totalRazingScore; - int customScore; - - int maxUpgradeLevel[UpgradeTypes::Enum::MAX]; - bool isResearchAvailable[TechTypes::Enum::MAX]; - bool isUnitAvailable[UnitTypes::Enum::MAX]; - }; -} diff --git a/bwapi-includes/BWAPI/Client/PlayerImpl.h b/bwapi-includes/BWAPI/Client/PlayerImpl.h deleted file mode 100644 index c4b7e20..0000000 --- a/bwapi-includes/BWAPI/Client/PlayerImpl.h +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once -#include -#include "PlayerData.h" -#include - -#include - -namespace BWAPI -{ - class ForceInterface; - typedef ForceInterface *Force; - - class PlayerImpl : public PlayerInterface - { - private: - int id; - public: - PlayerData* self; - Unitset units; - void clear(); - PlayerImpl(int id); - virtual int getID() const override; - virtual std::string getName() const override; - virtual const Unitset &getUnits() const override; - virtual Race getRace() const override; - virtual PlayerType getType() const override; - virtual Force getForce() const override; - virtual bool isAlly(const Player player) const override; - virtual bool isEnemy(const Player player) const override; - virtual bool isNeutral() const override; - virtual TilePosition getStartLocation() const override; - virtual bool isVictorious() const override; - virtual bool isDefeated() const override; - virtual bool leftGame() const override; - - virtual int minerals() const override; - virtual int gas() const override; - virtual int gatheredMinerals() const override; - virtual int gatheredGas() const override; - virtual int repairedMinerals() const override; - virtual int repairedGas() const override; - virtual int refundedMinerals() const override; - virtual int refundedGas() const override; - virtual int spentMinerals() const override; - virtual int spentGas() const override; - - virtual int supplyTotal(Race race = Races::None) const override; - virtual int supplyUsed(Race race = Races::None) const override; - - virtual int allUnitCount(UnitType unit) const override; - virtual int visibleUnitCount(UnitType unit) const override; - virtual int completedUnitCount(UnitType unit) const override; - virtual int deadUnitCount(UnitType unit) const override; - virtual int killedUnitCount(UnitType unit) const override; - - virtual int getUpgradeLevel(UpgradeType upgrade) const override; - virtual bool hasResearched(TechType tech) const override; - virtual bool isResearching(TechType tech) const override; - virtual bool isUpgrading(UpgradeType upgrade) const override; - - virtual BWAPI::Color getColor() const override; - - virtual int getUnitScore() const override; - virtual int getKillScore() const override; - virtual int getBuildingScore() const override; - virtual int getRazingScore() const override; - virtual int getCustomScore() const override; - - virtual bool isObserver() const override; - - virtual int getMaxUpgradeLevel(UpgradeType upgrade) const override; - virtual bool isResearchAvailable(TechType tech) const override; - virtual bool isUnitAvailable(UnitType unit) const override; - }; -}; diff --git a/bwapi-includes/BWAPI/Client/RegionData.h b/bwapi-includes/BWAPI/Client/RegionData.h deleted file mode 100644 index 4cbc8b4..0000000 --- a/bwapi-includes/BWAPI/Client/RegionData.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -namespace BWAPI -{ - struct RegionData - { - int id; - int islandID; - int center_x; - int center_y; - int priority; - - // region boundary - int leftMost; - int rightMost; - int topMost; - int bottomMost; - - int neighborCount; - int neighbors[256]; - - bool isAccessible; - bool isHigherGround; - }; -}; diff --git a/bwapi-includes/BWAPI/Client/RegionImpl.h b/bwapi-includes/BWAPI/Client/RegionImpl.h deleted file mode 100644 index 8a37817..0000000 --- a/bwapi-includes/BWAPI/Client/RegionImpl.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include -#include -#include - -#include - -namespace BWAPI -{ - class RegionImpl : public RegionInterface - { - private: - RegionData* self; - Regionset neighbors; - BWAPI::Region closestAccessibleRgn = nullptr; - BWAPI::Region closestInaccessibleRgn = nullptr; - public: - RegionImpl(int index); - void setNeighbors(); - virtual int getID() const override; - virtual int getRegionGroupID() const override; - virtual BWAPI::Position getCenter() const override; - virtual bool isHigherGround() const override; - virtual int getDefensePriority() const override; - virtual bool isAccessible() const override; - - virtual const Regionset &getNeighbors() const override; - - virtual int getBoundsLeft() const override; - virtual int getBoundsTop() const override; - virtual int getBoundsRight() const override; - virtual int getBoundsBottom() const override; - - virtual BWAPI::Region getClosestAccessibleRegion() const override; - virtual BWAPI::Region getClosestInaccessibleRegion() const override; - }; - -}; - diff --git a/bwapi-includes/BWAPI/Client/Shape.h b/bwapi-includes/BWAPI/Client/Shape.h deleted file mode 100644 index 6007fb5..0000000 --- a/bwapi-includes/BWAPI/Client/Shape.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -#include "ShapeType.h" -#include - -namespace BWAPIC -{ - struct Shape - { - Shape() - :type(ShapeType::None) - ,ctype(BWAPI::CoordinateType::None) - ,x1(0) - ,y1(0) - ,x2(0) - ,y2(0) - ,extra1(0) - ,extra2(0) - ,color(0) - ,isSolid(false) - { - } - - Shape(ShapeType::Enum _shapeType, BWAPI::CoordinateType::Enum _ctype, int _x1, int _y1, int _x2, int _y2, int _extra1, int _extra2, int _color, bool _isSolid) - :type(_shapeType) - ,ctype(_ctype) - ,x1(_x1) - ,y1(_y1) - ,x2(_x2) - ,y2(_y2) - ,extra1(_extra1) - ,extra2(_extra2) - ,color(_color) - ,isSolid(_isSolid) - { - } - - ShapeType::Enum type; - BWAPI::CoordinateType::Enum ctype; - int x1; - int y1; - int x2; - int y2; - int extra1; - int extra2; - int color; - bool isSolid; - }; -} diff --git a/bwapi-includes/BWAPI/Client/ShapeType.h b/bwapi-includes/BWAPI/Client/ShapeType.h deleted file mode 100644 index f5709e7..0000000 --- a/bwapi-includes/BWAPI/Client/ShapeType.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -/** - * Used in UnitCommand - */ - -namespace BWAPIC -{ - namespace ShapeType - { - enum Enum - { - None, - Text, - Box, - Triangle, - Circle, - Ellipse, - Dot, - Line - }; - } -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/Client/UnitCommand.h b/bwapi-includes/BWAPI/Client/UnitCommand.h deleted file mode 100644 index d62eb92..0000000 --- a/bwapi-includes/BWAPI/Client/UnitCommand.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -/** - * UnitOrder contains a single whole order - */ - -namespace BWAPIC -{ - struct UnitCommand - { - BWAPI::UnitCommandType type; - int unitIndex; - int targetIndex; - int x; - int y; - int extra; - }; -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/Client/UnitData.h b/bwapi-includes/BWAPI/Client/UnitData.h deleted file mode 100644 index 6df7fd4..0000000 --- a/bwapi-includes/BWAPI/Client/UnitData.h +++ /dev/null @@ -1,111 +0,0 @@ -#pragma once - -namespace BWAPI -{ - struct UnitData - { - int clearanceLevel; - int id; - int player; - int type; - int positionX; - int positionY; - double angle; - double velocityX; - double velocityY; - int hitPoints; - int lastHitPoints; - int shields; - int energy; - int resources; - int resourceGroup; - - int killCount; - int acidSporeCount; - int scarabCount; - int spiderMineCount; - int groundWeaponCooldown; - int airWeaponCooldown; - int spellCooldown; - int defenseMatrixPoints; - - int defenseMatrixTimer; - int ensnareTimer; - int irradiateTimer; - int lockdownTimer; - int maelstromTimer; - int orderTimer; - int plagueTimer; - int removeTimer; - int stasisTimer; - int stimTimer; - - int buildType; - int trainingQueueCount; - int trainingQueue[5]; - int tech; - int upgrade; - int remainingBuildTime; - int remainingTrainTime; - int remainingResearchTime; - int remainingUpgradeTime; - int buildUnit; - - int target; - int targetPositionX; - int targetPositionY; - int order; - int orderTarget; - int orderTargetPositionX; - int orderTargetPositionY; - int secondaryOrder; - int rallyPositionX; - int rallyPositionY; - int rallyUnit; - int addon; - int nydusExit; - int powerUp; - - int transport; - int carrier; - int hatchery; - - bool exists; - bool hasNuke; - bool isAccelerating; - bool isAttacking; - bool isAttackFrame; - bool isBeingGathered; - bool isBlind; - bool isBraking; - bool isBurrowed; - int carryResourceType; - bool isCloaked; - bool isCompleted; - bool isConstructing; - bool isDetected; - bool isGathering; - bool isHallucination; - bool isIdle; - bool isInterruptible; - bool isInvincible; - bool isLifted; - bool isMorphing; - bool isMoving; - bool isParasited; - bool isSelected; - bool isStartingAttack; - bool isStuck; - bool isTraining; - bool isUnderStorm; - bool isUnderDarkSwarm; - bool isUnderDWeb; - bool isPowered; - bool isVisible[9]; - int buttonset; - - int lastAttackerPlayer; - bool recentlyAttacked; - int replayID; - }; -} diff --git a/bwapi-includes/BWAPI/Client/UnitImpl.h b/bwapi-includes/BWAPI/Client/UnitImpl.h deleted file mode 100644 index bf39806..0000000 --- a/bwapi-includes/BWAPI/Client/UnitImpl.h +++ /dev/null @@ -1,242 +0,0 @@ -#pragma once -#include -#include "UnitData.h" -#include - -namespace BWAPI -{ - class PlayerInterface; - typedef PlayerInterface *Player; - - class UnitImpl : public UnitInterface - { - private: - int id; - UnitType initialType; - int initialResources; - int initialHitPoints; - Position initialPosition; - int lastCommandFrame; - UnitCommand lastCommand; - public: - UnitData* self; - Unitset connectedUnits; - Unitset loadedUnits; - void clear(); - void saveInitialState(); - - UnitImpl(int _id); - - virtual int getID() const override; - virtual bool exists() const override; - virtual int getReplayID() const override; - virtual Player getPlayer() const override; - virtual UnitType getType() const override; - virtual Position getPosition() const override; - virtual double getAngle() const override; - virtual double getVelocityX() const override; - virtual double getVelocityY() const override; - virtual int getHitPoints() const override; - virtual int getShields() const override; - virtual int getEnergy() const override; - virtual int getResources() const override; - virtual int getResourceGroup() const override; - - virtual int getLastCommandFrame() const override; - virtual UnitCommand getLastCommand() const override; - virtual BWAPI::Player getLastAttackingPlayer() const override; - - virtual UnitType getInitialType() const override; - virtual Position getInitialPosition() const override; - virtual TilePosition getInitialTilePosition() const override; - virtual int getInitialHitPoints() const override; - virtual int getInitialResources() const override; - - virtual int getKillCount() const override; - virtual int getAcidSporeCount() const override; - virtual int getInterceptorCount() const override; - virtual int getScarabCount() const override; - virtual int getSpiderMineCount() const override; - virtual int getGroundWeaponCooldown() const override; - virtual int getAirWeaponCooldown() const override; - virtual int getSpellCooldown() const override; - virtual int getDefenseMatrixPoints() const override; - - virtual int getDefenseMatrixTimer() const override; - virtual int getEnsnareTimer() const override; - virtual int getIrradiateTimer() const override; - virtual int getLockdownTimer() const override; - virtual int getMaelstromTimer() const override; - virtual int getOrderTimer() const override; - virtual int getPlagueTimer() const override; - virtual int getRemoveTimer() const override; - virtual int getStasisTimer() const override; - virtual int getStimTimer() const override; - - virtual UnitType getBuildType() const override; - virtual UnitType::list getTrainingQueue() const override; - virtual TechType getTech() const override; - virtual UpgradeType getUpgrade() const override; - virtual int getRemainingBuildTime() const override; - virtual int getRemainingTrainTime() const override; - virtual int getRemainingResearchTime() const override; - virtual int getRemainingUpgradeTime() const override; - virtual Unit getBuildUnit() const override; - - virtual Unit getTarget() const override; - virtual Position getTargetPosition() const override; - virtual Order getOrder() const override; - virtual Unit getOrderTarget() const override; - virtual Position getOrderTargetPosition() const override; - virtual Order getSecondaryOrder() const override; - virtual Position getRallyPosition() const override; - virtual Unit getRallyUnit() const override; - virtual Unit getAddon() const override; - virtual Unit getNydusExit() const override; - virtual Unit getPowerUp() const override; - - virtual Unit getTransport() const override; - virtual Unitset getLoadedUnits() const override; - virtual Unit getCarrier() const override; - virtual Unitset getInterceptors() const override; - virtual Unit getHatchery() const override; - virtual Unitset getLarva() const override; - - virtual bool hasNuke() const override; - virtual bool isAccelerating() const override; - virtual bool isAttackFrame() const override; - virtual bool isAttacking() const override; - virtual bool isBeingGathered() const override; - virtual bool isBeingHealed() const override; - virtual bool isBlind() const override; - virtual bool isBraking() const override; - virtual bool isBurrowed() const override; - virtual bool isCarryingGas() const override; - virtual bool isCarryingMinerals() const override; - virtual bool isCloaked() const override; - virtual bool isCompleted() const override; - virtual bool isConstructing() const override; - virtual bool isDetected() const override; - virtual bool isGatheringGas() const override; - virtual bool isGatheringMinerals() const override; - virtual bool isHallucination() const override; - virtual bool isIdle() const override; - virtual bool isInterruptible() const override; - virtual bool isInvincible() const override; - virtual bool isLifted() const override; - virtual bool isMorphing() const override; - virtual bool isMoving() const override; - virtual bool isParasited() const override; - virtual bool isSelected() const override; - virtual bool isStartingAttack() const override; - virtual bool isStuck() const override; - virtual bool isTraining() const override; - virtual bool isUnderAttack() const override; - virtual bool isUnderDarkSwarm() const override; - virtual bool isUnderDisruptionWeb() const override; - virtual bool isUnderStorm() const override; - virtual bool isPowered() const override; - virtual bool isVisible(Player player = nullptr) const override; - virtual bool isTargetable() const override; - - virtual bool canCommand() const override; - virtual bool canCommandGrouped(bool checkCommandibility = true) const override; - virtual bool canTargetUnit(Unit targetUnit, bool checkCommandibility = true) const override; - - virtual bool canAttack(bool checkCommandibility = true) const override; - virtual bool canAttack(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canAttackGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canAttackGrouped(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canAttackMove(bool checkCommandibility = true) const override; - virtual bool canAttackMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canAttackUnit(bool checkCommandibility = true) const override; - virtual bool canAttackUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canAttackUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canAttackUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canBuild(bool checkCommandibility = true) const override; - virtual bool canBuild(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canBuild(UnitType uType, BWAPI::TilePosition tilePos, bool checkTargetUnitType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canBuildAddon(bool checkCommandibility = true) const override; - virtual bool canBuildAddon(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canTrain(bool checkCommandibility = true) const override; - virtual bool canTrain(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canMorph(bool checkCommandibility = true) const override; - virtual bool canMorph(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canResearch(bool checkCommandibility = true) const override; - virtual bool canResearch(TechType type, bool checkCanIssueCommandType = true) const override; - virtual bool canUpgrade(bool checkCommandibility = true) const override; - virtual bool canUpgrade(UpgradeType type, bool checkCanIssueCommandType = true) const override; - virtual bool canSetRallyPoint(bool checkCommandibility = true) const override; - virtual bool canSetRallyPoint(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canSetRallyPosition(bool checkCommandibility = true) const override; - virtual bool canSetRallyUnit(bool checkCommandibility = true) const override; - virtual bool canSetRallyUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canMove(bool checkCommandibility = true) const override; - virtual bool canMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canPatrol(bool checkCommandibility = true) const override; - virtual bool canPatrolGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canFollow(bool checkCommandibility = true) const override; - virtual bool canFollow(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canGather(bool checkCommandibility = true) const override; - virtual bool canGather(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canReturnCargo(bool checkCommandibility = true) const override; - virtual bool canHoldPosition(bool checkCommandibility = true) const override; - virtual bool canStop(bool checkCommandibility = true) const override; - virtual bool canRepair(bool checkCommandibility = true) const override; - virtual bool canRepair(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canBurrow(bool checkCommandibility = true) const override; - virtual bool canUnburrow(bool checkCommandibility = true) const override; - virtual bool canCloak(bool checkCommandibility = true) const override; - virtual bool canDecloak(bool checkCommandibility = true) const override; - virtual bool canSiege(bool checkCommandibility = true) const override; - virtual bool canUnsiege(bool checkCommandibility = true) const override; - virtual bool canLift(bool checkCommandibility = true) const override; - virtual bool canLand(bool checkCommandibility = true) const override; - virtual bool canLand(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canLoad(bool checkCommandibility = true) const override; - virtual bool canLoad(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canUnloadWithOrWithoutTarget(bool checkCommandibility = true) const override; - virtual bool canUnloadAtPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canUnload(bool checkCommandibility = true) const override; - virtual bool canUnload(Unit targetUnit, bool checkCanTargetUnit = true, bool checkPosition = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canUnloadAll(bool checkCommandibility = true) const override; - virtual bool canUnloadAllPosition(bool checkCommandibility = true) const override; - virtual bool canUnloadAllPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canRightClick(bool checkCommandibility = true) const override; - virtual bool canRightClick(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canRightClickGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canRightClickGrouped(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canRightClickPosition(bool checkCommandibility = true) const override; - virtual bool canRightClickPositionGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canRightClickUnit(bool checkCommandibility = true) const override; - virtual bool canRightClickUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canRightClickUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canRightClickUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canHaltConstruction(bool checkCommandibility = true) const override; - virtual bool canCancelConstruction(bool checkCommandibility = true) const override; - virtual bool canCancelAddon(bool checkCommandibility = true) const override; - virtual bool canCancelTrain(bool checkCommandibility = true) const override; - virtual bool canCancelTrainSlot(bool checkCommandibility = true) const override; - virtual bool canCancelTrainSlot(int slot, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canCancelMorph(bool checkCommandibility = true) const override; - virtual bool canCancelResearch(bool checkCommandibility = true) const override; - virtual bool canCancelUpgrade(bool checkCommandibility = true) const override; - virtual bool canUseTechWithOrWithoutTarget(bool checkCommandibility = true) const override; - virtual bool canUseTechWithOrWithoutTarget(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canUseTech(BWAPI::TechType tech, PositionOrUnit target = nullptr, bool checkCanTargetUnit = true, bool checkTargetsType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canUseTechWithoutTarget(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canUseTechUnit(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canUseTechUnit(BWAPI::TechType tech, Unit targetUnit, bool checkCanTargetUnit = true, bool checkTargetsUnits = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canUseTechPosition(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canUseTechPosition(BWAPI::TechType tech, Position target, bool checkTargetsPositions = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canPlaceCOP(bool checkCommandibility = true) const override; - virtual bool canPlaceCOP(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - - virtual bool canIssueCommandType(BWAPI::UnitCommandType ct, bool checkCommandibility = true) const override; - virtual bool canIssueCommandTypeGrouped(BWAPI::UnitCommandType ct, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - virtual bool canIssueCommand(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanBuildUnitType = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override; - virtual bool canIssueCommandGrouped(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override; - - virtual bool issueCommand(UnitCommand command) override; - }; -} diff --git a/bwapi-includes/BWAPI/Color.h b/bwapi-includes/BWAPI/Color.h deleted file mode 100644 index e162569..0000000 --- a/bwapi-includes/BWAPI/Color.h +++ /dev/null @@ -1,223 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// The Color object is used in drawing routines to specify the color to use. - /// - /// @note Starcraft uses a 256 color palette for rendering. Thus, the colors available are - /// limited to this palette. - /// - /// @see Colors - /// @ingroup TypeClasses - class Color : public Type - { - public: - /// A constructor that uses the color at the specified palette index. - /// - /// - /// The index of the color in the 256-color palette. - /// - Color(int id = 0); - - /// A constructor that uses the color index in the palette that is closest to the - /// given rgb values. On its first call, the colors in the palette will be sorted - /// for fast indexing. - /// - /// @note This function computes the distance of the RGB values and may not be accurate. - /// - /// - /// The amount of red. - /// - /// - /// The amount of green. - /// - /// - /// The amount of blue. - /// - Color(int red, int green, int blue); - - /// Retrieves the red component of the color. - /// - /// @returns integer containing the value of the red component. - int red() const; - - /// Retrieves the green component of the color. - /// - /// @returns integer containing the value of the green component. - int green() const; - - /// Retrieves the blue component of the color. - /// - /// @returns integer containing the value of the blue component. - int blue() const; - }; - - /// Namespace containing known colors. - /// @see Color - /// @ingroup Types - namespace Colors - { - /// The default color for Player 1. - extern const Color Red; - - /// The default color for Player 2. - extern const Color Blue; - - /// The default color for Player 3. - extern const Color Teal; - - /// The default color for Player 4. - extern const Color Purple; - - /// The default color for Player 5. - extern const Color Orange; - - /// The default color for Player 6. - extern const Color Brown; - - /// A bright white. Note that this is lighter than Player 7's white. - extern const Color White; - - /// The default color for Player 8. - extern const Color Yellow; - - /// The alternate color for Player 7 on Ice tilesets. - extern const Color Green; - - /// The default color for Neutral (Player 12). - extern const Color Cyan; - - /// The color black - extern const Color Black; - - /// The color grey - extern const Color Grey; - } - - /// Namespace containing text formatting codes. Such codes are used in calls - /// to Game::drawText, Game::printf, and Broodwar::operator<< - namespace Text - { - /// Enumeration of text formatting codes - enum Enum - { - /// Uses the previous color that was specified before the current one. - Previous = 1, - - /// Uses the default blueish color. This color is used in standard game messages. - Default = 2, - - /// A solid yellow. This yellow is used in notifications and is also the default - /// color when printing text to Broodwar. - Yellow = 3, - - /// A bright white. This is used for timers. - White = 4, - - /// A dark grey. This color code will override all color formatting that follows. - Grey = 5, - - /// A deep red. This color code is used for error messages. - Red = 6, - - /// A solid green. This color is used for sent messages and resource counters. - Green = 7, - - /// A type of red. This color is used to color the name of the red player. - BrightRed = 8, - - /// This code hides all text and formatting that follows. - Invisible = 11, - - /// A deep blue. This color is used to color the name of the blue player. - Blue = 14, - - /// A teal color. This color is used to color the name of the teal player. - Teal = 15, - - /// A deep purple. This color is used to color the name of the purple player. - Purple = 16, - - /// A solid orange. This color is used to color the name of the orange player. - Orange = 17, - - /// An alignment directive that aligns the text to the right side of the screen. - Align_Right = 18, - - /// An alignment directive that aligns the text to the center of the screen. - Align_Center = 19, - - /// @copydoc Invisible - Invisible2 = 20, - - /// A dark brown. This color is used to color the name of the brown player. - Brown = 21, - - /// A dirty white. This color is used to color the name of the white player. - PlayerWhite = 22, - - /// A deep yellow. This color is used to color the name of the yellow player. - PlayerYellow = 23, - - /// A dark green. This color is used to color the name of the green player. - DarkGreen = 24, - - /// A bright yellow. - LightYellow = 25, - - /// A cyan color. Similar to Default. - Cyan = 26, - - /// A tan color. - Tan = 27, - - /// A dark blueish color. - GreyBlue = 28, - - /// A type of Green. - GreyGreen = 29, - - /// A different type of Cyan. - GreyCyan = 30, - - /// A bright blue color. - Turquoise = 31 - }; - - /// Namespace containing text sizes. - namespace Size - { - /// Enumeration of available text sizes - enum Enum - { - /// The smallest text size in the game. - Small, - - /// The standard text size, used for most things in the game such as chat messages. - Default, - - /// A larger text size. This size is used for the in-game countdown timer seen in @CTF and @UMS game types. - Large, - - /// The largest text size in the game. - Huge - }; - } - - /// Standard output stream operator for text formatting codes. This is - /// used to correctly format the codes for output. - /// - /// - /// Reference to destination output stream. - /// - /// - /// Reference to the Text formatting code to insert into the output stream. - /// - /// - /// @returns Reference to the \p out parameter that was passed in. - std::ostream &operator << (std::ostream &out, const Text::Enum &t); - } - - static_assert(sizeof(Color) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/ComparisonFilter.h b/bwapi-includes/BWAPI/ComparisonFilter.h deleted file mode 100644 index 15aa49b..0000000 --- a/bwapi-includes/BWAPI/ComparisonFilter.h +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once -// Prevent warnings if someone includes windows.h -#ifdef max -#undef max -#endif - -#include -#include - -#include "UnaryFilter.h" - -#define BWAPI_COMPARE_FILTER_OP(op) UnaryFilter operator op(const RType &cmp) const \ - { return [=](PType v)->bool{ return (*this)(v) op cmp; }; } - -#define BWAPI_ARITHMATIC_FILTER_OP(op) template \ - CompareFilter > operator op(const T &other) const \ - { return [=](PType v)->int{ return (*this)(v) op other(v); }; } \ - CompareFilter > operator op(RType other) const \ - { return [=](PType v)->int{ return (*this)(v) op other; }; } - -namespace BWAPI -{ - /// The CompareFilter is a container in which a stored function predicate returns a - /// value. Arithmetic and bitwise operators will return a new CompareFilter that - /// applies the operation to the result of the original functor. If any relational operators are - /// used, then it creates a UnaryFilter that returns the result of the operation. - /// - /// @tparam PType - /// The parameter type, which is the type passed into the functor. - /// @tparam RType (optional) - /// The functor's return type. It is int by default. - /// @tparam Container (optional) - /// Storage container for the function predicate. It is std::function by default. - template < typename PType, typename RType=int, class Container = std::function > - class CompareFilter - { - private: - Container pred; - public: - // ctor - template - CompareFilter(const T &predicate) : pred(predicate) {} - - // Default copy/move ctor/assign and dtor - - // Comparison operators - BWAPI_COMPARE_FILTER_OP(==); - BWAPI_COMPARE_FILTER_OP(!=); - BWAPI_COMPARE_FILTER_OP(<=); - BWAPI_COMPARE_FILTER_OP(>=); - BWAPI_COMPARE_FILTER_OP(<); - BWAPI_COMPARE_FILTER_OP(>); - - // Arithmetic operators - BWAPI_ARITHMATIC_FILTER_OP(+); - BWAPI_ARITHMATIC_FILTER_OP(-); - BWAPI_ARITHMATIC_FILTER_OP(|); - BWAPI_ARITHMATIC_FILTER_OP(&); - BWAPI_ARITHMATIC_FILTER_OP(*); - BWAPI_ARITHMATIC_FILTER_OP(^); - - // Division - template - CompareFilter > operator /(const T &other) const - { - return [=](PType v)->int{ int rval = other(v); - return rval == 0 ? std::numeric_limits::max() : (*this)(v) / rval; - }; - }; - - // Modulus - template - CompareFilter > operator %(const T &other) const - { - return [=](PType v)->int{ int rval = other(v); - return rval == 0 ? 0 : (*this)(v) % rval; - }; - }; - - // call - inline RType operator()(PType u) const - { - return pred(u); - }; - - inline bool isValid() const - { - return (bool)pred; - }; - }; -} - diff --git a/bwapi-includes/BWAPI/Constants.h b/bwapi-includes/BWAPI/Constants.h deleted file mode 100644 index b5821df..0000000 --- a/bwapi-includes/BWAPI/Constants.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -namespace BWAPI -{ - /** Used for converting between TilePosition coordinates and Position coordinates. */ - #define TILE_SIZE 32 -} diff --git a/bwapi-includes/BWAPI/CoordinateType.h b/bwapi-includes/BWAPI/CoordinateType.h deleted file mode 100644 index cfbc28f..0000000 --- a/bwapi-includes/BWAPI/CoordinateType.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -namespace BWAPI -{ - /// Contains the coordinate type enumeration for relative drawing positions. - namespace CoordinateType - { - /// The coordinate type enumeration, used to indicate relative drawing positions. - enum Enum - { - /// A default value for uninitialized coordinate types. - None = 0, - - /// Positions::Origin (0,0) corresponds to the top left corner of the screen. - Screen = 1, - - /// Positions::Origin (0,0) corresponds to the top left corner of the map. - Map = 2, - - /// Positions::Origin (0,0) corresponds to the location of the mouse cursor. - Mouse = 3, - }; - } -} diff --git a/bwapi-includes/BWAPI/DamageType.h b/bwapi-includes/BWAPI/DamageType.h deleted file mode 100644 index 6c9d9b1..0000000 --- a/bwapi-includes/BWAPI/DamageType.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// Namespace containing damage types. - /// - /// @see DamageType - /// - /// [View on Liquipedia](http://wiki.teamliquid.net/starcraft/Damage_Type)
- /// [View on Starcraft Campendium (Official Website)](http://classic.battle.net/scc/gs/damage.shtml)
- /// [View on Starcraft Wikia](http://starcraft.wikia.com/wiki/Damage_types)
- namespace DamageTypes - { - /// Enumeration of damage types. - /// @see DamageType - namespace Enum - { - /// Enumeration of damage types. - /// @see DamageType - enum Enum - { - Independent, - Explosive, - Concussive, - Normal, - Ignore_Armor, - None, - Unknown, - MAX - }; - } - } - /// Damage types are used in Broodwar to determine the amount of damage that will be - /// done to a unit. This corresponds with UnitSizeType to determine the damage done to - /// a unit. - /// - /// @see WeaponType, DamageTypes, UnitSizeType - /// - /// [View on Liquipedia](http://wiki.teamliquid.net/starcraft/Damage_Type)
- /// [View on Starcraft Campendium (Official Website)](http://classic.battle.net/scc/gs/damage.shtml)
- /// [View on Starcraft Wikia](http://starcraft.wikia.com/wiki/Damage_types)
- /// - /// @ingroup TypeClasses - class DamageType : public Type - { - public: - /// @copydoc Type::Type(int) - DamageType(int id = DamageTypes::Enum::None); - }; - - /// @ingroup Types - namespace DamageTypes - { - /// Retrieves the set of all the DamageTypes. - /// - /// @returns Set of DamageTypes. - const DamageType::set& allDamageTypes(); - - 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; - } - - static_assert(sizeof(DamageType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/Error.h b/bwapi-includes/BWAPI/Error.h deleted file mode 100644 index 79b7d36..0000000 --- a/bwapi-includes/BWAPI/Error.h +++ /dev/null @@ -1,106 +0,0 @@ -#pragma once -#include -#include - -namespace BWAPI -{ - class UnitType; - - /// Namespace containing error codes - /// @see Error - namespace Errors - { - /// Enumeration of Error types. - /// @see Error - namespace Enum - { - /// Enumeration of Error types. - /// @see Error - enum Enum - { - Unit_Does_Not_Exist, - Unit_Not_Visible, - Unit_Not_Owned, - Unit_Busy, - Incompatible_UnitType, - Incompatible_TechType, - Incompatible_State, - Already_Researched, - Fully_Upgraded, - Currently_Researching, - Currently_Upgrading, - Insufficient_Minerals, - Insufficient_Gas, - Insufficient_Supply, - Insufficient_Energy, - Insufficient_Tech, - Insufficient_Ammo, - Insufficient_Space, - Invalid_Tile_Position, - Unbuildable_Location, - Unreachable_Location, - Out_Of_Range, - Unable_To_Hit, - Access_Denied, - File_Not_Found, - Invalid_Parameter, - None, - Unknown, - MAX - }; - }; - }; - - /// The Error object is generally used to determine why certain functions in BWAPI - /// have failed. - /// - /// For example, you may not have enough resources to construct a unit. - /// @see Game::getLastError, Game::setLastError, Errors - /// @ingroup TypeClasses - class Error : public Type - { - public: - /// @copydoc Type::Type(int) - Error(int id = Errors::Enum::None); - }; - - /// @ingroup Types - namespace Errors - { - /// Retrieves the set of all the error codes. - /// - /// @returns Set of error types. - const Error::set& allErrors(); - - extern const Error Unit_Does_Not_Exist; - extern const Error Unit_Not_Visible; - extern const Error Unit_Not_Owned; - extern const Error Unit_Busy; - extern const Error Incompatible_UnitType; - extern const Error Incompatible_TechType; - extern const Error Incompatible_State; - extern const Error Already_Researched; - extern const Error Fully_Upgraded; - extern const Error Currently_Researching; - extern const Error Currently_Upgrading; - extern const Error Insufficient_Minerals; - extern const Error Insufficient_Gas; - extern const Error Insufficient_Supply; - extern const Error Insufficient_Energy; - extern const Error Insufficient_Tech; - extern const Error Insufficient_Ammo; - extern const Error Insufficient_Space; - extern const Error Invalid_Tile_Position; - extern const Error Unbuildable_Location; - extern const Error Unreachable_Location; - extern const Error Out_Of_Range; - extern const Error Unable_To_Hit; - extern const Error Access_Denied; - extern const Error File_Not_Found; - extern const Error Invalid_Parameter; - extern const Error None; - extern const Error Unknown; - } - - static_assert(sizeof(Error) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/Event.h b/bwapi-includes/BWAPI/Event.h deleted file mode 100644 index 4828865..0000000 --- a/bwapi-includes/BWAPI/Event.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once -#include -#include -#include - -#include - -namespace BWAPI -{ - // Forward Declarations - class PlayerInterface; - typedef PlayerInterface* Player; - - class Event - { - public: - Event() = default; - ~Event(); - Event(const Event& other); - Event(Event&& other); - Event& operator=(const Event& other); - Event& operator=(Event &&other); - bool operator==(const Event& other) const; - static Event MatchStart(); - static Event MatchEnd(bool isWinner); - static Event MatchFrame(); - static Event MenuFrame(); - static Event SendText(const char* text = nullptr); - static Event ReceiveText(Player player, const char* text = nullptr); - static Event PlayerLeft(Player player); - static Event NukeDetect(Position target); - static Event UnitDiscover(Unit unit); - static Event UnitEvade(Unit unit); - static Event UnitShow(Unit unit); - static Event UnitHide(Unit unit); - static Event UnitCreate(Unit unit); - static Event UnitDestroy(Unit unit); - static Event UnitMorph(Unit unit); - static Event UnitRenegade(Unit unit); - static Event SaveGame(const char* gameName = nullptr); - static Event UnitComplete(Unit unit); - EventType::Enum getType() const; - Position getPosition() const; - const std::string& getText() const; - Unit getUnit() const; - Player getPlayer() const; - bool isWinner() const; - - Event& setType(EventType::Enum type); - Event& setPosition(Position position); - Event& setText(const char* text); - Event& setUnit(Unit unit); - Event& setPlayer(Player player); - Event& setWinner(bool isWinner); - //static Event TriggerAction(); - private: - Position position = Positions::None; - std::string* text = nullptr; - Unit unit = nullptr; - Player player = nullptr; - EventType::Enum type = EventType::None; - bool winner = false; - }; -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/EventType.h b/bwapi-includes/BWAPI/EventType.h deleted file mode 100644 index aeef475..0000000 --- a/bwapi-includes/BWAPI/EventType.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -namespace BWAPI -{ - /// Contains a list of event types supported by BWAPI. - namespace EventType - { - /// Enumeration of callback event types. - enum Enum - { - MatchStart, - MatchEnd, - MatchFrame, - MenuFrame, - SendText, - ReceiveText, - PlayerLeft, - NukeDetect, - UnitDiscover, - UnitEvade, - UnitShow, - UnitHide, - UnitCreate, - UnitDestroy, - UnitMorph, - UnitRenegade, - SaveGame, - UnitComplete, - //TriggerAction, - None - }; - } -} diff --git a/bwapi-includes/BWAPI/ExplosionType.h b/bwapi-includes/BWAPI/ExplosionType.h deleted file mode 100644 index 1002ca8..0000000 --- a/bwapi-includes/BWAPI/ExplosionType.h +++ /dev/null @@ -1,96 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// Namespace containing explosion types. - /// @see ExplosionType - namespace ExplosionTypes - { - /// Enumeration of explosion types. - /// @see ExplosionType - namespace Enum - { - /// Enumeration of explosion types. - /// @see ExplosionType - enum Enum - { - None = 0, - Normal, - Radial_Splash, - Enemy_Splash, - Lockdown, - Nuclear_Missile, - Parasite, - Broodlings, - EMP_Shockwave, - Irradiate, - Ensnare, - Plague, - Stasis_Field, - Dark_Swarm, - Consume, - Yamato_Gun, - Restoration, - Disruption_Web, - Corrosive_Acid, - Mind_Control, - Feedback, - Optical_Flare, - Maelstrom, - Unused, - Air_Splash, - Unknown, - MAX - }; - }; - }; - /// A representation of a weapon's explosion type. This indicates how the - /// weapon behaves, such as if it deals splash damage or causes an effect to occur. - /// - /// @see ExplosionTypes - /// @ingroup TypeClasses - class ExplosionType : public Type - { - public: - /// @copydoc Type::Type(int) - ExplosionType(int id = ExplosionTypes::Enum::None); - }; - - /// @ingroup Types - namespace ExplosionTypes - { - /// Retrieves the set of all valid ExplosionTypes. - /// - /// @returns Set of ExplosionTypes. - const ExplosionType::set& allExplosionTypes(); - - 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; - } - - static_assert(sizeof(ExplosionType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/Filters.h b/bwapi-includes/BWAPI/Filters.h deleted file mode 100644 index b63fcb5..0000000 --- a/bwapi-includes/BWAPI/Filters.h +++ /dev/null @@ -1,476 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include - -namespace BWAPI -{ - // forwards - class PlayerInterface; - typedef PlayerInterface *Player; - class UnitType; - class UnitInterface; - typedef UnitInterface *Unit; - - // typedefs - typedef UnaryFilter UnitFilter; - typedef UnaryFilter PtrUnitFilter; - typedef BestFilter BestUnitFilter; - typedef CompareFilter PtrIntCompareUnitFilter; - - namespace Filter - { - /// A unary filter that checks if the unit type is a transport. - extern const PtrUnitFilter IsTransport; - - /// @see BWAPI::UnitType::canProduce - extern const PtrUnitFilter CanProduce; - - /// @see BWAPI::UnitType::canAttack - extern const PtrUnitFilter CanAttack; - - /// @see BWAPI::UnitType::canMove - extern const PtrUnitFilter CanMove; - - /// @see BWAPI::UnitType::isFlying - extern const PtrUnitFilter IsFlyer; - - /// @see BWAPI::UnitInterface::IsFlying - extern const PtrUnitFilter IsFlying; - - /// @see BWAPI::UnitType::regeneratesHP - extern const PtrUnitFilter RegeneratesHP; - - /// @see BWAPI::UnitType::isSpellcaster - extern const PtrUnitFilter IsSpellcaster; - - /// @see BWAPI::UnitType::hasPermanentCloak - extern const PtrUnitFilter HasPermanentCloak; - - /// @see BWAPI::UnitType::isOrganic - extern const PtrUnitFilter IsOrganic; - - /// @see BWAPI::UnitType::isMechanical - extern const PtrUnitFilter IsMechanical; - - /// @see BWAPI::UnitType::isRobotic - extern const PtrUnitFilter IsRobotic; - - /// @see BWAPI::UnitType::isDetector - extern const PtrUnitFilter IsDetector; - - /// @see BWAPI::UnitType::isResourceContainer - extern const PtrUnitFilter IsResourceContainer; - - /// @see BWAPI::UnitType::isResourceDepot - extern const PtrUnitFilter IsResourceDepot; - - /// @see BWAPI::UnitType::isRefinery - extern const PtrUnitFilter IsRefinery; - - /// @see BWAPI::UnitType::isWorker - extern const PtrUnitFilter IsWorker; - - /// @see BWAPI::UnitType::requiresPsi - extern const PtrUnitFilter RequiresPsi; - - /// @see BWAPI::UnitType::requiresCreep - extern const PtrUnitFilter RequiresCreep; - - /// @see BWAPI::UnitType::isBurrowable - extern const PtrUnitFilter IsBurrowable; - - /// @see BWAPI::UnitType::isCloakable - extern const PtrUnitFilter IsCloakable; - - /// @see BWAPI::UnitType::isBuilding - extern const PtrUnitFilter IsBuilding; - - /// @see BWAPI::UnitType::isAddon - extern const PtrUnitFilter IsAddon; - - /// @see BWAPI::UnitType::isFlyingBuilding - extern const PtrUnitFilter IsFlyingBuilding; - - /// @see BWAPI::UnitType::isNeutral - extern const PtrUnitFilter IsNeutral; - - /// @see BWAPI::UnitType::isHero - extern const PtrUnitFilter IsHero; - - /// @see BWAPI::UnitType::isPowerup - extern const PtrUnitFilter IsPowerup; - - /// @see BWAPI::UnitType::isBeacon - extern const PtrUnitFilter IsBeacon; - - /// @see BWAPI::UnitType::isFlagBeacon - extern const PtrUnitFilter IsFlagBeacon; - - /// @see BWAPI::UnitType::isSpecialBuilding - extern const PtrUnitFilter IsSpecialBuilding; - - /// @see BWAPI::UnitType::isSpell - extern const PtrUnitFilter IsSpell; - - /// @see BWAPI::UnitType::producesLarva - extern const PtrUnitFilter ProducesLarva; - - /// @see BWAPI::UnitType::isMineralField - extern const PtrUnitFilter IsMineralField; - - /// @see BWAPI::UnitType::isCritter - extern const PtrUnitFilter IsCritter; - - /// @see BWAPI::UnitType::canBuildAddon - extern const PtrUnitFilter CanBuildAddon; - - /// @see BWAPI::UnitInterface::getHitPoints - extern const PtrIntCompareUnitFilter HP; - - /// @see BWAPI::UnitType::maxHitPoints - extern const PtrIntCompareUnitFilter MaxHP; - - /// A comparison filter that retrieves the unit's HP percentage. The formula - /// is HP*100/MaxHP. - extern const PtrIntCompareUnitFilter HP_Percent; - - /// @see BWAPI::UnitInterface::getShields - extern const PtrIntCompareUnitFilter Shields; - - /// @see BWAPI::UnitType::maxShields - extern const PtrIntCompareUnitFilter MaxShields; - - /// A comparison filter that retrieves the unit's shields percentage. The - /// formula is Shields*100/MaxShields. - extern const PtrIntCompareUnitFilter Shields_Percent; - - /// @see BWAPI::UnitInterface::getEnergy - extern const PtrIntCompareUnitFilter Energy; - - /// @see BWAPI::PlayerInterface::maxEnergy - extern const PtrIntCompareUnitFilter MaxEnergy; - - /// A comparison filter that retrieves the unit's energy percentage. The - /// formula is Energy*100/MaxEnergy. - extern const PtrIntCompareUnitFilter Energy_Percent; - - /// @see BWAPI::PlayerInterface::armor - extern const PtrIntCompareUnitFilter Armor; - - /// @see BWAPI::UnitType::armorUpgrade - extern const CompareFilter ArmorUpgrade; - - /// @see BWAPI::UnitType::mineralPrice - extern const PtrIntCompareUnitFilter MineralPrice; - - /// @see BWAPI::UnitType::gasPrice - extern const PtrIntCompareUnitFilter GasPrice; - - /// @see BWAPI::UnitType::buildTime - extern const PtrIntCompareUnitFilter BuildTime; - - /// @see BWAPI::UnitType::supplyRequired - extern const PtrIntCompareUnitFilter SupplyRequired; - - /// @see BWAPI::UnitType::supplyProvided - extern const PtrIntCompareUnitFilter SupplyProvided; - - /// @see BWAPI::UnitType::spaceRequired - extern const PtrIntCompareUnitFilter SpaceRequired; - - /// @see BWAPI::UnitInterface::getSpaceRemaining - extern const PtrIntCompareUnitFilter SpaceRemaining; - - /// @see BWAPI::UnitType::spaceProvided - extern const PtrIntCompareUnitFilter SpaceProvided; - - /// @see BWAPI::UnitType::buildScore - extern const PtrIntCompareUnitFilter BuildScore; - - /// @see BWAPI::UnitType::destroyScore - extern const PtrIntCompareUnitFilter DestroyScore; - - /// @see BWAPI::PlayerInterface::topSpeed - extern const CompareFilter TopSpeed; - - /// @see BWAPI::PlayerInterface::sightRange - extern const PtrIntCompareUnitFilter SightRange; - - /// @see BWAPI::PlayerInterface::weaponDamageCooldown - extern const PtrIntCompareUnitFilter WeaponCooldown; - - /// @see BWAPI::UnitType::size - extern const CompareFilter SizeType; - - /// @see BWAPI::UnitType::groundWeapon - extern const CompareFilter GroundWeapon; - - /// @see BWAPI::UnitType::airWeapon - extern const CompareFilter AirWeapon; - - /// @see BWAPI::UnitInterface::getType - extern const CompareFilter GetType; - - /// @see BWAPI::UnitType::getRace - extern const CompareFilter GetRace; - - /// @see BWAPI::UnitInterface::getPlayer - extern const CompareFilter GetPlayer; - - /// @see BWAPI::UnitInterface::getResources - extern const PtrIntCompareUnitFilter Resources; - - /// @see BWAPI::UnitInterface::getResourceGroup - extern const PtrIntCompareUnitFilter ResourceGroup; - - /// @see BWAPI::UnitInterface::getAcidSporeCount - extern const PtrIntCompareUnitFilter AcidSporeCount; - - /// @see BWAPI::UnitInterface::getInterceptorCount - extern const PtrIntCompareUnitFilter InterceptorCount; - - /// @see BWAPI::UnitInterface::getScarabCount - extern const PtrIntCompareUnitFilter ScarabCount; - - /// @see BWAPI::UnitInterface::getSpiderMineCount - extern const PtrIntCompareUnitFilter SpiderMineCount; - - /// @see BWAPI::UnitInterface::getGroundWeaponCooldown - extern const PtrIntCompareUnitFilter MaxWeaponCooldown; - - /// @see BWAPI::UnitInterface::getSpellCooldown - extern const PtrIntCompareUnitFilter SpellCooldown; - - /// @see BWAPI::UnitInterface::getDefenseMatrixPoints - extern const PtrIntCompareUnitFilter DefenseMatrixPoints; - - /// @see BWAPI::UnitInterface::getDefenseMatrixTimer - extern const PtrIntCompareUnitFilter DefenseMatrixTime; - - /// @see BWAPI::UnitInterface::getEnsnareTimer - extern const PtrIntCompareUnitFilter EnsnareTime; - - /// @see BWAPI::UnitInterface::getIrradiateTimer - extern const PtrIntCompareUnitFilter IrradiateTime; - - /// @see BWAPI::UnitInterface::getLockdownTimer - extern const PtrIntCompareUnitFilter LockdownTime; - - /// @see BWAPI::UnitInterface::getMaelstromTimer - extern const PtrIntCompareUnitFilter MaelstromTime; - - /// @see BWAPI::UnitInterface::getOrderTimer - extern const PtrIntCompareUnitFilter OrderTime; - - /// @see BWAPI::UnitInterface::getPlagueTimer - extern const PtrIntCompareUnitFilter PlagueTimer; - - /// @see BWAPI::UnitInterface::getRemoveTimer - extern const PtrIntCompareUnitFilter RemoveTime; - - /// @see BWAPI::UnitInterface::getStasisTimer - extern const PtrIntCompareUnitFilter StasisTime; - - /// @see BWAPI::UnitInterface::getStimTimer - extern const PtrIntCompareUnitFilter StimTime; - - /// @see BWAPI::UnitInterface::getBuildType - extern const CompareFilter BuildType; - - /// @see BWAPI::UnitInterface::getRemainingBuildTime - extern const PtrIntCompareUnitFilter RemainingBuildTime; - - /// @see BWAPI::UnitInterface::getRemainingTrainTime - extern const PtrIntCompareUnitFilter RemainingTrainTime; - - /// @see BWAPI::UnitInterface::getTarget - extern const CompareFilter Target; - - /// @see BWAPI::UnitInterface::getOrder - extern const CompareFilter CurrentOrder; - - /// @see BWAPI::UnitInterface::getSecondaryOrder - extern const CompareFilter SecondaryOrder; - - /// @see BWAPI::UnitInterface::getOrderTarget - extern const CompareFilter OrderTarget; - - /// @see BWAPI::UnitInterface::getLeft - extern const PtrIntCompareUnitFilter GetLeft; - - /// @see BWAPI::UnitInterface::getTop - extern const PtrIntCompareUnitFilter GetTop; - - /// @see BWAPI::UnitInterface::getRight - extern const PtrIntCompareUnitFilter GetRight; - - /// @see BWAPI::UnitInterface::getBottom - extern const PtrIntCompareUnitFilter GetBottom; - - /// @see BWAPI::UnitInterface::exists - extern const PtrUnitFilter Exists; - - /// @see BWAPI::UnitInterface::isAttacking - extern const PtrUnitFilter IsAttacking; - - /// @see BWAPI::UnitInterface::isBeingConstructed - extern const PtrUnitFilter IsBeingConstructed; - - /// @see BWAPI::UnitInterface::isBeingGathered - extern const PtrUnitFilter IsBeingGathered; - - /// @see BWAPI::UnitInterface::isBeingHealed - extern const PtrUnitFilter IsBeingHealed; - - /// @see BWAPI::UnitInterface::isBlind - extern const PtrUnitFilter IsBlind; - - /// @see BWAPI::UnitInterface::isBraking - extern const PtrUnitFilter IsBraking; - - /// @see BWAPI::UnitInterface::isBurrowed - extern const PtrUnitFilter IsBurrowed; - - /// @see BWAPI::UnitInterface::isCarryingGas - extern const PtrUnitFilter IsCarryingGas; - - /// @see BWAPI::UnitInterface::isCarryingMinerals - extern const PtrUnitFilter IsCarryingMinerals; - - /// A unary filter that checks if IsCarryingGas or IsCarryingMinerals return true. - extern const PtrUnitFilter IsCarryingSomething; - - /// @see BWAPI::UnitInterface::isCloaked - extern const PtrUnitFilter IsCloaked; - - /// @see BWAPI::UnitInterface::isCompleted - extern const PtrUnitFilter IsCompleted; - - /// @see BWAPI::UnitInterface::isConstructing - extern const PtrUnitFilter IsConstructing; - - /// @see BWAPI::UnitInterface::isDefenseMatrixed - extern const PtrUnitFilter IsDefenseMatrixed; - - /// @see BWAPI::UnitInterface::isDetected - extern const PtrUnitFilter IsDetected; - - /// @see BWAPI::UnitInterface::isEnsnared - extern const PtrUnitFilter IsEnsnared; - - /// @see BWAPI::UnitInterface::isFollowing - extern const PtrUnitFilter IsFollowing; - - /// @see BWAPI::UnitInterface::isGatheringGas - extern const PtrUnitFilter IsGatheringGas; - - /// @see BWAPI::UnitInterface::isGatheringMinerals - extern const PtrUnitFilter IsGatheringMinerals; - - /// @see BWAPI::UnitInterface::isHallucination - extern const PtrUnitFilter IsHallucination; - - /// @see BWAPI::UnitInterface::isHoldingPosition - extern const PtrUnitFilter IsHoldingPosition; - - /// @see BWAPI::UnitInterface::isIdle - extern const PtrUnitFilter IsIdle; - - /// @see BWAPI::UnitInterface::isInterruptible - extern const PtrUnitFilter IsInterruptible; - - /// @see BWAPI::UnitInterface::isInvincible - extern const PtrUnitFilter IsInvincible; - - /// @see BWAPI::UnitInterface::isIrradiated - extern const PtrUnitFilter IsIrradiated; - - /// @see BWAPI::UnitInterface::isLifted - extern const PtrUnitFilter IsLifted; - - /// @see BWAPI::UnitInterface::isLoaded - extern const PtrUnitFilter IsLoaded; - - /// @see BWAPI::UnitInterface::isLockedDown - extern const PtrUnitFilter IsLockedDown; - - /// @see BWAPI::UnitInterface::isMaelstrommed - extern const PtrUnitFilter IsMaelstrommed; - - /// @see BWAPI::UnitInterface::isMorphing - extern const PtrUnitFilter IsMorphing; - - /// @see BWAPI::UnitInterface::isMoving - extern const PtrUnitFilter IsMoving; - - /// @see BWAPI::UnitInterface::isParasited - extern const PtrUnitFilter IsParasited; - - /// @see BWAPI::UnitInterface::isPatrolling - extern const PtrUnitFilter IsPatrolling; - - /// @see BWAPI::UnitInterface::isPlagued - extern const PtrUnitFilter IsPlagued; - - /// @see BWAPI::UnitInterface::isRepairing - extern const PtrUnitFilter IsRepairing; - - /// @see BWAPI::UnitInterface::isResearching - extern const PtrUnitFilter IsResearching; - - /// @see BWAPI::UnitInterface::isSieged - extern const PtrUnitFilter IsSieged; - - /// @see BWAPI::UnitInterface::isStartingAttack - extern const PtrUnitFilter IsStartingAttack; - - /// @see BWAPI::UnitInterface::isStasised - extern const PtrUnitFilter IsStasised; - - /// @see BWAPI::UnitInterface::isStimmed - extern const PtrUnitFilter IsStimmed; - - /// @see BWAPI::UnitInterface::isStuck - extern const PtrUnitFilter IsStuck; - - /// @see BWAPI::UnitInterface::isTraining - extern const PtrUnitFilter IsTraining; - - /// @see BWAPI::UnitInterface::isUnderAttack - extern const PtrUnitFilter IsUnderAttack; - - /// @see BWAPI::UnitInterface::isUnderDarkSwarm - extern const PtrUnitFilter IsUnderDarkSwarm; - - /// @see BWAPI::UnitInterface::isUnderDisruptionWeb - extern const PtrUnitFilter IsUnderDisruptionWeb; - - /// @see BWAPI::UnitInterface::isUnderStorm - extern const PtrUnitFilter IsUnderStorm; - - /// @see BWAPI::UnitInterface::isPowered - extern const PtrUnitFilter IsPowered; - - /// @see BWAPI::UnitInterface::isVisible - extern const PtrUnitFilter IsVisible; - - /// A unary filter that checks if the current unit is an enemy of the BWAPI player. - /// @note This will always be false when the BWAPI Player is unspecified, such as in a replay. - extern const PtrUnitFilter IsEnemy; - - /// A unary filter that checks if the current unit is an ally of the BWAPI player. - /// @note This will always be false when the BWAPI Player is unspecified, such as in a replay. - extern const PtrUnitFilter IsAlly; - - /// A unary filter that checks if the current unit is owned by the BWAPI player. - /// @note This will always be false when the BWAPI Player is unspecified, such as in a replay. - extern const PtrUnitFilter IsOwned; - } -} - diff --git a/bwapi-includes/BWAPI/Flag.h b/bwapi-includes/BWAPI/Flag.h deleted file mode 100644 index def9295..0000000 --- a/bwapi-includes/BWAPI/Flag.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -namespace BWAPI -{ - /// Contains flag enumerations for BWAPI. - /// @see Game::enableFlag, Game::isFlagEnabled - namespace Flag - { - /// Contains flag enumerations for BWAPI. - /// @see Game::enableFlag, Game::isFlagEnabled - 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, - - /// The maximum number of different flags available. - Max - }; - } -} diff --git a/bwapi-includes/BWAPI/Force.h b/bwapi-includes/BWAPI/Force.h deleted file mode 100644 index 56ac1ef..0000000 --- a/bwapi-includes/BWAPI/Force.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once -#include -#include - -namespace BWAPI -{ - // Forward Declarations - class Playerset; - - class ForceInterface; - typedef ForceInterface *Force; - - /// The Force class is used to get information about each force in a match. - /// Normally this is considered a team. - /// - /// @note It is not called a team because players on the same force do not necessarily need - /// to be allied at the beginning of a match. - /// - /// @ingroup Interface - class ForceInterface : public Interface - { - protected: - virtual ~ForceInterface() {}; - public : - /// Retrieves the unique ID that represents this Force. - /// - /// @returns - /// An integer containing the ID for the Force. - virtual int getID() const = 0; - - /// Retrieves the name of the Force. - /// - /// @returns - /// A std::string object containing the name of the force. - /// - /// Example usage: - /// @code - /// BWAPI::Force myForce = BWAPI::Broodwar->self()->getForce(); - /// if ( myForce->getName() == "Observers" ) - /// BWAPI::Broodwar << "Looks like we're observing a match." << std::endl; - /// @endcode - /// - /// @note Don't forget to use std::string::c_str() when passing this parameter to - /// Game::sendText and other variadic functions. - virtual std::string getName() const = 0; - - /// Retrieves the set of players that belong to this Force. - /// - /// @returns - /// A Playerset object containing the players that are part of this Force. - /// - /// Example usage: - /// @code - /// // Get the enemy force, but make sure we have an enemy - /// BWAPI::Force myEnemyForce = BWAPI::Broodwar->enemy() ? BWAPI::Broodwar->enemy()->getForce() : nullptr; - /// if ( myEnemyForce != nullptr ) - /// { - /// Broodwar << "The allies of my enemy are..." << std::endl; - /// for ( auto i = myEnemyForce.begin(); i != myEnemyForce.end(); ++i ) - /// Broodwar << " - " << i->getName() << std::endl; - /// } - /// @endcode - virtual Playerset getPlayers() const = 0; - }; -} diff --git a/bwapi-includes/BWAPI/Forceset.h b/bwapi-includes/BWAPI/Forceset.h deleted file mode 100644 index 5a94dab..0000000 --- a/bwapi-includes/BWAPI/Forceset.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "SetContainer.h" - -namespace BWAPI -{ - // Forward Declarations - class ForceInterface; - typedef ForceInterface *Force; - class Playerset; - - /// A container that holds a group of Forces. - /// - /// @see BWAPI::Force - class Forceset : public SetContainer> - { - public: - - /// @copydoc ForceInterface::getPlayers - Playerset getPlayers() const; - }; -} - diff --git a/bwapi-includes/BWAPI/Game.h b/bwapi-includes/BWAPI/Game.h deleted file mode 100644 index 2661abd..0000000 --- a/bwapi-includes/BWAPI/Game.h +++ /dev/null @@ -1,1743 +0,0 @@ -#pragma once -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace BWAPI -{ - // Forward Declarations - class Bulletset; - class Color; - class Event; - class ForceInterface; - typedef ForceInterface *Force; - class Forceset; - class GameType; - class PlayerInterface; - typedef PlayerInterface *Player; - class Playerset; - class Race; - - class RegionInterface; - typedef RegionInterface *Region; - - class Regionset; - class TechType; - class UnitCommand; - class Unitset; - class UpgradeType; - - /// The abstract Game class is implemented by BWAPI and is the primary means of obtaining all - /// game state information from Starcraft Broodwar. Game state information includes all units, - /// resources, players, forces, bullets, terrain, fog of war, regions, etc. - /// - /// @ingroup Interface - class Game : public Interface - { - protected: - virtual ~Game() {}; - - Game& operator=(const Game& other) = delete; - Game& operator=(Game&& other) = delete; - public : - /// Retrieves the set of all teams/forces. Forces are commonly seen in @UMS - /// game types and some others such as @TvB and the team versions of game types. - /// - /// @returns Forceset containing all forces in the game. - virtual const Forceset& getForces() const = 0; - - /// Retrieves the set of all players in the match. This includes the neutral - /// player, which owns all the resources and critters by default. - /// - /// @returns Playerset containing all players in the game. - virtual const Playerset& getPlayers() const = 0; - - /// Retrieves the set of all accessible units. If - /// Flag::CompleteMapInformation is enabled, then the set also includes units that are not - /// visible to the player. - /// - /// @note Units that are inside refineries are not included in this set. - /// - /// @returns Unitset containing all known units in the game. - virtual const Unitset& getAllUnits() const = 0; - - /// Retrieves the set of all accessible @minerals in the game. - /// - /// @returns Unitset containing @minerals - virtual const Unitset& getMinerals() const = 0; - - /// Retrieves the set of all accessible @geysers in the game. - /// - /// @returns Unitset containing @geysers - virtual const Unitset& getGeysers() const = 0; - - /// Retrieves the set of all accessible neutral units in the game. This - /// includes @minerals, @geysers, and @critters. - /// - /// @returns Unitset containing all neutral units. - virtual const Unitset& getNeutralUnits() const = 0; - - /// Retrieves the set of all @minerals that were available at the beginning of the - /// game. - /// - /// @note This set includes resources that have been mined out or are inaccessible. - /// - /// @returns Unitset containing static @minerals - virtual const Unitset& getStaticMinerals() const = 0; - - /// Retrieves the set of all @geysers that were available at the beginning of the - /// game. - /// - /// @note This set includes resources that are inaccessible. - /// - /// @returns Unitset containing static @geysers - virtual const Unitset& getStaticGeysers() const = 0; - - /// Retrieves the set of all units owned by the neutral player (resources, critters, - /// etc.) that were available at the beginning of the game. - /// - /// @note This set includes units that are inaccessible. - /// - /// @returns Unitset containing static neutral units - virtual const Unitset& getStaticNeutralUnits() const = 0; - - /// Retrieves the set of all accessible bullets. - /// - /// @returns Bulletset containing all accessible Bullet objects. - virtual const Bulletset& getBullets() const = 0; - - /// Retrieves the set of all accessible @Nuke dots. - /// - /// @note Nuke dots are the red dots painted by a @Ghost when using the nuclear strike ability. - /// - /// @returns Set of Positions giving the coordinates of nuke locations. - virtual const Position::list& getNukeDots() const = 0; - - /// Retrieves the list of all unhandled game events. - /// - /// @returns std::list containing Event objects. - virtual const std::list< Event >& getEvents() const = 0; - - /// Retrieves the Force interface object associated with a given identifier. - /// - /// - /// The identifier for the Force object. - /// - /// - /// @returns Force interface object mapped to the given \p forceID. - /// @retval nullptr if the given identifier is invalid. - virtual Force getForce(int forceID) const = 0; - - /// Retrieves the Player interface object associated with a given identifier. - /// - /// - /// The identifier for the Player object. - /// - /// - /// @returns Player interface object mapped to the given \p playerID. - /// @retval nullptr if the given identifier is invalid. - virtual Player getPlayer(int playerID) const = 0; - - /// Retrieves the Unit interface object associated with a given identifier. - /// - /// - /// The identifier for the Unit object. - /// - /// - /// @returns Unit interface object mapped to the given \p unitID. - /// @retval nullptr if the given identifier is invalid. - virtual Unit getUnit(int unitID) const = 0; - - /// Retrieves a Unit interface object from a given unit index. The value - /// given as an index maps directly to Broodwar's unit array index and matches the index found - /// in replay files. In order to use this function, CompleteMapInformation must be enabled. - /// - /// - /// The unitIndex to identify the Unit with. A valid index is 0 <= unitIndex & 0x7FF < 1700. - /// - /// - /// @returns Unit interface object that matches the given \p unitIndex. - /// @retval nullptr if the given index is invalid. - virtual Unit indexToUnit(int unitIndex) const = 0; - - /// Retrieves the Region interface object associated with a given identifier. - /// - /// - /// The identifier for the Region object. - /// - /// - /// @returns Region interface object mapped to the given \p regionID. - /// @retval nullptr if the given ID is invalid. - virtual Region getRegion(int regionID) const = 0; - - /// Retrieves the GameType of the current game. - /// - /// @returns GameType indicating the rules of the match. - /// @see GameType - virtual GameType getGameType() const = 0; - - /// Retrieves the current latency setting that the game is set to. Latency - /// indicates the delay between issuing a command and having it processed. - /// - /// @returns The latency setting of the game, which is of Latency::Enum. - /// @see Latency::Enum - /// - /// @todo Change return type to Latency::Enum without breaking everything. - virtual int getLatency() const = 0; - - /// Retrieves the number of logical frames since the beginning of the match. - /// If the game is paused, then getFrameCount will not increase. - /// - /// @returns Number of logical frames that have elapsed since the game started as an integer. - virtual int getFrameCount() const = 0; - - /// Retrieves the maximum number of logical frames that have been recorded in a - /// replay. If the game is not a replay, then the value returned is undefined. - /// - /// @returns The number of logical frames that the replay contains. - virtual int getReplayFrameCount() const = 0; - - /// Retrieves the logical frame rate of the game in frames per second (FPS). - /// - /// Example: - /// @code - /// BWAPI::Broodwar->setLocalSpeed(0); - /// - /// // Log and display the best logical FPS seen in the game - /// static int bestFPS = 0; - /// bestFPS = std::max(bestFPS, BWAPI::Broodwar->getFPS()); - /// BWAPI::Broodwar->drawTextScreen(BWAPI::Positions::Origin, "%cBest: %d GFPS\nCurrent: %d GFPS", BWAPI::Text::White, bestFPS, BWAPI::Broodwar->getFPS()); - /// @endcode - /// @returns Logical frames per second that the game is currently running at as an integer. - /// @see getAverageFPS - virtual int getFPS() const = 0; - - /// Retrieves the average logical frame rate of the game in frames per second (FPS). - /// - /// @returns Average logical frames per second that the game is currently running at as a - /// double. - /// @see getFPS - virtual double getAverageFPS() const = 0; - - /// Retrieves the position of the user's mouse on the screen, in Position coordinates. - /// - /// @returns Position indicating the location of the mouse. - /// @retval Positions::Unknown if Flag::UserInput is disabled. - virtual Position getMousePosition() const = 0; - - /// Retrieves the state of the given mouse button. - /// - /// - /// A MouseButton enum member indicating which button on the mouse to check. - /// - /// - /// @return A bool indicating the state of the given \p button. true if the button was pressed - /// and false if it was not. - /// @retval false always if Flag::UserInput is disabled. - /// - /// @see MouseButton - virtual bool getMouseState(MouseButton button) const = 0; - - /// Retrieves the state of the given keyboard key. - /// - /// - /// A Key enum member indicating which key on the keyboard to check. - /// - /// - /// @return A bool indicating the state of the given \p key. true if the key was pressed - /// and false if it was not. - /// @retval false always if Flag::UserInput is disabled. - /// - /// @see Key - virtual bool getKeyState(Key key) const = 0; - - /// Retrieves the top left position of the viewport from the top left corner of the - /// map, in pixels. - /// - /// @returns Position containing the coordinates of the top left corner of the game's viewport. - /// @retval Positions::Unknown always if Flag::UserInput is disabled. - /// @see setScreenPosition - virtual BWAPI::Position getScreenPosition() const = 0; - - /// Moves the top left corner of the viewport to the provided position relative to - /// the map's origin (top left (0,0)). - /// - /// - /// The x coordinate to move the screen to, in pixels. - /// - /// - /// The y coordinate to move the screen to, in pixels. - /// - /// @see getScreenPosition - virtual void setScreenPosition(int x, int y) = 0; - /// @overload - void setScreenPosition(BWAPI::Position p); - - /// Pings the minimap at the given position. Minimap pings are visible to - /// allied players. - /// - /// - /// The x coordinate to ping at, in pixels, from the map's origin (left). - /// - /// - /// The y coordinate to ping at, in pixels, from the map's origin (top). - /// - virtual void pingMinimap(int x, int y) = 0; - /// @overload - void pingMinimap(BWAPI::Position p); - - /// Checks if the state of the given flag is enabled or not. - /// - /// @note Flags may only be enabled at the start of the match during the AIModule::onStart - /// callback. - /// - /// - /// The Flag::Enum entry describing the flag's effects on BWAPI. - /// - /// - /// @returns true if the given \p flag is enabled, false if the flag is disabled. - /// - /// @see Flag::Enum - /// - /// @todo Take Flag::Enum as parameter instead of int - virtual bool isFlagEnabled(int flag) const = 0; - - /// Enables the state of a given flag. - /// - /// @note Flags may only be enabled at the start of the match during the AIModule::onStart - /// callback. - /// - /// - /// The Flag::Enum entry describing the flag's effects on BWAPI. - /// - /// - /// @see Flag::Enum - /// - /// @todo Take Flag::Enum as parameter instead of int - virtual void enableFlag(int flag) = 0; - - /// Retrieves the set of accessible units that are on a given build tile. - /// - /// - /// The X position, in tiles. - /// - /// - /// The Y position, in tiles. - /// - /// (optional) - /// A function predicate that indicates which units are included in the returned set. - /// - /// - /// @returns A Unitset object consisting of all the units that have any part of them on the - /// given build tile. - Unitset getUnitsOnTile(int tileX, int tileY, const UnitFilter &pred = nullptr) const; - /// @overload - Unitset getUnitsOnTile(BWAPI::TilePosition tile, const UnitFilter &pred = nullptr) const; - - /// Retrieves the set of accessible units that are in a given rectangle. - /// - /// - /// The X coordinate of the left position of the bounding box, in pixels. - /// - /// - /// The Y coordinate of the top position of the bounding box, in pixels. - /// - /// - /// The X coordinate of the right position of the bounding box, in pixels. - /// - /// - /// The Y coordinate of the bottom position of the bounding box, in pixels. - /// - /// (optional) - /// A function predicate that indicates which units are included in the returned set. - /// - /// - /// @returns A Unitset object consisting of all the units that have any part of them within the - /// given rectangle bounds. - virtual Unitset getUnitsInRectangle(int left, int top, int right, int bottom, const UnitFilter &pred = nullptr) const = 0; - /// @overload - Unitset getUnitsInRectangle(BWAPI::Position topLeft, BWAPI::Position bottomRight, const UnitFilter &pred = nullptr) const; - - /// Retrieves the set of accessible units that are within a given radius of a - /// position. - /// - /// - /// The x coordinate of the center, in pixels. - /// - /// - /// The y coordinate of the center, in pixels. - /// - /// - /// The radius from the center, in pixels, to include units. - /// - /// (optional) - /// A function predicate that indicates which units are included in the returned set. - /// - /// - /// @returns A Unitset object consisting of all the units that have any part of them within the - /// given radius from the center position. - Unitset getUnitsInRadius(int x, int y, int radius, const UnitFilter &pred = nullptr) const; - /// @overload - Unitset getUnitsInRadius(BWAPI::Position center, int radius, const UnitFilter &pred = nullptr) const; - - /// Retrieves the closest unit to center that matches the criteria of the callback - /// pred within an optional radius. - /// - /// - /// The position to start searching for the closest unit. - /// - /// (optional) - /// The UnitFilter predicate to determine which units should be included. This includes - /// all units by default. - /// - /// (optional) - /// The radius to search in. If omitted, the entire map will be searched. - /// - /// - /// @returns The desired unit that is closest to center. - /// @retval nullptr If a suitable unit was not found. - /// - /// @see getBestUnit, UnitFilter - Unit getClosestUnit(Position center, const UnitFilter &pred = nullptr, int radius = 999999) const; - - /// Retrieves the closest unit to center that matches the criteria of the callback - /// pred within an optional rectangle. - /// - /// - /// The position to start searching for the closest unit. - /// - /// (optional) - /// The UnitFilter predicate to determine which units should be included. This includes - /// all units by default. - /// - /// (optional) - /// The left position of the rectangle. This value is 0 by default. - /// - /// (optional) - /// The top position of the rectangle. This value is 0 by default. - /// - /// (optional) - /// The right position of the rectangle. This value includes the entire map width by default. - /// - /// (optional) - /// The bottom position of the rectangle. This value includes the entire map height by default. - /// - /// - /// @see UnitFilter - virtual Unit getClosestUnitInRectangle(Position center, const UnitFilter &pred = nullptr, int left = 0, int top = 0, int right = 999999, int bottom = 999999) const = 0; - - /// Compares all units with pred to determine which of them is the best. - /// All units are checked. If center and radius are specified, then it will check all units - /// that are within the radius of the position. - /// - /// - /// A BestUnitFilter that determines which parameters should be considered when calculating - /// which units are better than others. - /// - /// - /// A UnitFilter that determines which units to include in calculations. - /// - /// (optional) - /// The position to use in the search. If omitted, then the entire map is searched. - /// - /// (optional) - /// The distance from \p center to search for units. If omitted, then the entire map is - /// searched. - /// - /// - /// @returns The desired unit that best matches the given criteria. - /// @retval nullptr if a suitable unit was not found. - /// - /// @see getClosestUnit, BestUnitFilter, UnitFilter - virtual Unit getBestUnit(const BestUnitFilter &best, const UnitFilter &pred, Position center = Positions::Origin, int radius = 999999) const = 0; - - /// Returns the last error that was set using setLastError. If a function - /// call in BWAPI has failed, you can use this function to retrieve the reason it failed. - /// - /// @returns Error type containing the reason for failure. - /// - /// @see setLastError, Errors - virtual Error getLastError() const = 0; - - /// Sets the last error so that future calls to getLastError will return the value - /// that was set. - /// - /// (optional) - /// The error code to set. If omitted, then the last error will be cleared. - /// - /// - /// @retval true If the type passed was Errors::None, clearing the last error. - /// @retval false If any other error type was passed. - /// @see getLastError, Errors - virtual bool setLastError(BWAPI::Error e = Errors::None) const = 0; - - /// Retrieves the width of the map in build tile units. - /// - /// @returns Width of the map in tiles. - /// @see mapHeight - virtual int mapWidth() const = 0; - - /// Retrieves the height of the map in build tile units. - /// - /// @returns Height of the map in tiles. - /// @see mapHeight - virtual int mapHeight() const = 0; - - /// Retrieves the file name of the currently loaded map. - /// - /// @returns Map file name as std::string object. - /// - /// @see mapPathName, mapName - /// - /// @TODO: Note on campaign files. - virtual std::string mapFileName() const = 0; - - /// Retrieves the full path name of the currently loaded map. - /// - /// @returns Map file name as std::string object. - /// - /// @see mapFileName, mapName - /// - /// @TODO: Note on campaign files. - virtual std::string mapPathName() const = 0; - - /// Retrieves the title of the currently loaded map. - /// - /// @returns Map title as std::string object. - /// - /// @see mapFileName, mapPathName - virtual std::string mapName() const = 0; - - /// Calculates the SHA-1 hash of the currently loaded map file. - /// - /// @returns std::string object containing SHA-1 hash. - /// - /// @note Campaign maps will return a hash of their internal map chunk components(.chk), while - /// standard maps will return a hash of their entire map archive (.scm,.scx). - /// - /// @TODO: Note on replays. - virtual std::string mapHash() const = 0; - - /// Checks if the given mini-tile position is walkable. - /// - /// @note This function only checks if the static terrain is walkable. Its current occupied - /// state is excluded from this check. To see if the space is currently occupied or not, then - /// see #getUnitsInRectangle . - /// - /// - /// The x coordinate of the mini-tile, in mini-tile units (8 pixels). - /// - /// - /// The y coordinate of the mini-tile, in mini-tile units (8 pixels). - /// - /// - /// @returns true if the mini-tile is walkable and false if it is impassable for ground units. - virtual bool isWalkable(int walkX, int walkY) const = 0; - /// @overload - bool isWalkable(BWAPI::WalkPosition position) const; - - /// Returns the ground height at the given tile position. - /// - /// - /// X position to query, in tiles - /// - /// - /// Y position to query, in tiles - /// - /// - /// @returns The tile height as an integer. Possible values are: - /// - 0: Low ground - /// - 1: Low ground doodad - /// - 2: High ground - /// - 3: High ground doodad - /// - 4: Very high ground - /// - 5: Very high ground doodad - /// . - virtual int getGroundHeight(int tileX, int tileY) const = 0; - /// @overload - int getGroundHeight(TilePosition position) const; - - /// Checks if a given tile position is buildable. This means that, if all - /// other requirements are met, a structure can be placed on this tile. This function uses - /// static map data. - /// - /// - /// The x value of the tile to check. - /// - /// - /// The y value of the tile to check. - /// - /// (optional) - /// If this is true, then this function will also check if any visible structures are - /// occupying the space. If this value is false, then it only checks the static map data - /// for tile buildability. This value is false by default. - /// - /// - /// @returns boolean identifying if the given tile position is buildable (true) or not (false). - /// If \p includeBuildings was provided, then it will return false if a structure is currently - /// occupying the tile. - virtual bool isBuildable(int tileX, int tileY, bool includeBuildings = false) const = 0; - /// @overload - bool isBuildable(TilePosition position, bool includeBuildings = false) const; - - /// Checks if a given tile position is visible to the current player. - /// - /// - /// The x value of the tile to check. - /// - /// - /// The y value of the tile to check. - /// - /// - /// @returns boolean identifying the visibility of the tile. If the given tile is visible, then - /// the value is true. If the given tile is concealed by the fog of war, then this value will - /// be false. - virtual bool isVisible(int tileX, int tileY) const = 0; - /// @overload - bool isVisible(TilePosition position) const; - - /// Checks if a given tile position has been explored by the player. An - /// explored tile position indicates that the player has seen the location at some point in the - /// match, partially revealing the fog of war for the remainder of the match. - /// - /// - /// The x tile coordinate to check. - /// - /// - /// The y tile coordinate to check. - /// - /// - /// @retval true If the player has explored the given tile position (partially revealed fog). - /// @retval false If the tile position was never explored (completely black fog). - /// - /// @see isVisible - virtual bool isExplored(int tileX, int tileY) const = 0; - /// @overload - bool isExplored(TilePosition position) const; - - /// Checks if the given tile position has @Zerg creep on it. - /// - /// - /// The x tile coordinate to check. - /// - /// - /// The y tile coordinate to check. - /// - /// - /// @retval true If the given tile has creep on it. - /// @retval false If the given tile does not have creep, or if it is concealed by the fog of war. - virtual bool hasCreep(int tileX, int tileY) const = 0; - /// @overload - bool hasCreep(TilePosition position) const; - - /// Checks if the given pixel position is powered by an owned @Protoss_Pylon for an - /// optional unit type. - /// - /// - /// The x pixel coordinate to check. - /// - /// - /// The y pixel coordinate to check. - /// - /// (optional) - /// Checks if the given UnitType requires power or not. If ommitted, then it will assume - /// that the position requires power for any unit type. - /// - /// - /// @retval true if the type at the given position will have power. - /// @retval false if the type at the given position will be unpowered. - virtual bool hasPowerPrecise(int x, int y, UnitType unitType = UnitTypes::None ) const = 0; - /// @overload - bool hasPowerPrecise(Position position, UnitType unitType = UnitTypes::None) const; - - /// Checks if the given tile position if powered by an owned @Protoss_Pylon for an - /// optional unit type. - /// - /// - /// The x tile coordinate to check. - /// - /// - /// The y tile coordinate to check. - /// - /// (optional) - /// Checks if the given UnitType will be powered if placed at the given tile position. If - /// omitted, then only the immediate tile position is checked for power, and the function - /// will assume that the location requires power for any unit type. - /// - /// - /// @retval true if the type at the given tile position will receive power. - /// @retval false if the type will be unpowered at the given tile position. - bool hasPower(int tileX, int tileY, UnitType unitType = UnitTypes::None) const; - /// @overload - bool hasPower(TilePosition position, UnitType unitType = UnitTypes::None) const; - /// @overload - bool hasPower(int tileX, int tileY, int tileWidth, int tileHeight, UnitType unitType = UnitTypes::None) const; - /// @overload - bool hasPower(TilePosition position, int tileWidth, int tileHeight, UnitType unitType = UnitTypes::None) const; - - /// Checks if the given unit type can be built at the given build tile position. - /// This function checks for creep, power, and resource distance requirements in addition to - /// the tiles' buildability and possible units obstructing the build location. - /// - /// @note If the type is an addon and a builer is provided, then the location of the addon will - /// be placed 4 tiles to the right and 1 tile down from the given \p position. If the builder - /// is not given, then the check for the addon will be conducted at position. - /// - /// - /// Indicates the tile position that the top left corner of the structure is intended to go. - /// - /// - /// The UnitType to check for. - /// - /// (optional) - /// The intended unit that will build the structure. If specified, then this function will - /// also check if there is a path to the build site and exclude the builder from the set of - /// units that may be blocking the build site. - /// - /// (optional) - /// If this parameter is true, it will also check if the target position has been explored - /// by the current player. This value is false by default, ignoring the explored state of - /// the build site. - /// - /// - /// @returns true indicating that the structure can be placed at the given tile position, and - /// false if something may be obstructing the build location. - virtual bool canBuildHere(TilePosition position, UnitType type, Unit builder = nullptr, bool checkExplored = false) = 0; - - /// Checks all the requirements in order to make a given unit type for the current - /// player. These include resources, supply, technology tree, availability, and - /// required units. - /// - /// - /// The UnitType to check. - /// - /// (optional) - /// The Unit that will be used to build/train the provided unit \p type. If this value is - /// nullptr or excluded, then the builder will be excluded in the check. - /// - /// - /// @returns true indicating that the type can be made. If \p builder is provided, then it is - /// only true if \p builder can make the \p type. Otherwise it will return false, indicating - /// that the unit type can not be made. - virtual bool canMake(UnitType type, Unit builder = nullptr) const = 0; - - /// Checks all the requirements in order to research a given technology type for the - /// current player. These include resources, technology tree, availability, and - /// required units. - /// - /// - /// The TechType to check. - /// - /// (optional) - /// The Unit that will be used to research the provided technology \p type. If this value is - /// nullptr or excluded, then the unit will be excluded in the check. - /// - /// (optional) - /// TODO fill this in - /// - /// - /// @returns true indicating that the type can be researched. If \p unit is provided, then it is - /// only true if \p unit can research the \p type. Otherwise it will return false, indicating - /// that the technology can not be researched. - virtual bool canResearch(TechType type, Unit unit = nullptr, bool checkCanIssueCommandType = true) = 0; - - /// Checks all the requirements in order to upgrade a given upgrade type for the - /// current player. These include resources, technology tree, availability, and - /// required units. - /// - /// - /// The UpgradeType to check. - /// - /// (optional) - /// The Unit that will be used to upgrade the provided upgrade \p type. If this value is - /// nullptr or excluded, then the unit will be excluded in the check. - /// - /// (optional) - /// TODO fill this in - /// - /// - /// @returns true indicating that the type can be upgraded. If \p unit is provided, then it is - /// only true if \p unit can upgrade the \p type. Otherwise it will return false, indicating - /// that the upgrade can not be upgraded. - virtual bool canUpgrade(UpgradeType type, Unit unit = nullptr, bool checkCanIssueCommandType = true) = 0; - - /// Retrieves the set of all starting locations for the current map. A - /// starting location is essentially a candidate for a player's spawn point. - /// - /// @returns A TilePosition::list containing all the TilePosition objects that indicate a start - /// location. - /// @see PlayerInterface::getStartLocation - virtual const TilePosition::list& getStartLocations() const = 0; - - /// Prints text to the screen as a notification. This function allows text - /// formatting using Text::Enum members. The behaviour of this function is the same as printf, - /// located in header cstdio. - /// - /// @note That text printed through this function is not seen by other players or in replays. - /// - /// - /// Text formatting. See std::printf for more information. Refrain from passing non-constant - /// strings directly in this parameter. - /// - /// - /// The arguments that will be formatted using the given text formatting. - /// - /// - /// @see Text::Enum, std::printf - void printf(const char *format, ...); - - /// @copydoc printf - /// - /// This function is intended to forward an already-existing argument list. - /// - /// - /// The argument list that will be formatted. - /// - /// - /// @see printf - virtual void vPrintf(const char *format, va_list args) = 0; - - /// Sends a text message to all other players in the game. The behaviour of - /// this function is the same as std::printf, located in header cstdio. - /// - /// @note In a single player game this function can be used to execute cheat codes. - /// - /// - /// Text formatting. See std::printf for more information. Refrain from passing non-constant - /// strings directly in this parameter. - /// - /// - /// @see sendTextEx, std::printf - void sendText(const char *format, ...); - - /// @copydoc sendText - /// - /// This function is intended to forward an already-existing argument list. - /// - /// - /// The argument list that will be formatted. - /// - /// - /// @see sendText - void vSendText(const char *format, va_list args); - - /// An extended version of Game::sendText which allows messages to be forwarded to - /// allies. The behaviour of this function is the same as std::printf, located in - /// header cstdio. - /// - /// - /// If this parameter is set to true, then the message is only sent to allied players, - /// otherwise it will be sent to all players. - /// - /// - /// Text formatting. See std::printf for more information. Refrain from passing non-constant - /// strings directly in this parameter. - /// - /// - /// @see sendText, std::printf - void sendTextEx(bool toAllies, const char *format, ...); - - /// @copydoc sendTextEx - /// - /// This function is intended to forward an already-existing argument list. - /// - /// - /// The argument list that will be formatted. - /// - /// - /// @see sendTextEx - virtual void vSendTextEx(bool toAllies, const char *format, va_list args) = 0; - - /// Checks if the current client is inside a game. - /// - /// @returns true if the client is in a game, and false if it is not. - virtual bool isInGame() const = 0; - - /// Checks if the current client is inside a multiplayer game. - /// - /// @returns true if the client is in a multiplayer game, and false if it is a single player - /// game, a replay, or some other state. - virtual bool isMultiplayer() const = 0; - - /// Checks if the client is in a game that was created through the Battle.net - /// multiplayer gaming service. - /// - /// @returns true if the client is in a multiplayer Battle.net game and false if it is not. - virtual bool isBattleNet() const = 0; - - /// Checks if the current game is paused. While paused, AIModule::onFrame - /// will still be called. - /// - /// @returns true if the game is paused and false otherwise - /// @see pauseGame, resumeGame - virtual bool isPaused() const = 0; - - /// Checks if the client is watching a replay. - /// - /// @returns true if the client is watching a replay and false otherwise - virtual bool isReplay() const = 0; - - /// Pauses the game. While paused, AIModule::onFrame will still be called. - /// @see resumeGame - virtual void pauseGame() = 0; - - /// Resumes the game from a paused state. - /// @see pauseGame - virtual void resumeGame() = 0; - - /// Leaves the current game by surrendering and enters the post-game statistics/score - /// screen. - virtual void leaveGame() = 0; - - /// Restarts the match. Works the same as if the match was restarted from - /// the in-game menu (F10). This option is only available in single player games. - /// - /// @todo return a bool indicating success, document error code for invalid state - virtual void restartGame() = 0; - - /// Sets the number of milliseconds Broodwar spends in each frame. The - /// default values are as follows: - /// - Fastest: 42ms/frame - /// - Faster: 48ms/frame - /// - Fast: 56ms/frame - /// - Normal: 67ms/frame - /// - Slow: 83ms/frame - /// - Slower: 111ms/frame - /// - Slowest: 167ms/frame - /// - /// @note Specifying a value of 0 will not guarantee that logical frames are executed as fast - /// as possible. If that is the intention, use this in combination with #setFrameSkip. - /// - /// @bug Changing this value will cause the execution of @UMS scenario triggers to glitch. - /// This will only happen in campaign maps and custom scenarios (non-melee). - /// - /// - /// The time spent per frame, in milliseconds. A value of 0 indicates that frames are - /// executed immediately with no delay. Negative values will restore the default value - /// as listed above. - /// - /// - /// @see setFrameSkip, getFPS - virtual void setLocalSpeed(int speed) = 0; - - /// Issues a given command to a set of units. This function automatically - /// splits the set into groups of 12 and issues the same command to each of them. If a unit - /// is not capable of executing the command, then it is simply ignored. - /// - /// - /// A Unitset containing all the units to issue the command for. - /// - /// - /// A UnitCommand object containing relevant information about the command to be issued. - /// The Unit interface object associated with the command will be ignored. - /// - /// - /// @returns true if any one of the units in the Unitset were capable of executing the - /// command, and false if none of the units were capable of executing the command. - virtual bool issueCommand(const Unitset& units, UnitCommand command) = 0; - - /// Retrieves the set of units that are currently selected by the user outside of - /// BWAPI. This function requires that Flag::UserInput be enabled. - /// - /// @returns A Unitset containing the user's selected units. If Flag::UserInput is disabled, - /// then this set is always empty. - /// - /// @see enableFlag - virtual const Unitset& getSelectedUnits() const = 0; - - /// Retrieves the player object that BWAPI is controlling. - /// - /// @returns Pointer to Player interface object representing the current player. - /// @retval nullptr if the current game is a replay. - /// - /// Example usage - /// @code - /// void ExampleAIModule::onStart() - /// { - /// if ( BWAPI::Broodwar->self() ) - /// BWAPI::Broodwar->sendText("Hello, my name is %s.", BWAPI::Broodwar->self()->getName().c_str()); - /// } - /// @endcode - virtual Player self() const = 0; - - /// Retrieves the Player interface that represents the enemy player. If - /// there is more than one enemy, and that enemy is destroyed, then this function will still - /// retrieve the same, defeated enemy. If you wish to handle multiple opponents, see the - /// Game::enemies function. - /// - /// @returns Player interface representing an enemy player. - /// @retval nullptr If there is no enemy or the current game is a replay. - /// @see enemies - virtual Player enemy() const = 0; - - /// Retrieves the Player interface object representing the neutral player. - /// The neutral player owns all the resources and critters on the map by default. - /// - /// @returns Player interface indicating the neutral player. - virtual Player neutral() const = 0; - - /// Retrieves a set of all the current player's remaining allies. - /// - /// @returns Playerset containing all allied players. - virtual Playerset& allies() = 0; - - /// Retrieves a set of all the current player's remaining enemies. - /// - /// @returns Playerset containing all enemy players. - virtual Playerset& enemies() = 0; - - /// Retrieves a set of all players currently observing the game. An observer - /// is defined typically in a @UMS game type as not having any impact on the game. This means - /// an observer cannot start with any units, and cannot have any active trigger actions that - /// create units for it. - /// - /// @returns Playerset containing all currently active observer players - virtual Playerset& observers() = 0; - - /// @name Debugging Members - /// @{ - - /// Sets the size of the text for all calls to drawText following this one. - /// - /// (optional) - /// The size of the text. This value is one of Text::Size::Enum. If this value is omitted, - /// then a default value of Text::Size::Default is used. - /// - /// - /// Example usage - /// @code - /// void ExampleAIModule::onFrame() - /// { - /// // Centers the name of the player in the upper middle of the screen - /// BWAPI::Broodwar->setTextSize(BWAPI::Text::Size::Large); - /// BWAPI::Broodwar->drawTextScreen(BWAPI::Positions::Origin, "%c%c%s", - /// BWAPI::Text::Align_Center, - /// BWAPI::Text::Green, - /// BWAPI::Broodwar->self()->getName().c_str() ); - /// BWAPI::Broodwar->setTextSize(); // Set text size back to default - /// } - /// @endcode - /// @see Text::Size::Enum - virtual void setTextSize(Text::Size::Enum size = Text::Size::Default) = 0; - - /// Draws text on the screen at the given coordinates. Text can be drawn in - /// different colors or formatted using the Text::Enum members. - /// - /// - /// The coordinate type. Indicates the relative position to draw the shape. - /// - /// - /// The x coordinate, in pixels, relative to ctype. - /// - /// - /// The y coordinate, in pixels, relative to ctype. - /// - /// - /// The string formatting portion. This is the same as printf style formatting. - /// - /// - /// Arglist containing the intermediate list of arguments to format before finally sending - /// the string to Broodwar. - /// - virtual void vDrawText(CoordinateType::Enum ctype, int x, int y, const char *format, va_list arg) = 0; - /// @overload - void drawText(CoordinateType::Enum ctype, int x, int y, const char *format, ...); - /// @overload - void drawTextMap(int x, int y, const char *format, ...); - /// @overload - void drawTextMap(Position p, const char *format, ...); - /// @overload - void drawTextMouse(int x, int y, const char *format, ...); - /// @overload - void drawTextMouse(Position p, const char *format, ...); - /// @overload - void drawTextScreen(int x, int y, const char *format, ...); - /// @overload - void drawTextScreen(Position p, const char *format, ...); - - /// Draws a rectangle on the screen with the given color. - /// - /// - /// The coordinate type. Indicates the relative position to draw the shape. - /// - /// - /// The x coordinate, in pixels, relative to ctype, of the left edge of the rectangle. - /// - /// - /// The y coordinate, in pixels, relative to ctype, of the top edge of the rectangle. - /// - /// - /// The x coordinate, in pixels, relative to ctype, of the right edge of the rectangle. - /// - /// - /// The y coordinate, in pixels, relative to ctype, of the bottom edge of the rectangle. - /// - /// - /// The color of the rectangle. - /// - /// (optional) - /// If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn - /// as an outline. If omitted, this value will default to false. - /// - virtual void drawBox(CoordinateType::Enum ctype, int left, int top, int right, int bottom, Color color, bool isSolid = false) = 0; - /// @overload - void drawBoxMap(int left, int top, int right, int bottom, Color color, bool isSolid = false); - /// @overload - void drawBoxMap(Position leftTop, Position rightBottom, Color color, bool isSolid = false); - /// @overload - void drawBoxMouse(int left, int top, int right, int bottom, Color color, bool isSolid = false); - /// @overload - void drawBoxMouse(Position leftTop, Position rightBottom, Color color, bool isSolid = false); - /// @overload - void drawBoxScreen(int left, int top, int right, int bottom, Color color, bool isSolid = false); - /// @overload - void drawBoxScreen(Position leftTop, Position rightBottom, Color color, bool isSolid = false); - - /// Draws a triangle on the screen with the given color. - /// - /// - /// The coordinate type. Indicates the relative position to draw the shape. - /// - /// - /// The x coordinate, in pixels, relative to ctype, of the first point. - /// - /// - /// The y coordinate, in pixels, relative to ctype, of the first point. - /// - /// - /// The x coordinate, in pixels, relative to ctype, of the second point. - /// - /// - /// The y coordinate, in pixels, relative to ctype, of the second point. - /// - /// - /// The x coordinate, in pixels, relative to ctype, of the third point. - /// - /// - /// The y coordinate, in pixels, relative to ctype, of the third point. - /// - /// - /// The color of the triangle. - /// - /// (optional) - /// If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn - /// as an outline. If omitted, this value will default to false. - /// - virtual void drawTriangle(CoordinateType::Enum ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false) = 0; - /// @overload - void drawTriangleMap(int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false); - /// @overload - void drawTriangleMap(Position a, Position b, Position c, Color color, bool isSolid = false); - /// @overload - void drawTriangleMouse(int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false); - /// @overload - void drawTriangleMouse(Position a, Position b, Position c, Color color, bool isSolid = false); - /// @overload - void drawTriangleScreen(int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false); - /// @overload - void drawTriangleScreen(Position a, Position b, Position c, Color color, bool isSolid = false); - - /// Draws a circle on the screen with the given color. - /// - /// - /// The coordinate type. Indicates the relative position to draw the shape. - /// - /// - /// The x coordinate, in pixels, relative to ctype. - /// - /// - /// The y coordinate, in pixels, relative to ctype. - /// - /// - /// The radius of the circle, in pixels. - /// - /// - /// The color of the circle. - /// - /// (optional) - /// If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn - /// as an outline. If omitted, this value will default to false. - /// - virtual void drawCircle(CoordinateType::Enum ctype, int x, int y, int radius, Color color, bool isSolid = false) = 0; - /// @overload - void drawCircleMap(int x, int y, int radius, Color color, bool isSolid = false); - /// @overload - void drawCircleMap(Position p, int radius, Color color, bool isSolid = false); - /// @overload - void drawCircleMouse(int x, int y, int radius, Color color, bool isSolid = false); - /// @overload - void drawCircleMouse(Position p, int radius, Color color, bool isSolid = false); - /// @overload - void drawCircleScreen(int x, int y, int radius, Color color, bool isSolid = false); - /// @overload - void drawCircleScreen(Position p, int radius, Color color, bool isSolid = false); - - /// Draws an ellipse on the screen with the given color. - /// - /// - /// The coordinate type. Indicates the relative position to draw the shape. - /// - /// - /// The x coordinate, in pixels, relative to ctype. - /// - /// - /// The y coordinate, in pixels, relative to ctype. - /// - /// - /// The x radius of the ellipse, in pixels. - /// - /// - /// The y radius of the ellipse, in pixels. - /// - /// - /// The color of the ellipse. - /// - /// (optional) - /// If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn - /// as an outline. If omitted, this value will default to false. - /// - virtual void drawEllipse(CoordinateType::Enum ctype, int x, int y, int xrad, int yrad, Color color, bool isSolid = false) = 0; - /// @overload - void drawEllipseMap(int x, int y, int xrad, int yrad, Color color, bool isSolid = false); - /// @overload - void drawEllipseMap(Position p, int xrad, int yrad, Color color, bool isSolid = false); - /// @overload - void drawEllipseMouse(int x, int y, int xrad, int yrad, Color color, bool isSolid = false); - /// @overload - void drawEllipseMouse(Position p, int xrad, int yrad, Color color, bool isSolid = false); - /// @overload - void drawEllipseScreen(int x, int y, int xrad, int yrad, Color color, bool isSolid = false); - /// @overload - void drawEllipseScreen(Position p, int xrad, int yrad, Color color, bool isSolid = false); - - /// Draws a dot on the map or screen with a given color. - /// - /// - /// The coordinate type. Indicates the relative position to draw the shape. - /// - /// - /// The x coordinate, in pixels, relative to ctype. - /// - /// - /// The y coordinate, in pixels, relative to ctype. - /// - /// - /// The color of the dot. - /// - virtual void drawDot(CoordinateType::Enum ctype, int x, int y, Color color) = 0; - /// @overload - void drawDotMap(int x, int y, Color color); - /// @overload - void drawDotMap(Position p, Color color); - /// @overload - void drawDotMouse(int x, int y, Color color); - /// @overload - void drawDotMouse(Position p, Color color); - /// @overload - void drawDotScreen(int x, int y, Color color); - /// @overload - void drawDotScreen(Position p, Color color); - - /// Draws a line on the map or screen with a given color. - /// - /// - /// The coordinate type. Indicates the relative position to draw the shape. - /// - /// - /// The starting x coordinate, in pixels, relative to ctype. - /// - /// - /// The starting y coordinate, in pixels, relative to ctype. - /// - /// - /// The ending x coordinate, in pixels, relative to ctype. - /// - /// - /// The ending y coordinate, in pixels, relative to ctype. - /// - /// - /// The color of the line. - /// - virtual void drawLine(CoordinateType::Enum ctype, int x1, int y1, int x2, int y2, Color color) = 0; - /// @overload - void drawLineMap(int x1, int y1, int x2, int y2, Color color); - /// @overload - void drawLineMap(Position a, Position b, Color color); - /// @overload - void drawLineMouse(int x1, int y1, int x2, int y2, Color color); - /// @overload - void drawLineMouse(Position a, Position b, Color color); - /// @overload - void drawLineScreen(int x1, int y1, int x2, int y2, Color color); - /// @overload - void drawLineScreen(Position a, Position b, Color color); - - /// @} - - /// Retrieves the maximum delay, in number of frames, between a command being issued - /// and the command being executed by Broodwar. - /// - /// @note In Broodwar, latency is used to keep the game synchronized between players without - /// introducing lag. - /// - /// @returns Difference in frames between commands being sent and executed. - /// @see getLatencyTime, getRemainingLatencyFrames - virtual int getLatencyFrames() const = 0; - - /// Retrieves the maximum delay, in milliseconds, between a command being issued and - /// the command being executed by Broodwar. - /// - /// @returns Difference in milliseconds between commands being sent and executed. - /// @see getLatencyFrames, getRemainingLatencyTime - virtual int getLatencyTime() const = 0; - - /// Retrieves the number of frames it will take before a command sent in the current - /// frame will be executed by the game. - /// - /// @returns Number of frames until a command is executed if it were sent in the current - /// frame. - /// @see getRemainingLatencyTime, getLatencyFrames - virtual int getRemainingLatencyFrames() const = 0; - - /// Retrieves the number of milliseconds it will take before a command sent in the - /// current frame will be executed by Broodwar. - /// - /// @returns Amount of time, in milliseconds, until a command is executed if it were sent in - /// the current frame. - /// @see getRemainingLatencyFrames, getLatencyTime - virtual int getRemainingLatencyTime() const = 0; - - /// Retrieves the current revision of BWAPI. - /// - /// @returns The revision number of the current BWAPI interface. - /// - /// @threadsafe - virtual int getRevision() const = 0; - - /// Retrieves the debug state of the BWAPI build. - /// - /// @returns true if the BWAPI module is a DEBUG build, and false if it is a RELEASE build. - /// - /// @threadsafe - virtual bool isDebug() const = 0; - - /// Checks the state of latency compensation. - /// - /// @returns true if latency compensation is enabled, false if it is disabled. - /// @see setLatCom - virtual bool isLatComEnabled() const = 0; - - /// Changes the state of latency compensation. Latency compensation - /// modifies the state of BWAPI's representation of units to reflect the implications of - /// issuing a command immediately after the command was performed, instead of waiting - /// consecutive frames for the results. Latency compensation is enabled by default. - /// - /// - /// Set whether the latency compensation feature will be enabled (true) or disabled (false). - /// - /// - /// @see isLatComEnabled. - virtual void setLatCom(bool isEnabled) = 0; - - /// Checks if the GUI is enabled. The GUI includes all drawing functions of - /// BWAPI, as well as screen updates from Broodwar. - /// - /// @retval true If the GUI is enabled, and everything is visible - /// @retval false If the GUI is disabled and drawing functions are rejected - /// - /// @see setGUI - virtual bool isGUIEnabled() const = 0; - - /// Sets the rendering state of the Starcraft GUI. This typically gives - /// Starcraft a very low graphical frame rate and disables all drawing functionality in BWAPI. - /// - /// - /// A boolean value that determines the state of the GUI. Passing false to this function - /// will disable the GUI, and true will enable it. - /// - /// - /// Example Usage: - /// @code - /// void ExampleAIModule::onStart() - /// { // Make our bot run thousands of games as fast as possible! - /// Broodwar->setLocalSpeed(0); - /// Broodwar->setGUI(false); - /// } - /// @endcode - /// - /// @see isGUIEnabled - virtual void setGUI(bool enabled) = 0; - - /// Retrieves the Starcraft instance number recorded by BWAPI to identify which - /// Starcraft instance an AI module belongs to. The very first instance should - /// return 0. - /// - /// @returns - /// An integer value representing the instance number. - /// - /// @threadsafe - virtual int getInstanceNumber() const = 0; - - /// Retrieves the Actions Per Minute (APM) that the bot is producing. - /// - /// (optional) - /// If true, the return value will include selections as individual commands, otherwise - /// it will exclude selections. This value is false by default. - /// - /// - /// @returns The number of actions that the bot has executed per minute, on average. - virtual int getAPM(bool includeSelects = false) const = 0; - - /// Changes the map to the one specified. Once restarted, the game will - /// load the map that was provided. Changes do not take effect unless the game is restarted. - /// - /// - /// A string containing the path and file name to the desired map. - /// - /// - /// @retval true if the function succeeded and has changed the map. - /// @retval false if the function failed, does not have permission from the tournament module, - /// failed to find the map specified, or received an invalid parameter. - virtual bool setMap(const char *mapFileName) = 0; - /// @overload - bool setMap(const std::string &mapFileName); - - /// Sets the number of graphical frames for every logical frame. This - /// allows the game to run more logical frames per graphical frame, increasing the speed at - /// which the game runs. - /// - /// - /// Number of graphical frames per logical frame. If this value is 0 or less, then it will - /// default to 1. - /// - /// - /// @see setLocalSpeed - virtual void setFrameSkip(int frameSkip) = 0; - - /// Checks if there is a path from source to destination. This only checks - /// if the source position is connected to the destination position. This function does not - /// check if all units can actually travel from source to destination. Because of this - /// limitation, it has an O(1) complexity, and cases where this limitation hinders gameplay is - /// uncommon at best. - /// - /// - /// The source position. - /// - /// - /// The destination position. - /// - /// - /// @retval true if there is a path between the two positions - /// @retval false if there is no path - bool hasPath(Position source, Position destination) const; - - /// Sets the alliance state of the current player with the target player. - /// - /// - /// The target player to set alliance with. - /// - /// (optional) - /// If true, the current player will ally the target player. If false, the current player - /// will make the target player an enemy. This value is true by default. - /// - /// (optional) - /// Sets the state of "allied victory". If true, the game will end in a victory if all - /// allied players have eliminated their opponents. Otherwise, the game will only end if - /// no other players are remaining in the game. This value is true by default. - /// - virtual bool setAlliance(BWAPI::Player player, bool allied = true, bool alliedVictory = true) = 0; - - /// In a game, this function sets the vision of the current BWAPI player with the - /// target player. In a replay, this function toggles the visibility of the target - /// player. - /// - /// - /// The target player to toggle vision. - /// - /// (optional) - /// The vision state. If true, and in a game, the current player will enable shared vision - /// with the target player, otherwise it will unshare vision. If in a replay, the vision - /// of the target player will be shown, otherwise the target player will be hidden. This - /// value is true by default. - /// - virtual bool setVision(BWAPI::Player player, bool enabled = true) = 0; - - /// Retrieves current amount of time in seconds that the game has elapsed. - /// - /// @returns Time, in seconds, that the game has elapsed as an integer. - virtual int elapsedTime() const = 0; - - /// Sets the command optimization level. Command optimization is a feature - /// in BWAPI that tries to reduce the APM of the bot by grouping or eliminating unnecessary - /// game actions. For example, suppose the bot told 24 @Zerglings to @Burrow. At command - /// optimization level 0, BWAPI is designed to select each Zergling to burrow individually, - /// which costs 48 actions. With command optimization level 1, it can perform the same - /// behaviour using only 4 actions. The command optimizer also reduces the amount of bytes used - /// for each action if it can express the same action using a different command. For example, - /// Right_Click uses less bytes than Move. - /// - /// - /// An integer representation of the aggressiveness for which commands are optimized. A - /// lower level means less optimization, and a higher level means more optimization. - /// - /// - /// The values for \p level are as follows: - /// - 0: No optimization. - /// - 1: Some optimization. - /// - Is not detected as a hack. - /// - Does not alter behaviour. - /// - Units performing the following actions are grouped and ordered 12 at a time: - /// - Attack_Unit - /// - Morph (@Larva only) - /// - Hold_Position - /// - Stop - /// - Follow - /// - Gather - /// - Return_Cargo - /// - Repair - /// - Burrow - /// - Unburrow - /// - Cloak - /// - Decloak - /// - Siege - /// - Unsiege - /// - Right_Click_Unit - /// - Halt_Construction - /// - Cancel_Train (@Carrier and @Reaver only) - /// - Cancel_Train_Slot (@Carrier and @Reaver only) - /// - Cancel_Morph (for non-buildings only) - /// - Use_Tech - /// - Use_Tech_Unit - /// . - /// - The following order transformations are applied to allow better grouping: - /// - Attack_Unit becomes Right_Click_Unit if the target is an enemy - /// - Move becomes Right_Click_Position - /// - Gather becomes Right_Click_Unit if the target contains resources - /// - Set_Rally_Position becomes Right_Click_Position for buildings - /// - Set_Rally_Unit becomes Right_Click_Unit for buildings - /// - Use_Tech_Unit with Infestation becomes Right_Click_Unit if the target is valid - /// . - /// . - /// - 2: More optimization by grouping structures. - /// - Includes the optimizations made by all previous levels. - /// - May be detected as a hack by some replay utilities. - /// - Does not alter behaviour. - /// - Units performing the following actions are grouped and ordered 12 at a time: - /// - Attack_Unit (@Turrets, @Photon_Cannons, @Sunkens, @Spores) - /// - Train - /// - Morph - /// - Set_Rally_Unit - /// - Lift - /// - Cancel_Construction - /// - Cancel_Addon - /// - Cancel_Train - /// - Cancel_Train_Slot - /// - Cancel_Morph - /// - Cancel_Research - /// - Cancel_Upgrade - /// . - /// . - /// - 3: Extensive optimization - /// - Includes the optimizations made by all previous levels. - /// - Units may behave or move differently than expected. - /// - Units performing the following actions are grouped and ordered 12 at a time: - /// - Attack_Move - /// - Set_Rally_Position - /// - Move - /// - Patrol - /// - Unload_All - /// - Unload_All_Position - /// - Right_Click_Position - /// - Use_Tech_Position - /// . - /// . - /// - 4: Aggressive optimization - /// - Includes the optimizations made by all previous levels. - /// - Positions used in commands will be rounded to multiples of 32. - /// - @High_Templar and @Dark_Templar that merge into @Archons will be grouped and may - /// choose a different target to merge with. It will not merge with a target that - /// wasn't included. - /// . - /// . - /// - virtual void setCommandOptimizationLevel(int level) = 0; - - /// Returns the remaining countdown time. The countdown timer is used in - /// @CTF and @UMS game types. - /// - /// Example usage: - /// @code - /// void ExampleAIModule::onStart() - /// { - /// // Register a callback that only occurs once when the countdown timer reaches 0 - /// if ( BWAPI::Broodwar->getGameType() == BWAPI::GameTypes::Capture_The_Flag || - /// BWAPI::Broodwar->getGameType() == BWAPI::GameTypes::Team_Capture_The_Flag ) - /// { - /// BWAPI::Broodwar->registerEvent([](BWAPI::Game*){ BWAPI::Broodwar->sendText("Try to find my flag!"); }, // action - /// [](BWAPI::Game*){ return BWAPI::Broodwar->countdownTimer() == 0; }, // condition - /// 1); // times to run (once) - /// } - /// } - /// @endcode - /// - /// @returns Integer containing the time (in game seconds) on the countdown timer. - virtual int countdownTimer() const = 0; - - /// Retrieves the set of all regions on the map. - /// - /// @returns Regionset containing all map regions. - virtual const Regionset &getAllRegions() const = 0; - - /// Retrieves the region at a given position. - /// - /// - /// The x coordinate, in pixels. - /// - /// - /// The y coordinate, in pixels. - /// - /// - /// @returns Pointer to the Region interface at the given position. - /// @retval nullptr if the provided position is not valid (i.e. not within the map bounds). - /// - /// @note If the provided position is invalid, the error Errors::Invalid_Parameter is set. - /// @see getAllRegions, getRegion - virtual BWAPI::Region getRegionAt(int x, int y) const = 0; - /// @overload - BWAPI::Region getRegionAt(BWAPI::Position position) const; - - /// Retrieves the amount of time (in milliseconds) that has elapsed when running the last AI - /// module callback. This is used by tournament modules to penalize AI modules that use too - /// much processing time. - /// - /// @retval 0 When called from an AI module. - /// @returns Time in milliseconds spent in last AI module call. - virtual int getLastEventTime() const = 0; - - /// Sets the state of the fog of war when watching a replay. - /// - /// (optional) - /// The state of the reveal all flag. If false, all fog of war will be enabled. If true, - /// then the fog of war will be revealed. It is true by default. - /// - virtual bool setRevealAll(bool reveal = true) = 0; - - /// Retrieves a basic build position just as the default Computer AI would. - /// This allows users to find simple build locations without relying on external libraries. - /// - /// - /// A valid UnitType representing the unit type to accomodate space for. - /// - /// - /// A valid TilePosition containing the desired placement position. - /// - /// (optional) - /// The maximum distance (in tiles) to build from \p desiredPosition. - /// - /// (optional) - /// A special boolean value that changes the behaviour of @Creep_Colony placement. - /// - /// - /// @retval TilePositions::Invalid If a build location could not be found within \p maxRange. - /// @returns - /// A TilePosition containing the location that the structure should be constructed at. - TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition, int maxRange = 64, bool creep = false) const; - - /// Calculates the damage received for a given player. It can be understood - /// as the damage from \p fromType to \p toType. Does not include shields in calculation. - /// Includes upgrades if players are provided. - /// - /// - /// The unit type that will be dealing the damage. - /// - /// - /// The unit type that will be receiving the damage. - /// - /// (optional) - /// The player owner of the given type that will be dealing the damage. If omitted, then - /// no player will be used to calculate the upgrades for \p fromType. - /// - /// (optional) - /// The player owner of the type that will be receiving the damage. If omitted, then this - /// parameter will default to Broodwar->self(). - /// - /// - /// @returns The amount of damage that fromType would deal to toType. - /// @see getDamageTo - int getDamageFrom(UnitType fromType, UnitType toType, Player fromPlayer = nullptr, Player toPlayer = nullptr) const; - - /// Calculates the damage dealt for a given player. It can be understood as - /// the damage to \p toType from \p fromType. Does not include shields in calculation. - /// Includes upgrades if players are provided. - /// - /// @note This function is nearly the same as #getDamageFrom. The only difference is that - /// the last parameter is intended to default to Broodwar->self(). - /// - /// - /// The unit type that will be receiving the damage. - /// - /// - /// The unit type that will be dealing the damage. - /// - /// (optional) - /// The player owner of the type that will be receiving the damage. If omitted, then - /// no player will be used to calculate the upgrades for \p toType. - /// - /// (optional) - /// The player owner of the given type that will be dealing the damage. If omitted, then - /// this parameter will default to Broodwar->self(). - /// - /// - /// @returns The amount of damage that fromType would deal to toType. - /// @see getDamageFrom - int getDamageTo(UnitType toType, UnitType fromType, Player toPlayer = nullptr, Player fromPlayer = nullptr) const; - }; - - extern Game *BroodwarPtr; - - /// Broodwar wrapper - class GameWrapper - { - private: - std::ostringstream ss; - public: - /// Definition of ostream_manipulator type for convenience. - typedef std::ostream& (*ostream_manipulator)(std::ostream&); - - /// Member access operator to retain the original Broodwar-> behaviour. - Game *operator ->() const; - - /// Output stream operator for printing text to Broodwar. Using this - /// operator invokes Game::printf when a newline character is encountered. - template < class T > - inline GameWrapper &operator <<(const T &in) - { - // Pass whatever into the stream - ss << in; - return *this; - }; - /// @overload - GameWrapper &operator <<(ostream_manipulator fn); - - /// Flushes the Broodwar stream, printing all text in the stream to the screen. - void flush(); - }; - - /// The primary Game interface, used to access any Game information or perform Game - /// actions. - extern GameWrapper Broodwar; - -} - diff --git a/bwapi-includes/BWAPI/GameType.h b/bwapi-includes/BWAPI/GameType.h deleted file mode 100644 index 5ddad69..0000000 --- a/bwapi-includes/BWAPI/GameType.h +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// Namespace containing game types. - /// @see GameType - namespace GameTypes - { - /// Enumeration of game types. - /// @see GameType - namespace Enum - { - /// Enumeration of game types. - /// @see GameType - enum Enum - { - None = 0, - Custom, // Warcraft III - Melee, - Free_For_All, - One_on_One, - Capture_The_Flag, - Greed, - Slaughter, - Sudden_Death, - Ladder, - Use_Map_Settings, - Team_Melee, - Team_Free_For_All, - Team_Capture_The_Flag, - Unknown_0x0E, - Top_vs_Bottom, - Iron_Man_Ladder, // Warcraft II - - Pro_Gamer_League = 32, // Not valid - Unknown, - MAX - }; - }; - }; - /// A class that represents game types in Broodwar. A game type is selected - /// when creating a game. - /// - /// @see GameTypes - /// @ingroup TypeClasses - class GameType : public Type - { - public: - /// @copydoc Type::Type(int) - GameType(int id = GameTypes::Enum::None); - }; - - /// @ingroup Types - namespace GameTypes - { - /// Retrieves the set of all the valid GameTypes. - /// - /// @returns Set of available GameTypes. - const GameType::set& allGameTypes(); - - 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 None; - extern const GameType Unknown; - } - - static_assert(sizeof(GameType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/Input.h b/bwapi-includes/BWAPI/Input.h deleted file mode 100644 index 24eb06c..0000000 --- a/bwapi-includes/BWAPI/Input.h +++ /dev/null @@ -1,251 +0,0 @@ -#pragma once -namespace BWAPI -{ - /// An enumeration of mouse button inputs. - /// @see Game::getMouseState - enum MouseButton - { - M_LEFT = 0, - M_RIGHT, - M_MIDDLE, - M_MAX, - }; - - /// An enumeration of keyboard input values. - /// @see Game::getKeyState - enum Key - { - K_LBUTTON = 0x01, - K_RBUTTON, - K_CANCEL, - K_MBUTTON, - K_XBUTTON1, - K_XBUTTON2, - __UNDEFINED_7, - K_BACK, - K_TAB, - __RESERVED_A, - __RESERVED_B, - K_CLEAR, - K_RETURN, - __UNDEFINED_E, - __UNDEFINED_F, - K_SHIFT, - K_CONTROL, - K_MENU, - K_PAUSE, - K_CAPITAL, - K_KANA, - K_UNDEFINED_16, - K_JUNJA, - K_FINAL, - K_KANJI, - __UNDEFINED_1A, - K_ESCAPE, - K_CONVERT, - K_NONCONVERT, - K_ACCEPT, - K_MODECHANGE, - K_SPACE, - K_PRIOR, - K_NEXT, - K_END, - K_HOME, - K_LEFT, - K_UP, - K_RIGHT, - K_DOWN, - K_SELECT, - K_PRINT, - K_EXECUTE, - K_SNAPSHOT, - K_INSERT, - K_DELETE, - K_HELP, - K_0, - K_1, - K_2, - K_3, - K_4, - K_5, - K_6, - K_7, - K_8, - K_9, - __UNDEFINED_3A, - __UNDEFINED_3B, - __UNDEFINED_3C, - __UNDEFINED_3D, - __UNDEFINED_3E, - __UNDEFINED_3F, - __UNDEFINED_40, - K_A, - K_B, - K_C, - K_D, - K_E, - K_F, - K_G, - K_H, - K_I, - K_J, - K_K, - K_L, - K_M, - K_N, - K_O, - K_P, - K_Q, - K_R, - K_S, - K_T, - K_U, - K_V, - K_W, - K_X, - K_Y, - K_Z, - K_LWIN, - K_RWIN, - K_APPS, - __RESERVED_5E, - K_SLEEP, - K_NUMPAD0, - K_NUMPAD1, - K_NUMPAD2, - K_NUMPAD3, - K_NUMPAD4, - K_NUMPAD5, - K_NUMPAD6, - K_NUMPAD7, - K_NUMPAD8, - K_NUMPAD9, - K_MULTIPLY, - K_ADD, - K_SEPARATOR, - K_SUBTRACT, - K_DECIMAL, - K_DIVIDE, - K_F1, - K_F2, - K_F3, - K_F4, - K_F5, - K_F6, - K_F7, - K_F8, - K_F9, - K_F10, - K_F11, - K_F12, - K_F13, - K_F14, - K_F15, - K_F16, - K_F17, - K_F18, - K_F19, - K_F20, - K_F21, - K_F22, - K_F23, - K_F24, - __UNASSIGNED_88, - __UNASSIGNED_89, - __UNASSIGNED_8A, - __UNASSIGNED_8B, - __UNASSIGNED_8C, - __UNASSIGNED_8D, - __UNASSIGNED_8E, - __UNASSIGNED_8F, - K_NUMLOCK, - K_SCROLL, - - K_OEM_NEC_EQUAL, - K_OEM_FJ_JISHO, - K_OEM_FJ_MASSHOU, - K_OEM_FJ_TOUROKU, - K_OEM_FJ_LOYA, - __UNASSIGNED_97, - __UNASSIGNED_98, - __UNASSIGNED_99, - __UNASSIGNED_9A, - __UNASSIGNED_9B, - __UNASSIGNED_9C, - __UNASSIGNED_9D, - __UNASSIGNED_9E, - __UNASSIGNED_9F, - K_LSHIFT, - K_RSHIFT, - K_LCONTROL, - K_RCONTROL, - K_LMENU, - K_RMENU, - K_BROWSER_BACK, - K_BROWSER_FORWARD, - K_BROWSER_REFRESH, - K_BROWSER_STOP, - K_BROWSER_SEARCH, - K_BROWSER_FAVORITES, - K_BROWSER_HOME, - K_VOLUME_MUTE, - K_VOLUME_DOWN, - K_VOLUME_UP, - K_MEDIA_NEXT_TRACK, - K_MEDIA_PREV_TRACK, - K_MEDIA_STOP, - K_MEDIA_PLAY_PAUSE, - K_LAUNCH_MAIL, - K_LAUNCH_MEDIA_SELECT, - K_LAUNCH_APP1, - K_LAUNCH_APP2, - __RESERVED_B8, - __RESERVED_B9, - K_OEM_1, - K_OEM_PLUS, - K_OEM_COMMA, - K_OEM_MINUS, - K_OEM_PERIOD, - K_OEM_2, - K_OEM_3, - - K_OEM_4 = 0xDB, - K_OEM_5, - K_OEM_6, - K_OEM_7, - K_OEM_8, - __RESERVED_E0, - K_OEM_AX, - K_OEM_102, - K_ICO_HELP, - K_ICO_00, - K_PROCESSKEY, - K_ICO_CLEAR, - K_PACKET, - __UNASSIGNED_E8, - K_OEM_RESET, - K_OEM_JUMP, - K_OEM_PA1, - K_OEM_PA2, - K_OEM_PA3, - K_OEM_WSCTRL, - K_OEM_CUSEL, - K_OEM_ATTN, - K_OEM_FINISH, - K_OEM_COPY, - K_OEM_AUTO, - K_OEM_ENLW, - K_OEM_BACKTAB, - - K_ATTN, - K_CRSEL, - K_EXSEL, - K_EREOF, - K_PLAY, - K_ZOOM, - K_NONAME, - K_PA1, - K_OEM_CLEAR, - K_MAX - }; -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/Interface.h b/bwapi-includes/BWAPI/Interface.h deleted file mode 100644 index b210ead..0000000 --- a/bwapi-includes/BWAPI/Interface.h +++ /dev/null @@ -1,129 +0,0 @@ -#pragma once -#include -#include - -#include - -namespace BWAPI -{ - /// This generalized class allows the application of features that are common to all interface - /// classes. - /// - /// @tparam T - /// The class that inherits this interface. - template < typename T > - class Interface - { - protected: - /// @cond HIDDEN - Interface() = default; - virtual ~Interface() {}; - - std::map clientInfo; - std::list< InterfaceEvent > interfaceEvents; - - friend class GameImpl; - - // Function manages events and updates it for the given frame - void updateEvents() - { - auto e = interfaceEvents.begin(); - while ( e != interfaceEvents.end() ) - { - if ( e->isFinished() ) - { - e = interfaceEvents.erase(e); - } - else - { - e->execute(static_cast(this)); - ++e; - } - } - }; - /// @endcond - public: - /// Retrieves a pointer or value at an index that was stored for this interface using - /// setClientInfo. - /// - /// - /// The key containing the value to retrieve. Default is 0. - /// - /// - /// @retval nullptr if index is out of bounds. - /// @returns The client info at the given index. - /// @see setClientInfo - void *getClientInfo(int key = 0) const - { - // Retrieve iterator to element at index - auto result = this->clientInfo.find(key); - - // Return a default value if not found - if ( result == this->clientInfo.end() ) - return nullptr; - - // return the desired value - return result->second; - }; - - template - CT getClientInfo(int key = 0) const - { - return (CT)(int)this->getClientInfo(key); - }; - - /// Associates one or more pointers or values with any BWAPI interface. - /// - /// This client information is managed entirely by the AI module. It is not modified by BWAPI. - /// @warning If a pointer to allocated memory is used, then the AI module is responsible for - /// deallocating the memory when the game ends. - /// - /// If client info at the given index has already been set, then it will be overwritten. - /// - /// - /// The data to associate with this interface. - /// - /// - /// The key to use for this data. Default is 0. - /// - /// - /// @see getClientInfo - template < typename V > - void setClientInfo(const V &clientInfo, int key = 0) - { - this->clientInfo[key] = (void*)clientInfo; - }; - - /// Registers an event and associates it with the current Interface object. - /// Events can be used to automate tasks (like train X @Marines until Y of them have been - /// created by the given @Barracks) or to create user-defined callbacks. - /// - /// - /// The action callback to be executed when the event conditions are true. It is of type - /// void fn(T *inst) where fn is the function name and inst is a pointer to the instance of - /// the object performing the action. - /// - /// (optional) - /// The condition callback which will return true if the action is intended to be executed. - /// It is of type bool fn(T *inst) where fn is the function name and inst is a pointer to the - /// instance of the object performing the check. The condition will always be true if omitted. - /// - /// (optional) - /// The number of times to execute the action before the event is removed. If the value is - /// negative, then the event will never be removed. The value will be -1 if omitted, causing - /// the event to execute until the game ends. - /// - /// (optional) - /// The number of frames to skip between checks. If this value is 0, then a condition check is - /// made once per frame. If this value is 1, then the condition for this event is only checked - /// every other frame. This value is 0 by default, meaning the event's condition is checked - /// every frame. - /// - void registerEvent(const std::function &action, const std::function &condition = nullptr, int timesToRun = -1, int framesToCheck = 0) - { - interfaceEvents.push_back( InterfaceEvent(action,condition,timesToRun,framesToCheck) ); - }; - }; - - -} diff --git a/bwapi-includes/BWAPI/InterfaceEvent.h b/bwapi-includes/BWAPI/InterfaceEvent.h deleted file mode 100644 index e22a453..0000000 --- a/bwapi-includes/BWAPI/InterfaceEvent.h +++ /dev/null @@ -1,112 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// The interface event is an attachment to BWAPI interfaces which allows the user to - /// register powerful conditional callbacks that can be executed a user-specified number of - /// times. - /// - /// @tparam T - /// The interface that this class is being used for. - /// - /// @see Interface::registerEvent - template < typename T > - class InterfaceEvent - { - public: - InterfaceEvent() = default; - - /// This is the expected constructor for an interface event. - /// - /// - /// An function callback that is run when all other conditions for this event are met. - /// - /// (optioinal) - /// A function predicate that returns true if this event should be triggered. - /// - /// (optional) - /// The number of times that the action is called before this event is discarded. A value - /// of -1 means the event will never be discarded until the game has ended. - /// - /// (optional) - /// The frequency that the event will check its condition at. A lower value indicates a - /// higher frequency. A value of 0 means that the condition is checked every frame. - /// A value of 10 means that the condition is checked once every 10 frames. - /// - InterfaceEvent(const std::function &action, const std::function &condition = nullptr, int timesToRun = -1, int framesToCheck = 0) - : condProc( condition ) - , execProc( action ) - , runFreq( framesToCheck ) - , runCount( timesToRun ) - , step( framesToCheck ) - {}; - - /// Checks if the event has finished its execution and is marked for removal. - /// - /// @returns true if the event has completed all runs and/or is marked for removal, otherwise - /// it returns false if the event should continue execution. - bool isFinished() const - { - return this->runCount == 0; - }; - - /// Marks the event for removal. - void removeEvent() - { - this->runCount = 0; - }; - - protected: - template < typename U > - friend class Interface; - - // Function that runs the event, checkings its conditions and running its action, then - // decrementing the run count. - bool execute(T *instance) - { - // condition check - if ( !this->isConditionMet(instance) ) - return false; - - // There must be an exec proc! - if ( !this->execProc ) - return false; - - // execute - this->execProc(instance); - - // Decrement run count (-1 being infinite) - if ( this->runCount > 0 ) - --this->runCount; - return true; - }; - - // Function to check if the condition associated with the event is true. Includes frame and - // run count checking. - bool isConditionMet(T *instance) - { - // Validity check - if ( this->isFinished() ) - return false; - - // Frame check - --step; - if ( step > 0 ) - return false; - this->step = this->runFreq; - - // Conditional check - if ( this->condProc ) - return this->condProc(instance); - return true; // always run if there is no conditional function - }; - private: - // Data members - std::function condProc = nullptr; - std::function execProc = nullptr; - int runFreq = 0; // Frequency of runs, in frames (0 means every frame, 1 means every other frame) - int runCount = 0; // Number of times that the action can occur (-1 being infinite) - int step = 0; // Current step. Executes when reaches 0, then reset to runFreq. - }; -} diff --git a/bwapi-includes/BWAPI/Latency.h b/bwapi-includes/BWAPI/Latency.h deleted file mode 100644 index 6fffef9..0000000 --- a/bwapi-includes/BWAPI/Latency.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -namespace BWAPI -{ - /// Contains enumeration of known latency values. - /// @see Game::getLatency - namespace Latency - { - /// Contains enumeration of known latency values. - /// @see Game::getLatency - enum Enum - { - SinglePlayer = 2, - LanLow = 5, - LanMedium = 7, - LanHigh = 9, - BattlenetLow = 14, - BattlenetMedium = 19, - BattlenetHigh = 24 - }; - } -} diff --git a/bwapi-includes/BWAPI/Order.h b/bwapi-includes/BWAPI/Order.h deleted file mode 100644 index c29145d..0000000 --- a/bwapi-includes/BWAPI/Order.h +++ /dev/null @@ -1,394 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// Namespace containing unit orders. - /// @see Order - namespace Orders - { - /// Enumeration of unit orders. - /// @see Order - namespace Enum - { - /// Enumeration of unit orders. - /// @see Order - enum Enum - { - Die, - Stop, - Guard, - PlayerGuard, - TurretGuard, - BunkerGuard, - Move, - ReaverStop, - Attack1, - Attack2, - AttackUnit, - AttackFixedRange, - AttackTile, - Hover, - AttackMove, - InfestedCommandCenter, - UnusedNothing, - UnusedPowerup, - TowerGuard, - TowerAttack, - VultureMine, - StayInRange, - TurretAttack, - Nothing, - Unused_24, - DroneStartBuild, - DroneBuild, - CastInfestation, - MoveToInfest, - InfestingCommandCenter, - PlaceBuilding, - PlaceProtossBuilding, - CreateProtossBuilding, - ConstructingBuilding, - Repair, - MoveToRepair, - PlaceAddon, - BuildAddon, - Train, - RallyPointUnit, - RallyPointTile, - ZergBirth, - ZergUnitMorph, - ZergBuildingMorph, - IncompleteBuilding, - IncompleteMorphing, - BuildNydusExit, - EnterNydusCanal, - IncompleteWarping, - Follow, - Carrier, - ReaverCarrierMove, - CarrierStop, - CarrierAttack, - CarrierMoveToAttack, - CarrierIgnore2, - CarrierFight, - CarrierHoldPosition, - Reaver, - ReaverAttack, - ReaverMoveToAttack, - ReaverFight, - ReaverHoldPosition, - TrainFighter, - InterceptorAttack, - ScarabAttack, - RechargeShieldsUnit, - RechargeShieldsBattery, - ShieldBattery, - InterceptorReturn, - DroneLand, - BuildingLand, - BuildingLiftOff, - DroneLiftOff, - LiftingOff, - ResearchTech, - Upgrade, - Larva, - SpawningLarva, - Harvest1, - Harvest2, - MoveToGas, - WaitForGas, - HarvestGas, - ReturnGas, - MoveToMinerals, - WaitForMinerals, - MiningMinerals, - Harvest3, - Harvest4, - ReturnMinerals, - Interrupted, - EnterTransport, - PickupIdle, - PickupTransport, - PickupBunker, - Pickup4, - PowerupIdle, - Sieging, - Unsieging, - WatchTarget, - InitCreepGrowth, - SpreadCreep, - StoppingCreepGrowth, - GuardianAspect, - ArchonWarp, - CompletingArchonSummon, - HoldPosition, - QueenHoldPosition, - Cloak, - Decloak, - Unload, - MoveUnload, - FireYamatoGun, - MoveToFireYamatoGun, - CastLockdown, - Burrowing, - Burrowed, - Unburrowing, - CastDarkSwarm, - CastParasite, - CastSpawnBroodlings, - CastEMPShockwave, - NukeWait, - NukeTrain, - NukeLaunch, - NukePaint, - NukeUnit, - CastNuclearStrike, - NukeTrack, - InitializeArbiter, - CloakNearbyUnits, - PlaceMine, - RightClickAction, - SuicideUnit, - SuicideLocation, - SuicideHoldPosition, - CastRecall, - Teleport, - CastScannerSweep, - Scanner, - CastDefensiveMatrix, - CastPsionicStorm, - CastIrradiate, - CastPlague, - CastConsume, - CastEnsnare, - CastStasisField, - CastHallucination, - Hallucination2, - ResetCollision, - ResetHarvestCollision, - Patrol, - CTFCOPInit, - CTFCOPStarted, - CTFCOP2, - ComputerAI, - AtkMoveEP, - HarassMove, - AIPatrol, - GuardPost, - RescuePassive, - Neutral, - ComputerReturn, - InitializePsiProvider, - SelfDestructing, - Critter, - HiddenGun, - OpenDoor, - CloseDoor, - HideTrap, - RevealTrap, - EnableDoodad, - DisableDoodad, - WarpIn, - Medic, - MedicHeal, - HealMove, - MedicHoldPosition, - MedicHealToIdle, - CastRestoration, - CastDisruptionWeb, - CastMindControl, - DarkArchonMeld, - CastFeedback, - CastOpticalFlare, - CastMaelstrom, - JunkYardDog, - Fatal, - None, - Unknown, - MAX - }; - } - } - /// An Order (Order type) represents a Unit's current action and can be retrieved with - /// UnitInterface::getOrder. It can also be used to identify the current state of the - /// unit during command execution (gathering minerals can consist of Orders::MoveToMinerals, - /// Orders::WaitForMinerals, Orders::MiningMinerals, etc.). - /// - /// @see UnitInterface::getOrder, Orders - /// @ingroup TypeClasses - class Order : public Type - { - public: - /// @copydoc Type::Type(int) - Order(int id = Orders::Enum::None); - }; - - /// @ingroup Types - namespace Orders - { - /// Retrieves the set of all defined game orders. - /// - /// @returns Set of all Order types. - const Order::set& allOrders(); - - 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 CastInfestation; - extern const Order InfestingCommandCenter; - extern const Order PlaceBuilding; - extern const Order CreateProtossBuilding; - 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 Teleport; - 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 SelfDestructing; - 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 MedicHeal; - extern const Order HealMove; - extern const Order MedicHealToIdle; - 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; - }; - - static_assert(sizeof(Order) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/Player.h b/bwapi-includes/BWAPI/Player.h deleted file mode 100644 index 31959fe..0000000 --- a/bwapi-includes/BWAPI/Player.h +++ /dev/null @@ -1,643 +0,0 @@ -#pragma once -#include - -#include -#include -#include -#include -#include - -namespace BWAPI -{ - // Forwards - class Color; - class ForceInterface; - typedef ForceInterface *Force; - class PlayerType; - class TechType; - class Unitset; - class UpgradeType; - class WeaponType; - - struct PlayerData; - - class PlayerInterface; - typedef PlayerInterface *Player; - - /// The Player represents a unique controller in the game. Each player in - /// a match will have his or her own player instance. There is also a neutral player which owns - /// all the neutral units (such as mineral patches and vespene geysers). - /// - /// @see Playerset, PlayerType, Race - /// @ingroup Interface - class PlayerInterface : public Interface - { - protected: - virtual ~PlayerInterface() {}; - public : - /// Retrieves a unique ID that represents the player. - /// - /// @returns - /// An integer representing the ID of the player. - virtual int getID() const = 0; - - /// Retrieves the name of the player. - /// - /// @returns - /// A std::string object containing the player's name. - /// - /// @note Don't forget to use std::string::c_str() when passing this parameter to - /// Game::sendText and other variadic functions. - /// - /// Example usage: - /// @code - /// BWAPI::Player myEnemy = BWAPI::Broodwar->enemy(); - /// if ( myEnemy != nullptr ) // Make sure there is an enemy! - /// BWAPI::Broodwar->sendText("Prepare to be crushed, %s!", myEnemy->getName().c_str()); - /// @endcode - virtual std::string getName() const = 0; - - /// Retrieves the set of all units that the player owns. This also includes - /// incomplete units. - /// - /// @returns Reference to a Unitset containing the units. - /// - /// @note This does not include units that are loaded into transports, @Bunkers, @Refineries, - /// @Assimilators, or @Extractors. - /// - /// Example usage: - /// @code - /// Unitset myUnits = BWAPI::Broodwar->self()->getUnits(); - /// for ( auto u = myUnits.begin(); u != myUnits.end(); ++u ) - /// { - /// // Do something with your units - /// } - /// @endcode - virtual const Unitset &getUnits() const = 0; - - /// Retrieves the race of the player. This allows you to change strategies - /// against different races, or generalize some commands for yourself. - /// - /// @retval Races::Unknown If the player chose Races::Random when the game started and they - /// have not been seen. - /// - /// @returns - /// The Race that the player is using. - /// - /// Example usage: - /// @code - /// if ( BWAPI::Broodwar->enemy() ) - /// { - /// BWAPI::Race enemyRace = BWAPI::Broodwar->enemy()->getRace(); - /// if ( enemyRace == Races::Zerg ) - /// BWAPI::Broodwar->sendText("Do you really think you can beat me with a zergling rush?"); - /// } - /// @endcode - virtual Race getRace() const = 0; - - /// Retrieves the player's controller type. This allows you to distinguish - /// betweeen computer and human players. - /// - /// @returns - /// The PlayerType that identifies who is controlling a player. - /// - /// @note Other players using BWAPI will be treated as a human player and return - /// PlayerTypes::Player. - /// - /// @code - /// if ( BWAPI::Broodwar->enemy() ) - /// { - /// if ( BWAPI::Broodwar->enemy()->getType() == PlayerTypes::Computer ) - /// BWAPI::Broodwar << "Looks like something I can abuse!" << std::endl; - /// } - /// @endcode - virtual PlayerType getType() const = 0; - - /// Retrieves the player's force. A force is the team that the player is - /// playing on. - /// - /// @returns - /// The Force object that the player is part of. - virtual Force getForce() const = 0; - - /// Checks if this player is allied to the specified player. - /// - /// - /// The player to check alliance with. - /// - /// - /// @retval true if this player is allied with \p player . - /// @retval false if this player is not allied with \p player. - /// - /// @note This function will also return false if this player is neutral or an observer, or - /// if \p player is neutral or an observer. - /// - /// @see isEnemy - virtual bool isAlly(const Player player) const = 0; - - /// Checks if this player is unallied to the specified player. - /// - /// - /// The player to check alliance with. - /// - /// - /// @retval true if this player is allied with \p player . - /// @retval false if this player is not allied with \p player . - /// - /// @note This function will also return false if this player is neutral or an observer, or if - /// \p player is neutral or an observer. - /// - /// @see isAlly - virtual bool isEnemy(const Player player) const = 0; - - /// Checks if this player is the neutral player. - /// - /// @retval true if this player is the neutral player. - /// @retval false if this player is any other player. - virtual bool isNeutral() const = 0; - - /// Retrieve's the player's starting location. - /// - /// @returns - /// A TilePosition containing the position of the start location. - /// - /// @retval TilePositions::None if the player does not have a start location. - /// @retval TilePositions::Unknown if an error occured while trying to retrieve the start - /// location. - /// - /// @see Game::getStartLocations, Game::getLastError - virtual TilePosition getStartLocation() const = 0; - - /// Checks if the player has achieved victory. - /// - /// @returns true if this player has achieved victory, otherwise false - virtual bool isVictorious() const = 0; - - /// Checks if the player has been defeated. - /// - /// @returns true if the player is defeated, otherwise false - virtual bool isDefeated() const = 0; - - /// Checks if the player has left the game. - /// - /// @returns true if the player has left the game, otherwise false - virtual bool leftGame() const = 0; - - /// Retrieves the current amount of minerals/ore that this player has. - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Amount of minerals that the player currently has for spending. - virtual int minerals() const = 0; - - /// Retrieves the current amount of vespene gas that this player has. - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Amount of gas that the player currently has for spending. - virtual int gas() const = 0; - - /// Retrieves the cumulative amount of minerals/ore that this player has gathered - /// since the beginning of the game, including the amount that the player starts the game - /// with (if any). - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Cumulative amount of minerals that the player has gathered. - virtual int gatheredMinerals() const = 0; - - /// Retrieves the cumulative amount of vespene gas that this player has gathered since - /// the beginning of the game, including the amount that the player starts the game with (if - /// any). - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Cumulative amount of gas that the player has gathered. - virtual int gatheredGas() const = 0; - - /// Retrieves the cumulative amount of minerals/ore that this player has spent on - /// repairing units since the beginning of the game. This function only applies to - /// @Terran players. - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Cumulative amount of minerals that the player has spent repairing. - virtual int repairedMinerals() const = 0; - - /// Retrieves the cumulative amount of vespene gas that this player has spent on - /// repairing units since the beginning of the game. This function only applies to - /// @Terran players. - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Cumulative amount of gas that the player has spent repairing. - virtual int repairedGas() const = 0; - - /// Retrieves the cumulative amount of minerals/ore that this player has gained from - /// refunding (cancelling) units and structures. - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Cumulative amount of minerals that the player has received from refunds. - virtual int refundedMinerals() const = 0; - - /// Retrieves the cumulative amount of vespene gas that this player has gained from - /// refunding (cancelling) units and structures. - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Cumulative amount of gas that the player has received from refunds. - virtual int refundedGas() const = 0; - - /// Retrieves the cumulative amount of minerals/ore that this player has spent, - /// excluding repairs. - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Cumulative amount of minerals that the player has spent. - virtual int spentMinerals() const = 0; - - /// Retrieves the cumulative amount of vespene gas that this player has spent, - /// excluding repairs. - /// - /// @note This function will return 0 if the player is inaccessible. - /// - /// @returns Cumulative amount of gas that the player has spent. - virtual int spentGas() const = 0; - - /// Retrieves the total amount of supply the player has available for unit control. - /// - /// @note In Starcraft programming, the managed supply values are double than what they appear - /// in the game. The reason for this is because @Zerglings use 0.5 visible supply. - /// - /// @note In Starcraft, the supply for each race is separate. Having a @Pylon and an @Overlord - /// will not give you 32 supply. It will instead give you 16 @Protoss supply and 16 @Zerg - /// supply. - /// - /// (optional) - /// The race to query the total supply for. If this is omitted, then the player's current - /// race will be used. - /// - /// - /// @returns The total supply available for this player and the given \p race. - /// - /// Example usage: - /// @code - /// if ( BWAPI::Broodwar->self()->supplyUsed() + 8 >= BWAPI::Broodwar->self()->supplyTotal() ) - /// { - /// // Construct pylons, supply depots, or overlords - /// } - /// @endcode - /// @see supplyUsed - virtual int supplyTotal(Race race = Races::None) const = 0; - - /// Retrieves the current amount of supply that the player is using for unit control. - /// - /// (optional) - /// The race to query the used supply for. If this is omitted, then the player's current - /// race will be used. - /// - /// - /// @returns The supply that is in use for this player and the given \p race. - /// @see supplyTotal - virtual int supplyUsed(Race race = Races::None) const = 0; - - /// Retrieves the total number of units that the player has. If the - /// information about the player is limited, then this function will only return the number - /// of visible units. - /// - /// (optional) - /// The unit type to query. UnitType macros are accepted. If this parameter is omitted, - /// then it will use UnitTypes::AllUnits by default. - /// - /// - /// @returns The total number of units of the given type that the player owns. - /// @see visibleUnitCount, completedUnitCount, incompleteUnitCount - virtual int allUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0; - - /// Retrieves the total number of strictly visible units that the player has, even if - /// information on the player is unrestricted. - /// - /// (optional) - /// The unit type to query. UnitType macros are accepted. If this parameter is omitted, - /// then it will use UnitTypes::AllUnits by default. - /// - /// - /// @returns The total number of units of the given type that the player owns, and is visible - /// to the BWAPI player. - /// @see allUnitCount, completedUnitCount, incompleteUnitCount - virtual int visibleUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0; - - /// Retrieves the number of completed units that the player has. If the - /// information about the player is limited, then this function will only return the number of - /// visible completed units. - /// - /// (optional) - /// The unit type to query. UnitType macros are accepted. If this parameter is omitted, - /// then it will use UnitTypes::AllUnits by default. - /// - /// - /// @returns The number of completed units of the given type that the player owns. - /// - /// Example usage: - /// @code - /// bool obtainNextUpgrade(BWAPI::UpgradeType upgType) - /// { - /// BWAPI::Player self = BWAPI::Broodwar->self(); - /// int maxLvl = self->getMaxUpgradeLevel(upgType); - /// int currentLvl = self->getUpgradeLevel(upgType); - /// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl && - /// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 && - /// self->completedUnitCount(upgType.whatUpgrades()) > 0 ) - /// return self->getUnits().upgrade(upgType); - /// return false; - /// } - /// @endcode - /// - /// @see allUnitCount, visibleUnitCount, incompleteUnitCount - virtual int completedUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0; - - /// Retrieves the number of incomplete units that the player has. If the - /// information about the player is limited, then this function will only return the number of - /// visible incomplete units. - /// - /// @note This function is a macro for allUnitCount() - completedUnitCount(). - /// - /// (optional) - /// The unit type to query. UnitType macros are accepted. If this parameter is omitted, - /// then it will use UnitTypes::AllUnits by default. - /// - /// - /// @returns The number of incomplete units of the given type that the player owns. - /// @see allUnitCount, visibleUnitCount, completedUnitCount - int incompleteUnitCount(UnitType unit = UnitTypes::AllUnits) const; - - /// Retrieves the number units that have died for this player. - /// - /// (optional) - /// The unit type to query. UnitType macros are accepted. If this parameter is omitted, - /// then it will use UnitTypes::AllUnits by default. - /// - /// - /// @returns The total number of units that have died throughout the game. - virtual int deadUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0; - - /// Retrieves the number units that the player has killed. - /// - /// (optional) - /// The unit type to query. UnitType macros are accepted. If this parameter is omitted, - /// then it will use UnitTypes::AllUnits by default. - /// - /// - /// @returns The total number of units that the player has killed throughout the game. - virtual int killedUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0; - - /// Retrieves the current upgrade level that the player has attained for a given - /// upgrade type. - /// - /// - /// The UpgradeType to query. - /// - /// - /// @returns The number of levels that the \p upgrade has been upgraded for this player. - /// - /// Example usage: - /// @code - /// bool obtainNextUpgrade(BWAPI::UpgradeType upgType) - /// { - /// BWAPI::Player self = BWAPI::Broodwar->self(); - /// int maxLvl = self->getMaxUpgradeLevel(upgType); - /// int currentLvl = self->getUpgradeLevel(upgType); - /// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl && - /// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 && - /// self->completedUnitCount(upgType.whatUpgrades()) > 0 ) - /// return self->getUnits().upgrade(upgType); - /// return false; - /// } - /// @endcode - /// - /// @see UnitInterface::upgrade, getMaxUpgradeLevel - virtual int getUpgradeLevel(UpgradeType upgrade) const = 0; - - /// Checks if the player has already researched a given technology. - /// - /// - /// The TechType to query. - /// - /// - /// @returns true if the player has obtained the given \p tech, or false if they have not - /// @see isResearching, UnitInterface::research, isResearchAvailable - virtual bool hasResearched(TechType tech) const = 0; - - /// Checks if the player is researching a given technology type. - /// - /// - /// The TechType to query. - /// - /// - /// @returns true if the player is currently researching the \p tech, or false otherwise - /// @see UnitInterface::research, hasResearched - virtual bool isResearching(TechType tech) const = 0; - - /// Checks if the player is upgrading a given upgrade type. - /// - /// - /// The upgrade type to query. - /// - /// - /// @returns true if the player is currently upgrading the given \p upgrade, false otherwise - /// - /// Example usage: - /// @code - /// bool obtainNextUpgrade(BWAPI::UpgradeType upgType) - /// { - /// BWAPI::Player self = BWAPI::Broodwar->self(); - /// int maxLvl = self->getMaxUpgradeLevel(upgType); - /// int currentLvl = self->getUpgradeLevel(upgType); - /// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl && - /// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 && - /// self->completedUnitCount(upgType.whatUpgrades()) > 0 ) - /// return self->getUnits().upgrade(upgType); - /// return false; - /// } - /// @endcode - /// - /// @see UnitInterface::upgrade - virtual bool isUpgrading(UpgradeType upgrade) const = 0; - - /// Retrieves the color value of the current player. - /// - /// @returns Color object that represents the color of the current player. - virtual BWAPI::Color getColor() const = 0; - - /// Retrieves the control code character that changes the color of text messages to - /// represent this player. - /// - /// @returns character code to use for text in Broodwar. - char getTextColor() const; - - /// Retrieves the maximum amount of energy that a unit type will have, taking the - /// player's energy upgrades into consideration. - /// - /// - /// The UnitType to retrieve the maximum energy for. - /// - /// - /// @returns Maximum amount of energy that the given unit type can have. - int maxEnergy(UnitType unit) const; - - /// Retrieves the top speed of a unit type, taking the player's speed upgrades into - /// consideration. - /// - /// - /// The UnitType to retrieve the top speed for. - /// - /// - /// @returns Top speed of the provided unit type for this player. - double topSpeed(UnitType unit) const; - - /// Retrieves the maximum weapon range of a weapon type, taking the player's weapon - /// upgrades into consideration. - /// - /// - /// The WeaponType to retrieve the maximum range for. - /// - /// - /// @returns Maximum range of the given weapon type for units owned by this player. - int weaponMaxRange(WeaponType weapon) const; - - /// Retrieves the sight range of a unit type, taking the player's sight range - /// upgrades into consideration. - /// - /// - /// The UnitType to retrieve the sight range for. - /// - /// - /// @returns Sight range of the provided unit type for this player. - int sightRange(UnitType unit) const; - - /// Retrieves the weapon cooldown of a unit type, taking the player's attack speed - /// upgrades into consideration. - /// - /// - /// The UnitType to retrieve the damage cooldown for. - /// - /// - /// @returns Weapon cooldown of the provided unit type for this player. - int weaponDamageCooldown(UnitType unit) const; - - /// Calculates the armor that a given unit type will have, including upgrades. - /// - /// - /// The unit type to calculate armor for, using the current player's upgrades. - /// - /// - /// @returns The amount of armor that the unit will have with the player's upgrades. - int armor(UnitType unit) const; - - /// Calculates the damage that a given weapon type can deal, including upgrades. - /// - /// - /// The weapon type to calculate for. - /// - /// - /// @returns The amount of damage that the weapon deals with this player's upgrades. - int damage(WeaponType wpn) const; - - /// Retrieves the total unit score, as seen in the end-game score screen. - /// - /// @returns The player's unit score. - virtual int getUnitScore() const = 0; - - /// Retrieves the total kill score, as seen in the end-game score screen. - /// - /// @returns The player's kill score. - virtual int getKillScore() const = 0; - - /// Retrieves the total building score, as seen in the end-game score screen. - /// - /// @returns The player's building score. - virtual int getBuildingScore() const = 0; - - /// Retrieves the total razing score, as seen in the end-game score screen. - /// - /// @returns The player's razing score. - virtual int getRazingScore() const = 0; - - /// Retrieves the player's custom score. This score is used in @UMS game - /// types. - /// - /// @returns The player's custom score. - virtual int getCustomScore() const = 0; - - /// Checks if the player is an observer player, typically in a @UMS observer - /// game. An observer player does not participate in the game. - /// - /// @returns true if the player is observing, or false if the player is capable of playing in - /// the game. - virtual bool isObserver() const = 0; - - /// Retrieves the maximum upgrades available specific to the player. This - /// value is only different from UpgradeType::maxRepeats in @UMS games. - /// - /// - /// The UpgradeType to retrieve the maximum upgrade level for. - /// - /// - /// @returns Maximum upgrade level of the given \p upgrade type. - /// - /// Example usage: - /// @code - /// bool obtainNextUpgrade(BWAPI::UpgradeType upgType) - /// { - /// BWAPI::Player self = BWAPI::Broodwar->self(); - /// int maxLvl = self->getMaxUpgradeLevel(upgType); - /// int currentLvl = self->getUpgradeLevel(upgType); - /// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl && - /// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 && - /// self->completedUnitCount(upgType.whatUpgrades()) > 0 ) - /// return self->getUnits().upgrade(upgType); - /// return false; - /// } - /// @endcode - virtual int getMaxUpgradeLevel(UpgradeType upgrade) const = 0; - - /// Checks if a technology can be researched by the player. Certain - /// technologies may be disabled in @UMS game types. - /// - /// - /// The TechType to query. - /// - /// - /// @returns true if the \p tech type is available to the player for research. - virtual bool isResearchAvailable(TechType tech) const = 0; - - /// Checks if a unit type can be created by the player. Certain unit types - /// may be disabled in @UMS game types. - /// - /// - /// The UnitType to check. - /// - /// - /// @returns true if the \p unit type is available to the player. - virtual bool isUnitAvailable(UnitType unit) const = 0; - - /// Verifies that this player satisfies a unit type requirement. - /// This verifies complex type requirements involving morphable @Zerg structures. For example, - /// if something requires a @Spire, but the player has (or is in the process of morphing) a - /// @Greater_Spire, this function will identify the requirement. It is simply a convenience function - /// that performs all of the requirement checks. - /// - /// - /// The UnitType to check. - /// - /// (optional) - /// The amount of units that are required. - /// - /// - /// @returns true if the unit type requirements are met, and false otherwise. - /// - /// @since 4.1.2 - bool hasUnitTypeRequirement(UnitType unit, int amount = 1) const; - }; -}; diff --git a/bwapi-includes/BWAPI/PlayerType.h b/bwapi-includes/BWAPI/PlayerType.h deleted file mode 100644 index 56b1e52..0000000 --- a/bwapi-includes/BWAPI/PlayerType.h +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// Namespace containing player types (player controllers). - /// @see PlayerType - namespace PlayerTypes - { - /// Enumeration of player types (player controllers). - /// @see PlayerType - namespace Enum - { - /// Enumeration of player types (player controllers). - /// @see PlayerType - enum Enum - { - None = 0, - Computer, - Player, - RescuePassive, - RescueActive, - EitherPreferComputer, - EitherPreferHuman, - Neutral, - Closed, - Observer, - PlayerLeft, - ComputerLeft, - Unknown, - MAX - }; - }; - }; - /// Represents the type of controller for the player slot (i.e. human, computer). - /// - /// @see PlayerTypes - /// @ingroup TypeClasses - class PlayerType : public Type - { - public: - /// @copydoc Type::Type(int) - PlayerType(int id = PlayerTypes::Enum::None); - - /// Identifies whether or not this type is used for the pre-game lobby. - /// A type such as PlayerTypes::ComputerLeft would only appear in-game when a computer - /// player is defeated. - /// - /// @returns true if this type can appear in the pre-game lobby, false otherwise. - bool isLobbyType() const; - - /// Identifies whether or not this type is used in-game. A type such as - /// PlayerTypes::Closed would not be a valid in-game type. - /// - /// @returns true if the type can appear in-game, false otherwise. - /// @see isLobbyType - bool isGameType() const; - }; - - /// @ingroup Types - namespace PlayerTypes - { - /// Retrieves the set of all the PlayerTypes. - /// - /// @returns Set consisting of all valid PlayerTypes. - const PlayerType::set& allPlayerTypes(); - - 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; - } - - static_assert(sizeof(PlayerType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/Playerset.h b/bwapi-includes/BWAPI/Playerset.h deleted file mode 100644 index d1bd143..0000000 --- a/bwapi-includes/BWAPI/Playerset.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once -#include "SetContainer.h" - -#include -#include - -namespace BWAPI -{ - // Forward Declarations - class PlayerInterface; - typedef PlayerInterface *Player; - class Unitset; - - /// A set containing Player objects. - class Playerset : public SetContainer> - { - public: - - /// Returns the set of all units that every player in this set owns. - /// - /// @returns Unitset containing Playerset's units - /// @see PlayerInterface::getUnits - Unitset getUnits() const; - - /// Returns the list of races that each player in the set is. - /// - /// @returns Race::set containing Playerset's races - /// @see PlayerInterface::getRace - Race::set getRaces() const; - - /// Sets the alliance status with all players contained in the Playerset. - /// - /// - /// Set to true to set the player to allied, or false for enemy. - /// - /// - /// Set to true to turn on allied victory, or false to disable it. - /// - /// - /// @see Game::setAlliance - void setAlliance(bool allies = true, bool alliedVictory = true); - - }; -} - diff --git a/bwapi-includes/BWAPI/Position.h b/bwapi-includes/BWAPI/Position.h deleted file mode 100644 index 7f44401..0000000 --- a/bwapi-includes/BWAPI/Position.h +++ /dev/null @@ -1,435 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include - -namespace BWAPI -{ - // Declaration - template - class Point; - - // Restrictions (no division by 0 or types too small to contain map positions) - template class Point {}; - template class Point {}; - template class Point {}; - template class Point {}; - - /// The Point class is a base class that implements convenience members and performs - /// conversions for several different position scales. It is intended to be inherited - /// or typedef'd for use with BWAPI. Users can extend the Point class, and implement their own - /// members, and it will remain compatible with BWAPI. - /// - /// @tparam T - /// The underlying type of the x and y values. BWAPI uses int. - /// @tparam Scale - /// The underlying scale that this is intended to be used for. The smaller this value, the - /// higher the precision. A value of 1 indicates the pixel level. - /// - /// Consider the following: - /// @code - /// class VectorPos : public BWAPI::Point // Same as BWAPI::Position with underlying type double - /// { - /// public: - /// VectorPos(double x_, double y_) : BWAPI::Point(x_, y_) {} - /// // ... whatever members that operate with the underling type double - /// }; - /// @endcode - /// - /// It then follows that this code will work without incident: - /// @code - /// BWAPI::Unit myUnit; // assume that the unit is valid and assigned elsewhere - /// VectorPos myPos{5.7, 8.2}; - /// myUnit->move(myPos); // Automatic type conversion, unit is moved to (5,8) - /// @endcode - /// - /// @note For full compatibility with BWAPI, \p T must have a precision of at least 16 bits and - /// \p Scale must be a factor of 32. - template - class Point - { - public: - typedef std::deque< Point > list; - - Point() = default; - Point(T _x, T _y) : x(_x), y(_y) {} - - /// A copy constructor for positions with different underlying types. - /// - /// - /// The Point to receive data from. - /// - /// - /// @tparam FromT - /// The type being converted to type T. - template Point(const Point &pt) : x( static_cast(pt.x) ), y( static_cast(pt.y) ) {} - -#pragma warning( push ) -#pragma warning( disable: 4723 ) - /// A conversion copy constructor to convert positions of different scales to one - /// another. - /// - /// @tparam FromT - /// The type that it is converting from. - /// @tparam FromScale - /// The scale that it is converting from. - template explicit Point(const Point &pt) - : x(static_cast(FromScale > Scale ? pt.x*(FromScale / Scale) : pt.x / (Scale / FromScale))) - , y(static_cast(FromScale > Scale ? pt.y*(FromScale / Scale) : pt.y / (Scale / FromScale))) { } -#pragma warning( pop ) - - // Operators - /// A convenience for use with if statements to identify if a position is valid. - /// @see isValid - explicit operator bool() const { return this->isValid(); }; - - bool operator == (const Point &pos) const - { - return std::tie(this->x, this->y) == std::tie(pos.x, pos.y); - }; - bool operator != (const Point &pos) const - { - return !(*this == pos); - }; - - /// A less than operator that enables positions to be used by additional STL containers. - /// Compares lexicographically the x position, followed by the y position. - bool operator < (const Point &position) const - { - return std::tie(this->x, this->y) < std::tie(position.x, position.y); - }; - - inline Point &operator += (const Point &p) - { - x += p.x; - y += p.y; - return *this; - }; - inline Point operator + (const Point &p) const - { - Point r(*this); - return r += p; - }; - inline Point &operator -= (const Point &p) - { - x -= p.x; - y -= p.y; - return *this; - }; - inline Point operator - (const Point &p) const - { - Point r(*this); - return r -= p; - }; - - inline Point &operator *= (const T &v) - { - x *= v; - y *= v; - return *this; - }; - inline Point operator *(const T &v) const - { - Point r(*this); - return r *= v; - }; - inline Point &operator |= (const T &v) - { - x |= v; - y |= v; - return *this; - }; - inline Point operator |(const T &v) const - { - Point r(*this); - return r |= v; - }; - inline Point &operator &= (const T &v) - { - x &= v; - y &= v; - return *this; - }; - inline Point operator &(const T &v) const - { - Point r(*this); - return r &= v; - }; - inline Point &operator ^= (const T &v) - { - x ^= v; - y ^= v; - return *this; - }; - inline Point operator ^(const T &v) const - { - Point r(*this); - return r ^= v; - }; - - Point operator / (const T &v) const - { - Point result(*this); - return result /= v; - }; - Point &operator /= (const T &val) - { - if (val == 0) { x = 32000 / Scale; y = 32000 / Scale; } - else { x /= val; y /= val; } - return *this; - }; - Point operator %(const T &v) const - { - Point result(*this); - return result %= v; - }; - Point &operator %= (const T &val) - { - if (val == 0) { x = 32000 / Scale; y = 32000 / Scale; } - else { x %= val; y %= val; } - return *this; - }; - - /// Ouput stream operator overload. Outputs the Point in the format "(x,y)" without - /// quotations. - /// - /// - /// Output stream. - /// - /// - /// Point to output. - /// - /// @returns Output stream \p out. - friend std::ostream &operator << (std::ostream &out, const Point &pt) - { - return out << '(' << pt.x << ',' << pt.y << ')'; - }; - /// @overload - friend std::wostream &operator << (std::wostream &out, const Point &pt) - { - return out << L'(' << pt.x << L',' << pt.y << L')'; - }; - - /// Input stream operator overload. Reads the input in the form "x y" without - /// quotations. The x and y values are read as type T(typically int or float) and - /// stored into pt. - /// - /// - /// The input stream. - /// - /// - /// The receiving variable. - /// - /// @returns Input stream \p in. - friend std::istream &operator >> (std::istream &in, Point &pt) - { - return in >> pt.x >> pt.y; - }; - /// @overload - friend std::wistream &operator >> (std::wistream &in, Point &pt) - { - return in >> pt.x >> pt.y; - }; - - /// Checks if this point is within the game's map bounds. - /// - /// @note If the Broodwar pointer is not initialized, this function will check validity - /// against the largest (256x256) map size. - /// - /// @retval true If it is a valid position and on the map/playing field. - /// @retval false If this is not a valid position. - /// - /// @see makeValid - bool isValid() const; - - /// Checks if this point is within the game's map bounds, if not, then it will set - /// the x and y values to be within map bounds. For example, if x is less than 0, - /// then x is set to 0. - /// - /// @note If the Broodwar pointer is not initialized, this function will check validity - /// against the largest (256x256) map size. - /// - /// @returns A reference to itself. - /// @see isValid - Point &makeValid(); - - /// Gets an accurate distance measurement from this point to the given position. - /// - /// @note This function impedes performance. In most cases you should use getApproxDistance. - /// - /// - /// The target position to get the distance to. - /// - /// - /// @returns A double representing the distance between this point and \p position. - /// @see getApproxDistance - double getDistance(const Point &position) const - { - return ((*this) - position).getLength(); - }; - - /// Gets the length of this point from the top left corner of the map. - /// - /// @note This function impedes performance. In most cases you should use getApproxDistance. - /// - /// @returns A double representing the length of this point from (0,0). - /// @see getApproxDistance - double getLength() const - { - double x = (double)this->x; - double y = (double)this->y; - return sqrt(x * x + y * y); - }; - - /// Retrieves the approximate distance using an algorithm from Starcraft: Broodwar. - /// - /// @note This function is desired because it uses the same "imperfect" algorithm used in - /// Broodwar, so that calculations will be consistent with the game. It is also optimized - /// for performance. - /// - /// - /// The target point to measure the distance to. - /// - /// - /// @returns An integer representing the distance between this point and \p position. - /// @see getDistance - int getApproxDistance(const Point &position) const - { - unsigned int min = abs((int)(this->x - position.x)); - unsigned int max = abs((int)(this->y - position.y)); - if ( max < min ) - std::swap(min, max); - - if ( min < (max >> 2) ) - return max; - - unsigned int minCalc = (3*min) >> 3; - return (minCalc >> 5) + minCalc + max - (max >> 4) - (max >> 6); - }; - - /// Sets the maximum x and y values. If the current x or y values exceed - /// the given maximum, then values are set to the maximum. - /// - /// - /// Maximum x value. - /// - /// - /// Maximum y value. - /// - /// - /// @returns A reference to itself. - /// @see setMin - Point &setMax(T max_x, T max_y) - { - if ( x > max_x ) - x = max_x; - if ( y > max_y ) - y = max_y; - return *this; - }; - /// @overload - Point &setMax(const Point &max) - { - this->setMax(max.x, max.y); - return *this; - }; - - /// Sets the minimum x and y values. If the current x or y values are - /// below the given minimum, then values are set to the minimum. - /// - /// - /// Minimum x value. - /// - /// - /// Minimum y value. - /// - /// - /// @returns A reference to itself. - /// @see setMax - Point &setMin(T min_x, T min_y) - { - if ( x < min_x ) - x = min_x; - if ( y < min_y ) - y = min_y; - return *this; - }; - /// @overload - Point &setMin(const Point &min) - { - this->setMin(min.x, min.y); - return *this; - }; - - /// The x and y members for this class. - /// - /// Simply reference these members when retrieving a position's x and y values. - T x = T{}, y = T{}; - }; - - /// The scale of a @ref Position. Each position corresponds to a 1x1 pixel area. - /// @see Position - const int POSITION_SCALE = 1; - - /// The scale of a @ref WalkPosition. Each walk position corresponds to an 8x8 pixel area. - /// @see WalkPosition - const int WALKPOSITION_SCALE = 8; - - /// The scale of a @ref TilePosition. Each tile position corresponds to a 32x32 pixel area. - /// @see TilePosition - const int TILEPOSITION_SCALE = 32; - - /// Indicates a position that is 1x1 pixel in size. This is the most precise position type. - /// @see Positions - typedef BWAPI::Point Position; - - /// List of special @ref Position constants. - namespace Positions - { - /// @hideinitializer - const Position Invalid{32000 / POSITION_SCALE, 32000 / POSITION_SCALE}; - /// @hideinitializer - const Position None{32000 / POSITION_SCALE, 32032 / POSITION_SCALE}; - /// @hideinitializer - const Position Unknown{32000 / POSITION_SCALE, 32064 / POSITION_SCALE}; - const Position Origin{0, 0}; - } - - /// Indicates a position that is 8x8 pixels in size. - /// @see Game::isWalkable, WalkPositions - typedef BWAPI::Point WalkPosition; - - /// List of special @ref WalkPosition constants. - namespace WalkPositions - { - /// @hideinitializer - const WalkPosition Invalid{32000 / WALKPOSITION_SCALE, 32000 / WALKPOSITION_SCALE}; - /// @hideinitializer - const WalkPosition None{32000 / WALKPOSITION_SCALE, 32032 / WALKPOSITION_SCALE}; - /// @hideinitializer - const WalkPosition Unknown{32000 / WALKPOSITION_SCALE, 32064 / WALKPOSITION_SCALE}; - const WalkPosition Origin{0,0}; - } - - /// Indicates a position that is 32x32 pixels in size. Typically used for building placement. - /// @see TilePositions - typedef BWAPI::Point TilePosition; - - /// List of special @ref TilePosition constants. - namespace TilePositions - { - /// @hideinitializer - const TilePosition Invalid{32000 / TILEPOSITION_SCALE, 32000 / TILEPOSITION_SCALE}; - /// @hideinitializer - const TilePosition None{32000 / TILEPOSITION_SCALE, 32032 / TILEPOSITION_SCALE}; - /// @hideinitializer - const TilePosition Unknown{32000 / TILEPOSITION_SCALE, 32064 / TILEPOSITION_SCALE}; - const TilePosition Origin{0, 0}; - } - - static_assert(sizeof(Position) == 8, "Expected BWAPI Position to be 8 bytes."); - static_assert(sizeof(TilePosition) == 8, "Expected BWAPI Position to be 8 bytes."); - static_assert(sizeof(WalkPosition) == 8, "Expected BWAPI Position to be 8 bytes."); -} diff --git a/bwapi-includes/BWAPI/PositionUnit.h b/bwapi-includes/BWAPI/PositionUnit.h deleted file mode 100644 index 81a9309..0000000 --- a/bwapi-includes/BWAPI/PositionUnit.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - class UnitInterface; - typedef UnitInterface *Unit; - - /// PositionOrUnit is a class that is either a Position or a Unit. - /// The purpose of this class is to reduce interface overhead by combining two commonly passed - /// values into one, and to allow more function overloads with less effort. - class PositionOrUnit - { - public: - /// Unit constructor. Assigns this class to contain a unit. - /// - /// - /// The unit to assign to this class. - /// - PositionOrUnit(Unit unit = nullptr); - - /// Position constructor. Assigns this class to contain a position. - /// - /// - /// The position to assign to this class. - /// - PositionOrUnit(Position pos); - - /// Unit assignment operator. Assigns a unit to this class. - PositionOrUnit &operator =(Unit pUnit); - - /// Position assignment operator. Assigns a position to this class. - PositionOrUnit &operator =(Position pos); - - /// Indicates if a Unit is currently held in this class. - /// - /// @returns true if the value contained within this class is considered a unit, and false if - /// it is a position. - bool isUnit() const; - - /// Retrieves the Unit attached to this class, if there is one. - /// - /// @returns The Unit that was assigned to this class. - /// @retval nullptr If this class does not contain a unit, or if nullptr was assigned to - /// this class as a Unit. - Unit getUnit() const; - - /// Indicates if a Position is currently held in this class. - /// - /// @returns true if the value contained within this class is considered a position, and false - /// if it is a unit. - bool isPosition() const; - - /// Retrieves the position if it was assigned to this class, otherwise it will - /// retrieve the position of the unit contained within this class if there is one. - /// - /// @returns Position that was stored if there is one. If not, then the position of the unit - /// will be used instead. - /// @retval Positions::None if a nullptr Unit was assigned to this class. - Position getPosition() const; - - private: - /// @cond HIDDEN - union - { - struct - { - int x, y; - } position; - struct - { - Unit pUnit; - int y; - } unit; - }; - /// @endcond - }; - -} diff --git a/bwapi-includes/BWAPI/Race.h b/bwapi-includes/BWAPI/Race.h deleted file mode 100644 index 4190e75..0000000 --- a/bwapi-includes/BWAPI/Race.h +++ /dev/null @@ -1,107 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - class UnitType; - - /// Namespace containing all valid races. - /// @see Race - namespace Races - { - /// Enumeration of races. - /// @see Race - namespace Enum - { - /// Enumeration of races. - /// @see Race - enum Enum - { - Zerg = 0, - Terran, - Protoss, - Other, - Unused, - Select, - Random, - None, - Unknown, - MAX - }; - }; - } - - /// The Race object is used to get information about a particular race. For - /// example, the default worker and supply provider UnitType. - /// - /// As you should already know, Starcraft has three races: @Terran , @Protoss , and @Zerg . - /// @see UnitType::getRace, PlayerInterface::getRace, Races - /// @ingroup TypeClasses - class Race : public Type - { - public: - /// @copydoc Type::Type(int) - Race(int id = Races::Enum::None); - - /// Retrieves the default worker type for this Race. - /// - /// @note In Starcraft, workers are the units that are used to construct structures. - /// - /// @returns UnitType of the worker that this race uses. - UnitType getWorker() const; - - /// Retrieves the default resource center UnitType that is used to create expansions for - /// this Race. - /// - /// @note In Starcraft, the center is the very first structure of the Race's technology - /// tree. Also known as its base of operations or resource depot. - /// - /// @returns UnitType of the center that this race uses. - UnitType getCenter() const; - - /// Retrieves the default structure UnitType for this Race that is used to harvest gas from - /// @Geysers. - /// - /// @note In Starcraft, you must first construct a structure over a @Geyser in order to - /// begin harvesting Vespene Gas. - /// - /// @returns UnitType of the structure used to harvest gas. - UnitType getRefinery() const; - - /// Retrieves the default transport UnitType for this race that is used to transport ground - /// units across the map. - /// - /// @note In Starcraft, transports will allow you to carry ground units over unpassable - /// terrain. - /// - /// @returns UnitType for transportation. - UnitType getTransport() const; - - /// Retrieves the default supply provider UnitType for this race that is used to construct - /// units. - /// - /// @note In Starcraft, training, morphing, or warping in units requires that the player - /// has sufficient supply available for their Race. - /// - /// @returns UnitType that provides the player with supply. - UnitType getSupplyProvider() const; - }; - - /// @ingroup Types - namespace Races - { - /// Retrieves the set of all valid races. - /// - /// @returns Race::set containing all the Race types. - const Race::set& allRaces(); - - extern const Race Zerg; - extern const Race Terran; - extern const Race Protoss; - extern const Race Random; - extern const Race None; - extern const Race Unknown; - } - - static_assert(sizeof(Race) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/Region.h b/bwapi-includes/BWAPI/Region.h deleted file mode 100644 index 5cbbb36..0000000 --- a/bwapi-includes/BWAPI/Region.h +++ /dev/null @@ -1,134 +0,0 @@ -#pragma once -#include -#include -#include -#include - -namespace BWAPI -{ - class Regionset; - class Unitset; - - class RegionInterface; - typedef RegionInterface *Region; - - /// Region objects are created by Starcraft: Broodwar to contain several tiles with the same - /// properties, and create a node in pathfinding and other algorithms. Regions may not contain - /// detailed information, but have a sufficient amount of data to identify general chokepoints, - /// accessibility to neighboring terrain, be used in general pathing algorithms, and used as - /// nodes to rally units to. - /// - /// Most parameters that are available are explicitly assigned by Broodwar itself. - /// - /// @see Game::getAllRegions, Game::getRegionAt, UnitInterface::getRegion - /// @ingroup Interface - class RegionInterface : public Interface - { - protected: - virtual ~RegionInterface() {}; - public: - /// Retrieves a unique identifier for this region. - /// - /// @note This identifier is explicitly assigned by Broodwar. - /// - /// @returns An integer that represents this region. - /// @see Game::getRegion - virtual int getID() const = 0; - - /// Retrieves a unique identifier for a group of regions that are all connected and - /// accessible by each other. That is, all accessible regions will have the same - /// group ID. This function is generally used to check if a path is available between two - /// points in constant time. - /// - /// @note This identifier is explicitly assigned by Broodwar. - /// - /// @returns An integer that represents the group of regions that this one is attached to. - virtual int getRegionGroupID() const = 0; - - /// Retrieves the center of the region. This position is used as the node - /// of the region. - /// - /// @returns A Position indicating the center location of the Region, in pixels. - virtual BWAPI::Position getCenter() const = 0; - - /// Checks if this region is part of higher ground. Higher ground may be - /// used in strategic placement of units and structures. - /// - /// @returns true if this region is part of strategic higher ground, and false otherwise. - virtual bool isHigherGround() const = 0; - - /// Retrieves a value that represents the strategic advantage of this region relative - /// to other regions. A value of 2 may indicate a possible choke point, and a value - /// of 3 indicates a signficant strategic position. - /// - /// @note This value is explicitly assigned by Broodwar. - /// - /// @returns An integer indicating this region's strategic potential. - virtual int getDefensePriority() const = 0; - - /// Retrieves the state of accessibility of the region. The region is - /// considered accessible if it can be accessed by ground units. - /// - /// @returns true if ground units can traverse this region, and false if the tiles in this - /// region are inaccessible or unwalkable. - virtual bool isAccessible() const = 0; - - /// Retrieves the set of neighbor Regions that this one is connected to. - /// - /// @returns A reference to a Regionset containing the neighboring Regions. - virtual const Regionset &getNeighbors() const = 0; - - /// Retrieves the approximate left boundary of the region. - /// - /// @returns The x coordinate, in pixels, of the approximate left boundary of the region. - virtual int getBoundsLeft() const = 0; - - /// Retrieves the approximate top boundary of the region. - /// - /// @returns The y coordinate, in pixels, of the approximate top boundary of the region. - virtual int getBoundsTop() const = 0; - - /// Retrieves the approximate right boundary of the region. - /// - /// @returns The x coordinate, in pixels, of the approximate right boundary of the region. - virtual int getBoundsRight() const = 0; - - /// Retrieves the approximate bottom boundary of the region. - /// - /// @returns The y coordinate, in pixels, of the approximate bottom boundary of the region. - virtual int getBoundsBottom() const = 0; - - /// Retrieves the closest accessible neighbor region. - /// - /// @returns The closest Region that is accessible. - virtual BWAPI::Region getClosestAccessibleRegion() const = 0; - - /// Retrieves the closest inaccessible neighbor region. - /// - /// @returns The closest Region that is inaccessible. - virtual BWAPI::Region getClosestInaccessibleRegion() const = 0; - - /// Retrieves the center-to-center distance between two regions. - /// - /// - /// The target Region to calculate distance to. - /// - /// @returns The integer distance from this Region to \p other. - int getDistance(BWAPI::Region other) const; - - /// Retrieves a Unitset containing all the units that are in this region. - /// Also has the ability to filter the units before the creation of the Unitset. - /// - /// (optional) - /// If this parameter is used, it is a UnitFilter or function predicate that will retrieve - /// only the units whose attributes match the given criteria. If omitted, then a default - /// value of nullptr is used, in which case there is no filter. - /// - /// - /// @returns A Unitset containing all units in this region that have met the requirements - /// of \p pred. - /// - /// @see UnitFilter - Unitset getUnits(const UnitFilter &pred = nullptr) const; - }; -}; diff --git a/bwapi-includes/BWAPI/Regionset.h b/bwapi-includes/BWAPI/Regionset.h deleted file mode 100644 index e15586a..0000000 --- a/bwapi-includes/BWAPI/Regionset.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "SetContainer.h" -#include -#include - -namespace BWAPI -{ - // Forward Declarations - class RegionInterface; - typedef RegionInterface *Region; - - class Unitset; - - /// A container that holds a set of Region objects. - class Regionset : public SetContainer> - { - public: - - /// @copydoc RegionInterface::getCenter - Position getCenter() const; - - /// @copydoc RegionInterface::getUnits - Unitset getUnits(const UnitFilter &pred = nullptr) const; - }; -} - diff --git a/bwapi-includes/BWAPI/SetContainer.h b/bwapi-includes/BWAPI/SetContainer.h deleted file mode 100644 index f1aed25..0000000 --- a/bwapi-includes/BWAPI/SetContainer.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include -#include - -namespace BWAPI -{ - template - using SetContainerUnderlyingT = std::unordered_set < T, HashT >; - - /// This container is used to wrap convenience functions for BWAPI and be used as a - /// bridge with a built-in set type. - /// - /// @tparam T - /// Type that this set contains. - /// @tparam HashT - /// Hash type. Defaults to integral hashing for BWAPI usage. - template > - class SetContainer : public SetContainerUnderlyingT < T, HashT > - { - public: - SetContainer() : SetContainerUnderlyingT() {} - SetContainer(SetContainer const &other) : SetContainerUnderlyingT(other) {} - SetContainer(SetContainer &&other) : SetContainerUnderlyingT(std::forward(other)) {} - SetContainer(std::initializer_list ilist) : SetContainerUnderlyingT(ilist) {} - - template - SetContainer(IterT _begin, IterT _end) : SetContainerUnderlyingT(_begin, _end) {} - - /// Iterates the set and erases each element x where pred(x) returns true. - /// - /// - /// Predicate for removing elements. - /// - /// @see std::erase_if - template - void erase_if(const Pred& pred) { - auto it = this->begin(); - while (it != this->end()) { - if (pred(*it)) it = this->erase(it); - else ++it; - } - }; - - /// Checks if this set contains a specific value. - /// - /// - /// Value to search for. - /// - bool contains(T const &value) const - { - return count(value) != 0; - } - }; - -} diff --git a/bwapi-includes/BWAPI/TechType.h b/bwapi-includes/BWAPI/TechType.h deleted file mode 100644 index d2ae413..0000000 --- a/bwapi-includes/BWAPI/TechType.h +++ /dev/null @@ -1,214 +0,0 @@ -#pragma once -#include -#include - -namespace BWAPI -{ - class UnitType; - class WeaponType; - class Order; - class Race; - - /// Namespace containing tech types. - /// @see TechType - namespace TechTypes - { - /// Enumeration of Tech Types. - /// @see TechType - namespace Enum - { - /// Enumeration of Tech Types. - /// @see TechType - enum Enum - { - Stim_Packs = 0, - Lockdown, - EMP_Shockwave, - Spider_Mines, - Scanner_Sweep, - Tank_Siege_Mode, - Defensive_Matrix, - Irradiate, - Yamato_Gun, - Cloaking_Field, - Personnel_Cloaking, - Burrowing, - Infestation, - Spawn_Broodlings, - Dark_Swarm, - Plague, - Consume, - Ensnare, - Parasite, - Psionic_Storm, - Hallucination, - Recall, - Stasis_Field, - Archon_Warp, - Restoration, - Disruption_Web, - Unused_26, - Mind_Control, - Dark_Archon_Meld, - Feedback, - Optical_Flare, - Maelstrom, - Lurker_Aspect, - Unused_33, - Healing, - - None = 44, - Nuclear_Strike, - Unknown, - MAX - }; - }; - } - /// The TechType (or Technology Type, also referred to as an Ability) represents a Unit's ability - /// which can be researched with UnitInterface::research or used with UnitInterface::useTech. - /// In order for a Unit to use its own specialized ability, it must first be available and researched. - /// - /// @see TechTypes - /// @ingroup TypeClasses - class TechType : public Type - { - public: - /// @copydoc Type::Type(int) - TechType(int id = TechTypes::Enum::None); - - /// Retrieves the race that is required to research or use the TechType. - /// - /// @note There is an exception where @Infested_Kerrigan can use @Psi_Storm. This does not - /// apply to the behavior of this function. - /// - /// @returns Race object indicating which race is designed to use this technology type. - Race getRace() const; - - /// Retrieves the mineral cost of researching this technology. - /// - /// @returns Amount of minerals needed in order to research this technology. - int mineralPrice() const; - - /// Retrieves the vespene gas cost of researching this technology. - /// - /// @returns Amount of vespene gas needed in order to research this technology. - int gasPrice() const; - - /// Retrieves the number of frames needed to research the tech type. - /// - /// @returns The time, in frames, it will take for the research to complete. - /// @see UnitInterface::getRemainingResearchTime - int researchTime() const; - - /// Retrieves the amount of energy needed to use this TechType as an ability. - /// - /// @returns Energy cost of the ability. - /// @see UnitInterface::getEnergy - int energyCost() const; - - /// Retrieves the UnitType that can research this technology. - /// - /// @returns UnitType that is able to research the technology in the game. - /// @retval UnitTypes::None If the technology/ability is either provided for free or never - /// available. - UnitType whatResearches() const; - - /// Retrieves the Weapon that is attached to this tech type. - /// A technology's WeaponType is used to indicate the range and behaviour of the ability - /// when used by a Unit. - /// - /// @returns WeaponType containing information about the ability's behavior. - /// @retval WeaponTypes::None If there is no corresponding WeaponType. - WeaponType getWeapon() const; - - /// Checks if this ability can be used on other units. - /// - /// @returns true if the ability can be used on other units, and false if it can not. - bool targetsUnit() const; - - /// Checks if this ability can be used on the terrain (ground). - /// - /// @returns true if the ability can be used on the terrain. - bool targetsPosition() const; - - /// Retrieves the set of all UnitTypes that are capable of using this ability. - /// - /// @returns Set of UnitTypes that can use this ability when researched. - const UnitType::set& whatUses() const; - - /// Retrieves the Order that a Unit uses when using this ability. - /// - /// @returns Order representing the action a Unit uses to perform this ability - Order getOrder() const; - - /// Retrieves the UnitType required to research this technology. - /// The required unit type must be a completed unit owned by the player researching the - /// technology. - /// - /// @returns UnitType that is needed to research this tech type. - /// @retval UnitTypes::None if no unit is required to research this tech type. - /// - /// @see PlayerInterface::completedUnitCount - /// - /// @since 4.1.2 - UnitType requiredUnit() const; - }; - - /// @ingroup Types - namespace TechTypes - { - /// Retrieves the set of all the TechTypes. - /// - /// @returns Set of all available TechTypes. - const TechType::set& allTechTypes(); - - /// @name Terran Abilities - /// @{ - 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 Restoration; - extern const TechType Optical_Flare; - extern const TechType Healing; - extern const TechType Nuclear_Strike; - /// @} - /// @name Zerg Abilities - /// @{ - 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 Lurker_Aspect; - /// @} - /// @name Protoss Abilities - /// @{ - 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 Disruption_Web; - extern const TechType Mind_Control; - extern const TechType Dark_Archon_Meld; - extern const TechType Feedback; - extern const TechType Maelstrom; - /// @} - - extern const TechType None; - extern const TechType Unknown; - }; - - static_assert(sizeof(TechType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/TournamentAction.h b/bwapi-includes/BWAPI/TournamentAction.h deleted file mode 100644 index f4f1427..0000000 --- a/bwapi-includes/BWAPI/TournamentAction.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -namespace BWAPI -{ - /// Contains a list of interruptable actions that the tournament module can allow or deny. - /// @see TournamentModule::onAction - namespace Tournament - { - /// Contains a list of interruptable actions that the tournament module can allow or deny. - /// @see TournamentModule::onAction - enum ActionID - { - /// @see Game::enableFlag - EnableFlag, - - /// @see Game::pauseGame - PauseGame, - - /// @see Game::resumeGame - ResumeGame, - - /// @see Game::leaveGame - LeaveGame, - - /// @see Game::setLocalSpeed - SetLocalSpeed, - - /// @see Game::setTextSize - SetTextSize, - - /// @see Game::setLatCom - SetLatCom, - - /// @see Game::setGUI - SetGUI, - - /// @see Game::setMap - SetMap, - - /// @see Game::setFrameSkip - SetFrameSkip, - - /// @see Game::printf - Printf, - - /// @see Game::sendText - SendText, - - /// @see Game::setCommandOptimizationLevel - SetCommandOptimizationLevel - }; - - }; -}; diff --git a/bwapi-includes/BWAPI/Type.h b/bwapi-includes/BWAPI/Type.h deleted file mode 100644 index 79f13d8..0000000 --- a/bwapi-includes/BWAPI/Type.h +++ /dev/null @@ -1,160 +0,0 @@ -#pragma once -#include - -#include -#include -#include -#include -#include -#include - -namespace BWAPI -{ - template class Type; - - /// Base superclass for all BWAPI Types. - /// - /// @tparam T - /// The type class that this Type is representing. - /// - /// @tparam UnknownId - /// The enum ID of the unknown entry, which is also treated as the last entry for type - /// validity. - template - class Type - { - protected: - /// @cond HIDDEN - /// Primitive storage unit for the type identifier (type id). - int tid; - - /// Array of strings containing the type names. - static const std::string typeNames[UnknownId+1]; - - /// Type that maps names to their type values. - typedef std::unordered_map typeMapT; - /// @endcond - private: - static typeMapT typeMapInit() - { - typeMapT result(UnknownId+1); - for ( int i = 0; i < UnknownId + 1; ++i ) // include unknown - { - std::string n( typeNames[i] ); - - // erase-remove idiom, eliminates spaces and underscores from the string - n.erase( std::remove_if(n.begin(), n.end(), [](char const &c){ return isspace(c) || c == '_'; }), n.end() ); - - // Make lowercase - std::transform (n.begin (), n.end (), n.begin (), ::tolower); - - result.insert( typeMapT::value_type(n, T(i)) ); - } - return result; - } - public: - /// Expected type constructor. If the type is an invalid type, then it - /// becomes Types::Unknown. A type is invalid if its value is less than 0 or greater than - /// Types::Unknown. - /// - /// - /// The id that corresponds to this type. It is typically an integer value that corresponds - /// to an internal Broodwar type. If the given id is invalid, then it becomes Types::Unknown. - /// - explicit Type(int id) : tid( id < 0 || id > UnknownId ? UnknownId : id ) {}; - - /// A set type that contains the current type. - typedef SetContainer set; - - /// A list type that contains the current type. - typedef std::deque list; - - /// Conversion/convenience operator to convert this type to its primitive type. - /// - /// @returns An integer representation of this type. - inline operator int() const { return this->tid; }; - - /// Retrieves this type's identifier as an integer. - /// - /// @returns An integer representation of this type. - inline int getID() const { return this->tid; }; - - /// Checks if the current type has a valid identifier. The purpose of - /// this function is to prevent buffer overflows if a type has been handled improperly. - /// - /// A type is valid if it is between 0 and Unknown (inclusive). - /// - /// @returns true If this type is valid and false otherwise. - inline bool isValid() const { return this->tid >= 0 && this->tid <= UnknownId; }; - - /// Retrieves the variable name of the type. - /// - /// @returns Reference to std::string object containing the name. - inline const std::string &getName() const - { - return typeNames[this->isValid() ? this->tid : UnknownId]; - }; - - /// @copydoc Type::getName - inline const std::string &toString() const - { - return this->getName(); - }; - - /// Retrieves the variable name of the type as a c-style string. Meant to - /// be a convenience member. - /// - /// @returns Pointer to constant c-style string containing the name. - inline const char *c_str() const - { - return this->getName().c_str(); - }; - - /// Output stream operator overload. Allows printing of the type without - /// calling Type::getName. - /// - /// - /// The destination output stream. - /// - /// - /// The type to write as a string. - /// - friend inline std::ostream &operator << (std::ostream &out, const Type &t) - { - return out << t.getName(); - }; - /// @overload - friend inline std::wostream &operator << (std::wostream &out, const Type &t) - { - std::wstring wideName{ t.getName().begin(), t.getName().end() }; - return out << wideName; - }; - - /// Searches for the type associated with the given string and returns it. - /// - /// - /// A string containing the name of the type. - /// - /// @returns The type that resolves to the given name. - static T getType(std::string name) - { - // Mapping of strings to types - static const typeMapT typeMap( typeMapInit() ); - - // erase-remove idiom, eliminates spaces and underscores from the string to search - name.erase( std::remove_if(name.begin(), name.end(), [](char const &c){ return isspace(c) || c == '_'; }), name.end() ); - - // Make lowercase - std::transform (name.begin (), name.end (), name.begin (), ::tolower); - - // Find the type - auto it = typeMap.find(name); - if ( it != typeMap.end() ) - return it->second; - - // Return unknown if it wasn't found - return T(UnknownId); - }; - }; - -} diff --git a/bwapi-includes/BWAPI/UnaryFilter.h b/bwapi-includes/BWAPI/UnaryFilter.h deleted file mode 100644 index 043a5e1..0000000 --- a/bwapi-includes/BWAPI/UnaryFilter.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// UnaryFilter allows for logical functor combinations. - /// - /// @code - /// Unit myUnit; - /// // The following two if statements are equivalent - /// if ( myUnit->getType().isWorker() && myUnit->isCompleted() && myUnit->isIdle() ) - /// {} - /// - /// if ( (IsWorker && IsCompleted && IsIdle)(myUnit) ) - /// {} - /// @endcode - /// - /// @tparam PType - /// The type being passed into the predicate, which will be of type bool(PType). - /// @tparam Container (optional) - /// Storage container for the function predicate. It is std::function by default. - template > - class UnaryFilter - { - private: - Container pred; - public: - // ctor - template < typename T > - UnaryFilter(const T &predicate) : pred(predicate) {} - - // Default copy/move ctor/assign and dtor - - // logical operators - template - inline UnaryFilter > operator &&(const T& other) const - { - return [=](PType v){ return (*this)(v) && other(v); }; - }; - - template - inline UnaryFilter > operator ||(const T& other) const - { - return [=](PType v){ return (*this)(v) || other(v); }; - }; - - inline UnaryFilter > operator !() const - { - if ( !this->pred ) - return nullptr; - return [=](PType v){ return !(*this)(v); }; - }; - - // call - inline bool operator()(PType v) const - { - return pred(v); - }; - - // operator bool - inline bool isValid() const - { - return (bool)pred; - }; - - }; - -} diff --git a/bwapi-includes/BWAPI/Unit.h b/bwapi-includes/BWAPI/Unit.h deleted file mode 100644 index fdae652..0000000 --- a/bwapi-includes/BWAPI/Unit.h +++ /dev/null @@ -1,2460 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include - -namespace BWAPI -{ - // Forwards - class PlayerInterface; - typedef PlayerInterface *Player; - class Order; - class TechType; - class UpgradeType; - - class RegionInterface; - typedef RegionInterface *Region; - - class UnitCommand; - class UnitCommandType; - class Unitset; - class WeaponType; - - class UnitInterface; - typedef UnitInterface *Unit; - - /// 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 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, UnitInterface::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 - /// UnitInterface::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, then only the getInitial__ functions will be available to the AI. - /// However for units that were owned by the player, getPlayer and getType will continue to work for units - /// that have been destroyed. - /// - /// @ingroup Interface - class UnitInterface : public Interface - { - protected: - virtual ~UnitInterface() {}; - public: - /// Retrieves a unique identifier for this unit. - /// - /// @returns An integer containing the unit's identifier. - /// - /// @see getReplayID - virtual int getID() const = 0; - - /// Checks if the Unit exists in the view of the BWAPI player. - /// - /// This is used primarily to check if BWAPI has access to a specific unit, or if the - /// unit is alive. This function is more general and would be synonymous to an isAlive - /// function if such a function were necessary. - /// - /// @retval true If the unit exists on the map and is visible according to BWAPI. - /// @retval false If the unit is not accessible or the unit is dead. - /// - /// In the event that this function returns false, there are two cases to consider: - /// 1. You own the unit. This means the unit is dead. - /// 2. Another player owns the unit. This could either mean that you don't have access - /// to the unit or that the unit has died. You can specifically identify dead units - /// by polling onUnitDestroy. - /// - /// @see isVisible, isCompleted - virtual bool exists() const = 0; - - /// Retrieves the unit identifier for this unit as seen in replay data. - /// - /// @note This is only available if Flag::CompleteMapInformation is enabled. - /// - /// @returns An integer containing the replay unit identifier. - /// - /// @see getID - virtual int getReplayID() const = 0; - - /// Retrieves the player that owns this unit. - /// - /// @retval Game::neutral() If the unit is a neutral unit or inaccessible. - /// - /// @returns The owning Player interface object. - virtual Player getPlayer() const = 0; - - /// Retrieves the unit's type. - /// - /// @retval UnitTypes::Unknown if this unit is inaccessible or cannot be determined. - /// @returns A UnitType objects representing the unit's type. - /// - /// @see getInitialType - virtual UnitType getType() const = 0; - - /// Retrieves the unit's position from the upper left corner of the map in pixels. - /// The position returned is roughly the center if the unit. - /// - /// @note The unit bounds are defined as this value plus/minus the values of - /// UnitType::dimensionLeft, UnitType::dimensionUp, UnitType::dimensionRight, - /// and UnitType::dimensionDown, which is conveniently expressed in UnitInterface::getLeft, - /// UnitInterface::getTop, UnitInterface::getRight, and UnitInterface::getBottom respectively. - /// - /// @retval Positions::Unknown if this unit is inaccessible. - /// - /// @returns Position object representing the unit's current position. - /// - /// @see getTilePosition, getInitialPosition, getLeft, getTop - virtual Position getPosition() const = 0; - - /// Retrieves the unit's build position from the upper left corner of the map in - /// tiles. - /// - /// @note: This tile position is the tile that is at the top left corner of the structure. - /// - /// @retval TilePositions::Unknown if this unit is inaccessible. - /// - /// @returns TilePosition object representing the unit's current tile position. - /// - /// @see getPosition, getInitialTilePosition - TilePosition getTilePosition() const; - - /// Retrieves the unit's facing direction in radians. - /// - /// @note A value of 0.0 means the unit is facing east. - /// - /// @returns A double with the angle measure in radians. - virtual double getAngle() const = 0; - - /// Retrieves the x component of the unit's velocity, measured in pixels per frame. - /// - /// @returns A double that represents the velocity's x component. - /// - /// @see getVelocityY - virtual double getVelocityX() const = 0; - - /// Retrieves the y component of the unit's velocity, measured in pixels per frame. - /// - /// @returns A double that represents the velocity's y component. - /// - /// @see getVelocityX - virtual double getVelocityY() const = 0; - - /// Retrieves the Region that the center of the unit is in. - /// - /// @retval nullptr If the unit is inaccessible. - /// - /// @returns The Region object that contains this unit. - /// - /// Example - /// @code - /// Unitset myUnits = Broodwar->self()->getUnits(); - /// for ( auto u = myUnits.begin(); u != myUnits.end(); ++u ) - /// { - /// if ( u->isFlying() && u->isUnderAttack() ) // implies exists and isCompleted - /// { - /// Region r = u->getRegion(); - /// if ( r ) - /// u->move(r->getClosestInaccessibleRegion()); // Retreat to inaccessible region - /// } - /// } - /// @endcode - /// @implies exists - BWAPI::Region getRegion() const; - - /// Retrieves the X coordinate of the unit's left boundary, measured in pixels from - /// the left side of the map. - /// - /// @returns An integer representing the position of the left side of the unit. - /// - /// @see getTop, getRight, getBottom - int getLeft() const; - - /// Retrieves the Y coordinate of the unit's top boundary, measured in pixels from - /// the top of the map. - /// - /// @returns An integer representing the position of the top side of the unit. - /// - /// @see getLeft, getRight, getBottom - int getTop() const; - - /// Retrieves the X coordinate of the unit's right boundary, measured in pixels from - /// the left side of the map. - /// - /// @returns An integer representing the position of the right side of the unit. - /// - /// @see getLeft, getTop, getBottom - int getRight() const; - - /// Retrieves the Y coordinate of the unit's bottom boundary, measured in pixels from - /// the top of the map. - /// - /// @returns An integer representing the position of the bottom side of the unit. - /// - /// @see getLeft, getTop, getRight - int getBottom() const; - - /// Retrieves the unit's current Hit Points (HP) as seen in the game. - /// - /// @returns An integer representing the amount of hit points a unit currently has. - /// - /// @note In Starcraft, a unit usually dies when its HP reaches 0. It is possible however, to - /// have abnormal HP values in the Use Map Settings game type and as the result of a hack over - /// Battle.net. Such values include units that have 0 HP (can't be killed conventionally) - /// or even negative HP (death in one hit). - /// - /// @see UnitType::maxHitPoints, getShields, getInitialHitPoints - virtual int getHitPoints() const = 0; - - /// Retrieves the unit's current Shield Points (Shields) as seen in the game. - /// - /// @returns An integer representing the amount of shield points a unit currently has. - /// - /// @see UnitType::maxShields, getHitPoints - virtual int getShields() const = 0; - - /// Retrieves the unit's current Energy Points (Energy) as seen in the game. - /// - /// @returns An integer representing the amount of energy points a unit currently has. - /// - /// @note Energy is required in order for units to use abilities. - /// - /// @see UnitType::maxEnergy - virtual int getEnergy() const = 0; - - /// Retrieves the resource amount from a resource container, such as a Mineral Field - /// and Vespene Geyser. If the unit is inaccessible, then the last known resource - /// amount is returned. - /// - /// @returns An integer representing the last known amount of resources remaining in this - /// resource. - /// - /// @see getInitialResources - virtual int getResources() const = 0; - - /// Retrieves a grouping index from a resource container. Other resource - /// containers of the same value are considered part of one expansion location (group of - /// resources that are close together). - /// - /// @note This grouping method is explicitly determined by Starcraft itself and is used only - /// by the internal AI. - /// - /// @returns An integer with an identifier between 0 and 250 that determine which resources - /// are grouped together to form an expansion. - virtual int getResourceGroup() const = 0; - - /// Retrieves the distance between this unit and a target. - /// - /// @note Distance is calculated from the edge of this unit, using Starcraft's own distance - /// algorithm. - /// - /// - /// A Position or a Unit to calculate the distance to. If it is a unit, then it will - /// calculate the distance to the edge of the target unit. - /// - /// - /// @returns An integer representation of the number of pixels between this unit and the - /// \p target. - int getDistance(PositionOrUnit target) const; - - /// Using data provided by Starcraft, checks if there is a path available from this - /// unit to the given target. - /// - /// @note This function only takes into account the terrain data, and does not include - /// buildings when determining if a path is available. However, the complexity of this - /// function is constant ( O(1) ), and no extensive calculations are necessary. - /// - /// @note If the current unit is an air unit, then this function will always return true. - /// - /// - /// A Position or a Unit that is used to determine if this unit has a path to the target. - /// - /// - /// @retval true If there is a path between this unit and the target. - /// @retval false If the target is on a different piece of land than this one (such as an - /// island). - bool hasPath(PositionOrUnit target) const; - - /// Retrieves the frame number that sent the last successful command. - /// - /// @note This value is comparable to Game::getFrameCount. - /// - /// @returns The frame number that sent the last successfully processed command to BWAPI. - /// @see Game::getFrameCount, getLastCommand - virtual int getLastCommandFrame() const = 0; - - /// Retrieves the last successful command that was sent to BWAPI. - /// - /// @returns A UnitCommand object containing information about the command that was processed. - /// @see getLastCommandFrame - virtual UnitCommand getLastCommand() const = 0; - - /// Retrieves the Player that last attacked this unit. - /// - /// @returns Player interface object representing the player that last attacked this unit. - /// @retval nullptr If this unit was not attacked. - /// @implies exists() - virtual BWAPI::Player getLastAttackingPlayer() const = 0; - - /// Retrieves the initial type of the unit. This is the type that the unit - /// starts as in the beginning of the game. This is used to access the types of static neutral - /// units such as mineral fields when they are not visible. - /// - /// @returns UnitType of this unit as it was when it was created. - /// @retval UnitTypes::Unknown if this unit was not a static neutral unit in the beginning of - /// the game. - virtual UnitType getInitialType() const = 0; - - /// Retrieves the initial position of this unit. This is the position that - /// the unit starts at in the beginning of the game. This is used to access the positions of - /// static neutral units such as mineral fields when they are not visible. - /// - /// @returns Position indicating the unit's initial position when it was created. - /// @retval Positions::Unknown if this unit was not a static neutral unit in the beginning of - /// the game. - virtual Position getInitialPosition() const = 0; - - /// Retrieves the initial build tile position of this unit. This is the tile - /// position that the unit starts at in the beginning of the game. This is used to access the - /// tile positions of static neutral units such as mineral fields when they are not visible. - /// The build tile position corresponds to the upper left corner of the unit. - /// - /// @returns TilePosition indicating the unit's initial tile position when it was created. - /// @retval TilePositions::Unknown if this unit was not a static neutral unit in the beginning of - /// the game. - virtual TilePosition getInitialTilePosition() const = 0; - - /// Retrieves the amount of hit points that this unit started off with at the - /// beginning of the game. The unit must be neutral. - /// - /// @returns Number of hit points that this unit started with. - /// @retval 0 if this unit was not a neutral unit at the beginning of the game. - /// - /// @note: It is possible for the unit's initial hit points to differ from the maximum hit - /// points. - /// - /// @see Game::getStaticNeutralUnits - virtual int getInitialHitPoints() const = 0; - - /// Retrieves the amount of resources contained in the unit at the beginning of the - /// game. The unit must be a neutral resource container. - /// - /// @returns Amount of resources that this unit started with. - /// @retval 0 if this unit was not a neutral unit at the beginning of the game, or if this - /// unit does not contain resources. It is possible that the unit simply contains 0 resources. - /// - /// @see Game::getStaticNeutralUnits - virtual int getInitialResources() const = 0; - - /// Retrieves the number of units that this unit has killed in total. - /// - /// @note The maximum amount of recorded kills per unit is 255. - /// - /// @returns integer indicating this unit's kill count. - virtual int getKillCount() const = 0; - - /// Retrieves the number of acid spores that this unit is inflicted with. - /// - /// @returns Number of acid spores on this unit. - virtual int getAcidSporeCount() const = 0; - - /// Retrieves the number of interceptors that this unit manages. This - /// function is only for the @Carrier. - /// - /// @returns Number of interceptors in this unit. - virtual int getInterceptorCount() const = 0; - - /// Retrieves the number of scarabs that this unit has for use. This - /// function is only for the @Reaver. - /// - /// @returns Number of scarabs this unit has ready. - virtual int getScarabCount() const = 0; - - /// Retrieves the amount of @mines this unit has available. This function - /// is only for the @Vulture. - /// - /// @returns Number of spider mines available for placement. - virtual int getSpiderMineCount() const = 0; - - /// Retrieves the unit's ground weapon cooldown. This value decreases every - /// frame, until it reaches 0. When the value is 0, this indicates that the unit is capable of - /// using its ground weapon, otherwise it must wait until it reaches 0. - /// - /// @note This value will vary, because Starcraft adds an additional random value between - /// (-1) and (+2) to the unit's weapon cooldown. - /// - /// @returns Number of frames needed for the unit's ground weapon to become available again. - virtual int getGroundWeaponCooldown() const = 0; - - /// Retrieves the unit's air weapon cooldown. This value decreases every - /// frame, until it reaches 0. When the value is 0, this indicates that the unit is capable of - /// using its air weapon, otherwise it must wait until it reaches 0. - /// - /// @note This value will vary, because Starcraft adds an additional random value between - /// (-1) and (+2) to the unit's weapon cooldown. - /// - /// @returns Number of frames needed for the unit's air weapon to become available again. - virtual int getAirWeaponCooldown() const = 0; - - /// Retrieves the unit's ability cooldown. This value decreases every frame, - /// until it reaches 0. When the value is 0, this indicates that the unit is capable of using - /// one of its special abilities, otherwise it must wait until it reaches 0. - /// - /// @note This value will vary, because Starcraft adds an additional random value between - /// (-1) and (+2) to the unit's ability cooldown. - /// - /// @returns Number of frames needed for the unit's abilities to become available again. - virtual int getSpellCooldown() const = 0; - - /// Retrieves the amount of hit points remaining on the @matrix created by a - /// @Science_Vessel. The @matrix ability starts with 250 hit points when it is used. - /// - /// @returns Number of hit points remaining on this unit's @matrix. - /// - /// @see getDefenseMatrixTimer, isDefenseMatrixed - virtual int getDefenseMatrixPoints() const = 0; - - /// Retrieves the time, in frames, that the @matrix will remain active on the current - /// unit. - /// - /// @returns Number of frames remaining until the effect is removed. - /// - /// @see getDefenseMatrixPoints, isDefenseMatrixed - virtual int getDefenseMatrixTimer() const = 0; - - /// Retrieves the time, in frames, that @ensnare will remain active on the current - /// unit. - /// - /// @returns Number of frames remaining until the effect is removed. - /// - /// @see isEnsnared - virtual int getEnsnareTimer() const = 0; - - /// Retrieves the time, in frames, that @irradiate will remain active on the current - /// unit. - /// - /// @returns Number of frames remaining until the effect is removed. - /// - /// @see isIrradiated - virtual int getIrradiateTimer() const = 0; - - /// Retrieves the time, in frames, that @lockdown will remain active on the current - /// unit. - /// - /// @returns Number of frames remaining until the effect is removed. - /// - /// @see isLockdowned - virtual int getLockdownTimer() const = 0; - - /// Retrieves the time, in frames, that @maelstrom will remain active on the current - /// unit. - /// - /// @returns Number of frames remaining until the effect is removed. - /// - /// @see isMaelstrommed - virtual int getMaelstromTimer() const = 0; - - /// Retrieves an internal timer used for the primary order. Its use is - /// specific to the order type that is currently assigned to the unit. - /// - /// @returns A value used as a timer for the primary order. - /// @see getOrder - virtual int getOrderTimer() const = 0; - - /// Retrieves the time, in frames, that @plague will remain active on the current - /// unit. - /// - /// @returns Number of frames remaining until the effect is removed. - /// - /// @see isPlagued - virtual int getPlagueTimer() const = 0; - - /// Retrieves the time, in frames, until this temporary unit is destroyed or - /// removed. This is used to determine the remaining time for the following units - /// that were created by abilities: - /// - @hallucination - /// - @broodling - /// - @swarm - /// - @dweb - /// - @scanner - /// . - /// Once this value reaches 0, the unit is destroyed. - virtual int getRemoveTimer() const = 0; - - /// Retrieves the time, in frames, that @stasis will remain active on the current - /// unit. - /// - /// @returns Number of frames remaining until the effect is removed. - /// - /// @see isPlagued - virtual int getStasisTimer() const = 0; - - /// Retrieves the time, in frames, that @stim will remain active on the current - /// unit. - /// - /// @returns Number of frames remaining until the effect is removed. - /// - /// @see isPlagued - virtual int getStimTimer() const = 0; - - /// Retrieves the building type that a @worker is about to construct. If - /// the unit is morphing or is an incomplete structure, then this returns the UnitType that it - /// will become when it has completed morphing/constructing. - /// - /// @returns UnitType indicating the type that a @worker is about to construct, or an - /// incomplete unit will be when completed. - virtual UnitType getBuildType() const = 0; - - /// Retrieves the list of units queued up to be trained. - /// - /// @returns a UnitType::set containing all the types that are in this factory's training - /// queue. - /// @see train, cancelTrain, isTraining - virtual UnitType::list getTrainingQueue() const = 0; - - /// Retrieves the technology that this unit is currently researching. - /// - /// @returns TechType indicating the technology being researched by this unit. - /// @retval TechTypes::None if this unit is not researching anything. - /// - /// @see research, cancelResearch, isResearching, getRemainingResearchTime - virtual TechType getTech() const = 0; - - /// Retrieves the upgrade that this unit is currently upgrading. - /// - /// @return UpgradeType indicating the upgrade in progress by this unit. - /// @retval UpgradeTypes::None if this unit is not upgrading anything. - /// - /// @see upgrade, cancelUpgrade, isUpgrading, getRemainingUpgradeTime - virtual UpgradeType getUpgrade() const = 0; - - /// Retrieves the remaining build time for a unit or structure that is being trained - /// or constructed. - /// - /// @returns Number of frames remaining until the unit's completion. - virtual int getRemainingBuildTime() const = 0; - - /// Retrieves the remaining time, in frames, of the unit that is currently being - /// trained. - /// - /// @note If the unit is a @Hatchery, @Lair, or @Hive, this retrieves the amount of time until - /// the next larva spawns. - /// - /// @returns Number of frames remaining until the current training unit becomes completed, or - /// the number of frames remaining until the next larva spawns. - /// @retval 0 If the unit is not training or has three larvae. - /// @see train, getTrainingQueue - virtual int getRemainingTrainTime() const = 0; - - /// Retrieves the amount of time until the unit is done researching its currently - /// assigned TechType. - /// - /// @returns The remaining research time, in frames, for the current technology being - /// researched by this unit. - /// @retval 0 If the unit is not researching anything. - /// - /// @see research, cancelResearch, isResearching, getTech - virtual int getRemainingResearchTime() const = 0; - - /// Retrieves the amount of time until the unit is done upgrading its current upgrade. - /// - /// @returns The remaining upgrade time, in frames, for the current upgrade. - /// @retval 0 If the unit is not upgrading anything. - /// - /// @see upgrade, cancelUpgrade, isUpgrading, getUpgrade - virtual int getRemainingUpgradeTime() const = 0; - - /// Retrieves the corresponding paired unit for @SCVs and @Terran structures. - /// For example, if this unit is a @Factory under construction, this function will return the - /// @SCV that is constructing it. If this unit is a @SCV, then it will return the structure it - /// is currently constructing. - /// - /// @returns Paired build unit that is either constructing this unit, or being constructed by - /// this unit. - /// @retval nullptr If there is no unit constructing this one, or this unit is not constructing - /// another unit. - 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, etc.). To get a target that has been - /// acquired automatically without issuing an order, use getOrderTarget. - /// - /// @returns Unit that is currently being targeted by this unit. - /// @see getOrderTarget - virtual Unit getTarget() const = 0; - - /// Retrieves the target position the unit is moving to, provided a valid path to the - /// target position exists. - /// - /// @returns Target position of a movement action. - virtual Position getTargetPosition() const = 0; - - /// Retrieves the primary Order that the unit is assigned. Primary orders - /// are distinct actions such as Orders::AttackUnit and Orders::PlayerGuard. - /// - /// @returns The primary Order that the unit is executing. - virtual Order getOrder() const = 0; - - /// Retrieves the secondary Order that the unit is assigned. Secondary - /// orders are run in the background as a sub-order. An example would be Orders::TrainFighter, - /// because a @Carrier can move and train fighters at the same time. - /// - /// @returns The secondary Order that the unit is executing. - virtual Order getSecondaryOrder() const = 0; - - /// Retrieves the unit's primary order target. 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. - /// - /// @returns The Unit that this unit is currently targetting. - /// @see getTarget, getOrder - virtual Unit getOrderTarget() const = 0; - - /// Retrieves the target position for the unit's order. For example, when - /// Orders::Move is assigned, getTargetPosition returns the end of the unit's path, but this - /// returns the location that the unit is trying to move to. - /// - /// @returns Position that this unit is currently targetting. - /// @see getTargetPosition, getOrder - virtual Position getOrderTargetPosition() const = 0; - - /// Retrieves the position the structure is rallying units to once they are - /// completed. - /// - /// @returns Position that a completed unit coming from this structure will travel to. - /// @retval Positions::None If this building does not produce units. - /// - /// @note If getRallyUnit is valid, then this value is ignored. - /// - /// @see setRallyPoint, getRallyUnit - virtual Position getRallyPosition() const = 0; - - /// Retrieves the unit the structure is rallying units to once they are completed. - /// Units will then follow the targetted unit. - /// - /// @returns Unit that a completed unit coming from this structure will travel to. - /// @retval nullptr If the structure is not rallied to a unit or it does not produce units. - /// - /// @note A rallied unit takes precedence over a rallied position. That is if the return value - /// is valid(non-null), then getRallyPosition is ignored. - /// - /// @see setRallyPoint, getRallyPosition - virtual Unit getRallyUnit() const = 0; - - /// Retrieves the add-on that is attached to this unit. - /// - /// @returns Unit interface that represents the add-on that is attached to this unit. - /// @retval nullptr if this unit does not have an add-on. - virtual Unit getAddon() const = 0; - - /// Retrieves the @Nydus_Canal that is attached to this one. Every - /// @Nydus_Canal can place a "Nydus Exit" which, when connected, can be travelled through by - /// @Zerg units. - /// - /// @returns Unit interface representing the @Nydus_Canal connected to this one. - /// @retval nullptr if the unit is not a @Nydus_Canal, is not owned, or has not placed a Nydus - /// Exit. - virtual Unit getNydusExit() const = 0; - - /// Retrieves the power-up that the worker unit is holding. Power-ups are - /// special units such as the @Flag in the @CTF game type, which can be picked up by worker - /// units. - /// - /// @note If your bot is strictly melee/1v1, then this method is not necessary. - /// - /// @returns The Unit interface object that represents the power-up. - /// @retval nullptr If the unit is not carrying anything. - /// - /// Example - /// @code - /// BWAPI::Unitset myUnits = BWAPI::Broodwar->self()getUnits(); - /// for ( auto u = myUnits.begin(); u != myUnits.end(); ++u ) - /// { - /// // If we are carrying a flag - /// if ( u->getPowerUp() && u->getPowerUp()->getType() == BWAPI::UnitTypes::Powerup_Flag ) - /// u->move( u->getClosestUnit(BWAPI::Filter::IsFlagBeacon && BWAPI::Filter::IsOwned) ); // return it to our flag beacon to score - /// } - /// @endcode - /// @implies getType().isWorker(), isCompleted() - virtual Unit getPowerUp() const = 0; - - /// Retrieves the @Transport or @Bunker unit that has this unit loaded inside of it. - /// - /// @returns Unit interface object representing the @Transport containing this unit. - /// @retval nullptr if this unit is not in a @Transport. - virtual Unit getTransport() const = 0; - - /// Retrieves the set of units that are contained within this @Bunker or @Transport. - /// - /// @returns A Unitset object containing all of the units that are loaded inside of the - /// current unit. - virtual Unitset getLoadedUnits() const = 0; - - /// Retrieves the remaining unit-space available for @Bunkers and @Transports. - /// - /// @returns The number of spots available to transport a unit. - /// - /// @see getLoadedUnits - int getSpaceRemaining() const; - - /// Retrieves the parent @Carrier that owns this @Interceptor. - /// - /// @returns The parent @Carrier unit that has ownership of this one. - /// @retval nullptr if the current unit is not an @Interceptor. - virtual Unit getCarrier() const = 0; - - /// Retrieves the set of @Interceptors controlled by this unit. This is - /// intended for @Carriers. - /// - /// @returns Unitset containing @Interceptor units owned by this one. - virtual Unitset getInterceptors() const = 0; - - /// Retrieves the parent @Hatchery, @Lair, or @Hive that owns this particular unit. - /// This is intended for @Larvae. - /// - /// @returns Hatchery unit that has ownership of this larva. - /// @retval nullptr if the current unit is not a @Larva or has no parent. - virtual Unit getHatchery() const = 0; - - /// Retrieves the set of @Larvae that were spawned by this unit. Only - /// @Hatcheries, @Lairs, and @Hives are capable of spawning @Larvae. This is like clicking the - /// "Select Larva" button and getting the selection of @Larvae. - /// - /// @returns Unitset containing @Larva units owned by this unit. The set will be empty if - /// there are none. - virtual Unitset getLarva() const = 0; - - /// Retrieves the set of all units in a given radius of the current unit. - /// - /// Takes into account this unit's dimensions. Can optionally specify a filter that is composed - /// using BWAPI Filter semantics to include only specific units (such as only ground units, etc.) - /// - /// - /// The radius, in pixels, to search for units. - /// - /// (optional) - /// The composed function predicate to include only specific (desired) units in the set. Defaults to - /// nullptr, which means no filter. - /// - /// - /// @returns A Unitset containing the set of units that match the given criteria. - /// - /// Example usage: - /// @code - /// // Get main building closest to start location. - /// BWAPI::Unit pMain = BWAPI::Broodwar->getClosestUnit( BWAPI::Broodwar->self()->getStartLocation(), BWAPI::Filter::IsResourceDepot ); - /// if ( pMain ) // check if pMain is valid - /// { - /// // Get sets of resources and workers - /// BWAPI::Unitset myResources = pMain->getUnitsInRadius(1024, BWAPI::Filter::IsMineralField); - /// if ( !myResources.empty() ) // check if we have resources nearby - /// { - /// BWAPI::Unitset myWorkers = pMain->getUnitsInRadius(512, BWAPI::Filter::IsWorker && BWAPI::Filter::IsIdle && BWAPI::Filter::IsOwned ); - /// while ( !myWorkers.empty() ) // make sure we command all nearby idle workers, if any - /// { - /// for ( auto u = myResources.begin(); u != myResources.end() && !myWorkers.empty(); ++u ) - /// { - /// myWorkers.back()->gather(*u); - /// myWorkers.pop_back(); - /// } - /// } - /// } // myResources not empty - /// } // pMain != nullptr - /// @endcode - /// - /// @see getClosestUnit, getUnitsInWeaponRange, Game::getUnitsInRadius, Game::getUnitsInRectangle - Unitset getUnitsInRadius(int radius, const UnitFilter &pred = nullptr) const; - - /// Obtains the set of units within weapon range of this unit. - /// - /// - /// The weapon type to use as a filter for distance and units that can be hit by it. - /// - /// (optional) - /// A predicate used as an additional filter. If omitted, no additional filter is used. - /// - /// - /// @see getUnitsInRadius, getClosestUnit, Game::getUnitsInRadius, Game::getUnitsInRectangle - Unitset getUnitsInWeaponRange(WeaponType weapon, const UnitFilter &pred = nullptr) const; - - /// Retrieves the closest unit to this one. - /// - /// (optional) - /// A function predicate used to identify which conditions must be matched for a unit to - /// be considered. If omitted, then the closest unit owned by any player will be returned. - /// - /// (optional) - /// The maximum radius to check for the closest unit. For performance reasons, a developer - /// can limit the radius that is checked. If omitted, then the entire map is checked. - /// - /// - /// @see getUnitsInRadius, Game::getUnitsInRadius, Game::getUnitsInRectangle - Unit getClosestUnit(const UnitFilter &pred = nullptr, int radius = 999999) const; - - /// Checks if the current unit is housing a @Nuke. This is only available - /// for @Silos. - /// - /// @returns true if this unit has a @Nuke ready, and false if there is no @Nuke. - virtual bool hasNuke() const = 0; - - /// Checks if the current unit is accelerating. - /// - /// @returns true if this unit is accelerating, and false otherwise - virtual bool isAccelerating() const = 0; - - /// Checks if this unit is currently attacking something. - /// - /// @returns true if this unit is attacking another unit, and false if it is not. - virtual bool isAttacking() const = 0; - - /// Checks if this unit is currently playing an attack animation. Issuing - /// commands while this returns true may interrupt the unit's next attack sequence. - /// - /// @returns true if this unit is currently running an attack frame, and false if interrupting - /// the unit is feasible. - /// - /// @note This function is only available to some unit types, specifically those that play - /// special animations when they attack. - virtual bool isAttackFrame() const = 0; - - /// Checks if the current unit is being constructed. This is mostly - /// applicable to Terran structures which require an SCV to be constructing a structure. - /// - /// @retval true if this is either a Protoss structure, Zerg structure, or Terran structure - /// being constructed by an attached SCV. - /// @retval false if this is either completed, not a structure, or has no SCV constructing it - /// - /// @see build, cancelConstruction, haltConstruction, isConstructing - bool isBeingConstructed() const; - - /// Checks this @Mineral_Field or @Refinery is currently being gathered from. - /// - /// @returns true if this unit is a resource container and being harvested by a worker, and - /// false otherwise - virtual bool isBeingGathered() const = 0; - - /// Checks if this unit is currently being healed by a @Medic or repaired by a @SCV. - /// - /// @returns true if this unit is being healed, and false otherwise. - virtual bool isBeingHealed() const = 0; - - /// Checks if this unit is currently blinded by a @Medic 's @Optical_Flare ability. - /// Blinded units have reduced sight range and cannot detect other units. - /// - /// @returns true if this unit is blind, and false otherwise - virtual bool isBlind() const = 0; - - /// Checks if the current unit is slowing down to come to a stop. - /// - /// @returns true if this unit is breaking, false if it has stopped or is still moving at full - /// speed. - virtual bool isBraking() const = 0; - - /// Checks if the current unit is burrowed, either using the @Burrow ability, or is - /// an armed @Spider_Mine. - /// - /// @returns true if this unit is burrowed, and false otherwise - /// @see burrow, unburrow - virtual bool isBurrowed() const = 0; - - /// Checks if this worker unit is carrying some vespene gas. - /// - /// @returns true if this is a worker unit carrying vespene gas, and false if it is either - /// not a worker, or not carrying gas. - /// - /// Example - /// @code - /// BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits(); - /// for ( auto u = myUnits.begin(); u != myUnits.end(); ++u ) - /// { - /// if ( u->isIdle() && (u->isCarryingGas() || u->isCarryingMinerals()) ) - /// u->returnCargo(); - /// } - /// @endcode - /// @implies isCompleted(), getType().isWorker() - /// @see returnCargo, isGatheringGas, isCarryingMinerals - virtual bool isCarryingGas() const = 0; - - /// Checks if this worker unit is carrying some minerals. - /// - /// @returns true if this is a worker unit carrying minerals, and false if it is either - /// not a worker, or not carrying minerals. - /// - /// Example - /// @code - /// BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits(); - /// for ( auto u = myUnits.begin(); u != myUnits.end(); ++u ) - /// { - /// if ( u->isIdle() && (u->isCarryingGas() || u->isCarryingMinerals()) ) - /// u->returnCargo(); - /// } - /// @endcode - /// @implies isCompleted(), getType().isWorker() - /// @see returnCargo, isGatheringMinerals, isCarryingMinerals - virtual bool isCarryingMinerals() const = 0; - - /// Checks if this unit is currently @cloaked. - /// - /// @returns true if this unit is cloaked, and false if it is visible. - /// @see cloak, decloak - virtual bool isCloaked() const = 0; - - /// Checks if this unit has finished being constructed, trained, morphed, or warped - /// in, and can now receive orders. - /// - /// @returns true if this unit is completed, and false if it is under construction or inaccessible. - virtual bool isCompleted() const = 0; - - /// Checks if a unit is either constructing something or moving to construct something. - /// - /// @returns true when a unit has been issued an order to build a structure and is moving to - /// the build location, or is currently constructing something. - /// - /// @see isBeingConstructed, build, cancelConstruction, haltConstruction - virtual bool isConstructing() const = 0; - - /// Checks if this unit has the @matrix effect. - /// - /// @returns true if the @matrix ability was used on this unit, and false otherwise. - bool isDefenseMatrixed() const; - - /// Checks if this unit is visible or revealed by a detector unit. If this - /// is false and #isVisible is true, then the unit is only partially visible and requires a - /// detector in order to be targetted. - /// - /// @returns true if this unit is detected, and false if it needs a detector unit nearby in - /// order to see it. - /// @implies isVisible - virtual bool isDetected() const = 0; - - /// Checks if the @Queen ability @Ensnare has been used on this unit. - /// - /// @returns true if the unit is ensnared, and false if it is not - bool isEnsnared() const; - - /// This macro function checks if this unit is in the air. That is, the unit is - /// either a flyer or a flying building. - /// - /// @returns true if this unit is in the air, and false if it is on the ground - /// @see UnitType::isFlyer, UnitInterface::isLifted - bool isFlying() const; - - /// Checks if this unit is following another unit. When a unit is following - /// another unit, it simply moves where the other unit does, and does not attack enemies when - /// it is following. - /// - /// @returns true if this unit is following another unit, and false if it is not - /// @implies isCompleted - /// @see follow, getTarget - bool isFollowing() const; - - /// Checks if this unit is currently gathering gas. That is, the unit is - /// either moving to a refinery, waiting to enter a refinery, harvesting from the refinery, or - /// returning gas to a resource depot. - /// - /// @returns true if this unit is harvesting gas, and false if it is not - /// @implies isCompleted, getType().isWorker() - /// @see isCarryingGas - virtual bool isGatheringGas() const = 0; - - /// Checks if this unit is currently harvesting minerals. That is, the unit - /// is either moving to a @mineral_field, waiting to mine, mining minerals, or returning - /// minerals to a resource depot. - /// - /// @returns true if this unit is gathering minerals, and false if it is not - /// @implies isCompleted, getType().isWorker() - /// @see isCarryingMinerals - virtual bool isGatheringMinerals() const = 0; - - /// Checks if this unit is a hallucination. Hallucinations are created by - /// the @High_Templar using the @Hallucination ability. Enemy hallucinations are unknown if - /// Flag::CompleteMapInformation is disabled. Hallucinations have a time limit until they are - /// destroyed (see UnitInterface::getRemoveTimer). - /// - /// @returns true if the unit is a hallucination and false otherwise. - /// @see getRemoveTimer - virtual bool isHallucination() const = 0; - - /// Checks if the unit is currently holding position. A unit that is holding - /// position will attack other units, but will not chase after them. - /// - /// @returns true if this unit is holding position, and false if it is not. - /// - /// @see holdPosition - bool isHoldingPosition() const; - - /// Checks if this unit is running an idle order. This function is - /// particularly useful when checking for units that aren't doing any tasks that you assigned. - /// - /// A unit is considered idle if it is not doing any of the following: - /// - Training - /// - Constructing - /// - Morphing - /// - Researching - /// - Upgrading - /// - /// In addition to running one of the following orders: - /// - Orders::PlayerGuard: Player unit idle. - /// - Orders::Guard: Generic unit idle. - /// - Orders::Stop - /// - Orders::PickupIdle - /// - Orders::Nothing: Structure/generic idle. - /// - Orders::Medic: Medic idle. - /// - Orders::Carrier: Carrier idle. - /// - Orders::Reaver: Reaver idle. - /// - Orders::Critter: Critter idle. - /// - Orders::Neutral: Neutral unit idle. - /// - Orders::TowerGuard: Turret structure idle. - /// - Orders::Burrowed: Burrowed unit idle. - /// - Orders::NukeTrain - /// - Orders::Larva: Larva idle. - /// - /// @code - /// BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits(); - /// for ( auto u = myUnits.begin(); u != myUnits.end(); ++u ) - /// { - /// // Order idle worker to gather from closest mineral field - /// if ( u->getType().isWorker() && u->isIdle() ) - /// u->gather( u->getClosestUnit( BWAPI::Filter::IsMineralField ) ); - /// } - /// @endcode - /// - /// @returns true if this unit is idle, and false if this unit is performing any action, such - /// as moving or attacking - /// @implies isCompleted - /// @see UnitInterface::stop - virtual bool isIdle() const = 0; - - /// Checks if the unit can be interrupted. - /// - /// @returns true if this unit can be interrupted, or false if this unit is uninterruptable - virtual bool isInterruptible() const = 0; - - /// Checks the invincibility state for this unit. - /// - /// @returns true if this unit is currently invulnerable, and false if it is vulnerable - virtual bool isInvincible() const = 0; - - /// Checks if the target unit can immediately be attacked by this unit in the current - /// frame. - /// - /// - /// The target unit to use in this check. - /// - /// - /// @returns true if \p target is within weapon range of this unit's appropriate weapon, and - /// false otherwise. - /// @retval false if \p target is invalid, inaccessible, too close, too far, or this unit does - /// not have a weapon that can attack \p target. - bool isInWeaponRange(Unit target) const; - - /// Checks if this unit is irradiated by a @Science_Vessel 's @Irradiate ability. - /// - /// @returns true if this unit is irradiated, and false otherwise - /// - /// Example usage: - /// @code - /// BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits(); - /// for ( auto u = myUnits.begin(); u != myUnits.end(); ++u ) - /// { - /// if ( u->isIrradiated() && u->getIrradiateTimer > 50 && BWAPI::Broodwar->self()->hasResearched(BWAPI::TechTypes::Restoration) ) - /// { - /// BWAPI::Unit medic = u->getClosestUnit( BWAPI::Filter::GetType == BWAPI::UnitTypes::Terran_Medic && - /// BWAPI::Filter::Energy >= BWAPI::TechTypes::Restoration.energyCost() ); - /// if ( medic ) - /// medic->useTech(BWAPI::TechTypes::Restoration, *u); - /// } - /// } - /// @endcode - /// @see getIrradiateTimer - bool isIrradiated() const; - - /// Checks if this unit is a @Terran building and lifted off the ground. - /// This function generally implies this->getType().isBuilding() and this->isCompleted() both - /// return true. - /// - /// @returns true if this unit is a @Terran structure lifted off the ground. - /// @implies isCompleted, getType().isFlyingBuilding() - /// @see isFlying - virtual bool isLifted() const = 0; - - /// Checks if this unit is currently loaded into another unit such as a @Transport. - /// - /// @returns true if this unit is loaded in another one, and false otherwise - /// @implies isCompleted - /// @see load, unload, unloadAll - bool isLoaded() const; - - /// Checks if this unit is currently @locked by a @Ghost. - /// - /// @returns true if this unit is locked down, and false otherwise - /// @see getLockdownTimer - bool isLockedDown() const; - - /// Checks if this unit has been @Maelstrommed by a @Dark_Archon. - /// - /// @returns true if this unit is maelstrommed, and false otherwise - /// @see getMaelstromTimer - bool isMaelstrommed() const; - - /// Finds out if the current unit is morphing or not. @Zerg units and - /// structures often have the ability to #morph into different types of units. This function - /// allows you to identify when this process is occurring. - /// - /// @retval true if the unit is currently morphing. - /// @retval false if the unit is not morphing - /// - /// @see morph, cancelMorph, getBuildType, getRemainingBuildTime - virtual bool isMorphing() const = 0; - - /// Checks if this unit is currently moving. - /// - /// @returns true if this unit is moving, and false if it is not - /// @see stop - virtual bool isMoving() const = 0; - - /// Checks if this unit has been parasited by some other player. - /// - /// @returns true if this unit is inflicted with @parasite, and false if it is clean - virtual bool isParasited() const = 0; - - /// Checks if this unit is patrolling between two positions. - /// - /// @returns true if this unit is patrolling and false if it is not - /// @see patrol - bool isPatrolling() const; - - /// Checks if this unit has been been @plagued by a @defiler. - /// - /// @returns true if this unit is inflicted with @plague and is taking damage, and false if it - /// is clean - /// @see getPlagueTimer - bool isPlagued() const; - - /// Checks if this unit is repairing or moving to @repair another unit. - /// This is only applicable to @SCVs. - /// - /// @returns true if this unit is currently repairing or moving to @repair another unit, and - /// false if it is not - bool isRepairing() const; - - /// Checks if this unit is a structure that is currently researching a technology. - /// See TechTypes for a complete list of technologies in Broodwar. - /// - /// @returns true if this structure is researching a technology, false otherwise - /// @see research, cancelResearch, getTech, getRemainingResearchTime, - /// @implies exists(), isCompleted(), getType().isBuilding() - bool isResearching() const; - - /// Checks if this unit has been selected in the user interface. This - /// function is only available if the flag Flag::UserInput is enabled. - /// - /// @returns true if this unit is currently selected, and false if this unit is not selected - /// @see Game::getSelectedUnits - virtual bool isSelected() const = 0; - - /// Checks if this unit is currently @sieged. This is only applicable to - /// @Siege_Tanks. - /// - /// @returns true if the unit is in siege mode, and false if it is either not in siege mode or - /// not a @Siege_Tank - /// @see siege, unsiege - bool isSieged() const; - - /// Checks if the unit is starting to attack. - /// - /// @returns true if this unit is starting an attack. - /// - /// @see attack, getGroundWeaponCooldown, getAirWeaponCooldown - virtual bool isStartingAttack() const = 0; - - /// Checks if this unit is inflicted with @Stasis by an @Arbiter. - /// - /// @returns true if this unit is locked in a @Stasis and is unable to move, and false if it - /// is free. - /// - /// @note This function does not necessarily imply that the unit is invincible, since there - /// is a feature in the @UMS game type that allows stasised units to be vulnerable. - /// - /// @see getStasisTimer - bool isStasised() const; - - /// Checks if this unit is currently under the influence of a @Stim_Pack. - /// - /// @returns true if this unit has used a stim pack, false otherwise - /// @see getStimTimer - bool isStimmed() const; - - /// Checks if this unit is currently trying to resolve a collision by randomly moving - /// around. - /// - /// @returns true if this unit is currently stuck and trying to resolve a collision, and false - /// if this unit is free - virtual bool isStuck() const = 0; - - /// Checks if this unit is training a new unit. For example, a @Barracks - /// training a @Marine. - /// - /// @note It is possible for a unit to remain in the training queue with no progress. In that - /// case, this function will return false because of supply or unit count limitations. - /// - /// @returns true if this unit is currently training another unit, and false otherwise. - /// - /// @see train, getTrainingQueue, cancelTrain, getRemainingTrainTime - virtual bool isTraining() const = 0; - - /// Checks if the current unit is being attacked. Has a small delay before - /// this returns false - /// again when the unit is no longer being attacked. - /// - /// @returns true if this unit has been attacked within the past few frames, and false - /// if it has not - virtual bool isUnderAttack() const = 0; - - /// Checks if this unit is under the cover of a @Dark_Swarm. - /// - /// @returns true if this unit is protected by a @Dark_Swarm, and false if it is not - virtual bool isUnderDarkSwarm() const = 0; - - /// Checks if this unit is currently being affected by a @Disruption_Web. - /// - /// @returns true if this unit is under the effects of @Disruption_Web. - virtual bool isUnderDisruptionWeb() const = 0; - - /// Checks if this unit is currently taking damage from a @Psi_Storm. - /// - /// @returns true if this unit is losing hit points from a @Psi_Storm, and false otherwise. - virtual bool isUnderStorm() const = 0; - - /// Checks if this unit has power. Most structures are powered by default, - /// but @Protoss structures require a @Pylon to be powered and functional. - /// - /// @returns true if this unit has power or is inaccessible, and false if this unit is - /// unpowered. - /// - /// @since 4.0.1 Beta (previously isUnpowered) - virtual bool isPowered() const = 0; - - /// Checks if this unit is a structure that is currently upgrading an upgrade. - /// See UpgradeTypes for a full list of upgrades in Broodwar. - /// - /// @returns true if this structure is upgrading, false otherwise - /// @see upgrade, cancelUpgrade, getUpgrade, getRemainingUpgradeTime - /// @implies exists(), isCompleted(), getType().isBuilding() - bool isUpgrading() const; - - /// Checks if this unit is visible. - /// - /// (optional) - /// The player to check visibility for. If this parameter is omitted, then the BWAPI player - /// obtained from Game::self will be used. - /// - /// - /// @returns true if this unit is visible to the specified \p player, and false if it is not. - /// - /// @note If the Flag::CompleteMapInformation flag is enabled, existing units hidden by the - /// fog of war will be accessible, but isVisible will still return false. - /// - /// @see exists - virtual bool isVisible(Player player = nullptr) const = 0; - - /// Performs some cheap checks to attempt to quickly detect whether the unit is - /// unable to be targetted as the target unit of an unspecified command. - /// - /// @retval true if BWAPI was unable to determine whether the unit can be a target. - /// @retval false if an error occurred and the unit can not be a target. - /// - /// @see Game::getLastError, UnitInterface::canTargetUnit - virtual bool isTargetable() const = 0; - - /// @name Unit Commands - /// @{ - - /// This function issues a command to the unit(s), however it is used for interfacing - /// only, and is recommended to use one of the more specific command functions when writing an - /// AI. - /// - /// - /// A UnitCommand containing command parameters such as the type, position, target, etc. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see UnitCommandTypes, Game::getLastError, UnitInterface::canIssueCommand - virtual bool issueCommand(UnitCommand command) = 0; - - /// Orders the unit(s) to attack move to the specified position or attack the - /// specified unit. - /// - /// - /// A Position or a Unit to designate as the target. If a Position is used, the unit will - /// perform an Attack Move command. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @note A @Medic will use Heal Move instead of attack. - /// - /// @see Game::getLastError, UnitInterface::canAttack - bool attack(PositionOrUnit target, bool shiftQueueCommand = false); - - /// Orders the worker unit(s) to construct a structure at a target position. - /// - /// - /// The UnitType to build. - /// - /// - /// A TilePosition to specify the build location, specifically the upper-left corner of the - /// location. If the target is not specified, then the function call will be redirected to - /// the train command. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @note You must have sufficient resources and meet the necessary requirements in order to - /// build a structure. - /// - /// @see Game::getLastError, UnitInterface::train, UnitInterface::cancelConstruction, UnitInterface::canBuild - bool build(UnitType type, TilePosition target = TilePositions::None); - - /// Orders the @Terran structure(s) to construct an add-on. - /// - /// - /// The add-on UnitType to construct. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @note You must have sufficient resources and meet the necessary requirements in order to - /// build a structure. - /// - /// @see Game::getLastError, UnitInterface::build, UnitInterface::cancelAddon, UnitInterface::canBuildAddon - bool buildAddon(UnitType type); - - /// Orders the unit(s) to add a UnitType to its training queue, or morphs into the - /// UnitType if it is @Zerg. - /// - /// - /// The UnitType to train. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @note You must have sufficient resources, supply, and meet the necessary requirements in - /// order to train a unit. - /// @note This command is also used for training @Interceptors and @Scarabs. - /// @note If you call this using a @Hatchery, @Lair, or @Hive, then it will automatically - /// pass the command to one of its @Larvae. - /// - /// @see Game::getLastError, UnitInterface::build, UnitInterface::morph, UnitInterface::cancelTrain, UnitInterface::isTraining, - /// UnitInterface::canTrain - bool train(UnitType type = UnitTypes::None); - - /// Orders the unit(s) to morph into a different UnitType. - /// - /// - /// The UnitType to morph into. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see Game::getLastError, UnitInterface::build, UnitInterface::morph, UnitInterface::canMorph - bool morph(UnitType type); - - /// Orders the unit to research the given tech type. - /// - /// - /// The TechType to research. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see cancelResearch, isResearching, getRemainingResearchTime, getTech, canResearch - bool research(TechType tech); - - /// Orders the unit to upgrade the given upgrade type. - /// - /// - /// The UpgradeType to upgrade. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see cancelUpgrade, isUpgrading, getRemainingUpgradeTime, getUpgrade, canUpgrade - bool upgrade(UpgradeType upgrade); - - /// Orders the unit to set its rally position to the specified position or unit. - /// - /// - /// The target position or target unit that this structure will rally to. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see getRallyPosition, getRallyUnit, canSetRallyPoint, canSetRallyPosition, canSetRallyUnit - bool setRallyPoint(PositionOrUnit target); - - /// Orders the unit to move from its current position to the specified position. - /// - /// - /// The target position to move to. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see isMoving, canMove - bool move(Position target, bool shiftQueueCommand = false); - - /// Orders the unit to patrol between its current position and the specified position. - /// While patrolling, units will attack and chase enemy units that they encounter, and then - /// return to its patrol route. @Medics will automatically heal units and then return to their - /// patrol route. - /// - /// - /// The position to patrol to. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see isPatrolling, canPatrol - bool patrol(Position target, bool shiftQueueCommand = false); - - /// Orders the unit to hold its position. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see canHoldPosition, isHoldingPosition - bool holdPosition(bool shiftQueueCommand = false); - - /// Orders the unit to stop. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see canStop, isIdle - bool stop(bool shiftQueueCommand = false); - - /// Orders the unit to follow the specified unit. Units that are following - /// other units will not perform any other actions such as attacking. They will ignore attackers. - /// - /// - /// The target unit to start following. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see isFollowing, canFollow, getOrderTarget - bool follow(Unit target, bool shiftQueueCommand = false); - - /// Orders the unit to gather the specified unit (must be mineral or refinery type). - /// - /// - /// The target unit to gather from. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see isGatheringGas, isGatheringMinerals, canGather - bool gather(Unit target, bool shiftQueueCommand = false); - - /// 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. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see isCarryingGas, isCarryingMinerals, canReturnCargo - bool returnCargo(bool shiftQueueCommand = false); - - /// 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. - /// - /// - /// The unit to repair. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see isRepairing, canRepair - bool repair(Unit target, bool shiftQueueCommand = false); - - /// Orders the unit to burrow. Either the unit must be a @Lurker, or the - /// unit must be a @Zerg ground unit that is capable of @Burrowing, and @Burrow technology - /// must be researched. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see unburrow, isBurrowed, canBurrow - bool burrow(); - - /// Orders a burrowed unit to unburrow. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see burrow, isBurrowed, canUnburrow - bool unburrow(); - - /// Orders the unit to cloak. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see decloak, isCloaked, canCloak - bool cloak(); - - /// Orders a cloaked unit to decloak. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see cloak, isCloaked, canDecloak - bool decloak(); - - /// Orders the unit to siege. Only works for @Siege_Tanks. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see unsiege, isSieged, canSiege - bool siege(); - - /// Orders the unit to unsiege. Only works for sieged @Siege_Tanks. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see siege, isSieged, canUnsiege - bool unsiege(); - - /// Orders the unit to lift. Only works for liftable @Terran structures. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see land, isLifted, canLift - bool lift(); - - /// Orders the unit to land. Only works for @Terran structures that are - /// currently lifted. - /// - /// - /// The tile position to land this structure at. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see lift, isLifted, canLand - bool land(TilePosition target); - - /// Orders the unit to load the target unit. Only works if this unit is a - /// @Transport or @Bunker type. - /// - /// - /// The target unit to load into this @Transport or @Bunker. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see unload, unloadAll, getLoadedUnits, isLoaded - bool load(Unit target, bool shiftQueueCommand = false); - - /// Orders the unit to unload the target unit. Only works for @Transports - /// and @Bunkers. - /// - /// - /// Unloads the target unit from this @Transport or @Bunker. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see load, unloadAll, getLoadedUnits, isLoaded, canUnload, canUnloadAtPosition - bool unload(Unit target); - - /// Orders the unit to unload all loaded units at the unit's current position. - /// Only works for @Transports and @Bunkers. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see load, unload, getLoadedUnits, isLoaded, canUnloadAll, canUnloadAtPosition - bool unloadAll(bool shiftQueueCommand = false); - - /// Orders the unit to unload all loaded units at the specified location. - /// Only works for @Transports. Not applicable to @Bunkers. - /// - /// - /// The target position to unload the units at. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see load, unload, getLoadedUnits, isLoaded, canUnloadAllPosition, canUnloadAtPosition - bool unloadAll(Position target, bool shiftQueueCommand = false); - - /// Works like the right click in the GUI. - /// - /// - /// The target position or target unit to right click. - /// - /// (optional) - /// If this value is true, then the order will be queued instead of immediately executed. - /// If this value is omitted, then the order will be executed immediately by default. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see canRightClick, canRightClickPosition, canRightClickUnit - bool rightClick(PositionOrUnit target, bool shiftQueueCommand = false); - - /// Orders a @SCV to stop constructing a structure. This leaves the - /// structure in an incomplete state until it is either cancelled, razed, or completed by - /// another @SCV. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see isConstructing, canHaltConstruction - bool haltConstruction(); - - /// Orders this unit to cancel and refund itself from begin constructed. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see isBeingConstructed, build, canCancelConstruction - bool cancelConstruction(); - - /// Orders this unit to cancel and refund an add-on that is being constructed. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see canCancelAddon, buildAddon - bool cancelAddon(); - - /// Orders the unit to remove the specified unit from its training queue. - /// - /// (optional) - /// Identifies the slot that will be cancelled. If the specified value is at least 0, then - /// the unit in the corresponding slot from the list provided by getTrainingQueue will be - /// cancelled. If the value is either omitted or -2, then the last slot is cancelled. - /// - /// - /// @note The value of slot is passed directly to Broodwar. Other negative values have no - /// effect. - /// - /// @see train, cancelTrain, isTraining, getTrainingQueue, canCancelTrain, canCancelTrainSlot - bool cancelTrain(int slot = -2); - - /// Orders this unit to cancel and refund a unit that is morphing. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see morph, isMorphing, canCancelMorph - bool cancelMorph(); - - /// Orders this unit to cancel and refund a research that is in progress. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @see research, isResearching, getTech, canCancelResearch - bool cancelResearch(); - - /// Orders this unit to cancel and refund an upgrade that is in progress. - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// @see upgrade, isUpgrading, getUpgrade, canCancelUpgrade - bool cancelUpgrade(); - - /// Orders the unit to use a technology. - /// - /// - /// The technology type to use. - /// - /// (optional) - /// If specified, indicates the target location or unit to use the tech on. If unspecified, - /// causes the \p tech to be used without a target (i.e. @Stim_Packs). - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// - /// @see canUseTechWithOrWithoutTarget, canUseTech, canUseTechWithoutTarget, canUseTechUnit, - /// canUseTechPosition, TechTypes - bool useTech(TechType tech, PositionOrUnit target = nullptr); - - /// Moves a @Flag_Beacon to a different location. This is only used for @CTF - /// or @UMS game types. - /// - /// - /// The target tile position to place the @Flag_Beacon. - /// - /// - /// @returns true if the command was passed to Broodwar, and false if BWAPI determined that - /// the command would fail. - /// @note There is a small chance for a command to fail after it has been passed to Broodwar. - /// - /// @note This command is only available for the first 10 minutes of the game, as in Broodwar. - /// - /// @see canPlaceCOP - bool placeCOP(TilePosition target); - - /// @} - /// @name Command Verifiers - /// @{ - - /// Checks whether the unit is able to execute the given command. If you - /// are calling this function repeatedly (e.g. to generate a collection of valid commands), - /// you can avoid repeating the same kinds of checks by specifying false for some of the - /// optional boolean arguments. Make sure that the state hasn't changed since the check was - /// done though (eg a new frame/event, or a command issued). Also see the more specific functions. - /// - /// - /// A UnitCommand to check. - /// - /// - /// Only used if the command type is UnitCommandTypes::Enum::Use_Tech_Position. A boolean - /// for whether to perform cheap checks for whether the unit is unable to target any - /// positions using the command's TechType (i.e. regardless of what the other command - /// parameters are). You can set this to false if you know this check has already just been - /// performed. - /// - /// - /// Only used if the command type is UnitCommandTypes::Enum::Use_Tech_Unit. A boolean for - /// whether to perform cheap checks for whether the unit is unable to target any units using - /// the command's TechType (i.e. regardless of what the other command parameters are). You - /// can set this to false if you know this check has already just been performed. - /// - /// - /// Only used if the command type is UnitCommandTypes::Build. A boolean for whether to - /// perform cheap checks for whether the unit is unable to build the specified UnitType - /// (i.e. regardless of what the other command parameters are). You can set this to false if - /// you know this check has already just been performed. - /// - /// - /// Only used for command types that can target a unit. A boolean for whether to perform - /// UnitInterface::canTargetUnit as a check. You can set this to false if you know this check has - /// already just been performed. - /// - /// - /// A boolean for whether to perform UnitInterface::canIssueCommandType as a check. You can set this - /// to false if you know this check has already just been performed. - /// - /// - /// A boolean for whether to perform UnitInterface::canCommand as a check. You can set this to false - /// if you know this check has already just been performed. - /// - /// - /// @retval true if BWAPI determined that the command is valid. - /// @retval false if an error occurred and the command is invalid. - /// - /// @see UnitCommandTypes, Game::getLastError, UnitInterface::canCommand, UnitInterface::canIssueCommandType, - /// UnitInterface::canTargetUnit - virtual bool canIssueCommand(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanBuildUnitType = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute the given command as part of a Unitset - /// (even if none of the units in the Unitset are able to execute the command individually). - /// The reason this function exists is because some commands are valid for an individual unit - /// but not for those individuals as a group (e.g. buildings, critters) and some commands are - /// only valid for a unit if it is commanded as part of a unit group, e.g.: - /// 1. attackMove/attackUnit for a Unitset, some of which can't attack, e.g. @High_Templar. - /// This is supported simply for consistency with BW's behaviour - you - /// could issue move command(s) individually instead. - /// 2. attackMove/move/patrol/rightClickPosition for air unit(s) + e.g. @Larva, as part of - /// the air stacking technique. This is supported simply for consistency with BW's - /// behaviour - you could issue move/patrol/rightClickPosition command(s) for them - /// individually instead. - /// - /// @note BWAPI allows the following special cases to command a unit individually (rather than - /// only allowing it to be commanded as part of a Unitset). These commands are not available - /// to a user in BW when commanding units individually, but BWAPI allows them for convenience: - /// - attackMove for @Medic, which is equivalent to Heal Move. - /// - holdPosition for burrowed @Lurker, for ambushes. - /// - stop for @Larva, to move it to a different side of the @Hatchery / @Lair / @Hive (e.g. - /// so that @Drones morphed later morph nearer to minerals/gas). - /// - /// @see UnitCommandTypes, Game::getLastError, UnitInterface::canIssueCommand, - /// UnitInterface::canCommandGrouped, UnitInterface::canIssueCommandTypeGrouped, UnitInterface::canTargetUnit - virtual bool canIssueCommandGrouped(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Performs some cheap checks to attempt to quickly detect whether the unit is unable to - /// execute any commands (eg the unit is stasised). - /// - /// @retval true if BWAPI was unable to determine whether the unit can be commanded. - /// @retval false if an error occurred and the unit can not be commanded. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand - virtual bool canCommand() const = 0; - - /// Performs some cheap checks to attempt to quickly detect whether the unit is unable to - /// execute any commands as part of a Unitset (eg buildings, critters). - /// - /// @retval true if BWAPI was unable to determine whether the unit can be commanded grouped. - /// @retval false if an error occurred and the unit can not be commanded grouped. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canIssueCommand - virtual bool canCommandGrouped(bool checkCommandibility = true) const = 0; - - /// Performs some cheap checks to attempt to quickly detect whether the unit is unable to - /// execute the given command type (i.e. regardless of what other possible command parameters - /// could be). - /// - /// - /// A UnitCommandType. - /// - /// - /// A boolean for whether to perform UnitInterface::canCommand as a check. You can set this to false - /// if you know this check has already just been performed. - /// - /// - /// @retval true if BWAPI was unable to determine whether the command type is invalid. - /// @retval false if an error occurred and the command type is invalid. - /// - /// @see UnitCommandTypes, Game::getLastError, UnitInterface::canIssueCommand - virtual bool canIssueCommandType(UnitCommandType ct, bool checkCommandibility = true) const = 0; - - /// Performs some cheap checks to attempt to quickly detect whether the unit is unable to - /// execute the given command type (i.e. regardless of what other possible command parameters - /// could be) as part of a Unitset. - /// - /// - /// A UnitCommandType. - /// - /// - /// A boolean for whether to perform UnitInterface::canCommandGrouped as a check. You can set this - /// to false if you know this check has already just been performed. - /// - /// - /// A boolean for whether to perform UnitInterface::canCommand as a check. You can set this to false - /// if you know this check has already just been performed. - /// - /// - /// @retval true if BWAPI was unable to determine whether the command type is invalid. - /// @retval false if an error occurred and the command type is invalid. - /// - /// @see UnitCommandTypes, Game::getLastError, UnitInterface::canIssueCommandGrouped - virtual bool canIssueCommandTypeGrouped(UnitCommandType ct, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Performs some cheap checks to attempt to quickly detect whether the unit is unable to - /// use the given unit as the target unit of an unspecified command. - /// - /// - /// A target unit for an unspecified command. - /// - /// - /// A boolean for whether to perform UnitInterface::canCommand as a check. You can set this to false - /// if you know this check has already just been performed. - /// - /// - /// @retval true if BWAPI was unable to determine whether the unit can target the given unit. - /// @retval false if an error occurred and the unit can not target the given unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::isTargetable - virtual bool canTargetUnit(Unit targetUnit, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute an attack command to attack-move or attack a unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack, - /// UnitInterface::canAttackMove, UnitInterface::canAttackUnit - virtual bool canAttack(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an attack command to attack-move or attack a (non-null) - /// unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack, - /// UnitInterface::canAttackMove, UnitInterface::canAttackUnit - virtual bool canAttack(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute an attack command to attack-move or attack a unit, - /// as part of a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttack - virtual bool canAttackGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an attack command to attack-move or attack a - /// (non-null) unit, as part of a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttack - virtual bool canAttackGrouped(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an attack command to attack-move. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack - virtual bool canAttackMove(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an attack command to attack-move, as part of a - /// Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttackMove - virtual bool canAttackMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute an attack command to attack a unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack - virtual bool canAttackUnit(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an attack command to attack a unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::attack - virtual bool canAttackUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute an attack command to attack a unit, - /// as part of a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttackUnit - virtual bool canAttackUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an attack command to attack a unit, as part of - /// a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canAttackUnit - virtual bool canAttackUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a build command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::build - virtual bool canBuild(bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a build command for the given - /// UnitType. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::build - virtual bool canBuild(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a build command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::build - virtual bool canBuild(UnitType uType, BWAPI::TilePosition tilePos, bool checkTargetUnitType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a buildAddon command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::buildAddon - virtual bool canBuildAddon(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a buildAddon command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::buildAddon - virtual bool canBuildAddon(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a train command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::train - virtual bool canTrain(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a train command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::train - virtual bool canTrain(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a morph command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::morph - virtual bool canMorph(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a morph command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::morph - virtual bool canMorph(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a research command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::research - virtual bool canResearch(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a research command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::research - virtual bool canResearch(TechType type, bool checkCanIssueCommandType = true) const = 0; - - /// Cheap checks for whether the unit is able to execute an upgrade command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::upgrade - virtual bool canUpgrade(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an upgrade command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::upgrade - virtual bool canUpgrade(UpgradeType type, bool checkCanIssueCommandType = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a setRallyPoint command to a - /// position or unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint, - /// UnitInterface::canSetRallyPosition, UnitInterface::canSetRallyUnit. - virtual bool canSetRallyPoint(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a setRallyPoint command to a position - /// or (non-null) unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint, - /// UnitInterface::canSetRallyPosition, UnitInterface::canSetRallyUnit. - virtual bool canSetRallyPoint(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a setRallyPoint command to a position. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint - virtual bool canSetRallyPosition(bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a setRallyPoint command to a unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint - virtual bool canSetRallyUnit(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a setRallyPoint command to a unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::setRallyPoint - virtual bool canSetRallyUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a move command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::move - virtual bool canMove(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a move command, as part of a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canMove - virtual bool canMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a patrol command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::patrol - virtual bool canPatrol(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a patrol command, as part of a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canPatrol - virtual bool canPatrolGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a follow command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::follow - virtual bool canFollow(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a follow command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::follow - virtual bool canFollow(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a gather command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::gather - virtual bool canGather(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a gather command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::gather - virtual bool canGather(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a returnCargo command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::returnCargo - virtual bool canReturnCargo(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a holdPosition command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::holdPosition - virtual bool canHoldPosition(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a stop command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::stop - virtual bool canStop(bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a repair command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::repair - virtual bool canRepair(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a repair command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::repair - virtual bool canRepair(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a burrow command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::burrow - virtual bool canBurrow(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an unburrow command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unburrow - virtual bool canUnburrow(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a cloak command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cloak - virtual bool canCloak(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a decloak command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::decloak - virtual bool canDecloak(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a siege command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::siege - virtual bool canSiege(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an unsiege command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unsiege - virtual bool canUnsiege(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a lift command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::lift - virtual bool canLift(bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a land command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::land - virtual bool canLand(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a land command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::land - virtual bool canLand(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a load command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::load - virtual bool canLoad(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a load command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::load - virtual bool canLoad(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute an unload command or unloadAll at - /// current position command or unloadAll at a different position command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unload, UnitInterface::unloadAll - virtual bool canUnloadWithOrWithoutTarget(bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute an unload command or unloadAll at - /// current position command or unloadAll at a different position command, for a given - /// position. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unload, UnitInterface::unloadAll - virtual bool canUnloadAtPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute an unload command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unload - virtual bool canUnload(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an unload command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unload, UnitInterface::canUnloadAtPosition - virtual bool canUnload(Unit targetUnit, bool checkCanTargetUnit = true, bool checkPosition = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an unloadAll command for the current position. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unloadAll - virtual bool canUnloadAll(bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute an unloadAll command for a different - /// position. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unloadAll - virtual bool canUnloadAllPosition(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute an unloadAll command for a different position. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::unloadAll - virtual bool canUnloadAllPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a rightClick command to a position - /// or unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick, - /// UnitInterface::canRightClickPosition, UnitInterface::canRightClickUnit. - virtual bool canRightClick(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a rightClick command to a position or (non-null) - /// unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick, - /// UnitInterface::canRightClickPosition, UnitInterface::canRightClickUnit. - virtual bool canRightClick(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a rightClick command to a position - /// or unit, as part of a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClickUnit - virtual bool canRightClickGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a rightClick command to a position or (non-null) - /// unit, as part of a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClickUnit - virtual bool canRightClickGrouped(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a rightClick command for a position. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick - virtual bool canRightClickPosition(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a rightClick command for a position, as part of - /// a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClick - virtual bool canRightClickPositionGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a rightClick command to a unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick - virtual bool canRightClickUnit(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a rightClick command to a unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::rightClick - virtual bool canRightClickUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a rightClick command to a unit, as - /// part of a Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClickUnit - virtual bool canRightClickUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a rightClick command to a unit, as part of a - /// Unitset. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommandGrouped, UnitInterface::canRightClickUnit - virtual bool canRightClickUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a haltConstruction command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::haltConstruction - virtual bool canHaltConstruction(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a cancelConstruction command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelConstruction - virtual bool canCancelConstruction(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a cancelAddon command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelAddon - virtual bool canCancelAddon(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a cancelTrain command for any slot. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelTrain - virtual bool canCancelTrain(bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a cancelTrain command for an - /// unspecified slot. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelTrain - virtual bool canCancelTrainSlot(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a cancelTrain command for a specified slot. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelTrain - virtual bool canCancelTrainSlot(int slot, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a cancelMorph command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelMorph - virtual bool canCancelMorph(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a cancelResearch command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelResearch - virtual bool canCancelResearch(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a cancelUpgrade command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::cancelUpgrade - virtual bool canCancelUpgrade(bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a useTech command without a target or - /// or a useTech command with a target position or a useTech command with a target unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech - virtual bool canUseTechWithOrWithoutTarget(bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a useTech command without a target or - /// or a useTech command with a target position or a useTech command with a target unit, for a - /// given TechType. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech - virtual bool canUseTechWithOrWithoutTarget(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a useTech command for a specified position or - /// unit (only specify nullptr if the TechType does not target another position/unit). - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech, - /// UnitInterface::canUseTechWithoutTarget, UnitInterface::canUseTechUnit, UnitInterface::canUseTechPosition - virtual bool canUseTech(BWAPI::TechType tech, PositionOrUnit target = nullptr, bool checkCanTargetUnit = true, bool checkTargetsType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a useTech command without a target. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech - virtual bool canUseTechWithoutTarget(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a useTech command with an unspecified - /// target unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech - virtual bool canUseTechUnit(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a useTech command with a target unit. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech - virtual bool canUseTechUnit(BWAPI::TechType tech, Unit targetUnit, bool checkCanTargetUnit = true, bool checkTargetsUnits = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a useTech command with an unspecified target - /// position. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech - virtual bool canUseTechPosition(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a useTech command with a target position. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::useTech - virtual bool canUseTechPosition(BWAPI::TechType tech, Position target, bool checkTargetsPositions = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - /// Cheap checks for whether the unit is able to execute a placeCOP command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::placeCOP - virtual bool canPlaceCOP(bool checkCommandibility = true) const = 0; - - /// Checks whether the unit is able to execute a placeCOP command. - /// - /// @see Game::getLastError, UnitInterface::canIssueCommand, UnitInterface::placeCOP - virtual bool canPlaceCOP(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const = 0; - - ///@} - }; -} diff --git a/bwapi-includes/BWAPI/UnitCommand.h b/bwapi-includes/BWAPI/UnitCommand.h deleted file mode 100644 index af877f2..0000000 --- a/bwapi-includes/BWAPI/UnitCommand.h +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once -#include -#include - -namespace BWAPI -{ - // Forwards - class UnitType; - class TechType; - class UpgradeType; - class PositionOrUnit; - class UnitInterface; - typedef UnitInterface *Unit; - - class UnitCommand - { - public: - UnitCommand() = default; - UnitCommand(Unit _unit, UnitCommandType _type, Unit _target, int _x, int _y, int _extra); - - static UnitCommand attack(Unit unit, PositionOrUnit target, bool shiftQueueCommand = false); - static UnitCommand build(Unit unit, TilePosition target, UnitType type); - static UnitCommand buildAddon(Unit unit, UnitType type); - static UnitCommand train(Unit unit, UnitType type); - static UnitCommand morph(Unit unit, UnitType type); - static UnitCommand research(Unit unit, TechType tech); - static UnitCommand upgrade(Unit unit, UpgradeType upgrade); - static UnitCommand setRallyPoint(Unit unit, PositionOrUnit target); - static UnitCommand move(Unit unit, Position target, bool shiftQueueCommand = false); - static UnitCommand patrol(Unit unit, Position target, bool shiftQueueCommand = false); - static UnitCommand holdPosition(Unit unit, bool shiftQueueCommand = false); - static UnitCommand stop(Unit unit, bool shiftQueueCommand = false); - static UnitCommand follow(Unit unit, Unit target, bool shiftQueueCommand = false); - static UnitCommand gather(Unit unit, Unit target, bool shiftQueueCommand = false); - static UnitCommand returnCargo(Unit unit, bool shiftQueueCommand = false); - static UnitCommand repair(Unit unit, Unit target, bool shiftQueueCommand = false); - static UnitCommand burrow(Unit unit); - static UnitCommand unburrow(Unit unit); - static UnitCommand cloak(Unit unit); - static UnitCommand decloak(Unit unit); - static UnitCommand siege(Unit unit); - static UnitCommand unsiege(Unit unit); - static UnitCommand lift(Unit unit); - static UnitCommand land(Unit unit, TilePosition target); - static UnitCommand load(Unit unit, Unit target, bool shiftQueueCommand = false); - static UnitCommand unload(Unit unit, Unit target); - static UnitCommand unloadAll(Unit unit, bool shiftQueueCommand = false); - static UnitCommand unloadAll(Unit unit, Position target, bool shiftQueueCommand = false); - static UnitCommand rightClick(Unit unit, PositionOrUnit target, bool shiftQueueCommand = false); - static UnitCommand haltConstruction(Unit unit); - static UnitCommand cancelConstruction(Unit unit); - static UnitCommand cancelAddon(Unit unit); - static UnitCommand cancelTrain(Unit unit, int slot = -2); - static UnitCommand cancelMorph(Unit unit); - static UnitCommand cancelResearch(Unit unit); - static UnitCommand cancelUpgrade(Unit unit); - static UnitCommand useTech(Unit unit,TechType tech); - static UnitCommand useTech(Unit unit,TechType tech, PositionOrUnit target); - static UnitCommand placeCOP(Unit unit, TilePosition target); - - UnitCommandType getType() const; - Unit getUnit() const; - Unit getTarget() const; - Position getTargetPosition() const; - TilePosition getTargetTilePosition() const; - UnitType getUnitType() const; - TechType getTechType() const; - UpgradeType getUpgradeType() const; - int getSlot() const; - bool isQueued() const; - - bool operator==(const UnitCommand& other) const; - bool operator!=(const UnitCommand& other) const; - - Unit unit = nullptr; - UnitCommandType type = UnitCommandTypes::None; - Unit target = nullptr; - int x = Positions::None.x; - int y = Positions::None.y; - int extra = 0; - }; -} \ No newline at end of file diff --git a/bwapi-includes/BWAPI/UnitCommandType.h b/bwapi-includes/BWAPI/UnitCommandType.h deleted file mode 100644 index cd1bfc5..0000000 --- a/bwapi-includes/BWAPI/UnitCommandType.h +++ /dev/null @@ -1,138 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// Namespace containing unit command types. - /// @see UnitCommandType - namespace UnitCommandTypes - { - /// Enumeration of valid unit command types. - /// @see UnitCommandType - namespace Enum - { - /// Enumeration of valid unit command types. - /// @see UnitCommandType - enum Enum - { - Attack_Move = 0, - Attack_Unit, - Build, - Build_Addon, - Train, - Morph, - Research, - Upgrade, - Set_Rally_Position, - Set_Rally_Unit, - Move, - Patrol, - Hold_Position, - Stop, - Follow, - Gather, - Return_Cargo, - Repair, - Burrow, - Unburrow, - Cloak, - Decloak, - Siege, - Unsiege, - Lift, - Land, - Load, - Unload, - Unload_All, - Unload_All_Position, - Right_Click_Position, - Right_Click_Unit, - Halt_Construction, - Cancel_Construction, - Cancel_Addon, - Cancel_Train, - Cancel_Train_Slot, - Cancel_Morph, - Cancel_Research, - Cancel_Upgrade, - Use_Tech, - Use_Tech_Position, - Use_Tech_Unit, - Place_COP, - None, - Unknown, - MAX - }; - }; - }; - /// A representation of a unit command in BWAPI. This is used by bots to - /// notify BWAPI which commands to use. BWAPI filters commands accordingly and then converts - /// them to Broodwar commands, which differ in complexity. - /// - /// @see UnitCommandTypes - /// @ingroup TypeClasses - class UnitCommandType : public Type - { - public: - /// @copydoc Type::Type(int) - UnitCommandType(int id = UnitCommandTypes::Enum::None); - }; - - /// @ingroup Types - namespace UnitCommandTypes - { - /// Retrieves the set of all valid UnitCommandTypes. - /// - /// @returns Set of UnitCommandTypes. - const UnitCommandType::set& allUnitCommandTypes(); - - 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; - } - - static_assert(sizeof(UnitCommandType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/UnitSizeType.h b/bwapi-includes/BWAPI/UnitSizeType.h deleted file mode 100644 index 33fa978..0000000 --- a/bwapi-includes/BWAPI/UnitSizeType.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - /// Namespace containing unit size types. - /// - /// @see UnitSizeType - /// - /// [View on Starcraft Campendium (Official Website)](http://classic.battle.net/scc/gs/damage.shtml)
- namespace UnitSizeTypes - { - /// Enumeration of unit size types. - /// @see UnitSizeType - namespace Enum - { - /// Enumeration of unit size types. - /// @see UnitSizeType - enum Enum - { - Independent = 0, - Small, - Medium, - Large, - None, - Unknown, - MAX - }; - }; - }; - - /// Size types are used by unit types in Broodwar to determine how much damage will be - /// applied. This corresponds with DamageType for several different damage reduction - /// applications. - /// - /// @see DamageType, UnitType, UnitSizeTypes - /// - /// [View on Starcraft Campendium (Official Website)](http://classic.battle.net/scc/gs/damage.shtml)
- /// @ingroup TypeClasses - class UnitSizeType : public Type - { - public: - /// @copydoc Type::Type(int) - UnitSizeType(int id = UnitSizeTypes::Enum::None); - }; - - /// @ingroup Types - namespace UnitSizeTypes - { - /// Retrieves the set of all valid UnitSizeTypes. - /// - /// @returns Set of all UnitSizeTypes. - const UnitSizeType::set& allUnitSizeTypes(); - - extern const UnitSizeType Independent; - extern const UnitSizeType Small; - extern const UnitSizeType Medium; - extern const UnitSizeType Large; - extern const UnitSizeType None; - extern const UnitSizeType Unknown; - } - - static_assert(sizeof(UnitSizeType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/UnitType.h b/bwapi-includes/BWAPI/UnitType.h deleted file mode 100644 index 0074c85..0000000 --- a/bwapi-includes/BWAPI/UnitType.h +++ /dev/null @@ -1,1238 +0,0 @@ -#pragma once -#include - -#include -#include - -namespace BWAPI -{ - // Forward Declarations - class TechType; - class UpgradeType; - class WeaponType; - class UnitSizeType; - class Race; - - /// Namespace containing unit types. - /// @see UnitType - namespace UnitTypes - { - /// Enumeration of unit types - /// @see UnitType - namespace Enum - { - /// Enumeration of unit types - /// @see UnitType - enum Enum - { - Terran_Marine = 0, - Terran_Ghost, - Terran_Vulture, - Terran_Goliath, - Terran_Goliath_Turret, - Terran_Siege_Tank_Tank_Mode, - Terran_Siege_Tank_Tank_Mode_Turret, - Terran_SCV, - Terran_Wraith, - Terran_Science_Vessel, - Hero_Gui_Montag, - Terran_Dropship, - Terran_Battlecruiser, - Terran_Vulture_Spider_Mine, - Terran_Nuclear_Missile, - Terran_Civilian, - Hero_Sarah_Kerrigan, - Hero_Alan_Schezar, - Hero_Alan_Schezar_Turret, - Hero_Jim_Raynor_Vulture, - Hero_Jim_Raynor_Marine, - Hero_Tom_Kazansky, - Hero_Magellan, - Hero_Edmund_Duke_Tank_Mode, - Hero_Edmund_Duke_Tank_Mode_Turret, - Hero_Edmund_Duke_Siege_Mode, - Hero_Edmund_Duke_Siege_Mode_Turret, - Hero_Arcturus_Mengsk, - Hero_Hyperion, - Hero_Norad_II, - Terran_Siege_Tank_Siege_Mode, - Terran_Siege_Tank_Siege_Mode_Turret, - Terran_Firebat, - Spell_Scanner_Sweep, - Terran_Medic, - Zerg_Larva, - Zerg_Egg, - Zerg_Zergling, - Zerg_Hydralisk, - Zerg_Ultralisk, - Zerg_Broodling, - Zerg_Drone, - Zerg_Overlord, - Zerg_Mutalisk, - Zerg_Guardian, - Zerg_Queen, - Zerg_Defiler, - Zerg_Scourge, - Hero_Torrasque, - Hero_Matriarch, - Zerg_Infested_Terran, - Hero_Infested_Kerrigan, - Hero_Unclean_One, - Hero_Hunter_Killer, - Hero_Devouring_One, - Hero_Kukulza_Mutalisk, - Hero_Kukulza_Guardian, - Hero_Yggdrasill, - Terran_Valkyrie, - Zerg_Cocoon, - Protoss_Corsair, - Protoss_Dark_Templar, - Zerg_Devourer, - Protoss_Dark_Archon, - Protoss_Probe, - Protoss_Zealot, - Protoss_Dragoon, - Protoss_High_Templar, - Protoss_Archon, - Protoss_Shuttle, - Protoss_Scout, - Protoss_Arbiter, - Protoss_Carrier, - Protoss_Interceptor, - Hero_Dark_Templar, - Hero_Zeratul, - Hero_Tassadar_Zeratul_Archon, - Hero_Fenix_Zealot, - Hero_Fenix_Dragoon, - Hero_Tassadar, - Hero_Mojo, - Hero_Warbringer, - Hero_Gantrithor, - Protoss_Reaver, - Protoss_Observer, - Protoss_Scarab, - Hero_Danimoth, - Hero_Aldaris, - Hero_Artanis, - Critter_Rhynadon, - Critter_Bengalaas, - Special_Cargo_Ship, - Special_Mercenary_Gunship, - Critter_Scantid, - Critter_Kakaru, - Critter_Ragnasaur, - Critter_Ursadon, - Zerg_Lurker_Egg, - Hero_Raszagal, - Hero_Samir_Duran, - Hero_Alexei_Stukov, - Special_Map_Revealer, - Hero_Gerard_DuGalle, - Zerg_Lurker, - Hero_Infested_Duran, - Spell_Disruption_Web, - Terran_Command_Center, - Terran_Comsat_Station, - Terran_Nuclear_Silo, - Terran_Supply_Depot, - Terran_Refinery, - Terran_Barracks, - Terran_Academy, - Terran_Factory, - Terran_Starport, - Terran_Control_Tower, - Terran_Science_Facility, - Terran_Covert_Ops, - Terran_Physics_Lab, - Unused_Terran1, - Terran_Machine_Shop, - Unused_Terran2, - Terran_Engineering_Bay, - Terran_Armory, - Terran_Missile_Turret, - Terran_Bunker, - Special_Crashed_Norad_II, - Special_Ion_Cannon, - Powerup_Uraj_Crystal, - Powerup_Khalis_Crystal, - Zerg_Infested_Command_Center, - Zerg_Hatchery, - Zerg_Lair, - Zerg_Hive, - Zerg_Nydus_Canal, - Zerg_Hydralisk_Den, - Zerg_Defiler_Mound, - Zerg_Greater_Spire, - Zerg_Queens_Nest, - Zerg_Evolution_Chamber, - Zerg_Ultralisk_Cavern, - Zerg_Spire, - Zerg_Spawning_Pool, - Zerg_Creep_Colony, - Zerg_Spore_Colony, - Unused_Zerg1, - Zerg_Sunken_Colony, - Special_Overmind_With_Shell, - Special_Overmind, - Zerg_Extractor, - Special_Mature_Chrysalis, - Special_Cerebrate, - Special_Cerebrate_Daggoth, - Unused_Zerg2, - Protoss_Nexus, - Protoss_Robotics_Facility, - Protoss_Pylon, - Protoss_Assimilator, - Unused_Protoss1, - Protoss_Observatory, - Protoss_Gateway, - Unused_Protoss2, - Protoss_Photon_Cannon, - Protoss_Citadel_of_Adun, - Protoss_Cybernetics_Core, - Protoss_Templar_Archives, - Protoss_Forge, - Protoss_Stargate, - Special_Stasis_Cell_Prison, - Protoss_Fleet_Beacon, - Protoss_Arbiter_Tribunal, - Protoss_Robotics_Support_Bay, - Protoss_Shield_Battery, - Special_Khaydarin_Crystal_Form, - Special_Protoss_Temple, - Special_XelNaga_Temple, - Resource_Mineral_Field, - Resource_Mineral_Field_Type_2, - Resource_Mineral_Field_Type_3, - Unused_Cave, - Unused_Cave_In, - Unused_Cantina, - Unused_Mining_Platform, - Unused_Independant_Command_Center, - Special_Independant_Starport, - Unused_Independant_Jump_Gate, - Unused_Ruins, - Unused_Khaydarin_Crystal_Formation, - Resource_Vespene_Geyser, - Special_Warp_Gate, - Special_Psi_Disrupter, - Unused_Zerg_Marker, - Unused_Terran_Marker, - Unused_Protoss_Marker, - Special_Zerg_Beacon, - Special_Terran_Beacon, - Special_Protoss_Beacon, - Special_Zerg_Flag_Beacon, - Special_Terran_Flag_Beacon, - Special_Protoss_Flag_Beacon, - Special_Power_Generator, - Special_Overmind_Cocoon, - Spell_Dark_Swarm, - Special_Floor_Missile_Trap, - Special_Floor_Hatch, - Special_Upper_Level_Door, - Special_Right_Upper_Level_Door, - Special_Pit_Door, - Special_Right_Pit_Door, - Special_Floor_Gun_Trap, - Special_Wall_Missile_Trap, - Special_Wall_Flame_Trap, - Special_Right_Wall_Missile_Trap, - Special_Right_Wall_Flame_Trap, - Special_Start_Location, - Powerup_Flag, - Powerup_Young_Chrysalis, - Powerup_Psi_Emitter, - Powerup_Data_Disk, - Powerup_Khaydarin_Crystal, - Powerup_Mineral_Cluster_Type_1, - Powerup_Mineral_Cluster_Type_2, - Powerup_Protoss_Gas_Orb_Type_1, - Powerup_Protoss_Gas_Orb_Type_2, - Powerup_Zerg_Gas_Sac_Type_1, - Powerup_Zerg_Gas_Sac_Type_2, - Powerup_Terran_Gas_Tank_Type_1, - Powerup_Terran_Gas_Tank_Type_2, - - None, - AllUnits, - Men, - Buildings, - Factories, - Unknown, - MAX - }; - - }; - } - /// The UnitType is used to get information about a particular type of unit, such as its cost, - /// build time, weapon, hit points, abilities, etc. - /// - /// @see UnitInterface::getType, UnitTypes - /// @ingroup TypeClasses - class UnitType : public Type - { - public: - /// @copydoc Type::Type(int) - UnitType(int id = UnitTypes::Enum::None); - - /// Retrieves the Race that the unit type belongs to. - /// - /// @returns Race indicating the race that owns this unit type. - /// @retval Race::None indicating that the unit type does not belong to any particular race (a - /// critter for example). - Race getRace() const; - - /// Obtains the source unit type that is used to build or train this unit type, as well as the - /// amount of them that are required. - /// - /// @returns std::pair in which the first value is the UnitType that builds this unit type, and - /// the second value is the number of those types that are required (this value is 2 for - /// @Archons, and 1 for all other types). - /// @retval pair(UnitTypes::None,0) If this unit type cannot be made by the player. - const std::pair< UnitType, int > whatBuilds() const; - - /// Retrieves the immediate technology tree requirements to make this unit type. - /// - /// @returns std::map containing a UnitType to number mapping of UnitTypes required. - const std::map< UnitType, int >& requiredUnits() const; - - /// Identifies the required TechType in order to create certain units. - /// - /// @note The only unit that requires a technology is the @Lurker, which needs @Lurker_Aspect. - /// @returns TechType indicating the technology that must be researched in order to create this - /// unit type. - /// @retval TechTypes::None If creating this unit type does not require a technology to be - /// researched. - TechType requiredTech() const; - - /// Retrieves the cloaking technology associated with certain units. - /// - /// @returns TechType referring to the cloaking technology that this unit type uses as an - /// ability. - /// @retval TechTypes::None If this unit type does not have an active cloak ability. - TechType cloakingTech() const; - - /// Retrieves the set of abilities that this unit can use, provided it is available to you in - /// the game. - /// - /// @returns Set of TechTypes containing ability information. - const SetContainer& abilities() const; - - /// Retrieves the set of upgrades that this unit can use to enhance its fighting ability. - /// - /// @return Set of UpgradeTypes containing upgrade types that will impact this unit type. - const SetContainer& upgrades() const; - - /// Retrieves the upgrade type used to increase the armor of this unit type. For each upgrade, - /// this unit type gains +1 additional armor. - /// - /// @returns UpgradeType indicating the upgrade that increases this unit type's armor amount. - UpgradeType armorUpgrade() const; - - /// Retrieves the default maximum amount of hit points that this unit type can have. - /// - /// @note This value may not necessarily match the value seen in the @UMS game type. - /// - /// @returns Integer indicating the maximum amount of hit points for this unit type. - int maxHitPoints() const; - - /// Retrieves the default maximum amount of shield points that this unit type can have. - /// - /// @note This value may not necessarily match the value seen in the @UMS game type. - /// - /// @returns Integer indicating the maximum amount of shield points for this unit type. - /// @retval 0 If this unit type does not have shields. - int maxShields() const; - - /// Retrieves the maximum amount of energy this unit type can have by default. - /// - /// @returns Integer indicating the maximum amount of energy for this unit type. - /// @retval 0 If this unit does not gain energy for abilities. - int maxEnergy() const; - - /// Retrieves the default amount of armor that the unit type starts with, excluding upgrades. - /// - /// @note This value may not necessarily match the value seen in the @UMS game type. - /// - /// @returns The amount of armor the unit type has. - int armor() const; - - /// Retrieves the default mineral price of purchasing the unit. - /// - /// @note This value may not necessarily match the value seen in the @UMS game type. - /// - /// @returns Mineral cost of the unit. - int mineralPrice() const; - - /// Retrieves the default vespene gas price of purchasing the unit. - /// - /// @note This value may not necessarily match the value seen in the @UMS game type. - /// - /// @returns Vespene gas cost of the unit. - int gasPrice() const; - - /// Retrieves the default time, in frames, needed to train, morph, or build the unit. - /// - /// @note This value may not necessarily match the value seen in the @UMS game type. - /// - /// @returns Number of frames needed in order to build the unit. - /// @see UnitInterface::getRemainingBuildTime - int buildTime() const; - - /// Retrieves the amount of supply that this unit type will use when created. It will use the - /// supply pool that is appropriate for its Race. - /// - /// @note In Starcraft programming, the managed supply values are double than what they appear - /// in the game. The reason for this is because @Zerglings use 0.5 visible supply. - /// - /// @returns Integer containing the supply required to build this unit. - /// @see supplyProvided, PlayerInterface::supplyTotal, PlayerInterface::supplyUsed - int supplyRequired() const; - - /// Retrieves the amount of supply that this unit type produces for its appropriate Race's - /// supply pool. - /// - /// @note In Starcraft programming, the managed supply values are double than what they appear - /// in the game. The reason for this is because @Zerglings use 0.5 visible supply. - /// - /// @see supplyRequired, PlayerInterface::supplyTotal, PlayerInterface::supplyUsed - int supplyProvided() const; - - /// Retrieves the amount of space required by this unit type to fit inside a @Bunker or - /// @Transport. - /// - /// @returns Amount of space required by this unit type for transport. - /// @retval 255 If this unit type can not be transported. - /// @see spaceProvided - int spaceRequired() const; - - /// Retrieves the amount of space provided by this @Bunker or @Transport for unit - /// transportation. - /// - /// @returns The number of slots provided by this unit type. - /// @see spaceRequired - int spaceProvided() const; - - /// Retrieves the amount of score points awarded for constructing this unit type. This value is - /// used for calculating scores in the post-game score screen. - /// - /// @returns Number of points awarded for constructing this unit type. - /// @see destroyScore - int buildScore() const; - - /// Retrieves the amount of score points awarded for killing this unit type. This value is - /// used for calculating scores in the post-game score screen. - /// - /// @returns Number of points awarded for killing this unit type. - /// @see buildScore - int destroyScore() const; - - /// Retrieves the UnitSizeType of this unit, which is used in calculations along with weapon - /// damage types to determine the amount of damage that will be dealt to this type. - /// - /// @returns UnitSizeType indicating the conceptual size of the unit type. - /// @see WeaponType::damageType - UnitSizeType size() const; - - /// Retrieves the width of this unit type, in tiles. Used for determining the tile size of - /// structures. - /// - /// @returns Width of this unit type, in tiles. - int tileWidth() const; - - /// Retrieves the height of this unit type, in tiles. Used for determining the tile size of - /// structures. - /// - /// @returns Height of this unit type, in tiles. - int tileHeight() const; - - /// Retrieves the tile size of this unit type. Used for determining the tile size of - /// structures. - /// - /// @returns TilePosition containing the width (x) and height (y) of the unit type, in tiles. - TilePosition tileSize() const; - - /// Retrieves the distance from the center of the unit type to its left edge. - /// - /// @returns Distance to this unit type's left edge from its center, in pixels. - int dimensionLeft() const; - - /// Retrieves the distance from the center of the unit type to its top edge. - /// - /// @returns Distance to this unit type's top edge from its center, in pixels. - int dimensionUp() const; - - /// Retrieves the distance from the center of the unit type to its right edge. - /// - /// @returns Distance to this unit type's right edge from its center, in pixels. - int dimensionRight() const; - - /// Retrieves the distance from the center of the unit type to its bottom edge. - /// - /// @returns Distance to this unit type's bottom edge from its center, in pixels. - int dimensionDown() const; - - /// A macro for retrieving the width of the unit type, which is calculated using - /// dimensionLeft + dimensionRight + 1. - /// - /// @returns Width of the unit, in pixels. - int width() const; - - /// A macro for retrieving the height of the unit type, which is calculated using - /// dimensionUp + dimensionDown + 1. - /// - /// @returns Height of the unit, in pixels. - int height() const; - - /// Retrieves the range at which this unit type will start targeting enemy units. - /// - /// @returns Distance at which this unit type begins to seek out enemy units, in pixels. - int seekRange() const; - - /// Retrieves the sight range of this unit type. - /// - /// @returns Sight range of this unit type, measured in pixels. - int sightRange() const; - - /// Retrieves this unit type's weapon type used when attacking targets on the ground. - /// - /// @returns WeaponType used as this unit type's ground weapon. - /// @see maxGroundHits, airWeapon - WeaponType groundWeapon() const; - - /// Retrieves the maximum number of hits this unit can deal to a ground target using its - /// ground weapon. This value is multiplied by the ground weapon's damage to calculate the - /// unit type's damage potential. - /// - /// @returns Maximum number of hits given to ground targets. - /// @see groundWeapon, maxAirHits - int maxGroundHits() const; - - /// Retrieves this unit type's weapon type used when attacking targets in the air. - /// - /// @returns WeaponType used as this unit type's air weapon. - /// @see maxAirHits, groundWeapon - WeaponType airWeapon() const; - - /// Retrieves the maximum number of hits this unit can deal to a flying target using its - /// air weapon. This value is multiplied by the air weapon's damage to calculate the - /// unit type's damage potential. - /// - /// @returns Maximum number of hits given to air targets. - /// @see airWeapon, maxGroundHits - int maxAirHits() const; - - /// Retrieves this unit type's top movement speed with no upgrades. - /// - /// @note That some units have inconsistent movement and this value is sometimes an - /// approximation. - /// - /// @returns The approximate top speed, in pixels per frame, as a double. For liftable @Terran - /// structures, this function returns their movement speed while lifted. - double topSpeed() const; - - /// Retrieves the unit's acceleration amount. - /// - /// @returns How fast the unit can accelerate to its top speed. - /// - /// @todo Figure out the units this quantity is measured in. - int acceleration() const; - - /// Retrieves the unit's halting distance. This determines how fast a unit - /// can stop moving. - /// - /// @returns A halting distance value. - /// - /// @todo Figure out the units this quantity is measured in. - int haltDistance() const; - - /// Retrieves a unit's turning radius. This determines how fast a unit can - /// turn. - /// - /// @returns A turn radius value. - /// - /// @todo Figure out the units this quantity is measured in. - int turnRadius() const; - - /// Determines if a 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-structures: @Carrier (can produce interceptors) and @Reaver (can produce scarabs). - /// - /// @returns true if this unit type can have a production queue, and false otherwise. - bool canProduce() const; - - /// Checks if this unit is capable of attacking. - /// - /// @note This function returns false for units that can only inflict damage via special - /// abilities, such as the @High_Templar. - /// - /// @returns true if this unit type is capable of damaging other units with a standard attack, - /// and false otherwise. - bool canAttack() const; - - /// Checks if this unit type is capable of movement. - /// - /// @note Buildings will return false, including @Terran liftable buildings which are capable - /// of moving when lifted. - /// - /// @returns true if this unit can use a movement command, and false if they cannot move. - bool canMove() const; - - /// Checks if this unit type is a flying unit. Flying units ignore ground pathing and - /// collisions. - /// - /// @returns true if this unit type is in the air by default, and false otherwise. - bool isFlyer() const; - - /// Checks if this unit type can regenerate hit points. This generally applies to @Zerg units. - /// - /// @returns true if this unit type regenerates its hit points, and false otherwise. - bool regeneratesHP() const; - - /// Checks if this unit type has the capacity to store energy and use it for special abilities. - /// - /// @returns true if this unit type generates energy, and false if it does not have an energy - /// pool. - bool isSpellcaster() const; - - /// Checks if this unit type is permanently cloaked. This means the unit type is always - /// cloaked and requires a detector in order to see it. - /// - /// @returns true if this unit type is permanently cloaked, and false otherwise. - bool hasPermanentCloak() const; - - /// Checks if this unit type is invincible by default. Invincible units - /// cannot take damage. - /// - /// @returns true if this unit type is invincible, and false if it is vulnerable to attacks. - bool isInvincible() const; - - /// Checks if this unit is an organic unit. The organic property is required for some abilities - /// such as @Heal. - /// - /// @returns true if this unit type has the organic property, and false otherwise. - bool isOrganic() const; - - /// Checks if this unit is mechanical. The mechanical property is required for some actions - /// such as @Repair. - /// - /// @returns true if this unit type has the mechanical property, and false otherwise. - bool isMechanical() const; - - /// Checks if this unit is robotic. The robotic property is applied - /// to robotic units such as the @Probe which prevents them from taking damage from - /// @Irradiate. - /// - /// @returns true if this unit type has the robotic property, and false otherwise. - bool isRobotic() const; - - /// Checks if this unit type is capable of detecting units that are cloaked or burrowed. - /// - /// @returns true if this unit type is a detector by default, false if it does not have this - /// property - bool isDetector() const; - - /// Checks if this unit type is capable of storing resources such as @minerals. Resources - /// are harvested from resource containers. - /// - /// @returns true if this unit type may contain resources that can be harvested, false - /// otherwise. - bool isResourceContainer() const; - - /// Checks if this unit type is a resource depot. Resource depots must be placed a certain - /// distance from resources. Resource depots are typically the main building for any - /// particular race. Workers will return resources to the nearest resource depot. - /// - /// Example: - /// @code - /// if ( BWAPI::Broodwar->self() ) - /// { - /// BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits(); - /// for ( auto u : myUnits ) - /// { - /// if ( u->isIdle() && u->getType().isResourceDepot() ) - /// u->train( u->getType().getRace().getWorker() ); - /// } - /// } - /// @endcode - /// @returns true if the unit type is a resource depot, false if it is not. - bool isResourceDepot() const; - - /// Checks if this unit type is a refinery. A refinery is a structure that is placed on top of - /// a @geyser . Refinery types are @refinery , @extractor , and @assimilator. - /// - /// Example: - /// @code - /// if ( BWAPI::Broodwar->self() ) - /// { - /// BWAPI::Unitset myUnits = BWAPI::Broodwar->self()->getUnits(); - /// for ( auto u : myUnits ) - /// { - /// if ( u->getType().isRefinery() ) - /// { - /// int nWorkersAssigned = u->getClientInfo('work'); - /// if ( nWorkersAssigned < 3 ) - /// { - /// Unit pClosestIdleWorker = u->getClosestUnit(BWAPI::Filter::IsWorker && BWAPI::Filter::IsIdle); - /// if ( pClosestIdleWorker ) - /// { - /// // gather from the refinery (and check if successful) - /// if ( pClosestIdleWorker->gather(u) ) - /// { - /// // set a back reference for when the unit is killed or re-assigned (code not provided) - /// pClosestIdleWorker->setClientInfo(u, 'ref'); - /// - /// // Increment the number of workers assigned and associate it with the refinery - /// ++nWorkersAssigned; - /// u->setClientInfo(nWorkersAssigned, 'work'); - /// } - /// } - /// } // workers < 3 - /// } // isRefinery - /// } // for - /// } - /// @endcode - /// @returns true if this unit type is a refinery, and false if it is not. - bool isRefinery() const; - - /// Checks if this unit type is a worker unit. Worker units can harvest resources and build - /// structures. Worker unit types include the @SCV , @probe, and @drone. - /// - /// @returns true if this unit type is a worker, and false if it is not. - bool isWorker() const; - - /// Checks if this structure is powered by a psi field. Structures powered - /// by psi can only be placed near a @Pylon. If the @Pylon is destroyed, then this unit will - /// lose power. - /// - /// @returns true if this unit type can only be placed in a psi field, false otherwise. - /// @implies isBuilding(), getRace() == Races::Protoss - bool requiresPsi() const; - - /// Checks if this structure must be placed on @Zerg creep. - /// - /// @returns true if this unit type requires creep, false otherwise. - /// @implies isBuilding(), getRace() == Races::Zerg - bool requiresCreep() const; - - /// Checks if this unit type spawns two units when being hatched from an @Egg. - /// This is only applicable to @Zerglings and @Scourges. - /// - /// @returns true if morphing this unit type will spawn two of them, and false if only one - /// is spawned. - bool isTwoUnitsInOneEgg() const; - - /// Checks if this unit type has the capability to use the @Burrow technology when it - /// is researched. - /// - /// @note The @Lurker can burrow even without researching the ability. - /// @see TechTypes::Burrow - /// @returns true if this unit can use the @Burrow ability, and false otherwise. - /// @implies getRace() == Races::Zerg, !isBuilding(), canMove() - bool isBurrowable() const; - - /// Checks if this unit type has the capability to use a cloaking ability when it - /// is researched. This applies only to @Wraiths and @Ghosts, and does not include - /// units which are permanently cloaked. - /// - /// @returns true if this unit has a cloaking ability, false otherwise. - /// @see hasPermanentCloak, TechTypes::Cloaking_Field, TechTypes::Personnel_Cloaking - bool isCloakable() const; - - /// Checks if this unit is a structure. This includes @Mineral_Fields and - /// @Vespene_Geysers. - /// - /// @returns true if this unit is a building, and false otherwise. - bool isBuilding() const; - - /// Checks if this unit is an add-on. Add-ons are attachments used by some - /// @Terran structures such as the @Comsat_Station. - /// - /// @returns true if this unit is an add-on, and false otherwise. - /// @implies getRace() == Races::Terran, isBuilding() - bool isAddon() const; - - /// Checks if this structure has the capability to use the lift-off command. - /// - /// @returns true if this unit type is a flyable building, false otherwise. - /// @implies isBuilding() - bool isFlyingBuilding() const; - - /// Checks if this unit type is a neutral type, such as critters and resources. - /// - /// @returns true if this unit is intended to be neutral, and false otherwise. - bool isNeutral() const; - - /// Checks if this unit type is a hero. Heroes are types that the player - /// cannot obtain normally, and are identified by the white border around their icon when - /// selected with a group. - /// - /// @note There are two non-hero units included in this set, the @Civilian and @Dark_Templar_Hero. - /// - /// @returns true if this unit type is a hero type, and false otherwise. - bool isHero() const; - - /// Checks if this unit type is a powerup. Powerups can be picked up and - /// carried by workers. They are usually only seen in campaign maps and @Capture_the_flag. - /// - /// @returns true if this unit type is a powerup type, and false otherwise. - bool isPowerup() const; - - /// Checks if this unit type is a beacon. Each race has exactly one beacon - /// each. They are UnitTypes::Special_Zerg_Beacon, UnitTypes::Special_Terran_Beacon, and - /// UnitTypes::Special_Protoss_Beacon. - /// - /// @see isFlagBeacon - /// @returns true if this unit type is one of the three race beacons, and false otherwise. - bool isBeacon() const; - - /// Checks if this unit type is a flag beacon. Each race has exactly one - /// flag beacon each. They are UnitTypes::Special_Zerg_Flag_Beacon, - /// UnitTypes::Special_Terran_Flag_Beacon, and UnitTypes::Special_Protoss_Flag_Beacon. - /// Flag beacons spawn a @Flag after some ARBITRARY I FORGOT AMOUNT OF FRAMES. - /// - /// @see isBeacon - /// @returns true if this unit type is one of the three race flag beacons, and false otherwise. - /// - /// @todo specify number of frames for flag spawner - bool isFlagBeacon() const; - - /// Checks if this structure is special and cannot be obtained normally within the - /// game. - /// - /// @returns true if this structure is a special building, and false otherwise. - /// @implies isBuilding() - bool isSpecialBuilding() const; - - /// Identifies if this unit type is used to complement some @abilities. - /// These include UnitTypes::Spell_Dark_Swarm, UnitTypes::Spell_Disruption_Web, and - /// UnitTypes::Spell_Scanner_Sweep, which correspond to TechTypes::Dark_Swarm, - /// TechTypes::Disruption_Web, and TechTypes::Scanner_Sweep respectively. - /// - /// @returns true if this unit type is used for an ability, and false otherwise. - bool isSpell() const; - - /// Checks if this structure type produces creep. That is, the unit type - /// spreads creep over a wide area so that @Zerg structures can be placed on it. - /// - /// @returns true if this unit type spreads creep. - /// @implies getRace() == Races::Zerg, isBuilding() - /// - /// @since 4.1.2 - bool producesCreep() const; - - /// Checks if this unit type produces larva. This is essentially used to - /// check if the unit type is a @Hatchery, @Lair, or @Hive. - /// - /// @returns true if this unit type produces larva. - /// @implies getRace() == Races::Zerg, isBuilding() - bool producesLarva() const; - - /// Checks if this unit type is a mineral field and contains a resource amount. - /// This indicates that the unit type is either UnitTypes::Resource_Mineral_Field, - /// UnitTypes::Resource_Mineral_Field_Type_2, or UnitTypes::Resource_Mineral_Field_Type_3. - /// - /// @returns true if this unit type is a mineral field resource. - bool isMineralField() const; - - /// Checks if this unit type is a neutral critter. - /// - /// @returns true if this unit type is a critter, and false otherwise. - /// - /// Example usage: - /// @code - /// BWAPI::Position myBasePosition( BWAPI::Broodwar->self()->getStartLocation() ); - /// BWAPI::UnitSet unitsAroundTheBase = BWAPI::Broodwar->getUnitsInRadius(myBasePosition, 1024, !BWAPI::Filter::IsOwned && !BWAPI::Filter::IsParasited); - /// for ( auto u : unitsAroundTheBase ) - /// { - /// if ( u->getType().isCritter() && !u->isInvincible() ) - /// { - /// BWAPI::Unit myQueen = u->getClosestUnit(BWAPI::Filter::GetType == BWAPI::UnitTypes::Zerg_Queen && BWAPI::Filter::IsOwned); - /// if ( myQueen ) - /// myQueen->useTech(BWAPI::TechTypes::Parasite, u); - /// } - /// } - /// @endcode - bool isCritter() const; - - /// Checks if this unit type is capable of constructing an add-on. An add-on is an extension - /// or attachment for @Terran structures, specifically the @Command_Center, @Factory, - /// @Starport, and @Science_Facility. - /// - /// @returns true if this unit type can construct an add-on, and false if it can not. - /// @see isAddon - bool canBuildAddon() const; - - /// Retrieves the set of units that this unit type is capable of creating. - /// This includes training, constructing, warping, and morphing. - /// - /// @note Some maps have special parameters that disable construction of units that are otherwise - /// normally available. Use PlayerInterface::isUnitAvailable to determine if a unit type is - /// actually available in the current game for a specific player. - /// - /// @returns UnitType::set containing the units it can build. - /// @see PlayerInterface::isUnitAvailable - /// - /// @since 4.1.2 - const UnitType::set& buildsWhat() const; - - /// Retrieves the set of technologies that this unit type is capable of researching. - /// - /// @note Some maps have special parameters that disable certain technologies. Use - /// PlayerInterface::isResearchAvailable to determine if a technology is actually available in the - /// current game for a specific player. - /// - /// @returns TechType::set containing the technology types that can be researched. - /// @see PlayerInterface::isResearchAvailable - /// - /// @since 4.1.2 - const SetContainer& researchesWhat() const; - - /// Retrieves the set of upgrades that this unit type is capable of upgrading. - /// - /// @note Some maps have special upgrade limitations. Use PlayerInterface::getMaxUpgradeLevel - /// to check if an upgrade is available. - /// - /// @returns UpgradeType::set containing the upgrade types that can be upgraded. - /// @see PlayerInterface::getMaxUpgradeLevel - /// - /// @since 4.1.2 - const SetContainer& upgradesWhat() const; - }; - - /// The amount of shield points that a unit recovers over 256 frames. - /// That is, 7/256 shields are regenerated per frame. - /// - /// @since 4.1.0 Beta - static const int SHIELD_REGEN_RATE = 7; - - /// The amount of energy that a unit with special abilities recovers over 256 frames. - /// That is, 8/256 energy is generated per frame. - /// - /// @since 4.1.0 Beta - static const int ENERGY_REGEN_RATE = 8; - - /// The amount of life that a zerg unit recovers over 256 frames. - /// That is, 4/256 life is regenerated per frame. - /// - /// @since 4.1.0 Beta - static const int LIFE_REGEN_RATE = 4; - - /// @ingroup Types - namespace UnitTypes - { - /// Retrieves the maximum unit width from the set of all units. Used - /// internally to search through unit positions efficiently. - /// - /// @returns The maximum width of all unit types, in pixels. - int maxUnitWidth(); - - /// Retrieves the maximum unit height from the set of all units. Used - /// internally to search through unit positions efficiently. - /// - /// @returns The maximum height of all unit types, in pixels. - int maxUnitHeight(); - - /// Retrieves the set of all defined unit types. - /// - /// @returns A constant set of all available unit types. - const UnitType::set& allUnitTypes(); - - /// Retrieves the set of all macro unit types. A macro type is a fake unit - /// type, used by some functions. These include #AllUnits, #Men, #Buildings, and #Factories. - /// The purpose of these types are to match the same ones used in Broodwar, also seen in the - /// StarEdit map editor. - /// - /// @returns A constant set of all macro unit types. - const UnitType::set& allMacroTypes(); - - /// @name Terran Ground Units - /// @{ - extern const UnitType Terran_Firebat; - extern const UnitType Terran_Ghost; - extern const UnitType Terran_Goliath; - extern const UnitType Terran_Marine; - extern const UnitType Terran_Medic; - extern const UnitType Terran_SCV; - extern const UnitType Terran_Siege_Tank_Siege_Mode; - extern const UnitType Terran_Siege_Tank_Tank_Mode; - extern const UnitType Terran_Vulture; - extern const UnitType Terran_Vulture_Spider_Mine; - /// @} - /// @name Terran Air Units - /// @{ - extern const UnitType Terran_Battlecruiser; - extern const UnitType Terran_Dropship; - extern const UnitType Terran_Nuclear_Missile; - extern const UnitType Terran_Science_Vessel; - extern const UnitType Terran_Valkyrie; - extern const UnitType Terran_Wraith; - /// @} - /// @name Terran Heroes - /// @{ - extern const UnitType Hero_Alan_Schezar; - extern const UnitType Hero_Alexei_Stukov; - extern const UnitType Hero_Arcturus_Mengsk; - extern const UnitType Hero_Edmund_Duke_Tank_Mode; - extern const UnitType Hero_Edmund_Duke_Siege_Mode; - extern const UnitType Hero_Gerard_DuGalle; - extern const UnitType Hero_Gui_Montag; - extern const UnitType Hero_Hyperion; - extern const UnitType Hero_Jim_Raynor_Marine; - extern const UnitType Hero_Jim_Raynor_Vulture; - extern const UnitType Hero_Magellan; - extern const UnitType Hero_Norad_II; - extern const UnitType Hero_Samir_Duran; - extern const UnitType Hero_Sarah_Kerrigan; - extern const UnitType Hero_Tom_Kazansky; - extern const UnitType Terran_Civilian; - /// @} - /// @name Terran Buildings - /// @{ - extern const UnitType Terran_Academy; - extern const UnitType Terran_Armory; - extern const UnitType Terran_Barracks; - extern const UnitType Terran_Bunker; - extern const UnitType Terran_Command_Center; - extern const UnitType Terran_Engineering_Bay; - extern const UnitType Terran_Factory; - extern const UnitType Terran_Missile_Turret; - extern const UnitType Terran_Refinery; - extern const UnitType Terran_Science_Facility; - extern const UnitType Terran_Starport; - extern const UnitType Terran_Supply_Depot; - /// @} - /// @name Terran Addons - /// @{ - extern const UnitType Terran_Comsat_Station; - extern const UnitType Terran_Control_Tower; - extern const UnitType Terran_Covert_Ops; - extern const UnitType Terran_Machine_Shop; - extern const UnitType Terran_Nuclear_Silo; - extern const UnitType Terran_Physics_Lab; - /// @} - /// @name Terran Special Buildings - /// @{ - extern const UnitType Special_Crashed_Norad_II; - extern const UnitType Special_Ion_Cannon; - extern const UnitType Special_Power_Generator; - extern const UnitType Special_Psi_Disrupter; - /// @} - /// @name Protoss Ground Units - /// @{ - extern const UnitType Protoss_Archon; - extern const UnitType Protoss_Dark_Archon; - extern const UnitType Protoss_Dark_Templar; - extern const UnitType Protoss_Dragoon; - extern const UnitType Protoss_High_Templar; - extern const UnitType Protoss_Probe; - extern const UnitType Protoss_Reaver; - extern const UnitType Protoss_Scarab; - extern const UnitType Protoss_Zealot; - /// @} - /// @name Protoss Air Units - /// @{ - extern const UnitType Protoss_Arbiter; - extern const UnitType Protoss_Carrier; - extern const UnitType Protoss_Corsair; - extern const UnitType Protoss_Interceptor; - extern const UnitType Protoss_Observer; - extern const UnitType Protoss_Scout; - extern const UnitType Protoss_Shuttle; - /// @} - /// @name Protoss Heroes Units - /// @{ - extern const UnitType Hero_Aldaris; - extern const UnitType Hero_Artanis; - extern const UnitType Hero_Danimoth; - extern const UnitType Hero_Dark_Templar; - extern const UnitType Hero_Fenix_Dragoon; - extern const UnitType Hero_Fenix_Zealot; - extern const UnitType Hero_Gantrithor; - extern const UnitType Hero_Mojo; - extern const UnitType Hero_Raszagal; - extern const UnitType Hero_Tassadar; - extern const UnitType Hero_Tassadar_Zeratul_Archon; - extern const UnitType Hero_Warbringer; - extern const UnitType Hero_Zeratul; - /// @} - /// @name Protoss Buildings - /// @{ - extern const UnitType Protoss_Arbiter_Tribunal; - extern const UnitType Protoss_Assimilator; - extern const UnitType Protoss_Citadel_of_Adun; - extern const UnitType Protoss_Cybernetics_Core; - extern const UnitType Protoss_Fleet_Beacon; - extern const UnitType Protoss_Forge; - extern const UnitType Protoss_Gateway; - extern const UnitType Protoss_Nexus; - extern const UnitType Protoss_Observatory; - extern const UnitType Protoss_Photon_Cannon; - extern const UnitType Protoss_Pylon; - extern const UnitType Protoss_Robotics_Facility; - extern const UnitType Protoss_Robotics_Support_Bay; - extern const UnitType Protoss_Shield_Battery; - extern const UnitType Protoss_Stargate; - extern const UnitType Protoss_Templar_Archives; - /// @} - /// @name Protoss Special Buildings - /// @{ - extern const UnitType Special_Khaydarin_Crystal_Form; - extern const UnitType Special_Protoss_Temple; - extern const UnitType Special_Stasis_Cell_Prison; - extern const UnitType Special_Warp_Gate; - extern const UnitType Special_XelNaga_Temple; - /// @} - /// @name Zerg Ground Units - /// @{ - extern const UnitType Zerg_Broodling; - extern const UnitType Zerg_Defiler; - extern const UnitType Zerg_Drone; - extern const UnitType Zerg_Egg; - extern const UnitType Zerg_Hydralisk; - extern const UnitType Zerg_Infested_Terran; - extern const UnitType Zerg_Larva; - extern const UnitType Zerg_Lurker; - extern const UnitType Zerg_Lurker_Egg; - extern const UnitType Zerg_Ultralisk; - extern const UnitType Zerg_Zergling; - /// @} - /// @name Zerg Air Units - /// @{ - extern const UnitType Zerg_Cocoon; - extern const UnitType Zerg_Devourer; - extern const UnitType Zerg_Guardian; - extern const UnitType Zerg_Mutalisk; - extern const UnitType Zerg_Overlord; - extern const UnitType Zerg_Queen; - extern const UnitType Zerg_Scourge; - /// @} - /// @name Zerg Heroes - /// @{ - extern const UnitType Hero_Devouring_One; - extern const UnitType Hero_Hunter_Killer; - extern const UnitType Hero_Infested_Duran; - extern const UnitType Hero_Infested_Kerrigan; - extern const UnitType Hero_Kukulza_Guardian; - extern const UnitType Hero_Kukulza_Mutalisk; - extern const UnitType Hero_Matriarch; - extern const UnitType Hero_Torrasque; - extern const UnitType Hero_Unclean_One; - extern const UnitType Hero_Yggdrasill; - /// @} - /// @name Zerg Buildings - /// @{ - extern const UnitType Zerg_Creep_Colony; - extern const UnitType Zerg_Defiler_Mound; - extern const UnitType Zerg_Evolution_Chamber; - extern const UnitType Zerg_Extractor; - extern const UnitType Zerg_Greater_Spire; - extern const UnitType Zerg_Hatchery; - extern const UnitType Zerg_Hive; - extern const UnitType Zerg_Hydralisk_Den; - extern const UnitType Zerg_Infested_Command_Center; - extern const UnitType Zerg_Lair; - extern const UnitType Zerg_Nydus_Canal; - extern const UnitType Zerg_Queens_Nest; - extern const UnitType Zerg_Spawning_Pool; - extern const UnitType Zerg_Spire; - extern const UnitType Zerg_Spore_Colony; - extern const UnitType Zerg_Sunken_Colony; - extern const UnitType Zerg_Ultralisk_Cavern; - /// @} - /// @name Zerg Special Buildings - /// @{ - extern const UnitType Special_Cerebrate; - extern const UnitType Special_Cerebrate_Daggoth; - extern const UnitType Special_Mature_Chrysalis; - extern const UnitType Special_Overmind; - extern const UnitType Special_Overmind_Cocoon; - extern const UnitType Special_Overmind_With_Shell; - /// @} - /// @name Critters - /// @{ - extern const UnitType Critter_Bengalaas; - extern const UnitType Critter_Kakaru; - extern const UnitType Critter_Ragnasaur; - extern const UnitType Critter_Rhynadon; - extern const UnitType Critter_Scantid; - extern const UnitType Critter_Ursadon; - /// @} - /// @name Resources - /// @{ - 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 Resource_Vespene_Geyser; - /// @} - /// @name Spells - /// @{ - extern const UnitType Spell_Dark_Swarm; - extern const UnitType Spell_Disruption_Web; - extern const UnitType Spell_Scanner_Sweep; - /// @} - /// @name Beacons - /// @{ - extern const UnitType Special_Protoss_Beacon; - extern const UnitType Special_Protoss_Flag_Beacon; - extern const UnitType Special_Terran_Beacon; - extern const UnitType Special_Terran_Flag_Beacon; - extern const UnitType Special_Zerg_Beacon; - extern const UnitType Special_Zerg_Flag_Beacon; - /// @} - /// @name Powerups - /// @{ - extern const UnitType Powerup_Data_Disk; - extern const UnitType Powerup_Flag; - extern const UnitType Powerup_Khalis_Crystal; - 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_Psi_Emitter; - extern const UnitType Powerup_Terran_Gas_Tank_Type_1; - extern const UnitType Powerup_Terran_Gas_Tank_Type_2; - extern const UnitType Powerup_Uraj_Crystal; - extern const UnitType Powerup_Young_Chrysalis; - extern const UnitType Powerup_Zerg_Gas_Sac_Type_1; - extern const UnitType Powerup_Zerg_Gas_Sac_Type_2; - /// @} - /// @name Traps - /// @{ - extern const UnitType Special_Floor_Gun_Trap; - extern const UnitType Special_Floor_Missile_Trap; - extern const UnitType Special_Right_Wall_Flame_Trap; - extern const UnitType Special_Right_Wall_Missile_Trap; - extern const UnitType Special_Wall_Flame_Trap; - extern const UnitType Special_Wall_Missile_Trap; - /// @} - /// @name Doors - /// @{ - extern const UnitType Special_Pit_Door; - extern const UnitType Special_Right_Pit_Door; - extern const UnitType Special_Right_Upper_Level_Door; - extern const UnitType Special_Upper_Level_Door; - /// @} - /// @name Special - /// @{ - extern const UnitType Special_Cargo_Ship; - extern const UnitType Special_Floor_Hatch; - extern const UnitType Special_Independant_Starport; - extern const UnitType Special_Map_Revealer; - extern const UnitType Special_Mercenary_Gunship; - 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; - } - - static_assert(sizeof(UnitType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/Unitset.h b/bwapi-includes/BWAPI/Unitset.h deleted file mode 100644 index af1e098..0000000 --- a/bwapi-includes/BWAPI/Unitset.h +++ /dev/null @@ -1,186 +0,0 @@ -#pragma once -#include "SetContainer.h" -#include -#include -#include - -namespace BWAPI -{ - // Forward declarations - class UnitType; - class Regionset; - class UnitCommand; - class TechType; - - /// The Unitset is a container for a set of pointers to Unit objects. It is typically - /// used for groups of units instead of having to manage each Unit individually. - /// - /// @see Unit - class Unitset : public SetContainer> - { - public: - /// A blank Unitset containing no elements. This is typically used as a - /// return value for BWAPI interface functions that have encountered an error. - static const Unitset none; - - - /// Calculates the average of all valid Unit positions in this set. - /// - /// @returns Average Position of all units in the set. - /// - /// @see UnitInterface::getPosition - Position getPosition() const; - - /// Creates a single set containing all units that are loaded into units of this set. - /// - /// @returns The set of all loaded units. - /// - /// @see UnitInterface::getLoadedUnits - Unitset getLoadedUnits() const; - - /// Creates a single set containing all the @Interceptors of all @Carriers in this set. - /// - /// @returns The set of all @Interceptors . - /// - /// @see UnitInterface::getInterceptors - Unitset getInterceptors() const; - - /// Creates a single set containing all the @Larvae of all @Hatcheries, @Lairs, and - /// @Hives in this set. - /// - /// @returns The set of all @Larvae . - /// - /// @see UnitInterface::getLarva - Unitset getLarva() const; - - /// Sets the client info for every unit in this set. - /// - /// (optional) - /// A pointer to client information, managed by the AI module, or nullptr if client - /// information is to be cleared. - /// - /// (optional) - /// An key value for the client info mapping so that more than one piece of data can be - /// mapped to the same unit. - /// - /// - /// @see UnitInterface::setClientInfo - void setClientInfo(void *clientInfo = nullptr, int index = 0) const; - /// @overload - void setClientInfo(int clientInfo = 0, int index = 0) const; - - /// @copydoc UnitInterface::getUnitsInRadius - Unitset getUnitsInRadius(int radius, const UnitFilter &pred = nullptr) const; - - /// @copydoc UnitInterface::getClosestUnit - Unit getClosestUnit(const UnitFilter &pred = nullptr, int radius = 999999) const; - - /// @name Unit Commands - /// @{ - - /// @copydoc UnitInterface::issueCommand - bool issueCommand(UnitCommand command) const; - - /// @copydoc UnitInterface::attack - bool attack(PositionOrUnit target, bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::build - bool build(UnitType type, TilePosition target = TilePositions::None) const; - - /// @copydoc UnitInterface::buildAddon - bool buildAddon(UnitType type) const; - - /// @copydoc UnitInterface::train - bool train(UnitType type) const; - - /// @copydoc UnitInterface::morph - bool morph(UnitType type) const; - - /// @copydoc UnitInterface::setRallyPoint - bool setRallyPoint(PositionOrUnit target) const; - - /// @copydoc UnitInterface::move - bool move(Position target, bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::patrol - bool patrol(Position target, bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::holdPosition - bool holdPosition(bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::stop - bool stop(bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::follow - bool follow(Unit target, bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::gather - bool gather(Unit target, bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::returnCargo - bool returnCargo(bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::repair - bool repair(Unit target, bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::burrow - bool burrow() const; - - /// @copydoc UnitInterface::unburrow - bool unburrow() const; - - /// @copydoc UnitInterface::cloak - bool cloak() const; - - /// @copydoc UnitInterface::decloak - bool decloak() const; - - /// @copydoc UnitInterface::siege - bool siege() const; - - /// @copydoc UnitInterface::unsiege - bool unsiege() const; - - /// @copydoc UnitInterface::lift - bool lift() const; - - /// @copydoc UnitInterface::load - bool load(Unit target, bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::unloadAll(bool) - bool unloadAll(bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::unloadAll(Position,bool) - bool unloadAll(Position target, bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::rightClick - bool rightClick(PositionOrUnit target, bool shiftQueueCommand = false) const; - - /// @copydoc UnitInterface::haltConstruction - bool haltConstruction() const; - - /// @copydoc UnitInterface::cancelConstruction - bool cancelConstruction() const; - - /// @copydoc UnitInterface::cancelAddon - bool cancelAddon() const; - - /// @copydoc UnitInterface::cancelTrain - bool cancelTrain(int slot = -2) const; - - /// @copydoc UnitInterface::cancelMorph - bool cancelMorph() const; - - /// @copydoc UnitInterface::cancelResearch - bool cancelResearch() const; - - /// @copydoc UnitInterface::cancelUpgrade - bool cancelUpgrade() const; - - /// @copydoc UnitInterface::useTech - bool useTech(TechType tech, PositionOrUnit target = nullptr) const; - - ///@} - }; -} - diff --git a/bwapi-includes/BWAPI/UpgradeType.h b/bwapi-includes/BWAPI/UpgradeType.h deleted file mode 100644 index 7b91239..0000000 --- a/bwapi-includes/BWAPI/UpgradeType.h +++ /dev/null @@ -1,249 +0,0 @@ -#pragma once -#include -#include - -namespace BWAPI -{ - class Race; - - /// Namespace of upgrade types. - namespace UpgradeTypes - { - /// Enumeration of upgrade types. - namespace Enum - { - /// Enumeration of upgrade types. - enum Enum - { - Terran_Infantry_Armor = 0, - Terran_Vehicle_Plating = 1, - Terran_Ship_Plating = 2, - Zerg_Carapace = 3, - Zerg_Flyer_Carapace = 4, - Protoss_Ground_Armor = 5, - Protoss_Air_Armor = 6, - Terran_Infantry_Weapons = 7, - Terran_Vehicle_Weapons = 8, - Terran_Ship_Weapons = 9, - Zerg_Melee_Attacks = 10, - Zerg_Missile_Attacks = 11, - Zerg_Flyer_Attacks = 12, - Protoss_Ground_Weapons = 13, - Protoss_Air_Weapons = 14, - Protoss_Plasma_Shields = 15, - U_238_Shells = 16, - Ion_Thrusters = 17, - - Titan_Reactor = 19, - Ocular_Implants = 20, - Moebius_Reactor = 21, - Apollo_Reactor = 22, - Colossus_Reactor = 23, - Ventral_Sacs = 24, - Antennae = 25, - Pneumatized_Carapace = 26, - Metabolic_Boost = 27, - Adrenal_Glands = 28, - Muscular_Augments = 29, - Grooved_Spines = 30, - Gamete_Meiosis = 31, - Metasynaptic_Node = 32, - Singularity_Charge = 33, - Leg_Enhancements = 34, - Scarab_Damage = 35, - Reaver_Capacity = 36, - Gravitic_Drive = 37, - Sensor_Array = 38, - Gravitic_Boosters = 39, - Khaydarin_Amulet = 40, - Apial_Sensors = 41, - Gravitic_Thrusters = 42, - Carrier_Capacity = 43, - Khaydarin_Core = 44, - - Argus_Jewel = 47, - - Argus_Talisman = 49, - - Caduceus_Reactor = 51, - Chitinous_Plating = 52, - Anabolic_Synthesis = 53, - Charon_Boosters = 54, - - Upgrade_60 = 60, - None = 61, - Unknown, - MAX - }; - } - } - - /// The upgrade type represents a passive upgrade that can be obtained with - /// UnitInterface::upgrade. - /// - /// @see UpgradeTypes - /// - /// @ingroup TypeClasses - class UpgradeType : public Type - { - public: - /// @copydoc Type::Type(int) - UpgradeType(int id = UpgradeTypes::Enum::None); - - /// Retrieves the race the upgrade is for. - /// For example, UpgradeTypes::Terran_Infantry_Armor.getRace() will return Races::Terran. - /// - /// @returns Race that this upgrade belongs to. - Race getRace() const; - - /// Returns the mineral price for the upgrade. - /// - /// (optional) - /// The next upgrade level. - /// - /// - /// @note Upgrades start at level 0. - /// - /// @returns The mineral cost of the upgrade for the given \p level. - int mineralPrice(int level = 1) const; - - /// The amount that the mineral price increases for each additional upgrade. - /// - /// @returns The mineral cost added to the upgrade after each level. - int mineralPriceFactor() const; - - /// Returns the vespene gas price for the first upgrade. - /// - /// (optional) - /// The next upgrade level. - /// - /// - /// @note Upgrades start at level 0. - /// - /// @returns The gas cost of the upgrade for the given \p level. - int gasPrice(int level = 1) const; - - /// Returns the amount that the vespene gas price increases for each additional upgrade. - /// - /// @returns The gas cost added to the upgrade after each level. - int gasPriceFactor() const; - - /// Returns the number of frames needed to research the first upgrade. - /// - /// (optional) - /// The next upgrade level. - /// - /// - /// @note Upgrades start at level 0. - /// - /// @returns The time cost of the upgrade for the given \p level. - int upgradeTime(int level = 1) const; - - /// Returns the number of frames that the upgrade time increases for each additional upgrade. - /// - /// @returns The time cost added to the upgrade after each level. - int upgradeTimeFactor() const; - - /// Returns the maximum number of times the upgrade can be researched. - /// - /// @returns Maximum number of times this upgrade can be upgraded. - int maxRepeats() const; - - /// Returns the type of unit that researches the upgrade. - /// - /// @returns The UnitType that is used to upgrade this type. - UnitType whatUpgrades() const; - - /// Returns the type of unit that is required for the upgrade. The player - /// must have at least one of these units completed in order to start upgrading this upgrade. - /// - /// (optional) - /// The next upgrade level. - /// - /// - /// @note Upgrades start at level 0. - /// - /// @returns UnitType required to obtain this upgrade. - UnitType whatsRequired(int level = 1) const; - - /// Returns the set of units that are affected by this upgrade. - /// - /// @returns Set of unit types that passively use this upgrade type. - const UnitType::set& whatUses() const; - }; - - /// @ingroup Types - namespace UpgradeTypes - { - /// Returns the set of all the UpgradeTypes. - /// - /// @returns UpgradeType::set containing all of the well-defined UpgradeTypes. - const UpgradeType::set& allUpgradeTypes(); - - /// @name Terran Upgrades - /// @{ - extern const UpgradeType Terran_Infantry_Armor; - extern const UpgradeType Terran_Vehicle_Plating; - extern const UpgradeType Terran_Ship_Plating; - extern const UpgradeType Terran_Infantry_Weapons; - extern const UpgradeType Terran_Vehicle_Weapons; - extern const UpgradeType Terran_Ship_Weapons; - 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 Caduceus_Reactor; - extern const UpgradeType Charon_Boosters; - /// @} - /// @name Zerg Upgrades - /// @{ - extern const UpgradeType Zerg_Carapace; - extern const UpgradeType Zerg_Flyer_Carapace; - extern const UpgradeType Zerg_Melee_Attacks; - extern const UpgradeType Zerg_Missile_Attacks; - extern const UpgradeType Zerg_Flyer_Attacks; - 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 Chitinous_Plating; - extern const UpgradeType Anabolic_Synthesis; - /// @} - /// @name Protoss Upgrades - /// @{ - extern const UpgradeType Protoss_Ground_Armor; - extern const UpgradeType Protoss_Air_Armor; - extern const UpgradeType Protoss_Ground_Weapons; - extern const UpgradeType Protoss_Air_Weapons; - extern const UpgradeType Protoss_Plasma_Shields; - 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 Upgrade_60; - extern const UpgradeType None; - extern const UpgradeType Unknown; - } - - static_assert(sizeof(UpgradeType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/WeaponType.h b/bwapi-includes/BWAPI/WeaponType.h deleted file mode 100644 index 03a2a82..0000000 --- a/bwapi-includes/BWAPI/WeaponType.h +++ /dev/null @@ -1,443 +0,0 @@ -#pragma once -#include - -namespace BWAPI -{ - class TechType; - class UpgradeType; - class DamageType; - class ExplosionType; - class UnitType; - - /// namespace containing weapon types. - /// @see WeaponType - namespace WeaponTypes - { - /// Enumeration of weapon types. - /// @see WeaponType - namespace Enum - { - /// Enumeration of weapon types. - /// @see WeaponType - enum Enum - { - Gauss_Rifle = 0, - Gauss_Rifle_Jim_Raynor = 1, - C_10_Canister_Rifle = 2, - C_10_Canister_Rifle_Sarah_Kerrigan = 3, - Fragmentation_Grenade = 4, - Fragmentation_Grenade_Jim_Raynor = 5, - Spider_Mines = 6, - Twin_Autocannons = 7, - Hellfire_Missile_Pack = 8, - Twin_Autocannons_Alan_Schezar = 9, - Hellfire_Missile_Pack_Alan_Schezar = 10, - Arclite_Cannon = 11, - Arclite_Cannon_Edmund_Duke = 12, - Fusion_Cutter = 13, - - Gemini_Missiles = 15, - Burst_Lasers = 16, - Gemini_Missiles_Tom_Kazansky = 17, - Burst_Lasers_Tom_Kazansky = 18, - ATS_Laser_Battery = 19, - ATA_Laser_Battery = 20, - ATS_Laser_Battery_Hero = 21, - ATA_Laser_Battery_Hero = 22, - ATS_Laser_Battery_Hyperion = 23, - ATA_Laser_Battery_Hyperion = 24, - Flame_Thrower = 25, - Flame_Thrower_Gui_Montag = 26, - Arclite_Shock_Cannon = 27, - Arclite_Shock_Cannon_Edmund_Duke = 28, - Longbolt_Missile = 29, - Yamato_Gun = 30, - Nuclear_Strike = 31, - Lockdown = 32, - EMP_Shockwave = 33, - Irradiate = 34, - Claws = 35, - Claws_Devouring_One = 36, - Claws_Infested_Kerrigan = 37, - Needle_Spines = 38, - Needle_Spines_Hunter_Killer = 39, - Kaiser_Blades = 40, - Kaiser_Blades_Torrasque = 41, - Toxic_Spores = 42, - Spines = 43, - - Acid_Spore = 46, - Acid_Spore_Kukulza = 47, - Glave_Wurm = 48, - Glave_Wurm_Kukulza = 49, - - Seeker_Spores = 52, - Subterranean_Tentacle = 53, - Suicide_Infested_Terran = 54, - Suicide_Scourge = 55, - Parasite = 56, - Spawn_Broodlings = 57, - Ensnare = 58, - Dark_Swarm = 59, - Plague = 60, - Consume = 61, - Particle_Beam = 62, - - Psi_Blades = 64, - Psi_Blades_Fenix = 65, - Phase_Disruptor = 66, - Phase_Disruptor_Fenix = 67, - - Psi_Assault = 69, - Psionic_Shockwave = 70, - Psionic_Shockwave_TZ_Archon = 71, - - Dual_Photon_Blasters = 73, - Anti_Matter_Missiles = 74, - Dual_Photon_Blasters_Mojo = 75, - Anti_Matter_Missiles_Mojo = 76, - Phase_Disruptor_Cannon = 77, - Phase_Disruptor_Cannon_Danimoth = 78, - Pulse_Cannon = 79, - STS_Photon_Cannon = 80, - STA_Photon_Cannon = 81, - Scarab = 82, - Stasis_Field = 83, - Psionic_Storm = 84, - Warp_Blades_Zeratul = 85, - Warp_Blades_Hero = 86, - - Platform_Laser_Battery = 92, - Independant_Laser_Battery = 93, - - Twin_Autocannons_Floor_Trap = 96, - Hellfire_Missile_Pack_Wall_Trap = 97, - Flame_Thrower_Wall_Trap = 98, - Hellfire_Missile_Pack_Floor_Trap = 99, - - Neutron_Flare = 100, - Disruption_Web = 101, - Restoration = 102, - Halo_Rockets = 103, - Corrosive_Acid = 104, - Mind_Control = 105, - Feedback = 106, - Optical_Flare = 107, - Maelstrom = 108, - Subterranean_Spines = 109, - - Warp_Blades = 111, - C_10_Canister_Rifle_Samir_Duran = 112, - C_10_Canister_Rifle_Infested_Duran = 113, - Dual_Photon_Blasters_Artanis = 114, - Anti_Matter_Missiles_Artanis = 115, - C_10_Canister_Rifle_Alexei_Stukov = 116, - - None = 130, - Unknown, - MAX - }; - } - } - /// This object identifies a weapon type used by a unit to attack and deal damage. - /// Some weapon types can be upgraded while others are used for special abilities. - /// - /// @see WeaponTypes - /// @ingroup TypeClasses - class WeaponType : public Type - { - public: - /// @copydoc Type::Type(int) - WeaponType(int id = WeaponTypes::Enum::None); - - /// Retrieves the technology type that must be researched before this weapon can - /// be used. - /// - /// @returns TechType required by this weapon. - /// @retval TechTypes::None if no tech type is required to use this weapon. - /// @see TechType::getWeapon - TechType getTech() const; - - /// Retrieves the unit type that is intended to use this weapon type. - /// - /// @note There is a rare case where some hero unit types use the same weapon. - /// - /// @todo specify which types use the same weapon - /// - /// @returns The UnitType that uses this weapon. - /// @see UnitType::groundWeapon, UnitType::airWeapon - UnitType whatUses() const; - - /// Retrieves the base amount of damage that this weapon can deal per attack. - /// - /// @note That this damage amount must go through a DamageType and UnitSizeType filter - /// before it is applied to a unit. - /// - /// @returns Amount of base damage that this weapon deals. - int damageAmount() const; - - /// Determines the bonus amount of damage that this weapon type increases by for every - /// upgrade to this type. - /// - /// @see upgradeType - /// @returns Amount of damage added for every weapon upgrade. - int damageBonus() const; - - /// Retrieves the base amount of cooldown time between each attack, in frames. - /// - /// @returns The amount of base cooldown applied to the unit after an attack. - /// @see UnitInterface::getGroundWeaponCooldown, UnitInterface::getAirWeaponCooldown - int damageCooldown() const; - - /// Obtains the intended number of missiles/attacks that are used. - /// This is used to multiply with the damage amount to obtain the full amount of damage - /// for an attack. - /// - /// @returns The damage factor multiplied by the amount to obtain the total damage. - /// @see damageAmount - int damageFactor() const; - - /// Retrieves the upgrade type that increases this weapon's damage output. - /// - /// @returns The UpgradeType used to upgrade this weapon's damage. - /// @see damageBonus - UpgradeType upgradeType() const; - - /// Retrieves the damage type that this weapon applies to a unit type. - /// - /// @returns DamageType used for damage calculation. - /// @see DamageType, UnitSizeType - DamageType damageType() const; - - /// Retrieves the explosion type that indicates how the weapon deals damage. - /// - /// @returns ExplosionType identifying how damage is applied to a target location. - ExplosionType explosionType() const; - - /// Retrieves the minimum attack range of the weapon, measured in pixels. - /// This value is 0 for almost all weapon types, except for WeaponTypes::Arclite_Shock_Cannon - /// and WeaponTypes::Arclite_Shock_Cannon_Edmund_Duke. - /// - /// @returns Minimum attack range, in pixels. - int minRange() const; - - /// Retrieves the maximum attack range of the weapon, measured in pixels. - /// - /// @returns Maximum attack range, in pixels. - int maxRange() const; - - /// Retrieves the inner radius used for splash damage calculations, in pixels. - /// - /// @returns Radius of the inner splash area, in pixels. - /// - /// @todo Add damage calculation. - int innerSplashRadius() const; - - /// Retrieves the middle radius used for splash damage calculations, in pixels. - /// - /// @returns Radius of the middle splash area, in pixels. - /// - /// @todo Add damage calculation. - int medianSplashRadius() const; - - /// Retrieves the outer radius used for splash damage calculations, in pixels. - /// - /// @returns Radius of the outer splash area, in pixels. - /// - /// @todo Add damage calculation. - int outerSplashRadius() const; - - /// Checks if this weapon type can target air units. - /// - /// @returns true if this weapon type can target air units, and false otherwise. - /// @see UnitInterface::isFlying, UnitType::isFlyer - bool targetsAir() const; - - /// Checks if this weapon type can target ground units. - /// - /// @returns true if this weapon type can target ground units, and false otherwise. - /// @see UnitInterface::isFlying, UnitType::isFlyer - bool targetsGround() const; - - /// Checks if this weapon type can only target mechanical units. - /// - /// @returns true if this weapon type can only target mechanical units, and false otherwise. - /// @see targetsOrgOrMech, UnitType::isMechanical - bool targetsMechanical() const; - - /// Checks if this weapon type can only target organic units. - /// - /// @returns true if this weapon type can only target organic units, and false otherwise. - /// @see targetsOrgOrMech, UnitType::isOrganic - bool targetsOrganic() const; - - /// Checks if this weapon type cannot target structures. - /// - /// @returns true if this weapon type cannot target buildings, and false if it can. - /// @see UnitType::isBuilding - bool targetsNonBuilding() const; - - /// Checks if this weapon type cannot target robotic units. - /// - /// @returns true if this weapon type cannot target robotic units, and false if it can. - /// @see UnitType::isRobotic - bool targetsNonRobotic() const; - - /// Checks if this weapon type can target the ground. - /// - /// @note This is more for attacks like @Psi_Storm which can target a location, not to be - /// confused with attack move. - /// - /// @returns true if this weapon type can target a location, and false otherwise. - bool targetsTerrain() const; - - /// Checks if this weapon type can only target organic or mechanical units. - /// - /// @returns true if this weapon type can only target organic or mechanical units, and false otherwise. - /// @see targetsOrganic, targetsMechanical, UnitType::isOrganic, UnitType::isMechanical - bool targetsOrgOrMech() const; - - /// Checks if this weapon type can only target units owned by the same player. - /// This is used for WeaponTypes::Consume. - /// - /// @returns true if this weapon type can only target your own units, and false otherwise. - /// @see UnitInterface::getPlayer - bool targetsOwn() const; - }; - - /// @ingroup Types - namespace WeaponTypes - { - /// Retrieves the set of all defined weapon types. This is a union between - /// the normal and special weapon types. - /// - /// @returns set consisting of all defined weapon types. - /// @see normalWeaponTypes, specialWeaponTypes - const WeaponType::set& allWeaponTypes(); - - /// Retrieves the set of all defined normal weapon types. This set contains - /// all weapons that are not used for abilities. - /// - /// @returns constant set consisting of all normal weapon types. - const WeaponType::set& normalWeaponTypes(); - - /// Retrieves the set of all special weapon types. This set contains all - /// weapons that are used exclusively for special unit abilities. - /// - /// @returns constant set consisting of all special weapon types. - const WeaponType::set& specialWeaponTypes(); - - /// @name Normal Weapons - ///@{ - 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; - ///@} - - /// @name Special Weapons - ///@{ - 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; - } - - static_assert(sizeof(WeaponType) == sizeof(int), "Expected type to resolve to primitive size."); -} diff --git a/bwapi-includes/BWAPI/WindowsTypes.h b/bwapi-includes/BWAPI/WindowsTypes.h deleted file mode 100644 index 9accb7c..0000000 --- a/bwapi-includes/BWAPI/WindowsTypes.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -typedef char CHAR; -typedef short SHORT; -typedef long LONG; -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef int BOOL; -typedef void* HANDLE; -typedef void* PVOID; -typedef void* LPVOID; - -#ifndef WINAPI -#define WINAPI __stdcall -#endif - -#ifndef APIENTRY -#define APIENTRY WINAPI -#endif - -#ifndef DLL_PROCESS_ATTACH -#define DLL_PROCESS_ATTACH 1 -#define DLL_THREAD_ATTACH 2 -#define DLL_THREAD_DETACH 3 -#define DLL_PROCESS_DETACH 0 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif diff --git a/bwta2-includes/BWTA.h b/bwta2-includes/BWTA.h deleted file mode 100644 index 9bc15bd..0000000 --- a/bwta2-includes/BWTA.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -namespace BWTA -{ - void readMap(); - void analyze(); - void computeDistanceTransform(); - void balanceAnalysis(); - void cleanMemory(); - - int getMaxDistanceTransform(); - RectangleArray* getDistanceTransformMap(); - - const std::set& getRegions(); - const std::set& getChokepoints(); - const std::set& getBaseLocations(); - const std::set& getStartLocations(); - const std::set& getUnwalkablePolygons(); - - BaseLocation* getStartLocation(BWAPI::Player player); - - Region* getRegion(int x, int y); - Region* getRegion(BWAPI::TilePosition tileposition); - Region* getRegion(BWAPI::Position position); - - Chokepoint* getNearestChokepoint(int x, int y); - Chokepoint* getNearestChokepoint(BWAPI::TilePosition tileposition); - Chokepoint* getNearestChokepoint(BWAPI::Position position); - - BaseLocation* getNearestBaseLocation(int x, int y); - BaseLocation* getNearestBaseLocation(BWAPI::TilePosition tileposition); - BaseLocation* getNearestBaseLocation(BWAPI::Position position); - - Polygon* getNearestUnwalkablePolygon(int x, int y); - Polygon* getNearestUnwalkablePolygon(BWAPI::TilePosition tileposition); - BWAPI::Position getNearestUnwalkablePosition(BWAPI::Position position); - - bool isConnected(int x1, int y1, int x2, int y2); - bool isConnected(BWAPI::TilePosition a, BWAPI::TilePosition b); - - double getGroundDistance(BWAPI::TilePosition start, BWAPI::TilePosition end); - std::pair getNearestTilePosition(BWAPI::TilePosition start, const std::set& targets); - std::map getGroundDistances(BWAPI::TilePosition start, const std::set& targets); - void getGroundDistanceMap(BWAPI::TilePosition start, RectangleArray& distanceMap); - void getGroundWalkDistanceMap(int walkx, int walky, RectangleArray& distanceMap); - std::vector getShortestPath(BWAPI::TilePosition start, BWAPI::TilePosition end); - std::vector getShortestPath(BWAPI::TilePosition start, const std::set& targets); - - // HPA* implementation - void buildChokeNodes(); - std::list getShortestPath2(BWAPI::TilePosition start, BWAPI::TilePosition target); - int getGroundDistance2(BWAPI::TilePosition start, BWAPI::TilePosition end); - -} \ No newline at end of file diff --git a/bwta2-includes/BWTA/BaseLocation.h b/bwta2-includes/BWTA/BaseLocation.h deleted file mode 100644 index fa33e45..0000000 --- a/bwta2-includes/BWTA/BaseLocation.h +++ /dev/null @@ -1,29 +0,0 @@ - #pragma once -#include -namespace BWTA -{ - class Region; - class BaseLocation - { - public: - virtual ~BaseLocation(){}; - virtual BWAPI::Position getPosition() const = 0; - virtual BWAPI::TilePosition getTilePosition() const = 0; - - virtual Region* getRegion() const = 0; - - virtual int minerals() const = 0; - virtual int gas() const = 0; - - virtual const BWAPI::Unitset &getMinerals() = 0; - virtual const BWAPI::Unitset &getStaticMinerals() const = 0; - virtual const BWAPI::Unitset &getGeysers() const = 0; - - virtual double getGroundDistance(BaseLocation* other) const = 0; - virtual double getAirDistance(BaseLocation* other) const = 0; - - virtual bool isIsland() const = 0; - virtual bool isMineralOnly() const = 0; - virtual bool isStartLocation() const = 0; - }; -} \ No newline at end of file diff --git a/bwta2-includes/BWTA/Chokepoint.h b/bwta2-includes/BWTA/Chokepoint.h deleted file mode 100644 index 34e42f1..0000000 --- a/bwta2-includes/BWTA/Chokepoint.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include -#include -namespace BWTA -{ - class Region; - class Chokepoint - { - public: - virtual ~Chokepoint(){}; - virtual const std::pair& getRegions() const = 0; - virtual const std::pair& getSides() const = 0; - virtual BWAPI::Position getCenter() const = 0; - virtual double getWidth() const = 0; - }; -} \ No newline at end of file diff --git a/bwta2-includes/BWTA/Polygon.h b/bwta2-includes/BWTA/Polygon.h deleted file mode 100644 index d65ca16..0000000 --- a/bwta2-includes/BWTA/Polygon.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include -#include -namespace BWTA -{ - class Polygon : public std::vector - { - public: - Polygon(); - Polygon(const Polygon& b); - double getArea() const; - double getPerimeter() const; - BWAPI::Position getCenter() const; - bool isInside(BWAPI::Position p) const; - BWAPI::Position getNearestPoint(BWAPI::Position p) const; - const std::vector& getHoles() const; - std::vector holes; - }; -} \ No newline at end of file diff --git a/bwta2-includes/BWTA/RectangleArray.h b/bwta2-includes/BWTA/RectangleArray.h deleted file mode 100644 index 01cfcc6..0000000 --- a/bwta2-includes/BWTA/RectangleArray.h +++ /dev/null @@ -1,283 +0,0 @@ -#pragma once - -namespace BWTA -{ - /** - * Template used for work with dynamically initialized array with dimension 2. - */ - template - class RectangleArray - { - public : - /** - * Creates the array with the specified proportions. - * @param width Width of the new array. - * @param height Height of the new array. - */ - RectangleArray(unsigned int width = 1, unsigned int height = 1, Type* data = NULL); - /** Copy constructor */ - RectangleArray(const RectangleArray& rectangleArray); - /** Assignment operator */ - const RectangleArray& operator=(const RectangleArray& rectangleArray); - /** Destroys the array and deletes all content of array. */ - ~RectangleArray(void); - /** - * Gets the width of the array. - * @return width of the array. - */ - unsigned int getWidth(void) const; - /** - * Gets the height of the array. - * @return height of the array. - */ - unsigned int getHeight(void) const; - /** - * Gets item of the array on the specified position. - * @param x horizontal index of the array position. - * @param y vertical index of the array position. - * @return item on the specified position. - */ - Type getItem(unsigned int x, unsigned int y); - Type getItemSafe(unsigned int x, unsigned int y); - inline Type* operator[](int i) { return this->getColumn(i); } - inline Type const * const operator[](int i) const {return this->getColumn(i); } - /** - * Sets item of the array on the specified position. - * @param x horizontal index of the array position. - * @param y vertical index of the array position. - * @param item new value of the field. - */ - void setItem(unsigned int x, unsigned int y, Type *item); - void resize(unsigned int width, unsigned int height); - void saveToFile(const std::string& fileName); - /** Sets all fields of the array to the specified value */ - void setTo(const Type& value); - void setBorderTo(const Type& value); - /** Set a rectangle area of the array to the specified values */ - void setRectangleTo(unsigned int xLeft, unsigned int yTop, unsigned int xRight, unsigned int yBottom, const Type& value); - private : - bool owner; - /** width of array */ - unsigned int width; - /** height of array */ - unsigned int height; - /** Array data, stored as linear array of size width*height */ - Type *data; - /** Pointers to begins of lines*/ - Type **columns; - /** - * Gets data item on the specified index - * @param index index of the data to be returned. - */ - Type getData(unsigned int index); - /** - * Gets the pointer in data to the beginning of line with the specified - * index. - * @param index index of the line. - */ - Type *getColumn(unsigned int index); - /** - * Gets the pointer in data to the beginning of line with the specified - * index. - * @param index index of the line. - */ - const Type *getColumn(unsigned int index) const; - /** - * Sets the width of the array. - * @param width New width of the array. - */ - void setWidth(unsigned int width); - /** - * Sets the height of the array. - * @param height New height of the array. - */ - void setHeight(unsigned int height); - }; - //---------------------------------------------- CONSTRUCTOR ----------------------------------------------- - template - RectangleArray::RectangleArray(unsigned int width, unsigned int height, Type* data) - { - this->setWidth(width); - this->setHeight(height); - this->owner = (data == NULL); - if (this->owner) - this->data = new Type[this->getWidth()*this->getHeight()]; - else - this->data = data; - - columns = new Type*[this->getWidth()]; - unsigned int i = 0; - for (unsigned int position = 0;i < width; i ++,position += height) - columns[i] = &this->data[position]; - } - //-------------------------------------------- COPY CONSTRUCTOR -------------------------------------------- - template - RectangleArray::RectangleArray(const RectangleArray& rectangleArray) - :owner(true) - { - this->setWidth(rectangleArray.getWidth()); - this->setHeight(rectangleArray.getHeight()); - this->data = new Type[this->getWidth()*this->getHeight()]; - columns = new Type*[this->getWidth()]; - - unsigned int i = 0; - for (unsigned int position = 0;i < width; i ++,position += height) - columns[i] = &data[position]; - memcpy(this->data, rectangleArray.data, sizeof(Type)*this->getWidth()*this->getHeight()); - } - //------------------------------------------ ASSIGNMENT OPERATOR ------------------------------------------- - template - const RectangleArray& RectangleArray::operator=(const RectangleArray& rectangleArray) - { - this->setWidth(rectangleArray.getWidth()); - this->setHeight(rectangleArray.getHeight()); - this->owner = true; - this->data = new Type[this->getWidth()*this->getHeight()]; - columns = new Type*[this->getWidth()]; - - unsigned int i = 0; - for (unsigned int position = 0; i < width; i++, position += height) - columns[i] = &data[position]; - memcpy(this->data, rectangleArray.data, sizeof(Type)*this->getWidth()*this->getHeight()); - return *this; - } - //----------------------------------------------- DESTRUCTOR ----------------------------------------------- - template - RectangleArray::~RectangleArray(void) - { - delete [] columns; - if (this->owner) - delete [] data; - } - //----------------------------------------------- GET WIDTH ------------------------------------------------ - template - unsigned int RectangleArray::getWidth(void) const - { - return this->width; - } - //----------------------------------------------- SET WIDTH ------------------------------------------------ - template - void RectangleArray::setWidth(unsigned int width) - { - this->width = width; - } - //----------------------------------------------- GET HEIGHT ----------------------------------------------- - template - unsigned int RectangleArray::getHeight(void) const - { - return this->height; - } - //----------------------------------------------- SET HEIGHT ----------------------------------------------- - template - void RectangleArray::setHeight(unsigned int height) - { - this->height = height; - } - //------------------------------------------------ GET ITEM ------------------------------------------------ - template - Type RectangleArray::getItem(unsigned int x, unsigned int y) - { - return this->getColumn(x)[y]; - } - //------------------------------------------------ GET ITEM ------------------------------------------------ - template - Type RectangleArray::getItemSafe(unsigned int x, unsigned int y) - { - if (x<0 || y<0 || x>=this->width || y>=this->height) - { - return (Type)NULL; - } - return this->getColumn(x)[y]; - } - //------------------------------------------------ SET ITEM ------------------------------------------------ - template - void RectangleArray::setItem(unsigned int x, unsigned int y, Type* item) - { - this->getColumn(x)[y] = item; - } - //------------------------------------------------ GET LINE ------------------------------------------------ - template - Type* RectangleArray::getColumn(unsigned int index) - { - return columns[index]; - } - //------------------------------------------------ GET LINE ------------------------------------------------ - template - const Type* RectangleArray::getColumn(unsigned int index) const - { - return columns[index]; - } - //------------------------------------------------- RESIZE ------------------------------------------------- - template - void RectangleArray::resize(unsigned int width, unsigned int height) - { - if (this->getWidth() == width && - this->getHeight() == height) - return; - - delete [] this->columns; - delete [] this->data; - - this->setWidth(width); - this->setHeight(height); - - this->data = new Type[this->width * this->height]; - - this->columns = new Type*[this->width]; - unsigned int i = 0; - for (unsigned int position = 0;i < this->width; i ++,position += this->height) - columns[i] = &data[position]; - } - //---------------------------------------------- SAVE TO FILE ---------------------------------------------- - template - void RectangleArray::saveToFile(const std::string& fileName) - { - std::ofstream outputFile(fileName); - if (!outputFile) - exit(1); - - for (unsigned int y = 0; y < this->getHeight(); ++y) { - for (unsigned int x = 0; x < this->getWidth(); ++x) { - outputFile << this->getColumn(x)[y]; - } - outputFile << std::endl; - } - outputFile.close(); - } - //------------------------------------------------- SET TO ------------------------------------------------- - template - void RectangleArray::setTo(const Type& value) - { - for (unsigned int i = 0; i < this->getWidth()*this->getHeight(); i++) - this->data[i] = value; - } - //--------------------------------------------- SET BORDER TO ---------------------------------------------- - template - void RectangleArray::setBorderTo(const Type& value) - { - for (unsigned int i = 0; i < this->width; i++) - { - this->getColumn(i)[0] = value; - this->getColumn(i)[this->height - 1] = value; - } - for (unsigned int i = 0; i < this->height; i++) - { - this->getColumn(0)[i] = value; - this->getColumn(this->width - 1)[i] = value; - } - } - //------------------------------------------- SET RECTANGLE TO --------------------------------------------- - template - void RectangleArray::setRectangleTo(unsigned int xLeft, unsigned int yTop, unsigned int xRight, unsigned int yBottom, const Type& value) { - xLeft = std::max(xLeft,0); - yTop = std::max(yTop,0); - xRight = std::min(xRight,this->width-1); - yBottom = std::min(yBottom,this->height-1); - for (unsigned int x = xLeft; x <= xRight; x++) { - for (unsigned int y = yTop; y <= yBottom; y++) { - this->getColumn(x)[y] = value; - } - } - } - //---------------------------------------------------------------------------------------------------------- -} \ No newline at end of file diff --git a/bwta2-includes/BWTA/Region.h b/bwta2-includes/BWTA/Region.h deleted file mode 100644 index 3d4a6dc..0000000 --- a/bwta2-includes/BWTA/Region.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include -#include -#include -namespace BWTA -{ - class Chokepoint; - class BaseLocation; - class Region - { - public: - virtual ~Region() {}; - virtual const Polygon& getPolygon() const = 0; - virtual const BWAPI::Position& getCenter() const = 0; - virtual const std::set& getChokepoints() const = 0; - virtual const std::set& getBaseLocations() const = 0; - virtual bool isReachable(Region* region) const = 0; - virtual const std::set& getReachableRegions() const = 0; - virtual const int getMaxDistance() const = 0; - }; -} \ No newline at end of file diff --git a/generator/src/main/java/bwmirror/generator/CJavaPipeline.java b/generator/src/main/java/bwmirror/generator/CJavaPipeline.java index fc0f1ca..c7a7d34 100644 --- a/generator/src/main/java/bwmirror/generator/CJavaPipeline.java +++ b/generator/src/main/java/bwmirror/generator/CJavaPipeline.java @@ -319,17 +319,29 @@ public class CJavaPipeline { System.out.println("Absolute base path: " + basePath.getAbsolutePath()); System.out.println(); + if (System.getenv("BWAPI_HOME") == null || !(new File(System.getenv("BWAPI_HOME")).exists())) { + System.out.println("Missing or unable to read environment variable BWAPI_HOME."); + System.exit(1); + return; + } + + if (System.getenv("BWTA_HOME") == null || !(new File(System.getenv("BWTA_HOME")).exists())) { + System.out.println("Missing or unable to read environment variable BWTA_HOME."); + System.exit(1); + return; + } + try { ignoredClasses.add("Position"); PackageProcessOptions bwapiOptions = new PackageProcessOptions(); bwapiOptions.packageName = "bwapi"; - bwapiOptions.cHeadersDir = new File(basePath.getPath() + "/bwapi-includes"); - bwapiOptions.manualCopyClassesDir = new File(basePath.getPath() + "/manual-bwapi"); + bwapiOptions.cHeadersDir = new File(System.getenv("BWAPI_HOME") + "/include"); + bwapiOptions.manualCopyClassesDir = new File(basePath.getPath() + "/manual-bwapi-src"); PackageProcessOptions bwtaOptions = new PackageProcessOptions(); bwtaOptions.packageName = "bwta"; - bwtaOptions.cHeadersDir = new File(basePath.getPath() + "/bwta2-includes"); + bwtaOptions.cHeadersDir = new File(System.getenv("BWTA_HOME") + "/include"); bwtaOptions.additionalImportClasses = Arrays.asList("bwapi.Position", "bwapi.TilePosition", "bwapi.Player", "bwapi.Unit", "bwapi.Pair"); bwtaOptions.globalClassName = "BWTA"; diff --git a/manual-bwapi/AIModule.java b/manual-bwapi-src/AIModule.java similarity index 100% rename from manual-bwapi/AIModule.java rename to manual-bwapi-src/AIModule.java diff --git a/manual-bwapi/AbstractPoint.java b/manual-bwapi-src/AbstractPoint.java similarity index 100% rename from manual-bwapi/AbstractPoint.java rename to manual-bwapi-src/AbstractPoint.java diff --git a/manual-bwapi/BWEventListener.java b/manual-bwapi-src/BWEventListener.java similarity index 100% rename from manual-bwapi/BWEventListener.java rename to manual-bwapi-src/BWEventListener.java diff --git a/manual-bwapi/BestUnitFilter.java b/manual-bwapi-src/BestUnitFilter.java similarity index 100% rename from manual-bwapi/BestUnitFilter.java rename to manual-bwapi-src/BestUnitFilter.java diff --git a/manual-bwapi/CenteredObject.java b/manual-bwapi-src/CenteredObject.java similarity index 100% rename from manual-bwapi/CenteredObject.java rename to manual-bwapi-src/CenteredObject.java diff --git a/manual-bwapi/Color.java b/manual-bwapi-src/Color.java similarity index 100% rename from manual-bwapi/Color.java rename to manual-bwapi-src/Color.java diff --git a/manual-bwapi/DefaultBWListener.java b/manual-bwapi-src/DefaultBWListener.java similarity index 100% rename from manual-bwapi/DefaultBWListener.java rename to manual-bwapi-src/DefaultBWListener.java diff --git a/manual-bwapi/Mirror.java b/manual-bwapi-src/Mirror.java similarity index 100% rename from manual-bwapi/Mirror.java rename to manual-bwapi-src/Mirror.java diff --git a/manual-bwapi/Pair.java b/manual-bwapi-src/Pair.java similarity index 100% rename from manual-bwapi/Pair.java rename to manual-bwapi-src/Pair.java diff --git a/manual-bwapi/Position.java b/manual-bwapi-src/Position.java similarity index 100% rename from manual-bwapi/Position.java rename to manual-bwapi-src/Position.java diff --git a/manual-bwapi/PositionOrUnit.java b/manual-bwapi-src/PositionOrUnit.java similarity index 100% rename from manual-bwapi/PositionOrUnit.java rename to manual-bwapi-src/PositionOrUnit.java diff --git a/manual-bwapi/PositionedObject.java b/manual-bwapi-src/PositionedObject.java similarity index 100% rename from manual-bwapi/PositionedObject.java rename to manual-bwapi-src/PositionedObject.java diff --git a/manual-bwapi/ResourceList.java b/manual-bwapi-src/ResourceList.java similarity index 100% rename from manual-bwapi/ResourceList.java rename to manual-bwapi-src/ResourceList.java diff --git a/manual-bwapi/TilePosition.java b/manual-bwapi-src/TilePosition.java similarity index 100% rename from manual-bwapi/TilePosition.java rename to manual-bwapi-src/TilePosition.java diff --git a/manual-bwapi/UnitCommand.java b/manual-bwapi-src/UnitCommand.java similarity index 100% rename from manual-bwapi/UnitCommand.java rename to manual-bwapi-src/UnitCommand.java diff --git a/manual-bwapi/UnitFilter.java b/manual-bwapi-src/UnitFilter.java similarity index 100% rename from manual-bwapi/UnitFilter.java rename to manual-bwapi-src/UnitFilter.java diff --git a/manual-bwapi/Utils.java b/manual-bwapi-src/Utils.java similarity index 100% rename from manual-bwapi/Utils.java rename to manual-bwapi-src/Utils.java diff --git a/manual-bwapi/WalkPosition.java b/manual-bwapi-src/WalkPosition.java similarity index 100% rename from manual-bwapi/WalkPosition.java rename to manual-bwapi-src/WalkPosition.java