MonsterAIAutomata.xml

Defines the state transition rules that drive monster behavior. Each Automata is a state machine: "when in state X and condition Y, go to state Z". Each automata number holds up to 30 rules per state, evaluated in Priority order.

File Location#

Data/Monster/MonsterAIAutomata.xml

Loaded once at GameServer startup. Changes require a restart.

AI Hierarchy#

The monster AI system layers four files:

MonsterAIGroup.xml   -> which monsters spawn where, with what AI
         |
         v
MonsterAIUnit.xml    -> AI personality (Automata + Element mappings)
         |
         +-> MonsterAIAutomata.xml   <-- this file (transition rules)
         +-> MonsterAIElement.xml    (the actual actions)

AI States#

StateNameMeaning
0NORMALIdle / general
1MOVEChasing target or patrolling
2ATTACKAttacking target
3HEALSelf or group healing
4AVOIDFleeing danger
5HELPSupporting allies (heal, buff)
6SPECIALSummon, invisibility, immunity, teleport, skill attack, AI change
7EVENTReserved for event-class actions

Each state uses the Element slot with the matching index in MonsterAIUnit.xml (ElementNormal, ElementMove, ElementAttack, ElementHeal, ElementAvoid, ElementHelp, ElementSpecial, ElementEvent).

Transition Types#

TypeNameTriggered when
0NO_ENEMYNo enemy currently targeted (or target left viewport)
1IN_ENEMYTarget is within the monster's AttackRange
2OUT_ENEMYTarget is at or beyond AttackRange (out of attack range)
3DIE_ENEMYCurrent target died. TODO: verify (declared in enum, not handled in evaluator switch)
4DEC_HPMonster's current HP is less than or equal to TransitionValue (absolute HP)
5DEC_HP_PERMonster's current HP is at or below TransitionValue percent of max HP
6IMMEDIATELYRolls TransitionRate unconditionally
7AGRO_UPAggro on current target is at or above TransitionValue
8AGRO_DOWNAggro on current target is at or below TransitionValue
10GROUP_SUMMONA dead group member is available to re-summon
11GROUP_HEALA group member within 6 tiles has HP below TransitionValue percent
12SUPPORT_HEALAn allied monster within 6 tiles has HP below TransitionValue percent

Attributes#

<Automata Number="..." Description="..." Priority="..."
         CurrentState="..." NextState="..."
         TransitionType="..." TransitionRate="..."
         TransitionValueType="..." TransitionValue="..."
         DelayTime="..." />
AttributeTypeEffect
Number0-299Automata group ID. Referenced by MonsterAIUnit.Automata.
DescriptionstringHuman-readable label. Stored but not used for logic.
Priority0-29Check order within the CurrentState bucket. Lower fires first.
CurrentState0-7State this rule applies FROM.
NextState0-7State to transition TO on success.
TransitionTypeenumCondition type (see table above).
TransitionRate0-100Probability the transition fires when the condition matches (random 0-99 is compared against the rate).
TransitionValueTypeint or ** is stored as -1. Currently unused by the evaluator.
TransitionValueint or *Condition parameter (HP amount, HP percent, aggro threshold). * is stored as -1.
DelayTimemsApplied as LastAutomataDelay when the rule fires; controls the wait before the next transition check.

How a Tick Works#

  1. Monster spawns in State 0 (NORMAL) with the Unit referenced by StartAI.
  2. Each AI tick iterates rules whose CurrentState equals the monster's current state, ordered by insertion (effectively by Priority 0, 1, 2 ...).
  3. For each rule, the evaluator checks the TransitionType condition. If the condition holds, it rolls a random 0-99 against TransitionRate.
  4. The first rule that passes returns immediately. The monster moves to NextState, its LastAutomataDelay is set to DelayTime, and the matching Element from the AI Unit executes.
  5. If no rule passes, the monster stays in the current state.

Cross-File Dependencies#

AttributeRelated in
NumberReferenced by MonsterAIUnit.Automata in MonsterAIUnit.xml
NextState mappingAction defined by the matching Element in MonsterAIElement.xml via the AI Unit
AttackRange used by Types 1 and 2See Monster.xml and MonsterAIRule.xml

Common Issues#

  • Monster never attacks - no transition from state 0 (NORMAL) to state 2 (ATTACK) with a matching TransitionType.
  • Monster goes passive after a hit - transition from 2 (ATTACK) to 0 (NORMAL) firing too easily; raise Priority of the stay-in-combat rule or lower the NORMAL rule's TransitionRate.
  • Boss phases never advance - no transition to state 6 or 7 with DEC_HP_PER and a NextState Element of Type 68 (AI Change).
  • Monster heals forever - transition into state 3 (HEAL) fires but no transition out; add a rule from state 3 with Type 6 (IMMEDIATELY) back to NORMAL/MOVE/ATTACK.
  • Group summon never fires - group members still alive, or monster is not assigned a valid GroupNumber.

Last updated April 21, 2026