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

# CastleDeepEvent.dat

Castle Deep event (also known internally as Loren Deep): schedule of daily run start times, spawn group selection rates, when each group spawns within a run, and the monster placements per group and stage.

## File Location

```
Data/Event/CastleDeepEvent.dat
```

Loaded once at GameServer startup. Gated by [Event.dat](/docs/gameserver/event-dat.md#castle-deep) `CastleDeepEvent`. Changes require a restart.

## Sections

### Section 0 - Schedule

```
0
//Year   Month   Day   DoW   Hour   Minute   Second
*        *       *     *     4      0        0
*        *       *     *     12     0        0
*        *       *     *     20     0        0
end
```

Each row is one scheduled run. `*` is a wildcard (matches any value); concrete numbers pin the run to that field. The shipped template uses wildcards on Year/Month/Day/DoW with fixed Hour/Minute/Second, producing three daily runs at 04:00, 12:00, and 20:00.

### Section 1 - Group Spawn Rates

```
1
//Group   SpawnRate
1         50
2         50
end
```

| Column      | Effect                                                  |
| ----------- | ------------------------------------------------------- |
| `Group`     | Spawn group ID (referenced by sections 2 and 3)         |
| `SpawnRate` | Percent chance this group is picked when rolled (0-100) |

At the start of each run, the GameServer loops through the group list and rolls `rand() % 100 < SpawnRate` per entry, repeating until one group is chosen. Groups listed earlier have priority when multiple rolls succeed. If all entries fail, the loop repeats until one hits, so at least one `SpawnRate` must be above zero.

### Section 2 - Group Spawn Timing

```
2
//Index   Group   SpawnMinute
1         1       0
1         2       10
1         3       20
...
end
```

Controls when within a run each stage's monsters spawn.

| Column        | Effect                                                               |
| ------------- | -------------------------------------------------------------------- |
| `Index`       | The active group picked in section 1 is matched against this column  |
| `Group`       | Stage ID within the selected group; spawns advance stage 1, 2, 3 ... |
| `SpawnMinute` | Minutes after run start when this stage spawns                       |

At each tick, the server spawns the stage whose `Index` equals the active group and whose `Group` equals the current stage counter, once `(CastleDeepEventTime - RemainingMinutes)` equals `SpawnMinute`.

### Section 3 - Monster Spawns

```
3
//Index   Group   Monster   Count   X      Y      TX      TY
1         1       39        15     60     28     132     73
...
end
```

| Column     | Effect                                   |
| ---------- | ---------------------------------------- |
| `Index`    | Active-group match (section 1 selection) |
| `Group`    | Stage match (section 2 `Group`)          |
| `Monster`  | Monster class index                      |
| `Count`    | Number to spawn                          |
| `X`, `Y`   | Spawn rectangle top-left corner          |
| `TX`, `TY` | Spawn rectangle bottom-right corner      |

Monsters spawn at random walkable positions inside the `(X,Y)-(TX,TY)` rectangle. All Castle Deep monsters spawn on the Castle Siege map (map 30), not on Kalima. They are tagged with a dedicated attribute so the ClearMonster pass at run end removes only Castle Deep entities.

## Cross-File Dependencies

| Value                                                  | Related in                                                       |
| ------------------------------------------------------ | ---------------------------------------------------------------- |
| Enable flag                                            | [Event.dat](/docs/gameserver/event-dat.md) `CastleDeepEvent`     |
| Run duration (minutes)                                 | [Event.dat](/docs/gameserver/event-dat.md) `CastleDeepEventTime` |
| `Monster` class indices                                | [Monster.xml](/docs/data/monster/monster.md)                     |
| Map 30 (Castle Siege; host map for Castle Deep spawns) | [MapManager.xml](/docs/data/mapmanager.md)                       |

## Common Issues

* **Nothing spawns at the scheduled time** - section 3 has no rows matching the active `Index`/`Group` combination, or section 2's `SpawnMinute` exceeds `CastleDeepEventTime`
* **Run starts but never ends** - `CastleDeepEventTime` is zero in Event.dat
* **Event always picks the same group** - one `SpawnRate` dominates; reduce it or raise the other
* **Monsters spawn outside the map** - `X/Y/TX/TY` rectangle extends past the Castle Siege playable area; check MapManager terrain bounds
* **Event collides with Castle Siege** - section 0 times overlap with the active CS battle window; stagger the hours
