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

# DevilSquare.dat

Devil Square event: timing, schedule, rank-based per-tier reward tables (XP and money), and optional coin rewards.

## File Location

```
Data/Event/DevilSquare.dat
```

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

## Event Summary

Devil Square is a monster-survival arena with 7 tiers (0-6). Tiers 0-3 use map 9 and tiers 4-6 use map 32. Tier eligibility is decided by [configurable bracket bounds](/docs/gameserver/event-dat.md#bracket-entry-gates) on level, reset, grand reset, and master reset. The vanilla brackets below apply when every `DevilSquareTier<N>...` key in Event.dat is `-1`; setting any bound activates configured brackets for every tier and syncs them to the client (entry dialog and Invitation of the Devil Square tooltip).

**Vanilla fallback brackets:**

| Tier | DK / BK / ME / MU / SM / GM / ELF / MUSE / HE / SUM / BS Level | MG / DL / RF Level                     |
| ---- | -------------------------------------------------------------- | -------------------------------------- |
| 0    | 15 - 130                                                       | 10 - 110                               |
| 1    | 131 - 180                                                      | 111 - 160                              |
| 2    | 181 - 230                                                      | 161 - 210                              |
| 3    | 231 - 280                                                      | 211 - 260                              |
| 4    | 281 - 330                                                      | 261 - 310                              |
| 5    | 331 - MaxLevel                                                 | 311 - MaxLevel                         |
| 6    | Any character with 2nd or later Master (ChangeUp >= 2)         | Any character with 2nd or later Master |

Entry requires the Invitation of the Devil Square ticket (item 14, 19, whose item-level equals tier + 1) or a Premium ticket (item 13, 46). Characters can only enter the tier matching their own bracket. Set `DevilSquareMasterAnyTier = 1` to let master characters pick any tier; set `DevilSquarePerIpCharCap` to limit alt-stacking from one IP.

During the round players kill monsters to accumulate a score. At the end of the round players are ranked by score and granted XP and money from the rank-indexed tables below.

## Sections

Sections are numbered 0-4 and terminated with `end`.

### Section 0 - Timing

```
0
//WarningTime   NotifyTime   EventTime   CloseTime
5               1            20          4
end
```

| Column        | Unit    | Effect                                                                                      |
| ------------- | ------- | ------------------------------------------------------------------------------------------- |
| `WarningTime` | minutes | Pre-event entry window during which minute-countdowns are broadcast and tickets can be used |
| `NotifyTime`  | minutes | Short entry-open announcement window                                                        |
| `EventTime`   | minutes | Main round duration                                                                         |
| `CloseTime`   | minutes | Post-event hold before survivors are teleported out and the instance is cleaned             |

### Section 1 - Schedule

```
1
//Year   Month   Day   DoW   Hour   Minute   Second
*        *       *     *     0      30       0
...
end
```

The shipped template runs 12 times per day at 30 minutes past every even hour (00:30, 02:30, ..., 22:30).

| Column   | Type        | Meaning                                |
| -------- | ----------- | -------------------------------------- |
| `Year`   | int or `*`  | 4-digit year                           |
| `Month`  | 1-12 or `*` | Month                                  |
| `Day`    | 1-31 or `*` | Day of month                           |
| `DoW`    | 1-7 or `*`  | Day of week (1 = Sunday, 7 = Saturday) |
| `Hour`   | 0-23 or `*` | Hour                                   |
| `Minute` | 0-59 or `*` | Minute                                 |
| `Second` | 0-59 or `*` | Second                                 |

### Section 2 - XP Reward Table

Per-tier XP indexed by rank. Columns 1-10 correspond to the top 10 ranks (rank 1 is the top scorer). Players outside the top 10 receive nothing from this table.

```
2
//Level   RewardExperience1 ... RewardExperience10
0         6000 4000 4000 2000 2000 2000 1000 1000 1000 1000
...
6         26000 24000 24000 22000 22000 22000 20000 20000 20000 20000
end
```

The first column is the tier (`Level`, 0-6). The remaining 10 columns are the XP awarded to the 1st through 10th ranked players in that tier. The final granted XP is further multiplied by the account-level event-XP rate from [Common.dat](/docs/gameserver/common-dat.md).

### Section 3 - Money Reward Table

Same structure as section 2 but for zen. Columns 1-10 are the money awarded to the 1st through 10th ranked players.

```
3
//Level   RewardMoney1 ... RewardMoney10
0         30000 25000 25000 20000 20000 20000 15000 15000 15000 15000
...
6         150000 140000 140000 120000 120000 120000 90000 90000 90000 90000
end
```

### Section 4 - Coin Rewards

```
4
//Level   WC   WP   GP
0         0    0    0
...
6         0    0    0
end
```

Per-tier cash-coin reward. Four columns: the tier number followed by WCoin (WC), WCoin-Premium (WP), Goblin Point (GP). All zero in the shipped template.

## Important Behavior

* First-wave monsters spawn exactly once at round start. Earlier builds could double-spawn the opening wave, leaving roughly twice the intended monster count on the map for tier 1; the shipped build spawns each wave a single time.

## Cross-File Dependencies

| Value                  | Related in                                                                              |
| ---------------------- | --------------------------------------------------------------------------------------- |
| Enable flag            | [Event.dat](/docs/gameserver/event-dat.md#devil-square) `DevilSquareEvent`              |
| Max users per instance | [Event.dat](/docs/gameserver/event-dat.md#devil-square) `DevilSquareMaxUser`            |
| Entry ticket recipes   | [ChaosMix plugin](/docs/data/plugins/chaosmix/recipes.md) (Keynote of Illusion recipes) |
| PK access              | [Common.dat](/docs/gameserver/common-dat.md#pk-event-access) `PkCanEnterDS`             |
| Instance map rules     | [MapManager.xml](/docs/data/mapmanager.md) entries for maps 9 and 32                    |
| Arena monster stats    | [Monster.txt](/docs/data/monster/monster.md)                                            |

## Common Issues

* **Players joined but timer never started** - `DevilSquareMaxUser` too high for current participant count, preventing the round from starting, or `EventTime` is `0`.
* **Only the top scorers get XP/money** - by design: sections 2 and 3 are rank-indexed and only ranks 1-10 receive rewards. TODO: verify whether ranks beyond 10 receive anything from section 4 (coin rewards).
* **Ticket-holders cannot enter** - the entry window driven by `NotifyTime` in section 0 has already closed, or the player's level is outside the bracket for the tier they attempted to enter.
* **Rewards scale strangely across ranks** - the shipped template is front-loaded: rank 1 receives substantially more than ranks 2-3, which in turn receive more than ranks 4-6, and so on.
