Skip to content

Effects

The Effects module manages technology effects - the actual game modifications that happen when a technology is researched.

Quick Example

python
from aoe2_genie_tooling import GenieWorkspace

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

# Get the effect manager
effect_manager = workspace.effect_manager

# Get an existing effect
effect = effect_manager.get(100)

# Create a new effect
new_effect = effect_manager.add_new("Archer Upgrade")
new_effect.add_command.attribute_modifier_add(a=4, b=0, c=-1, d=10)

Sub-Pages

PageDescription
MethodsAll EffectManager and EffectHandle methods
Effect CommandsComplete command type reference

Overview

EffectManager (workspace.effect_manager)

The manager handles effect CRUD operations:

MethodDescription
get(effect_id)Get an EffectHandle
add_new(name)Create a new effect
copy(source_id)Copy an effect
delete(effect_id)Delete an effect
exists(effect_id)Check if effect exists
find_by_name(name)Find by name
count()Total effect slots

EffectHandle

The handle provides access to a single effect:

Properties:

  • id - Effect ID
  • name - Effect name
  • commands - List of commands

Methods:

  • add_command - Fluent command builder
  • new_command(type, a, b, c, d) - Raw command creation
  • get_command(index) - Get command by index

Effect Structure

Effects follow a two-tier structure:

  1. Effect Holder - A named container
  2. Effect Commands - The actual modifications inside
Effect (ID: 100, Name: "Fletching")
├── Command 1: +1 range for archers
├── Command 2: +1 attack for archers
└── Command 3: +1 LoS for archers

Creating Effects

python
effect_manager = workspace.effect_manager

# Create a new effect
effect = effect_manager.add_new("My Upgrade Effect")

# Add commands using the builder
effect.add_command.attribute_modifier_add(a=4, b=0, c=-1, d=10)  # +10 HP
effect.add_command.attribute_modifier_add(a=4, b=9, c=-1, d=2)   # +2 attack

# Or using raw parameters
effect.new_command(type=4, a=4, b=12, c=-1, d=1)  # +1 range

Linking Effects to Techs

Effects don't do anything until linked to a technology:

python
# Create the effect
effect = effect_manager.add_new("Elite Upgrade")
effect.add_command.attribute_modifier_add(a=4, b=0, c=-1, d=20)

# Create the tech and link
tech_manager = workspace.tech_manager
tech = tech_manager.create("Elite Research")
tech.effect_id = effect.id
tech.research_time = 45

See Techs for technology configuration.


Command Types Summary

TypeMethodDescription
0attribute_modifier_setSet attribute to value
1resource_modifierAdd to resource
2enable_disable_unitEnable/disable unit
3upgrade_unitUpgrade unit A → B
4attribute_modifier_addAdd to attribute
5attribute_modifier_multiplyMultiply attribute
6resource_modifier_multiplyMultiply resource
7spawn_unitSpawn units
10-18team_*Team versions
20-28enemy_*Enemy versions

See Effect Commands for complete details.


Managing Commands

python
# List all commands
for cmd in effect.commands:
    print(f"Type {cmd.type}: a={cmd.a}, d={cmd.d}")

# Get specific command
cmd = effect.get_command(0)
cmd.d = 20  # Modify value

# Remove command
effect.remove_command(0)

# Clear all
effect.clear_commands()

Released under the MIT License.