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#
| State | Name | Meaning |
|---|---|---|
0 | NORMAL | Idle / general |
1 | MOVE | Chasing target or patrolling |
2 | ATTACK | Attacking target |
3 | HEAL | Self or group healing |
4 | AVOID | Fleeing danger |
5 | HELP | Supporting allies (heal, buff) |
6 | SPECIAL | Summon, invisibility, immunity, teleport, skill attack, AI change |
7 | EVENT | Reserved 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#
| Type | Name | Triggered when |
|---|---|---|
0 | NO_ENEMY | No enemy currently targeted (or target left viewport) |
1 | IN_ENEMY | Target is within the monster's AttackRange |
2 | OUT_ENEMY | Target is at or beyond AttackRange (out of attack range) |
3 | DIE_ENEMY | Current target died. TODO: verify (declared in enum, not handled in evaluator switch) |
4 | DEC_HP | Monster's current HP is less than or equal to TransitionValue (absolute HP) |
5 | DEC_HP_PER | Monster's current HP is at or below TransitionValue percent of max HP |
6 | IMMEDIATELY | Rolls TransitionRate unconditionally |
7 | AGRO_UP | Aggro on current target is at or above TransitionValue |
8 | AGRO_DOWN | Aggro on current target is at or below TransitionValue |
10 | GROUP_SUMMON | A dead group member is available to re-summon |
11 | GROUP_HEAL | A group member within 6 tiles has HP below TransitionValue percent |
12 | SUPPORT_HEAL | An allied monster within 6 tiles has HP below TransitionValue percent |
Attributes#
<Automata Number="..." Description="..." Priority="..."
CurrentState="..." NextState="..."
TransitionType="..." TransitionRate="..."
TransitionValueType="..." TransitionValue="..."
DelayTime="..." />
| Attribute | Type | Effect |
|---|---|---|
Number | 0-299 | Automata group ID. Referenced by MonsterAIUnit.Automata. |
Description | string | Human-readable label. Stored but not used for logic. |
Priority | 0-29 | Check order within the CurrentState bucket. Lower fires first. |
CurrentState | 0-7 | State this rule applies FROM. |
NextState | 0-7 | State to transition TO on success. |
TransitionType | enum | Condition type (see table above). |
TransitionRate | 0-100 | Probability the transition fires when the condition matches (random 0-99 is compared against the rate). |
TransitionValueType | int or * | * is stored as -1. Currently unused by the evaluator. |
TransitionValue | int or * | Condition parameter (HP amount, HP percent, aggro threshold). * is stored as -1. |
DelayTime | ms | Applied as LastAutomataDelay when the rule fires; controls the wait before the next transition check. |
How a Tick Works#
- Monster spawns in State 0 (NORMAL) with the Unit referenced by
StartAI. - Each AI tick iterates rules whose
CurrentStateequals the monster's current state, ordered by insertion (effectively by Priority 0, 1, 2 ...). - For each rule, the evaluator checks the
TransitionTypecondition. If the condition holds, it rolls a random 0-99 againstTransitionRate. - The first rule that passes returns immediately. The monster moves to
NextState, itsLastAutomataDelayis set toDelayTime, and the matching Element from the AI Unit executes. - If no rule passes, the monster stays in the current state.
Cross-File Dependencies#
| Attribute | Related in |
|---|---|
Number | Referenced by MonsterAIUnit.Automata in MonsterAIUnit.xml |
NextState mapping | Action defined by the matching Element in MonsterAIElement.xml via the AI Unit |
| AttackRange used by Types 1 and 2 | See 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
Priorityof the stay-in-combat rule or lower the NORMAL rule'sTransitionRate. - Boss phases never advance - no transition to state 6 or 7 with
DEC_HP_PERand aNextStateElement 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.