Skip to content

Unit Attributes

Complete reference of all attributes available on UnitHandle.

How to Read This Table

ColumnDescription
AttributeProperty name to use in code
TypeData type (int, float, str, etc.)
R/WRead-only (R) or Read/Write (RW)
SourceWhich component the attribute comes from
DescriptionWhat the attribute controls

Core Attributes

These are direct properties of the Unit object.

AttributeTypeR/WDescription
idintRUnit ID (read-only)
namestrRWInternal unit name
typeintRWUnit type (10=living, 20=animal, 30=eye candy, 40=animated, 50=combat, 60=projectile, 70=creatable, 80=building)
hit_pointsintRWMaximum HP
line_of_sightfloatRWVision range in tiles
garrison_capacityintRWNumber of units that can garrison
speedfloatRWMovement speed
class_intRWUnit class (0=archer, 1=infantry, etc.)
enabledintRWWhether unit is enabled (0=disabled, 1=enabled)
icon_idintRWIcon index in the icon SLP
train_soundintRWSound ID when unit starts training
damage_soundintRWSound ID when unit takes damage

Usage

python
unit_manager = workspace.unit_manager
unit = unit_manager.get(4)

# Read
print(f"HP: {unit.hit_points}")
print(f"Speed: {unit.speed}")

# Write
unit.hit_points = 100
unit.speed = 1.5
unit.name = "CustomArcher"

Movement/Behavior Attributes

Flattened attributes controlling search behavior, work rates, and movement.

AttributeTypeR/WDescription
default_task_idintRWDefault task index (-1 = none)
search_radiusfloatRWRange for auto-target search
work_ratefloatRWBase work/gather rate
attack_soundintRWSound ID when attacking
move_soundintRWSound ID when moving
walking_graphicintRWGraphic ID for walking animation
rotation_speedfloatRWHow fast the unit turns

Usage

python
unit.search_radius = 12.0
unit.work_rate = 0.35
unit.move_sound = 50
unit.walking_graphic = 1000
unit.rotation_speed = 0.5

Type50 Attributes (Combat)

Flattened from the type_50 (combat) component. Controls ranged combat.

AttributeTypeR/WDescription
base_armorintRWBase armor value (most armor comes from armours list)
max_rangefloatRWMaximum attack range
min_rangefloatRWMinimum attack range
reload_timefloatRWTime between attacks (seconds)
projectile_unit_idintRWUnit ID of projectile fired
attack_graphicintRWGraphic ID for attack animation
displayed_attackintRWAttack value shown in UI
displayed_rangefloatRWRange value shown in UI
displayed_melee_armorintRWMelee armor shown in UI
displayed_pierce_armorintRWPierce armor shown in UI
accuracy_percentintRWHit chance (0-100)
blast_widthfloatRWArea damage radius
blast_levelintRWBlast damage falloff

Usage

python
unit.max_range = 8.0
unit.reload_time = 1.5
unit.projectile_unit_id = 189  # Crossbow bolt
unit.accuracy_percent = 90

Projectile Attributes

For projectile units (type 60). Flattened from projectile component.

AttributeTypeR/WDescription
projectile_typeintRWProjectile behavior type
smart_modeintRWSmart targeting mode
hit_modeintRWWhat the projectile can hit
vanish_modeintRWHow projectile disappears
projectile_arcfloatRWArc height of trajectory

Usage

python
unit_manager = workspace.unit_manager
projectile = unit_manager.get(189)
projectile.projectile_arc = 0.5
projectile.smart_mode = 1

Creatable Attributes (Training)

For trainable units (type 70+). Flattened from creatable component.

AttributeTypeR/WDescription
hero_modeintRWHero flags (regeneration, etc.)
garrison_graphicintRWGraphic when garrisoned
train_timeintRWTime to train (seconds)
button_idintRWUI button position

Usage

python
unit.train_time = 20
unit.button_id = 1
unit.hero_mode = 1  # Enable hero regeneration

Building Attributes

For buildings (type 80). Flattened from building component.

AttributeTypeR/WDescription
construction_graphic_idintRWGraphic during construction
garrison_typeintRWTypes of units that can garrison
tech_idintRWTech required to build

Usage

python
unit_manager = workspace.unit_manager
building = unit_manager.get(109)  # Town Center
building.garrison_type = 14  # Infantry + villagers

Collection Attributes

These return lists/managers rather than single values. See dedicated pages for details.

AttributeTypeDescriptionSee Page
attacksAttacksManagerAttack damage by classAttacks & Armours
armoursArmoursManagerArmor by classAttacks & Armours
tasksTasksManagerUnit tasks/actionsTasks
costsCostsManagerTraining costs-
train_locationsListWhere unit is trainedTrain Locations
drop_sitesListResource drop sitesMethods page

Wrapper Access

For organized access to related attributes, use wrappers:

WrapperAccessDescription
combatunit.combatType50 combat attributes
creatableunit.creatableTraining attributes
buildingunit.buildingBuilding-specific
projectileunit.projectileProjectile behavior
python
# These are equivalent:
unit.max_range = 8.0
unit.combat.max_range = 8.0

Wrappers are useful for grouping related operations:

python
# Configure all combat settings together
unit.combat.max_range = 8.0
unit.combat.reload_time = 1.5
unit.combat.accuracy_percent = 85
unit.combat.attack_graphic = some_graphic.id

Released under the MIT License.