TechType¶
-
class
BWAPI.
TechType
¶ The
TechType
(or Technology Type, also referred to as an Ability) represents aUnit
‘s ability which can be researched withUnit.research()
or used withUnit.useTech()
.In order for a Unit to use its own specialized ability, it must first be available and researched.
See also
Constructors
-
TechType
([id = TechTypes.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 thanUnknown
.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 andfalse
otherwise.Return type: boolean
-
getName
() → string¶ Returns: The variable name of the type. Return type: string
-
energyCost
() → int¶ Retrieves the amount of energy needed to use this
TechType
as an ability.Returns: Energy cost of the ability. Return type: int See also
-
gasPrice
() → int¶ Retrieves the vespene gas cost of researching this technology.
Returns: Amount of vespene gas needed in order to research this technology. Return type: int
-
getOrder
() → Order¶ Retrieves the
Order
that aUnit
uses when using this ability.Returns: Order
representing the action a Unit uses to perform this abilityReturn type: BWAPI.Order
-
getRace
() → Race¶ Retrieves the race that is required to research or use the
TechType
.Returns: Race
object indicating which race is designed to use this technology type.Return type: BWAPI.Race
Note
There is an exception where
Infested Kerrigan
can usePsionic Storm
. This does not apply to the behavior of this function.
-
getWeapon
() → WeaponType¶ 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. ReturnsWeaponTypes.None
if there is no correspondingWeaponType
.Return type: BWAPI.WeaponType
-
mineralPrice
() → int¶ Retrieves the mineral cost of researching this technology.
Returns: Amount of minerals needed in order to research this technology. Return type: int
-
requiredUnit
() → UnitType¶ 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. ReturnsUnitTypes.None
if no unit is required to research this tech type.Return type: BWAPI.UnitType
See also
-
researchTime
() → int¶ Retrieves the number of frames needed to research the tech type.
Returns: The time, in frames, it will take for the research to complete. Return type: int See also
-
targetsPosition
() → boolean¶ Checks if this ability can be used on the terrain (ground).
Returns: true if the ability can be used on the terrain. Return type: boolean
-
targetsUnit
() → boolean¶ 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. Return type: boolean
-
whatResearches
() → UnitType¶ Retrieves the
UnitType
that can research this technology.Returns: UnitType
that is able to research the technology in the game. ReturnsUnitTypes.None
if the technology/ability is either provided for free or never available.Return type: BWAPI.UnitType
-
whatUses
() → UnitTypeset¶ Retrieves the set of all
UnitTypes
that are capable of using this ability.Returns: Set of UnitTypes
that can use this ability when researched.Return type: BWAPI.UnitTypeset
-
TechTypeset¶
-
class
BWAPI.
TechTypeset
¶ A container for a set of
TechType
objects.Constructors
-
TechTypeset
()¶ Default constructor.
-
TechTypeset
(set) Copy constructor.
Parameters: set (BWAPI.TechTypeset) – The TechTypeset to copy.
-
TechTypeset
(tbl) Constructor to convert a Lua table to a set. Any values in the table that are of type
TechType
are added to the set.Parameters: tbl (table) – A table containing TechType
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 either1
or0
. Because of this, it’s recommended to usecontains()
instead.See also
-
contains
(val) → boolean¶ Checks if this set contains a specific value.
Returns: true
if the set contains the specified value, orfalse
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
), orfalse
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
or0
.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 andfalse
otherwise.
-
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 andfalse
for elements that should be erased.
-