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

# MuCastleData.dat

Castle Siege event data: cycle length in days, the 9-entry state schedule that governs the Castle Siege state machine, and the NPC/monster placements for the siege map including gates, statues, Guardian Dragons, and peaceful NPCs. Requires both Common.dat `EnableCastleSiege = 1` and Event.dat `CastleSiegeEvent = 1`.

## File Location

```
Data/Event/MuCastleData.dat
```

Loaded once at GameServer startup. Changes require a restart.

## Sections

### Section 0 - Cycle Length

```
0
//Cycle
7
end
```

Days in a full Castle Siege cycle. Shipped default: 7 (weekly). The state schedule in section 1 repeats every `Cycle` days. Must be greater than zero.

### Section 1 - State Schedule

```
1
//State   StartDay   StartHour   StartMinute
1         0          0           0
2         1          23          59
3         2          0           0
4         3          0           0
5         4          12          0
6         4          19          0
7         6          09          0
8         6          23          0
9         7          0           0
end
```

One row per Castle Siege state, scheduled by day-of-cycle and time-of-day. Entries are sorted by `StartDay`/`StartHour`/`StartMinute`; ordering must be strictly increasing after sort, and each state number must appear exactly once.

| State | Internal name | Description                                  |
| ----- | ------------- | -------------------------------------------- |
| 1     | IDLE\_1       | Pre-registration idle                        |
| 2     | REGSIEGE      | Guild siege registration window              |
| 3     | IDLE\_2       | Idle between registration and mark sign-up   |
| 4     | REGMARK       | Mark-of-Lord sign-up window                  |
| 5     | IDLE\_3       | Idle between sign-up and battle notification |
| 6     | NOTIFY        | Battle notification broadcast                |
| 7     | READYSIEGE    | Pre-battle readiness window                  |
| 8     | STARTSIEGE    | Active siege battle                          |
| 9     | ENDSIEGE      | Post-battle tribute / result window          |

`StartDay` is day-of-cycle (0 = first day). `StartHour` and `StartMinute` are wall-clock time within that day.

### Section 2 - NPC / Monster Placements

```
2
//Monster   Index   DBSave   Side   DFLevel   RGLevel   MaxLife   X      Y      TX      TY      Dir
283         1       1        1      0         0         400000    94     227    -1      -1      1
...
end
```

One row per placement. The shipped template covers gates, statues, Guardian Dragons, the Crown Switch NPCs, and peaceful siege-map NPCs.

{% hint style="warning" %}
The column order in the loader does not match the `//` header comment that ships in the file. The order below is what the loader actually reads; the trailing `//Monster Index Side DBSave ...` header comment you may see in legacy files is misleading.
{% endhint %}

| Column     | Effect                                                                                                                         |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `Monster`  | Monster class index from [Monster.xml](/docs/data/monster/monster.md)                                                          |
| `Index`    | Placement instance ID, unique per `Monster` class                                                                              |
| `DBSave`   | `1` = state persists across restarts via DataServer; `0` = always fresh; `2` = special persistence path for Crown-related NPCs |
| `Side`     | `1` = destructible siege target (gate, statue, Guardian Dragon, Crown); `2` = peaceful siege-map NPC                           |
| `DFLevel`  | Defense upgrade level (applied to gates/statues via chaos gem upgrade; `0` = baseline)                                         |
| `RGLevel`  | Regeneration upgrade level (applied to statues; `0` = baseline)                                                                |
| `MaxLife`  | Placement HP override                                                                                                          |
| `X`, `Y`   | Spawn coordinates                                                                                                              |
| `TX`, `TY` | Destination / patrol target; `-1 -1` = stationary                                                                              |
| `Dir`      | Facing direction (0-7)                                                                                                         |

### Section 3 - Gate Defense-Level Upgrade Table

```
3
//Level   GemCount   Zen
1         2          1000000
2         4          2000000
...
end
```

Per-level chaos-gem and zen cost to upgrade castle gates' defense level via the Crown Switch / siege upgrade NPC. Capped at `CS_MAX_UPGRADE` entries.

| Column     | Effect                                      |
| ---------- | ------------------------------------------- |
| `Level`    | Target defense level (1, 2, 3, ...)         |
| `GemCount` | Number of chaos gems consumed for this step |
| `Zen`      | Zen cost for this step                      |

### Section 4 - Statue Defense-Level Upgrade Table

Same column layout as section 3 but applies to the Crown Statue.

### Section 5 - Gate Max-HP Upgrade Table

```
5
//HP   GemCount   Zen
4000   2          1000000
...
end
```

Per-step gate Max-HP upgrade cost.

| Column     | Effect                                 |
| ---------- | -------------------------------------- |
| `HP`       | Additional Max-HP granted at this step |
| `GemCount` | Chaos-gem cost                         |
| `Zen`      | Zen cost                               |

### Section 6 - Statue Max-HP Upgrade Table

Same column layout as section 5 but for the Crown Statue.

### Section 7 - Statue Regeneration-Level Upgrade Table

```
7
//Level   GemCount   Zen
1         2          1000000
...
end
```

Per-level regeneration upgrade cost for the Crown Statue.

### Section 8 - Gate Defense-Value Baseline

```
8
//Defense
50
80
...
end
```

One row per defense level (index 0 = baseline level 0; subsequent rows = upgrades from section 3). The integer is the raw defense value applied to gates at that level. Capped at `CS_MAX_UPGRADE + 1` entries.

### Section 9 - Statue Defense-Value Baseline

Same column layout as section 8 but applied to the Crown Statue.

## Cross-File Dependencies

| Value                    | Related in                                                                                                                               |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Master enable            | [Common.dat](/docs/gameserver/common-dat.md) `EnableCastleSiege`                                                                         |
| Event enable flag        | [Event.dat](/docs/gameserver/event-dat.md) `CastleSiegeEvent`                                                                            |
| Weapon damage            | [Event.dat](/docs/gameserver/event-dat.md) `CastleSiegeOffensiveWeaponDamage` / `CastleSiegeDefensiveWeaponDamage` (raw HP, not percent) |
| Accumulated time decay   | [Event.dat](/docs/gameserver/event-dat.md) `CastleSiegeLowerAccumulatedTimeValue` / `CastleSiegeDecayAccumulatedTimeValue`               |
| Damage scaling           | [Character.dat](/docs/gameserver/character-dat.md) `CastleSiegeDamageRate1/2/3`                                                          |
| Elemental scaling        | [Character.dat](/docs/gameserver/character-dat.md#elemental-damage-rates) `CastleSiegeElementalDamageRate1/2/3`                          |
| CS skills outside CS map | [Common.dat](/docs/gameserver/common-dat.md) `EnableCsSkillsAllMaps`                                                                     |
| Map 30 (Castle Siege)    | [MapManager.xml](/docs/data/mapmanager.md)                                                                                               |

## Common Issues

* **CS never enters STARTSIEGE** - day/hour/minute of state 8 is later than current weekday, or `Cycle` mismatch
* **Guardian dragon missing** - monster index in section 2 not in Monster.xml, `Side` misconfigured, or `MaxLife` is zero
* **Gates indestructible** - `MaxLife` set too high or weapon damage in Event.dat too low
* **Cycle flips daily instead of weekly** - section 0 `Cycle` set to `1`; restore to `7`
* **State overrides never unstick** - `CastleSiegeSpecificState` in Event.dat non-zero; reset to `0` to resume automatic state progression
* **Schedule load fails silently** - section 1 has a duplicated `State` value, or entries are out of order after sort
