Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Unit
====
.. class:: library.Unit
An instance of the class Unit represents one unit in the game. The units are
not limited to moveable units, but every entity which is not part of the
background is a unit. For example, the minerals and geysers are units as
well as all buildings.
For all possible types of units see the enum :class:`library.UNIT_TYPEID`.
Some types of objects are almost the same, for example there are many types
of mineral deposits, but all of them are mineable. This is one of the
motivations behind the :class:`library.UnitType` which aims to to make the
list of types more manageable. The UnitType can be accessed by the
:any:`Unit.unit_type` property.
It is possible to use Unit as keys in a dictionary, which might be helpful
for bookkeeping.
Properties:
.. autoattribute:: build_percentage
.. autoattribute:: energy
.. autoattribute:: hit_points
.. autoattribute:: id
.. autoattribute:: is_alive
.. autoattribute:: is_being_constructed
.. autoattribute:: is_burrowed
.. autoattribute:: is_cloaked
.. autoattribute:: is_completed
.. autoattribute:: is_constructing
.. autoattribute:: is_flying
.. autoattribute:: is_idle
.. autoattribute:: is_powered
.. autoattribute:: is_training
.. autoattribute:: is_valid
.. attribute:: Unit.player
.. TODO: Add page about PLAYER_* constants
Returns the constant corresponding to player which this unit belongs to.
See the page :doc:`playerconstants` for more information on player
constants.
.. autoattribute:: position
.. autoattribute:: shields
.. autoattribute:: tile_position
.. autoattribute:: unit_type
.. autoattribute:: weapon_cooldown
Methods:
.. automethod:: stop
.. automethod:: attack_unit
.. automethod:: attack_move
.. method:: Unit.move(self, point)
Move the unit to the given point, the point being an instance of either
:class:`library.Point2D` or :class:`library.Point2DI`.
.. automethod:: right_click
.. automethod:: repair
.. automethod:: build
.. TODO: Maybe should I put the limits of build here, and when to use build_target
.. automethod:: build_target
.. automethod:: train
.. automethod:: morph