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

# ChaosMix (overview)

The ChaosMix plugin owns almost every recipe in the Chaos Machine. Three XML files define the full system: formulas for computing success rate, option presets, and the recipe list itself.

## File Location

```
Data/Plugins/Items/ChaosMix/
├── ChaosMix_Formulas.xml
├── ChaosMix_Options.xml
└── ChaosMix_Recipes.xml
```

All three loaded once at GameServer startup. Plugin supports hot reload via admin command.

## Authority Over Chaos Mix

The plugin is the sole authority for the Chaos Machine. Every recipe, rate, and item filter comes from these three XML files. There is no legacy fall-through: if no recipe matches the submitted `MixType` + `MixIndex`, the server refuses the mix (the client shows "wrong combination", nothing is consumed). The old hardcoded chaos system no longer supplies rates, recipes, or a fallback for any mix.

When a recipe matches, the plugin owns the mix end-to-end: input validation, zen cost, success rate, the success/fail roll, and the reward. Talisman of Luck / Elemental Talisman bonuses and the item Luck option bonus are applied inside the plugin, so the rate the player sees in the chaos box widget is the same rate the server rolls against (post-tax included; identical between display and execute).

The legacy `GameServerInfo - ChaosMix.dat` file is **no longer shipped or read**. Recipes that previously lived there (Devil Square / Blood Castle / Illusion Temple entry tickets, Plus Item Mix, wing mixes, Fenrir mixes, Lucky Item Create/Refine, etc.) all moved into [`ChaosMix_Recipes.xml`](/docs/data/plugins/chaosmix/recipes.md). The old per-mix rate keys are no longer the source of truth for any recipe; rates live in [`ChaosMix_Formulas.xml`](/docs/data/plugins/chaosmix/formulas.md).

The plugin serves both the chaos-box NPC dialog and the trainer NPC dialog; recipes can be opened from either context without extra configuration.

Every chaos mix interface reads the same recipe data, so all of them (chaos machine, chaos cards, cherry blossom, Lucky Item create/refine, and the rest) display the zen cost and success rate before the player combines.

{% hint style="info" %}
`MixID="51"` (Lucky Item Create) and `MixID="52"` (Lucky Item Refine) are now ordinary plugin recipes shipped in `ChaosMix_Recipes.xml`, not engine exceptions. They route through the plugin like every other mix. See [Recipes - MixID Ranges](/docs/data/plugins/chaosmix/recipes.md#recommended-mixid-ranges) for which values are safe to use for new custom recipes.
{% endhint %}

## System Components

| File                                                              | Purpose                                                                                                            |
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [ChaosMix\_Recipes.xml](/docs/data/plugins/chaosmix/recipes.md)   | The recipes themselves, grouped by NPC / mix context                                                               |
| [ChaosMix\_Options.xml](/docs/data/plugins/chaosmix/options.md)   | `MixOption` / `CharmOption` / `ChaosCharmOption` presets that gate which items the player may put in the chaos box |
| [ChaosMix\_Formulas.xml](/docs/data/plugins/chaosmix/formulas.md) | Success-rate expressions each recipe can reference by `Id`                                                         |

For admin reading order, start with [recipes](/docs/data/plugins/chaosmix/recipes.md) (what mixes exist), then [options](/docs/data/plugins/chaosmix/options.md) (what filters apply), then [formulas](/docs/data/plugins/chaosmix/formulas.md) (how rates are computed). Recipes reference formulas and options by `Id`. Plugin load order at startup is the inverse: Formulas first, Options second, Recipes last, so cross-references resolve correctly.

## MixType Reference

Each recipe carries a `MixType` that identifies the NPC or mix context the client was using when it submitted the mix:

| MixType | Context                     |
| ------- | --------------------------- |
| `0`     | Goblin (normal recipes)     |
| `1`     | Goblin (chaos item recipes) |
| `2`     | Goblin (item+380 recipes)   |
| `3`     | Castle Senior               |
| `4`     | Trainer                     |
| `5`     | Osbourne                    |
| `6`     | Jerridon                    |
| `7`     | Elpis                       |
| `8`     | Chaos Card                  |
| `9`     | Cherry Blossom              |
| `10`    | Extract Seed                |
| `11`    | Seed Sphere                 |
| `12`    | Attach Socket               |
| `13`    | Detach Socket               |

The client chooses `MixType` based on which NPC dialog or button opened the chaos box. `MixIndex` is the row within that `MixType` (a 0-based slot).

## Logging

Every mix attempt is written to the ChaosMix log so admins can audit and reproduce transactions. Logs are written to `GameServer/ChaosMix/YYYY-MM-DD.txt` (one file per day), gated by `WriteChaosMixLog` in [Common.dat](/docs/gameserver/common-dat.md#log-settings) (default `1` = on).

Each mix records the account and character name, the `MixID` / `MixType` / `MixIndex`, the computed success rate and zen cost, the outcome, and a full dump of every item that was in the chaos box at submission time (category, index, level, durability, stack count, serial, and all options). This is enough to reconstruct exactly what the player put in and what the mix decided.

The AxiomEditor **ChaosMix logs** parser (Beta) reads these daily files and presents per-user and per-character transaction history, so you do not have to read the raw text logs by hand.

{% hint style="info" %}
If `WriteChaosMixLog` is `0`, no mix transactions are recorded and the AxiomEditor parser has nothing to read. Leave it on if you want an audit trail.
{% endhint %}

## Hot Reload

Admins can reload ChaosMix XML without restarting the GameServer via the plugin's admin command. Reload clears all three maps (formulas, options, recipes) and re-parses the files in order: formulas first, options second, recipes last. If any file is missing or malformed, that file's map stays empty after reload and a warning is logged; the plugin will still serve whatever parsed successfully. Reload does not block in-flight mixes, so trigger it during low-traffic windows.

## Cross-File Dependencies

| Setting                              | Related in                                                                                |
| ------------------------------------ | ----------------------------------------------------------------------------------------- |
| Mix log toggle                       | [Common.dat](/docs/gameserver/common-dat.md#log-settings) `WriteChaosMixLog`              |
| Announce on +15                      | [Custom.dat](/docs/gameserver/custom-dat.md#announce-chaos-mix) `AnnounceChaosMix`        |
| Roll simulation                      | [Custom.dat](/docs/gameserver/custom-dat.md) `ChaosMixSimEnable`, `ChaosMixSimIterations` |
| Source item definitions              | [Item.xml](/docs/data/item/item.md)                                                       |
| Reward items (when `ItemBagId != 0`) | [EventItemBag](/docs/data/eventitembag.md)                                                |

## Roll Simulation

For tuning success rates before going live, the plugin can simulate a batch of rolls each time a real mix is performed and log the observed win rate against the configured rate. This is a diagnostic aid; it does not change the actual mix outcome, which is still a single roll.

| Key                     | File       | Type | Range | Default | Effect                                                                                                                                                        |
| ----------------------- | ---------- | ---- | ----- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ChaosMixSimEnable`     | Custom.dat | int  | 0-1   | `0`     | `0` = off. `1` = on each performed mix, run the simulation below and write the result to the ChaosMix log                                                     |
| `ChaosMixSimIterations` | Custom.dat | int  | 1+    | `10000` | Number of simulated rolls to run against the mix's computed success rate. The log line reports how many of the N rolls succeeded and the resulting percentage |

Turn `ChaosMixSimEnable` off in production - it adds a log line and a batch of rolls to every mix.
