> For the complete documentation index, see [llms.txt](https://axiomemu.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://axiomemu.gitbook.io/docs/data/monster/monsteraigroup.md).

# MonsterAIGroup

Top-level AI configuration. Each entry ties a monster (from `Monster.xml`) to an AI Unit, a spawn location, and a group membership. Groups enable shared behaviors such as leader-triggered summons, group healing, and phase-based AI changes via Element Type 68.

Supports up to 50 groups, each with up to 100 members.

## File Location

```
Data/Monster/MonsterAIGroup.xml
```

Loaded once at GameServer startup. Changes require a restart.

## Role in the AI Hierarchy

```
MonsterAIGroup.xml  <-- this file (spawn + AI assignments)
         |
         v
MonsterAIUnit.xml   (AI personality)
         |
         +-> MonsterAIAutomata.xml
         +-> MonsterAIElement.xml
```

## Attributes

```xml
<Member Group="..." Guid="..." Class="..." Rank="..."
        StartAI="..." AI01="..." AI02="..." AI03="..."
        CreateType="..." Map="..." X="..." Y="..." Dir="..." RegenType="..." />
```

Note: the XML root is `<MonsterAIGroup>`, the child entries are `<Member>`.

### Identity

| Attribute | Type       | Effect                                                                                                                                 |
| --------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `Group`   | 0-49       | Group ID. Members with the same Group can summon and heal each other, and can be switched in bulk by Element Type 68                   |
| `Guid`    | 0-99       | Unique member slot within the group. Used as the index into the member array; does NOT mark a leader                                   |
| `Class`   | int        | Monster class index from [Monster.xml](/docs/data/monster/monster.md)                                                                  |
| `Rank`    | int or `*` | `0` marks this member as the group leader (returned by leader lookups). Any other integer or `*` (stored as -1) marks a regular member |

### AI Assignment

| Attribute | Type | Effect                                                    |
| --------- | ---- | --------------------------------------------------------- |
| `StartAI` | int  | AI Unit used on spawn (initial `CurrentAI` and `BasicAI`) |
| `AI01`    | int  | AI Unit after an Element Type 68 with order `1`           |
| `AI02`    | int  | AI Unit after an Element Type 68 with order `2`           |
| `AI03`    | int  | AI Unit after an Element Type 68 with order `3`           |

AI changes are triggered by Element Type 68 (which calls the group-wide AI-order switch) or by event code paths such as Kanturu, Crywolf, Imperial Guardian, and Double Goer stage transitions.

### Spawn Configuration

| Attribute    | Type       | Effect                                                                                                                                                                                                                                                                                                           |
| ------------ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CreateType` | int        | `0` = spawn exactly at (`X`, `Y`). `1` = try to find a random free tile within a 10x10 box around (`X`, `Y`) (up to 100 retries); falls back to (`X`, `Y`) if none is free                                                                                                                                       |
| `Map`        | int        | Map index                                                                                                                                                                                                                                                                                                        |
| `X`, `Y`     | int        | Spawn coordinates (also copied to `StartX` / `StartY` / `OldX` / `OldY` / `TX` / `TY`)                                                                                                                                                                                                                           |
| `Dir`        | 0-7 or `*` | Facing direction. `*` stored as -1                                                                                                                                                                                                                                                                               |
| `RegenType`  | int or `*` | Controls whether the generic respawn pipeline touches this monster. `*` (stored as -1) means group-managed and never re-summonable by Element Type 62. `0` means the monster uses the normal world respawn flow. Any other value (for example `1`) means group-managed but re-summonable by Type 62 group summon |

## Cross-File Dependencies

| Attribute                                            | Related in                                                                             |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------- |
| `Class`                                              | [Monster.xml](/docs/data/monster/monster.md)                                           |
| `StartAI`, `AI01`, `AI02`, `AI03`                    | [MonsterAIUnit.xml](/docs/data/monster/monsteraiunit.md) `Number`                      |
| `Map`, `X`, `Y`                                      | [MapManager.xml](/docs/data/mapmanager.md), terrain walkability                        |
| `Group` referenced from Element Type 68 `TargetType` | [MonsterAIElement.xml](/docs/data/monster/monsteraielement.md)                         |
| Transition rules driving state changes               | [MonsterAIAutomata.xml](/docs/data/monster/monsteraiautomata.md) via the selected Unit |
| AI personality (Automata + Element mapping)          | [MonsterAIUnit.xml](/docs/data/monster/monsteraiunit.md)                               |
| Event-driven AI order changes                        | event configs under [event/](/docs/data/event.md)                                      |

## Common Issues

* **Monster spawns but has no AI** - `StartAI` references a Unit number missing from `MonsterAIUnit.xml`, or points at a Unit with no `Automata`.
* **Group heal or group summon does not work** - intended members carry different `Group` values, so they are not visible to each other's group lookups.
* **AI phase never advances** - `AI01` / `AI02` / `AI03` point at the same Unit, or no Element Type 68 ever triggers on the leader's Unit.
* **Boss respawns immediately** - `RegenType` set to `0` on a unique boss; use `*` to keep it group-managed and non-respawning.
* **Spawn lands off-map or on unwalkable tile** - with `CreateType="0"` the monster spawns on the exact (`X`, `Y`); switch to `CreateType="1"` to pick a random nearby free tile.
* **Leader lookup returns nothing** - no member has `Rank="0"`; group-summon and related lookups that need a leader will fail.
