> For the complete documentation index, see [llms.txt](https://changelog.matrixemulator.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://changelog.matrixemulator.com/welcome/server/muserver/data/event/mucastledata.md).

# MuCastleData

<mark style="color:green;">Configuration for the Castle Siege event: cycle duration, phase schedule, and the castle's defense NPCs (gates, statues, towers, etc.). The file contains 3 blocks, each starting with the block number (</mark><mark style="color:green;">`0`</mark> <mark style="color:green;"></mark><mark style="color:green;">to</mark> <mark style="color:green;"></mark><mark style="color:green;">`2`</mark><mark style="color:green;">) on its own line and ending with</mark> <mark style="color:green;"></mark><mark style="color:green;">`end`</mark><mark style="color:green;">.</mark>

### <mark style="color:yellow;">Section 0 — cycle duration</mark>

| Column | Accepted Values | Description                                                                      |
| ------ | --------------- | -------------------------------------------------------------------------------- |
| Cycle  | Number, in days | Number of days between each Castle Siege cycle (registration → siege → results). |

### <mark style="color:yellow;">Section 1 — cycle phase schedule</mark>

| Column                             | Accepted Values                | Description                                                                                                             |
| ---------------------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| State                              | Sequential number (1, 2, 3...) | The phase of the Castle Siege cycle. The order and behavior of each phase are hardcoded in the server.                  |
| StartDay / StartHour / StartMinute | Number                         | When this phase begins, **relative to the start of the cycle** (day 0, hour 0). This is **not** an absolute clock time. |

### <mark style="color:yellow;">Section 2 — castle defense NPCs</mark>

<table data-search="false"><thead><tr><th>Column</th><th>Accepted Values</th><th>Description</th></tr></thead><tbody><tr><td>Monster</td><td>Monster class number</td><td>The defense NPC (gate, statue, tower, etc.).</td></tr><tr><td>Index</td><td>Number, unique in combination with <code>Monster</code></td><td>Identifies this specific instance of the NPC.</td></tr><tr><td>DBSave</td><td><code>0</code> or <code>1</code></td><td>Whether this NPC's current HP is saved and restored across server restarts.</td></tr><tr><td>Side</td><td>Number</td><td>The faction/group this NPC belongs to (statue and gate defenders use one value, while support NPCs use another).</td></tr><tr><td>DFLevel</td><td>Number from 0 to 3</td><td>Initial defense level of the NPC (the castle owner can upgrade it later).</td></tr><tr><td>RGLevel</td><td>Number from 0 to 3</td><td>Initial HP regeneration level of the NPC (also upgradeable by the castle owner).</td></tr><tr><td>MaxLife</td><td>Number</td><td>Maximum HP of the NPC.</td></tr><tr><td>X / Y</td><td>Coordinates</td><td>Where the NPC spawns.</td></tr><tr><td>TX / TY</td><td>Coordinates or <code>-1</code></td><td>Destination the NPC walks to after spawning. <code>-1</code> = remains at its spawn position.</td></tr><tr><td>Dir</td><td>Number from 0 to 7</td><td>Direction the NPC faces.</td></tr></tbody></table>

### <mark style="color:yellow;">Notes</mark>

* **The header comment inside the original file lists the columns as `Monster Index Side DBSave ...`, but the server actually reads them in the order `Monster Index DBSave Side ...`.** In other words, the 3rd column is `DBSave` and the 4th is `Side`, the opposite of what the comment suggests. The table above reflects the actual order used by the server, as confirmed in `CastleSiege.cpp`.
* `StartDay`, `StartHour`, and `StartMinute` in Block 1 are offsets relative to the beginning of the Castle Siege cycle, not fixed clock times. This is why the values increase from one row to the next (for example: `0 0 0`, then `1 23 59`, then `2 0 0`, etc.) until the full cycle duration defined by `Cycle` is reached.
* `DFLevel` and `RGLevel` are only the initial values assigned to each NPC when a new Castle Siege cycle begins. During the preparation phase, the castle owner can spend resources to upgrade these levels through another game system.
