ChaosMixFormulas.xml
Named formulas for computing a recipe's success rate. Each formula has a unique Id and a sequence of tokens evaluated as a postfix expression. Recipes pick a formula by Id in their <SuccessRate FormulaId="..."/>.
File Location#
Data/Plugins/Items/ChaosMix/ChaosMix_Formulas.xml
Loaded once at GameServer startup. Hot reloadable via the ChaosMix plugin admin command.
Schema#
<ChaosMixFormulas>
<Formula Id="..." MaxRate="...">
<Token Op="..." />
<Token Op="..." Value="..." />
</Formula>
</ChaosMixFormulas>
Formula Attributes#
| Attribute | Type | Effect |
|---|---|---|
Id | int | Unique formula identifier. Recipes reference this |
Name | string | Optional label for readability |
MaxRate | int 0-100 | Hard ceiling on the computed success rate. Engine clamps the final number to this |
Token Operations#
Tokens form an infix expression, read left to right by a recursive-descent evaluator with standard precedence: MUL / DIV bind tighter than ADD / SUB, and LP / RP group sub-expressions. Each operand token (constants and item-derived values) sits between or around the arithmetic operators, exactly the way the expression would read in code.
Operand tokens#
| Op | Effect |
|---|---|
NUMBER | The literal number supplied in the Value attribute |
MAXRATE | The formula's own MaxRate value |
LUCKOPT | 25 if any item in the chaos box has the Luck option, 0 otherwise |
ITEM | Sum of the BuyMoney of every item currently in the chaos box |
WING | Sum of the BuyMoney of chaos-box items whose item section is 12 (wings/capes) |
EXCELLENT | Sum of the BuyMoney of chaos-box items that carry any Excellent option |
EQUIP | Sum of the BuyMoney of chaos-box items in equipment sections (0..11) |
SET | Sum of the BuyMoney of chaos-box items flagged as Set (Ancient) items |
LEVEL1 | The +level of the item that matches the recipe's source index 0. If nothing in the box matches source 0 (for example the box is empty), this is 0 |
NONJEWELITEM | Sum of the BuyMoney of chaos-box items excluding Bless/Soul/Life/Creation/Guardian jewels in section 14 |
Operator tokens#
| Op | Effect |
|---|---|
ADD | Infix + |
SUB | Infix - |
MUL | Infix * |
DIV | Infix / (float division; divisor of 0 leaves the running result unchanged) |
LP / RP | Open/close parenthesis - genuinely affect evaluation order, not just readability |
INT | Truncation function. Must be followed by an LP ... RP group; the enclosed sub-expression is truncated toward zero |
The final numeric result is clamped to MaxRate (and then to 100) by the calling code in the recipe layer before use.
Example Formulas#
<Formula Id="1" MaxRate="90">
<Token Op="MAXRATE" />
</Formula>
Evaluates to MaxRate, i.e. 90. Final rate is a flat 90%.
<Formula Id="2" MaxRate="75">
<Token Op="NUMBER" Value="50" />
<Token Op="ADD" />
<Token Op="LUCKOPT" />
</Formula>
Evaluates to 50 + LUCKOPT. LUCKOPT is 25 when any chaos-box item has Luck and 0 otherwise, so the result is 75 or 50. Both values already sit at or below MaxRate=75.
<Formula Id="10" MaxRate="90">
<Token Op="INT" />
<Token Op="LP" />
<Token Op="WING" />
<Token Op="DIV" />
<Token Op="NUMBER" Value="4000000" />
<Token Op="RP" />
<Token Op="ADD" />
<Token Op="INT" />
<Token Op="LP" />
<Token Op="EXCELLENT" />
<Token Op="DIV" />
<Token Op="NUMBER" Value="40000" />
<Token Op="RP" />
</Formula>
Evaluates to INT(WING / 4000000) + INT(EXCELLENT / 40000), clamped to MaxRate=90. Each INT(...) truncates its parenthesised sub-expression toward zero before the outer ADD runs.
Cross-File Dependencies#
| Attribute | Related in |
|---|---|
Id | Referenced by ChaosMix_Recipes.xml <SuccessRate FormulaId="..."/> |
| Parent plugin overview | ChaosMix plugin README |
Common Issues#
- Recipe always fails - formula produces 0 (missing tokens, wrong token order, or
MaxRate=0). Remember the tokens are infix: an orphan operator at the start or end yields 0 - Recipe's cap does not match the formula - the recipe's own
<SuccessRate MaxRate="..."/>overrides the formula'sMaxRatewhenever the recipe sets it to anything other than100. Leave the attribute off the recipe to inherit the formula's cap LUCKOPTtoken has no effect - no item in the chaos box has the Luck option.LUCKOPTreads the combined Luck flag across the box, not a single sourceLEVEL1evaluates as0- nothing in the chaos box matches the recipe's source index0at the moment of evaluationINTseems to do nothing -INTmust be immediately followed by anLP...RPgroup; without the parenthesis it is a no-op factor- Edits to
MaxRatenot applying - formulas are keyed byId. Keep the sameIdwhen editing and reload the plugin