My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
UnitType  
Updated Apr 14, 2011 by AHein...@gmail.com

Class header file: BWAPI/UnitType.h

The UnitType class is used to get information about a particular type of unit, such as the build time of a Lurker, or the mineral price of an Ultralisk.

Table of all UnitTypes (along with some stat info obtained via BWAPI).

Methods

getID

int getID() const;

Returns a unique ID for this unit type.

getName

std::string getName() const;

Returns the name of the unit.

getRace

Race getRace() const;

Returns the race that the unit belongs to. For example UnitTypes::Terran_SCV.getRace() will return Races::Terran.

whatBuilds

const std::pair< UnitType, int > whatBuilds() const;

Returns what builds this unit type. The second number will usually be 1 unless the unit type is Protoss_Archon or Protoss_Dark_Archon. Units that cannot be created, such as critters and mineral fields, will return a pair where the unit type is UnitTypes::None, and the second component is 0.

Example: UnitTypes::Terran_Marine.whatBuilds() will return an std::pair, where the first component is UnitTypes::Terran_Barracks.

requiredUnits

const std::map< UnitType, int > requiredUnits() const;

Returns the units the player is required to have before it can train or build the given unit type. In addition to having the required units, the player must also have sufficient minerals, gas, and the requiredTech (if any).

Example: UnitTypes::Terran_Battlecruiser.requiredUnits() will return a map of three keys: UnitTypes::Terran_Starport, UnitTypes::Terran_Control_Tower, and UnitTypes::Terran_Physics_Lab.

requiredTech

TechType requiredTech() const;

Included in the API for completeness, since the only units that actually needs tech to be trained are the Zerg_Lurker and Zerg_Lurker_Egg. The tech type needed is TechTypes::Lurker_Aspect.

cloakingTech

TechType cloakingTech() const;

Returns the Tech type used for cloaking the unit, or TechTypes::None if the unit does not have the cloak ability or is permanently cloaked.

abilities

const std::set< TechType >& abilities() const;

Returns the set of tech types this unit can use, provided the tech types have been researched and the unit has enough energy.

upgrades

const std::set< UpgradeType >& upgrades() const;

Returns the set of upgrade types that can affect this unit.

armorUpgrade

UpgradeType armorUpgrade() const;

Returns the upgrade that increase's the unit's armor, or UpgradeTypes::None if no upgrade increase's this unit's armor. For example UnitTypes::Terran_Marine.armorUpgrade() will return a pointer to UpgradeTypes::Terran_Infantry_Armor.

maxHitPoints

int maxHitPoints() const;

Returns the maximum amount of hit points the unit type can have.

maxShields

int maxShields() const;

Returns the maximum amount of shields the unit type can have.

maxEnergy

int maxEnergy() const;

Returns the maximum amount of energy the unit type can have.

armor

int armor() const;

Returns the amount of armor the non-upgraded unit type has.

mineralPrice

int mineralPrice() const;

Returns the mineral price of the unit. Example: UnitTypes::Siege_Tank_Tank_Mode.mineralPrice() returns 150.

gasPrice

int gasPrice() const;

Returns the gas price of the unit. Example: UnitTypes::Siege_Tank_Tank_Mode.gasPrice() returns 100.

buildTime

int buildTime() const;

Returns the number of frames needed to make this unit type.

supplyRequired

int supplyRequired() const;

Returns the amount of supply used by this unit. Supply counts returned by BWAPI are double what you would expect to see from playing the game. This is because zerglings take up 0.5 in-game supply.

supplyProvided

int supplyProvided() const;

Returns the amount of supply produced by this unit (i.e. for a Protoss_Pylon). Supply counts returned by BWAPI are double what you would expect to see from playing the game. This is because zerglings take up 0.5 in-game supply.

spaceRequired

int spaceRequired() const;

Returns the amount of space this unit type takes up inside a bunker or transport unit.

spaceProvided

int spaceProvided() const;

Returns the amount of space this unit type provides.

buildScore

int buildScore() const;

Returns the score which is used to determine the total scores in the after-game stats screen.

destroyScore

int destroyScore() const;

Returns the score which is used to determine the total scores in the after-game stats screen.

size

UnitSizeType size() const;

Returns the size of the unit - either Small, Medium, Large, or Independent.

tileWidth

int tileWidth() const;

Returns the tile width of the unit. Useful for determining the size of buildings. For example UnitTypes::Terran_Supply_Depot.tileWidth() will return 3.

tileHeight

int tileHeight() const;

Returns the tile height of the unit. Useful for determining the size of buildings. For example UnitTypes::Terran_Supply_Depot.tileHeight() will return 2.

dimensionLeft

int dimensionLeft() const;

Distance from the center of the unit to the left edge of the unit, measured in pixels.

dimensionUp

int dimensionUp() const;

Distance from the center of the unit to the top edge of the unit, measured in pixels.

dimensionRight

int dimensionRight() const;

Distance from the center of the unit to the right edge of the unit, measured in pixels.

dimensionDown

int dimensionDown() const;

Distance from the center of the unit to the bottom edge of the unit, measured in pixels.

seekRange

int seekRange() const;

Returns the range at which the unit will start targeting enemy units, measured in pixels.

sightRange

int sightRange() const;

Returns how far the un-upgraded unit type can see into the fog of war, measured in pixels.

groundWeapon

WeaponType groundWeapon() const;

Returns the unit's ground weapon, or WeaponTypes::None if the unit cannot shoot ground units.

maxGroundHits

int maxGroundHits() const;

airWeapon

WeaponType airWeapon() const;

Returns the unit's air weapon, or WeaponTypes::None if the unit cannot shoot air units.

maxAirHits

int maxAirHits() const;

topSpeed

double topSpeed() const;

Returns the unit's non-upgraded top speed in pixels per frame. For Terran buildings that can lift off and the Zerg Infested Command Center, this returns how fast the building moves when it is lifted.

acceleration

int acceleration() const;

Returns how fast the unit can accelerate to its top speed. What units this quantity is measured in is currently unknown.

haltDistance

int haltDistance() const;

Related to how fast the unit can halt. What units this quantity is measured in is currently unknown.

turnRadius

int turnRadius() const;

Related to how fast the unit can turn. What units this quantity is measured in is currently unknown.

canBuildAddon

bool canBuildAddon() const;

Returns true if the unit type is capable of constructing any addon. This includes the Command Center, Factory, Starport, and Science Facility.

canProduce

bool canProduce() const;

Returns true if the unit can train other units. For example, UnitTypes::Terran_Barracks.canProduce() will return true, while UnitTypes::Terran_Marine.canProduce() will return false. This is also true for two non-building units: Protoss Carrier (can produce interceptors) and Protoss Reaver (can produce scarabs).

canAttack

bool canAttack() const;

Returns true if the unit can attack (either ground or air). Returns false for units that can only inflict damage via special abilities (such as Protoss High Templar).

canMove

bool canMove() const;

Returns true if the unit can move. Note that buildings will return false, even Terran buildings which can move once lifted.

isFlyer

bool isFlyer() const;

Returns true for flying/air units.

regeneratesHP

bool regeneratesHP() const;

Returns true for units that regenerate health (i.e. zerg units).

isSpellcaster

bool isSpellcaster() const;

Returns true if the unit type is capable of casting spells / using technology.

hasPermanentCloak

bool hasPermanentCloak() const;

Returns true for the two units that are permanently cloaked - Protoss Observer and Protoss Dark Templar.

isInvincible

bool isInvincible() const;

Returns true for units that cannot be destroyed (i.e. Terran Nuclear Missile, Mineral Field, Vespene Geyser, etc)

isOrganic

bool isOrganic() const;

Returns true if the unit is organic, such as a Terran Marine.

isMechanical

bool isMechanical() const;

Returns true if the unit is mechanical such as a Terran Vulture.

isRobotic

bool isRobotic() const;

Returns true for the four robotic Protoss units - Probe, Shuttle, Reaver, and Observer.

isDetector

bool isDetector() const;

Returns true if the unit is capable of detecting cloaked units.

isResourceContainer

bool isResourceContainer() const;

Returns true for the seven units that hold resources - Mineral Field (Type 1, Type 2, Type 3), Vespene Geyser, Terran Refinery, Zerg Extractor, and Protoss Assimilator.

isResourceDepot

bool isResourceDepot() const;

Returns true for the six units that can accept resources - Terran Command Center, Protoss Nexus, Zerg Hatchery, Zerg Lair, Zerg Hive, and Start Location.

isRefinery

bool isRefinery() const;

Returns true for Terran Refinery, Zerg Extractor, and Protoss Assimilator.

isMineralField

bool isMineralField() const;

Returns true for the three types of Mineral Fields. BWAPI typically interprets all resources as "Type 1", so this may be used in the future.

isWorker

bool isWorker() const;

Returns true for Protoss Probe, Terran SCV, and Zerg Drone.

requiresPsi

bool requiresPsi() const;

Returns true for buildings that must be near a pylon to be constructed.

requiresCreep

bool requiresCreep() const;

Returns true for buildings that can only be built on zerg creep.

isTwoUnitsInOneEgg

bool isTwoUnitsInOneEgg() const;

Returns true for Zergling and Scourge.

isBurrowable

bool isBurrowable() const;

Returns true for Zerg Lurker and units that can burrow when burrow tech is researched.

isCloakable

bool isCloakable() const;

Returns true for units that can be cloaked - Terran Ghost and Terran Wraith. Does not include units which have permanent cloak (Protoss Observer and Protoss Dark Templar).

isBuilding

bool isBuilding() const;

Returns true if the unit is a building (also true for mineral field and vespene geyser).

isAddon

bool isAddon() const;

Returns true if the unit is an add-on, such as a Terran Comsat Station.

isFlyingBuilding

bool isFlyingBuilding() const;

Returns true for Terran buildings that can lift off (i.e. Barracks).

isNeutral

bool isNeutral() const;

Returns true if the unit is neutral, such as a critter or mineral field.

isHero

bool isHero() const;

Returns true if the unit is a Hero unit. Hero units are special units used by the Campaign and Use Map Settings.

isPowerup

bool isPowerup() const;

Returns true if the unit is a powerup. Powerups such as a Flag are used by other game types like Capture the Flag and can be carried by a worker unit.

isBeacon

bool isBeacon() const;

Returns true if the unit is a Zerg, Terran, or Protoss Beacon. Beacons are used in the Campaign and Use Map Settings.

isFlagBeacon

bool isFlagBeacon() const;

Returns true if the unit is a Zerg, Terran, or Protoss Flag Beacon. Flag beacons will create a flag unit for Capture the Flag mode and allow you to relocate the beacon to another location so that you may hide your flag from the enemy.

isSpecialBuilding

bool isSpecialBuilding() const;

Returns true if the unit is a special building such as the Overmind.

isSpell

bool isSpell() const;

Returns true if the unit is either a Scanner Sweep, Disruption Web, or Dark Swarm.

Non-Member Methods

getUnitType

UnitType getUnitType(std::string name);

Given the name of a unit type, this function will return the unit type.

For example, UnitTypes::getUnitType("Terran Marine") will return UnitTypes::Terran_Marine.

allUnitTypes

std::set<UnitType>& allUnitTypes();

Returns the set of all the UnitTypes.

allMacroTypes

std::set<UnitType>& allMacroTypes();

Returns the set of all the macro UnitTypes.

Comment by zshock....@gmail.com, Feb 19, 2010

I'm quite certain that turnRadius() and acceleration() return the UnitType's turn radius and acceleration (duh) per frame, but multiplied by 256. Similarly, haltDistance() returns the distance a unit travels while it accelerates from zero speed to top speed, but multiplied by 256. It'd be great if you could update the table of UnitTypes to include these values as well.


Sign in to add a comment
Powered by Google Project Hosting