MonsterAIUnit.xml
AI personality glue. Each Unit picks one Automata (state machine) and maps each of the 8 AI states to an Element (the action to perform). Groups and rules reference Units by Number.
File Location#
Data/Monster/MonsterAIUnit.xml
Loaded at GameServer startup. /reload monster (or reload.monster in the Server Manager) reloads it without a restart. That command reloads every monster file and removes and respawns all monsters and NPCs on the server.
Dependencies#
| Depends On | Purpose |
|---|---|
| MonsterAIAutomata.xml | Supplies the state machine referenced by Automata |
| MonsterAIElement.xml | Supplies the per-state actions referenced by Element* |
| Used By | Purpose |
|---|---|
| MonsterAIGroup.xml | Assigns Units to monsters via StartAI / AI01 / AI02 / AI03 |
| MonsterAIRule.xml | Temporarily overrides a monster class's Unit on a schedule |
Role in the AI Hierarchy#
MonsterAIGroup.xml (BasicAI per monster)
|
v
MonsterAIUnit.xml <-- this file (picks Automata + maps states -> Elements)
|
+-> MonsterAIAutomata.xml (state machine)
+-> MonsterAIElement.xml (actions)
Attributes#
<Unit Number="..." Name="..." DelayTime="..."
Automata="..."
ElementNormal="..." ElementMove="..." ElementAttack="..." ElementHeal="..."
ElementAvoid="..." ElementHelp="..." ElementSpecial="..." ElementEvent="..." />
| Attribute | Type | Effect |
|---|---|---|
Number | int | Unique Unit ID. Valid range 0-99. Used as the storage index, so duplicates overwrite each other |
Name | string | Human-readable label. Truncated at 49 characters |
DelayTime | ms | Minimum delay between AI dispatcher runs for monsters using this Unit. Lower = more reactive |
Automata | int | Number from MonsterAIAutomata.xml. Required - a Unit with no Automata never ticks |
ElementNormal | int or * | Element for state 0 (NORMAL) |
ElementMove | int or * | Element for state 1 (MOVE) |
ElementAttack | int or * | Element for state 2 (ATTACK) |
ElementHeal | int or * | Element for state 3 (HEAL) |
ElementAvoid | int or * | Element for state 4 (AVOID) |
ElementHelp | int or * | Element for state 5 (HELP) |
ElementSpecial | int or * | Element for state 6 (SPECIAL) |
ElementEvent | int or * | Element for state 7 (EVENT) |
All Element references resolve against the Number attribute in MonsterAIElement.xml. Using * or omitting an Element attribute leaves that state unwired - if the Automata transitions to that state, no action runs and the tick no-ops.
State-to-Element Mapping#
| State ID | State | Unit attribute |
|---|---|---|
| 0 | NORMAL | ElementNormal |
| 1 | MOVE | ElementMove |
| 2 | ATTACK | ElementAttack |
| 3 | HEAL | ElementHeal |
| 4 | AVOID | ElementAvoid |
| 5 | HELP | ElementHelp |
| 6 | SPECIAL | ElementSpecial |
| 7 | EVENT | ElementEvent |
Each tick the Automata picks a transition; the Element bound to that transition's next state runs. The engine does not validate that the Element's declared class matches the state - an ElementAttack can point at a HEAL-class Element and the engine will still execute it, just as the wrong thing.
Tick Timing#
Two delays gate every AI tick for a monster:
- The Unit's
DelayTime(this file) caps how often the Automata is consulted. - The Element returned by the Automata can set its own per-element delay on the monster, applied before the next Automata run.
Both are in milliseconds. Lower values increase CPU load for the class.
Cross-File References#
| Attribute | Resolved Against |
|---|---|
Number | MonsterAIGroup.xml StartAI / AI01 / AI02 / AI03, and MonsterAIRule.xml Unit |
Automata | MonsterAIAutomata.xml Number |
Element* | MonsterAIElement.xml Number |
Common Issues#
- Monster idle forever -
ElementNormalis wired but the Automata never transitions to any other state, so the non-idle Elements never run. - Wrong action in the wrong state - Element class does not match the slot. The engine executes whatever it is bound to.
DelayTimetoo low - the dispatcher runs faster than the monster's animation or path can complete, producing jerky behaviour.- AI change event does nothing -
ElementEventis missing or set to*; state 7 transitions fire but no action runs. - Duplicate
Number- the later entry overwrites the earlier one silently. Numberoutside 0-99 - entry is dropped silently at load.
Related Systems#
- MonsterAIAutomata.xml - state machine that drives transitions
- MonsterAIElement.xml - per-state action definitions
- MonsterAIGroup.xml - assigns Units to individual monsters
- MonsterAIRule.xml - time-scheduled Unit overrides
- Monster.xml - monster stats and base combat parameters