WeaponType

class BWAPI.WeaponType

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 also

WeaponTypes

Constructors

WeaponType([id = WeaponTypes.Enum.None])

Expected type constructor.

If the type is an invalid type, then it becomes Unknown. A type is invalid if its value is less than 0 or greater than Unknown.

Parameters:id (int) – 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 Unknown.

Member Functions

getID() → int

Retrieves this type’s identifier as an integer.

Returns:An integer representation of this type.
Return type:int
isValid() → boolean

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.
Return type:boolean
getName() → string
Returns:The variable name of the type.
Return type:string
damageAmount() → int

Retrieves the base amount of damage that this weapon can deal per attack.

Returns:Amount of base damage that this weapon deals.
Return type:int

Note

That this damage amount must go through a DamageType and UnitSizeType filter before it is applied to a unit.

damageBonus() → int

Determines the bonus amount of damage that this weapon type increases by for every upgrade to this type.

Returns:Amount of damage added for every weapon upgrade.
Return type:int

See also

upgradeType()

damageCooldown() → int

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.
Return type:int
damageFactor() → int

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.
Return type:int

See also

damageAmount()

damageType() → DamageType

Retrieves the damage type that this weapon applies to a unit type.

Returns:DamageType used for damage calculation.
Return type:BWAPI.DamageType
explosionType() → ExplosionType

Retrieves the explosion type that indicates how the weapon deals damage.

Returns:ExplosionType identifying how damage is applied to a target location.
Return type:BWAPI.ExplosionType
getTech() → TechType

Retrieves the technology type that must be researched before this weapon can be used.

Returns:TechType required by this weapon. Returns TechTypes.None if no tech type is required to use this weapon.
Return type:BWAPI.TechType
innerSplashRadius() → int

Retrieves the inner radius used for splash damage calculations, in pixels.

Returns:Radius of the inner splash area, in pixels.
Return type:int
maxRange() → int

Retrieves the maximum attack range of the weapon, measured in pixels.

Returns:Maximum attack range, in pixels.
Return type:int
medianSplashRadius() → int

Retrieves the middle radius used for splash damage calculations, in pixels.

Returns:Radius of the middle splash area, in pixels.
Return type:int
minRange() → int

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.
Return type:int
outerSplashRadius() → int

Retrieves the outer radius used for splash damage calculations, in pixels.

Returns:Radius of the outer splash area, in pixels.
Return type:int
targetsAir() → boolean

Checks if this weapon type can target air units.

Returns:true if this weapon type can target air units, and false otherwise.
Return type:boolean
targetsGround() → boolean

Checks if this weapon type can target ground units.

Returns:true if this weapon type can target ground units, and false otherwise.
Return type:boolean
targetsMechanical() → boolean

Checks if this weapon type can only target mechanical units.

Returns:true if this weapon type can only target mechanical units, and false otherwise.
Return type:boolean
targetsNonBuilding() → boolean

Checks if this weapon type cannot target structures.

Returns:true if this weapon type cannot target buildings, and false if it can.
Return type:boolean
targetsNonRobotic() → boolean

Checks if this weapon type cannot target robotic units.

Returns:true if this weapon type cannot target robotic units, and false if it can.
Return type:boolean
targetsOrganic() → boolean

Checks if this weapon type can only target organic units.

Returns:true if this weapon type can only target organic units, and false otherwise.
Return type:boolean
targetsOrgOrMech() → boolean

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.
Return type:boolean
targetsOwn() → boolean

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.
Return type:boolean

See also

Unit.getPlayer()

targetsTerrain() → boolean

Checks if this weapon type can target the ground.

Returns:true if this weapon type can target a location, and false otherwise.
Return type:boolean

Note

This is more for attacks like Psionic Storm <BWAPI.TechTypes.Psionic_Storm> which can target a location, not to be confused with attack move.

upgradeType() → UpgradeType

Retrieves the upgrade type that increases this weapon’s damage output.

Returns:The UpgradeType used to upgrade this weapon’s damage.
Return type:BWAPI.UpgradeType

See also

damageBonus()

whatUses() → UnitType

Retrieves the unit type that is intended to use this weapon type.

Returns:The UnitType that uses this weapon.
Return type:BWAPI.UnitType

Note

There is a rare case where some hero unit types use the same weapon.

WeaponTypeset

class BWAPI.WeaponTypeset

A container for a set of WeaponType objects.

Constructors

WeaponTypeset()

Default constructor.

WeaponTypeset(set)

Copy constructor.

Parameters:set (BWAPI.WeaponTypeset) – The WeaponTypeset to copy.
WeaponTypeset(tbl)

Constructor to convert a Lua table to a set. Any values in the table that are of type WeaponType are added to the set.

Parameters:tbl (table) – A table containing WeaponType objects.

Member Functions

iterator() → iteratorFunction

Returns an iterator function intended to be used in for loops (e.g. for item in set:iterator() do).

Returns:An iterator function that will return the next value in the set with each successive call.
Return type:function
asTable() → table

Returns the values of the set as an array-like Lua table.

Note

The ordering of the returned table is arbitrary (due to sets being unordered in the C++ implementation).

Returns:An array-like Lua table containing each value in the set.
Return type:table
count(val) → int

Searches the set for elements with a value of val and returns the number of elements found. Because sets do not allow for duplicate values, this means that the function will return either 1 or 0. Because of this, it’s recommended to use contains() instead.

contains(val) → boolean

Checks if this set contains a specific value.

Returns:true if the set contains the specified value, or false otherwise.
Return type:boolean
size() → int
Returns:The number of values in the set.
Return type:int

Note

set:size() is exactly equivalent to #set

empty() → boolean
Returns:true if the set is empty (size() == 0), or false otherwise.
Return type:boolean
insert(val)

Inserts the value into the set.

Note

Sets cannot contain duplicate values. If the value already exists in the set, the set will not be modified.

erase(val) → numElementsErased

Removes val from the set if it exists.

Returns:The number of elements removed. Because sets do not allow for duplicate values, this means that the function will return either 1 or 0.
Return type:int
clear()

Removes all elements from the set, leaving it with a size of 0.

eraseIf(pred)

Iterates the set and erases each element x where pred(x) returns true. The set is modified in place.

Parameters:pred (function) – A predicate function that takes a value and returns true for values that should be erased and false otherwise.
erase_if(pred)

Alias of eraseIf()

filter(pred)

Iterates the set and erases each element x where pred(x) returns false. The set is modified in place.

Parameters:pred (function) – A predicate function that takes a value and returns true for values that should be kept and false for elements that should be erased.
keepIf(pred)

Alias of filter()/keep_if()

keep_if(pred)

Alias of filter()/keepIf()