Skip to content

Datasets ​

The Datasets module provides typed enumerations and constants for common game values.

Using these enums instead of raw integers makes code more readable and reduces errors.

Quick Example ​

python
from aoe2_genie_tooling import GenieWorkspace
from aoe2_genie_tooling.Datasets import Attribute, Resource, Task, UnitClass

workspace = GenieWorkspace.load("empires2_x2_p1.dat")

# Use enums instead of magic numbers
unit = workspace.unit_manager.get(4)

# Instead of: effect.add_command.attribute_modifier_add(a=4, b=0, c=-1, d=10)
effect.add_command.attribute_modifier_add(
    a=4,
    b=Attribute.HIT_POINTS,  # Much clearer than "0"
    c=-1,
    d=10
)

Attribute ​

Unit attribute IDs used in effect commands.

python
from aoe2_genie_tooling.Datasets import Attribute
EnumValueDescription
HIT_POINTS0Maximum HP
LINE_OF_SIGHT1Vision range
GARRISON_CAPACITY2Garrison slots
UNIT_SIZE_X3Collision X
UNIT_SIZE_Y4Collision Y
MOVEMENT_SPEED5Speed
ROTATION_SPEED6Turn speed
ARMOR8Base armor
ATTACK9Base attack
ATTACK_RELOAD_TIME10Attack speed
ACCURACY_PERCENT11Hit chance
MAX_RANGE12Attack range
WORK_RATE13Gather/build rate
RESOURCE_CAPACITY14Carry capacity
PROJECTILE_UNIT16Projectile unit ID
ICON_ID17Icon index
TRAIN_TIME19Creation time
TRAIN_LOCATION20Where trained
BLAST_WIDTH21Area damage width
BONUS_DAMAGE_RESISTANCE24Cavalry armor
......See full list in source

Usage ​

python
# In effect commands
effect.add_command.attribute_modifier_add(
    a=4,                         # Archer unit ID
    b=Attribute.MAX_RANGE,       # Range attribute
    c=-1,
    d=2                          # +2 range
)

effect.add_command.attribute_modifier_multiply(
    a=-1,                        # All units
    b=Attribute.MOVEMENT_SPEED,  # Speed
    c=-1,
    d=1.1                        # +10% speed
)

Resource ​

Resource type IDs.

python
from aoe2_genie_tooling.Datasets import Resource
EnumValueDescription
FOOD0Food
WOOD1Wood
STONE2Stone
GOLD3Gold
POPULATION_HEADROOM4Available pop space
CONVERSION_RANGE5Monk range
CURRENT_AGE6Current age
RELICS_CAPTURED7Relics held
TRADE_BONUS8Trade profit
CURRENT_POPULATION11Current pop
CORPSE_DECAY_TIME12Decay timer
BONUS_POPULATION_CAP32Pop cap bonus
......See full list

Usage ​

python
# Set starting resources
civ.resource[Resource.FOOD] = 500
civ.resource[Resource.GOLD] = 200

# In effect commands
effect.add_command.resource_modifier(
    a=Resource.GOLD,
    d=500  # +500 gold
)

Task ​

Unit task/action type IDs for TaskBuilder.

python
from aoe2_genie_tooling.Datasets import Task
EnumValueDescription
NONE0No action
MOVE_TO1Move to location
FOLLOW2Follow unit
GARRISON3Garrison
EXPLORE4Auto-explore
GATHER5Gather resource
GRAZE6Graze (animals)
COMBAT7Attack
SHOOT8Ranged attack
ATTACK9Melee attack
FLY10Fly
SCARE_HUNT11Scare prey
UNLOAD12Unload transport
GUARD13Guard unit
BUILD101Construct building
MAKE_UNIT102Train unit
MAKE_TECH103Research tech
CONVERT104Convert enemy
HEAL105Heal friendly
REPAIR106Repair building
TRADE111Trade with market
RESOURCE_GENERATION151Passive income
AURA155Area buff
......See TaskBuilder for all types

Usage ​

python
# When using raw create_task
unit.create_task(action_type=Task.COMBAT, class_id=0)

# TaskBuilder uses these internally
unit.add_task.combat(class_id=0)  # Same as Task.COMBAT

UnitClass ​

Unit class IDs for targeting.

python
from aoe2_genie_tooling.Datasets import UnitClass
EnumValueDescription
ARCHER0Archers
INFANTRY1Infantry
CAVALRY2Cavalry
SIEGE3Siege weapons
BUILDING11Buildings
VILLAGER4Villagers
MONK18Monks
SHIP22Ships
WALL27Walls
GATE28Gates
TOWER52Towers
......See full list

Usage ​

python
# Tasks targeting a class
unit.add_task.combat(class_id=UnitClass.INFANTRY)

# Effect commands targeting a class
effect.add_command.attribute_modifier_add(
    a=-1,                    # All units in class
    b=Attribute.HIT_POINTS,
    c=UnitClass.CAVALRY,     # Target cavalry
    d=20                     # +20 HP
)

Effect (Command Types) ​

Effect command type IDs.

python
from aoe2_genie_tooling.Datasets import Effect
EnumValueDescription
ATTRIBUTE_MODIFIER_SET0Set attribute
RESOURCE_MODIFIER1Modify resource
ENABLE_DISABLE_UNIT2Enable/disable
UPGRADE_UNIT3Upgrade unit
ATTRIBUTE_MODIFIER_ADD4Add to attribute
ATTRIBUTE_MODIFIER_MULTIPLY5Multiply attribute
RESOURCE_MODIFIER_MULTIPLY6Multiply resource
SPAWN_UNIT7Spawn units
MODIFY_TECH8Modify tech
TEAM_ATTRIBUTE_MODIFIER_SET10Team set attr
TEAM_RESOURCE_MODIFIER11Team resource
TEAM_ENABLE_DISABLE_UNIT12Team enable
TEAM_UPGRADE_UNIT13Team upgrade
......See EffectCommandBuilder

Usage ​

python
# When using raw new_command
effect.new_command(type=Effect.ATTRIBUTE_MODIFIER_ADD, a=4, b=0, d=10)

# EffectCommandBuilder is clearer
effect.add_command.attribute_modifier_add(a=4, b=0, d=10)

Importing Multiple Datasets ​

python
from aoe2_genie_tooling.Datasets import (
    Attribute,
    Resource,
    Task,
    UnitClass,
    Effect,
)

# Now use them throughout your code
unit.hit_points = 100
effect.add_command.attribute_modifier_add(
    a=4,
    b=Attribute.MAX_RANGE,
    c=UnitClass.ARCHER,
    d=2
)

Benefits of Using Datasets ​

  1. Readability: Attribute.HIT_POINTS is clearer than 0
  2. Autocomplete: IDEs can suggest values
  3. Error Prevention: Typos become syntax errors instead of silent bugs
  4. Documentation: Enums serve as inline documentation

Released under the MIT License.