> 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/monstersetbase.md).

# MonsterSetBase

Controls where and how monsters spawn across all maps. The server scans one folder of per-map XML files at startup and appends every entry into a single global spawn table.

## File Location

**Per-map spawns:** `Data/Monster/MonsterSetBase/*.xml` (one file per map)

No master registry file ships with AXIOM-EMU. The server scans the `MonsterSetBase/` directory and loads every `.xml` file it finds.

{% hint style="info" %}
**Unified folder**: Castle Siege event maps (Castle Siege, Land of Trials, Crywolf, Barracks, Refuge, Loren Market) were historically split into a separate `MonsterSetBaseCS/` folder. That split is gone; everything lives in `MonsterSetBase/`. On non-Castle-Siege deployments, NPCs on CS-only maps still spawn but their interaction handlers self-gate, so they are inert.
{% endhint %}

## Dependencies

| Depends On                                   | Purpose                                                                       |
| -------------------------------------------- | ----------------------------------------------------------------------------- |
| [Monster.xml](/docs/data/monster/monster.md) | Spawns reference monster stats by Class (Index)                               |
| [MapManager.xml](/docs/data/mapmanager.md)   | Entries on a map not enabled by this server are silently dropped at load time |

| Used By       | Purpose                                                                                                                                                                                       |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Map loading   | Server reads spawn files during map initialization                                                                                                                                            |
| Event systems | Blood Castle, Devil Square, Illusion Temple, Imperial Guardian, Raklion, Crywolf, Castle Siege, Chaos Castle, and Invasion Manager all scan the spawn table for their Type 3 / Type 4 entries |

## File Structure

### Per-Map Spawn Files

Each map has its own file: `MonsterSetBase/000 - Lorencia.xml`, `MonsterSetBase/001 - Dungeon.xml`, etc. The filename is documentation only; the actual map is chosen by each entry's `Map` attribute. Files load in alphabetical order and their entries are appended into one global spawn table, so adding or renaming a file is all that is needed to register new spawns.

Map numbers match the game's internal map IDs (00 = Lorencia, 01 = Dungeon, 02 = Devias, etc.) and must match the Map value written inside each entry.

## Spawn Entry Attributes

| Attribute | Type   | Description                                                                |
| --------- | ------ | -------------------------------------------------------------------------- |
| `Type`    | int    | Spawn type (see Spawn Types below)                                         |
| `Class`   | int    | Monster Index from Monster.xml                                             |
| `Map`     | int    | Map number (00 = Lorencia, 01 = Dungeon, etc.)                             |
| `Dis`     | int    | Roaming distance from spawn point (in tiles)                               |
| `X`       | int    | Spawn X coordinate                                                         |
| `Y`       | int    | Spawn Y coordinate                                                         |
| `TX`      | int    | Target X coordinate (Type 1/3 only) - defines spawn area with X            |
| `TY`      | int    | Target Y coordinate (Type 1/3 only) - defines spawn area with Y            |
| `Dir`     | int    | Facing direction (0-7, or -1 for random)                                   |
| `Count`   | int    | Number of monsters to spawn (Type 1/3 only, minimum 1 if 0)                |
| `Value`   | int    | Event identifier (Type 3 only) - used by Invasion Manager to filter spawns |
| `Comment` | string | Description (optional, for admin reference)                                |

## Spawn Types

| Type | Name        | Behavior                                                                                                                           | Use Case                                                                |
| ---- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| 0    | Fixed       | Single monster at exact X/Y; respawns at the same location                                                                         | NPCs, guards, stationary bosses                                         |
| 1    | Group       | Count monsters spawn randomly inside the (X,Y)-(TX,TY) rectangle; each respawn re-rolls a point in the same rectangle              | Normal hunting zones                                                    |
| 2    | Spot        | Single monster; loader offsets X/Y by -3..+3 once at load, then every (re)spawn picks a fresh point within +/-3 of that offset X/Y | Scattered individual spawns                                             |
| 3    | Event       | Same geometry as Type 1; filtered out of normal init and activated by Invasion Manager using the Value field                       | Invasion Manager, White Wizard events                                   |
| 4    | Event Fixed | Single monster at exact X/Y; filtered out of normal init and activated by event code matching on MonsterClass and Map              | Blood Castle, Devil Square, Illusion Temple, Imperial Guardian, Raklion |

### Type 0: Fixed Spawn

```xml
<Monster Type="0" Class="226" Map="00" Dis="00" X="122" Y="110" Dir="03" Comment="Trainer"/>
```

* Spawns exactly 1 monster at X=122, Y=110
* Dis="00" means the monster cannot roam
* Dir is a 0-7 facing index; use -1 for random
* Use for NPCs and bosses at specific locations

### Type 1: Group Spawn

```xml
<Monster Type="1" Class="003" Map="00" Dis="10" X="187" Y="121" TX="187" TY="121" Dir="-1" Count="007" Comment="Spider"/>
```

* Spawns 7 spiders at (187,121) because TX=X and TY=Y (the spawn rectangle collapses to a single tile)
* TX/TY must be set larger than X/Y to create a real spawn area; otherwise every unit of `Count` spawns at the exact point
* `Dis="10"` allows each monster to roam 10 tiles from its spawn point
* `Dir="-1"` means random facing
* Use for normal monster packs in hunting zones

### Type 2: Spot Spawn

```xml
<Monster Type="2" Class="028" Map="03" Dis="05" X="202" Y="155" Dir="-1" Comment="BeetleMonster"/>
```

* Spawns 1 monster within a 7x7 box centered on the configured X/Y (coordinates offset by -3..+3 on each axis)
* The loader offsets the stored X/Y once at load time, then picks a fresh random point within +/-3 of that offset X/Y on every spawn and respawn
* Good for scattered individual monsters that should not cluster
* Commonly used in Noria for BeetleMonster and ForestMonster

### Type 3: Event Spawn (Invasion Manager)

```xml
<Monster Type="3" Class="089" Map="00" Dis="10" X="100" Y="100" TX="120" TY="120" Dir="-1" Count="010" Value="1" Comment="White Wizard Event"/>
```

* Similar to Type 1 but controlled by Invasion Manager and event systems
* Count monsters spawn randomly between (X,Y) and (TX,TY)
* **Value attribute** is used by event systems to filter/identify spawn groups
* Used by White Wizard invasions and custom event systems
* NOT directly used by Blood Castle, Devil Square (they use Type 4)

### Type 4: Event Fixed Spawn

```xml
<Monster Type="4" Class="131" Map="11" Dis="00" X="100" Y="100" Dir="03" Comment="Blood Castle Gate"/>
```

* Single monster at exact X/Y for event systems
* Behaves like Type 0 but filtered by event code (Type 3/4 are excluded from normal spawns)
* Used by Blood Castle, Devil Square, Illusion Temple, Imperial Guardian, Raklion
* Event systems programmatically control when these spawns are activated

## Direction Values

| Dir | Meaning                                                       |
| --- | ------------------------------------------------------------- |
| 0-7 | Facing index (MU Online standard 8-way facing)                |
| -1  | Random; loader rolls a fresh 0-7 value per entry at load time |

TODO: verify exact compass mapping of each 0-7 value against the client's direction table.

## Important Behavior

### Spawn Timing

{% hint style="info" %}
**Initial spawn**: All Type 0, 1, and 2 monsters spawn when the GameServer starts and loads maps. Type 3 and 4 entries are skipped during the normal spawn pass and are instantiated later by event systems on their own schedules.

**Respawn**: After death, monsters respawn based on their `RegenTime` in Monster.xml. The respawn location depends on spawn type:

* Type 0 / Type 4: exact same X/Y
* Type 1 / Type 3: fresh random point inside the (X,Y)-(TX,TY) rectangle
* Type 2: fresh random point inside +/-3 of the load-time offset X/Y (re-rolled every respawn)
  {% endhint %}

### Coordinate System

* Coordinates are in tiles (not pixels)
* Origin (0,0) is typically top-left corner
* Maximum coordinates vary by map (usually 255x255 or similar)
* Invalid coordinates = monster spawns but is unreachable/invisible

### Dis (Roaming Distance)

* Dis="00" = Monster cannot move (stays at spawn point)
* Dis="10" = Monster can wander up to 10 tiles from spawn point before AI forces return
* Distance is calculated as Euclidean distance from spawn point (sqrt formula)
* Too high Dis on maps with walls = monsters may appear to walk through walls when returning
* NPCs should always have Dis="00" to prevent walking away

{% hint style="warning" %}
The roaming distance check uses the monster's current spawn point, not the original config X/Y. For Type 2, the spawn point is the randomized location rolled at spawn time, so the roam box travels with each respawn.
{% endhint %}

### Count Behavior

Type 1 and 3 spawn exactly `Count` monsters:

* `Count="007"` spawns 7 monsters
* `Count="000"` spawns 1 monster (the loader converts zero to one)
* Each monster rolls its initial location inside the (X,Y)-(TX,TY) rectangle
* On death, the respawn rolls a new location in the same rectangle (Type 1/3 only)

Internally the loader expands each Type 1 / Type 3 entry into `Count` individual spawn slots in the 20000-slot global table. A `Count="050"` entry consumes 50 slots.

### TX/TY as Spawn Area

For Type 1/3, (X,Y) and (TX,TY) define a rectangular spawn area:

* If `TX=X` and `TY=Y`, every unit of `Count` spawns at the exact point (the box collapses to a single tile). Use this only when you want stacked spawns
* If `TX` > `X` or `TY` > `Y`, spawns are spread across the rectangle (must be greater than, not just not equal)
* Example: `X="100" Y="100" TX="120" TY="120"` = 20x20 tile spawn zone
* The picker retries up to 100 times to find a walkable tile before giving up on that roll

### Event Spawn Filtering (Type 3/4)

{% hint style="info" %}
Type 3 and 4 spawns are **NOT included** in the normal monster spawn during map initialization. They are filtered out and only activated by event systems:

* **Type 3**: Invasion Manager uses the `Value` attribute to match spawn groups
* **Type 4**: Blood Castle, Devil Square, Illusion Temple, Imperial Guardian, and Raklion use `MonsterClass` and `Map` to find specific spawns

This allows event monsters to be defined alongside normal monsters without interfering with regular gameplay.
{% endhint %}

## Examples

{% tabs %}
{% tab title="NPC (Fixed)" %}

```xml
<Monster Type="0" Class="226" Map="00" Dis="00" X="122" Y="110" Dir="03" Comment="Trainer"/>
```

Spawns Trainer NPC at fixed location in Lorencia, cannot roam (Dis=0), facing index 3.
{% endtab %}

{% tab title="Monster Group" %}

```xml
<Monster Type="1" Class="000" Map="00" Dis="10" X="201" Y="069" TX="201" TY="069" Dir="-1" Count="007" Comment="BullFighter"/>
```

Spawns 7 Bull Fighters at (201,69) with 10-tile roaming range, random facing. Because TX=X and TY=Y, all 7 start on the same tile before they roam apart.
{% endtab %}

{% tab title="Scattered Spawns" %}

```xml
<Monster Type="1" Class="003" Map="00" Dis="10" X="140" Y="080" TX="220" TY="180" Dir="-1" Count="050" Comment="Spider Zone"/>
```

Spawns 50 Spiders across an 80x100 tile zone (from 140,80 to 220,180), creating a dense hunting area.
{% endtab %}

{% tab title="Boss Spawn" %}

```xml
<Monster Type="0" Class="018" Map="00" Dis="05" X="125" Y="125" Dir="00" Comment="Gorgon Boss"/>
```

Spawns Gorgon boss at (125,125), can roam 5 tiles, facing index 0. Respawn time is controlled by Monster.xml RegenTime.
{% endtab %}

{% tab title="Event Spawn (Blood Castle)" %}

```xml
<Monster Type="4" Class="131" Map="11" Dis="00" X="015" Y="075" Dir="00" Comment="Blood Castle Gate"/>
```

Defines a gate spawn for the Blood Castle event. Type 4 is filtered out of the normal map initialization spawn pass; Blood Castle finds it by scanning the spawn table for matching MonsterClass and Map.
{% endtab %}

{% tab title="Scattered Individual Monsters" %}

```xml
<Monster Type="2" Class="028" Map="03" Dis="05" X="202" Y="155" Dir="-1" Comment="BeetleMonster"/>
<Monster Type="2" Class="028" Map="03" Dis="05" X="212" Y="157" Dir="-1" Comment="BeetleMonster"/>
```

The loader offsets each entry's X/Y by -3..+3 once at load time. On every spawn and respawn the server rolls a fresh random point inside +/-3 of that offset X/Y, so each entry occupies a 7x7 tile box.
{% endtab %}
{% endtabs %}

## Per-Map Spawn Files

Each map has its own spawn file. The folder ships with files covering at least the following map IDs:

| Map ID    | File                                                                                  | Map Name                    |
| --------- | ------------------------------------------------------------------------------------- | --------------------------- |
| 00        | `000 - Lorencia.xml`                                                                  | Lorencia                    |
| 01        | `001 - Dungeon.xml`                                                                   | Dungeon                     |
| 02        | `002 - Devias.xml`                                                                    | Devias                      |
| 03        | `003 - Noria.xml`                                                                     | Noria                       |
| 04        | `004 - Lost Tower.xml`                                                                | Lost Tower                  |
| 06        | `006 - Arena.xml`                                                                     | Arena                       |
| 07        | `007 - Atlans.xml`                                                                    | Atlans                      |
| 08        | `008 - Tarkan.xml`                                                                    | Tarkan                      |
| 09        | `009 - Devil Square 1.xml`                                                            | Devil Square (lower tiers)  |
| 10        | `010 - Icarus.xml`                                                                    | Icarus                      |
| 11-17, 52 | `011 - Blood Castle 1.xml` ... `017 - Blood Castle 7.xml`, `052 - Blood Castle 8.xml` | Blood Castle                |
| 18-23, 53 | `018 - Chaos Castle 1.xml` ... `023 - Chaos Castle 6.xml`, `053 - Chaos Castle 7.xml` | Chaos Castle                |
| 24-29, 36 | `024 - Kalima 1.xml` ... `029 - Kalima 6.xml`, `036 - Kalima 7.xml`                   | Kalima                      |
| 30        | `030 - Castle Siege.xml`                                                              | Castle Siege                |
| 31        | `031 - Land of Trials.xml`                                                            | Land of Trials              |
| 32        | `032 - Devil Square 2.xml`                                                            | Devil Square (higher tiers) |
| 33        | `033 - Aida.xml`                                                                      | Aida                        |
| 34        | `034 - Crywolf.xml`                                                                   | Crywolf                     |
| 37-39     | `037 - Kanturu 1.xml` ... `039 - Kanturu 3.xml`                                       | Kanturu                     |
| 40        | `040 - Silent.xml`                                                                    | Silent Map                  |
| 41        | `041 - Barracks.xml`                                                                  | Barracks of the Balgass     |
| 42        | `042 - Refuge.xml`                                                                    | Refuge of the Balgass       |
| 45-50     | `045 - Illusion Temple 1.xml` ... `050 - Illusion Temple 6.xml`                       | Illusion Temple             |
| 51        | `051 - Elbeland.xml`                                                                  | Elbeland                    |

Kanturu 3 (map 39) also has dedicated spawn entries in [`KanturuMonsterSetBase.xml`](/docs/data/monster/kanturumonstersetbase.md) loaded separately for the Kanturu event.

{% hint style="info" %}
When adding spawns to a map, edit the corresponding map file (e.g., `000 - Lorencia.xml` for Lorencia spawns); there is no parent MonsterSetBase.xml file.
{% endhint %}

## Common Tasks

### Add Monster Spawn to Map

1. Find the map file (e.g., `002 - Devias.xml`)
2. Add a new `<Monster>` entry
3. Set Type (usually 1 for monster groups)
4. Set Class to monster Index from Monster.xml
5. Set X/Y coordinates and Count

### Increase Monster Density

Find existing spawn entries and increase `Count`:

```xml
<!-- Before -->
<Monster Type="1" Class="003" Map="00" Dis="10" X="187" Y="121" TX="187" TY="121" Dir="-1" Count="007" Comment="Spider"/>

<!-- After -->
<Monster Type="1" Class="003" Map="00" Dis="10" X="187" Y="121" TX="187" TY="121" Dir="-1" Count="020" Comment="Spider"/>
```

### Create Dense Hunting Zone

Add multiple spawn entries with overlapping areas:

```xml
<Monster Type="1" Class="005" Map="02" Dis="10" X="100" Y="100" TX="120" TY="120" Dir="-1" Count="015"/>
<Monster Type="1" Class="005" Map="02" Dis="10" X="110" Y="110" TX="130" TY="130" Dir="-1" Count="015"/>
<Monster Type="1" Class="005" Map="02" Dis="10" X="120" Y="100" TX="140" TY="120" Dir="-1" Count="015"/>
```

Creates 45 Hell Hounds across overlapping zones for intense hunting.

### Remove Monster from Map

Delete or comment out the spawn entry:

```xml
<!-- <Monster Type="1" Class="003" Map="00" Dis="10" X="187" Y="121" TX="187" TY="121" Dir="-1" Count="007" Comment="Spider"/> -->
```

### Move Boss Location

Change X and Y coordinates:

```xml
<!-- Before -->
<Monster Type="0" Class="018" Map="01" Dis="05" X="125" Y="125" Dir="00" Comment="Gorgon"/>

<!-- After -->
<Monster Type="0" Class="018" Map="01" Dis="05" X="200" Y="200" Dir="00" Comment="Gorgon"/>
```

## Common Issues

{% hint style="warning" %}
**Monsters spawn inside walls.** Check that X/Y coordinates are on walkable terrain. Use in-game /move command to verify coordinates are valid.
{% endhint %}

{% hint style="warning" %}
**Count="000" spawns 1 monster, not 0** (only for Type 1/3). The code automatically converts Count=0 to Count=1. To disable a spawn, delete the entry or comment it out with `<!-- -->`.
{% endhint %}

{% hint style="warning" %}
**Changes don't appear immediately.** Monsters already spawned remain until they die. For immediate updates, restart the GameServer or use /reload commands if available.
{% endhint %}

{% hint style="info" %}
**Dis too high causes wall clipping.** If monsters appear to walk through walls, reduce their Dis value to keep them within the intended area. The pathfinding return-to-spawn logic can cause monsters to walk through obstacles.
{% endhint %}

{% hint style="warning" %}
**Type 2 spawns are not deterministic.** The loader rolls a -3..+3 offset on each restart, then every individual spawn and respawn rolls a fresh point inside +/-3 of that offset. Do not use Type 2 when you need a precise fixed location.
{% endhint %}

{% hint style="danger" %}
**Hard ceiling of 20000 spawn entries across all maps.** Each entry past the limit is silently dropped. For Type 1 and Type 3 the loader creates one spawn slot per unit of `Count`, so `Type="1" Count="050"` consumes 50 slots. On boot the GameServer logs `[MonsterSetBase] loaded N / 20000 entries`; if the cap is hit it also logs `[MonsterSetBase] CAP HIT - trailing spawn entries silently dropped. Raise MAX_MSB_MONSTER in MonsterSetBase.h`. Vanilla S6 spawn data expands to \~10035 entries on its own; the previous 10000-slot limit silently dropped the tail of Arkania and any later map.
{% endhint %}

{% hint style="warning" %}
**Entries on disabled maps are dropped.** If the `Map` value belongs to a map this GameServer instance does not run (per [MapManager.xml](/docs/data/mapmanager.md)), the loader silently skips the entry instead of logging an error.
{% endhint %}

{% hint style="info" %}
**Per-map loading**: The server scans the `MonsterSetBase/` folder and loads every `.xml` file inside it into one global spawn table. There is no master registry file.
{% endhint %}

## Related Pages

* [Monster.xml](/docs/data/monster/monster.md) - Stats, RegenTime, and level for every Class referenced here
* [KanturuMonsterSetBase.xml](/docs/data/monster/kanturumonstersetbase.md) - Separate Kanturu-event spawn list for map 39
* [MapManager.xml](/docs/data/mapmanager.md) - Map index table controlling which maps this server actually runs
