Formula Reference
Formula is the custom notation used by RPG Wizard G to compute values inside the game. It is used in virtually every situation involving game calculations, including damage calculation, hit judgment, level-up values, conditional branches, and drop rates.
TIP
You can view the same content inside the editor by pressing the "Formula Help" button at the bottom of each tab (Home, Event, Char, etc.).
What is a Formula?
What formulas can do
A formula is an expression that combines values inside the game. Typical uses include:
- Damage calculation: "Attacker's STR × 2 − target's DEF"
- Hit judgment: "A random number from 0 to 99; if under 95, the attack hits"
- Conditional branches: "If variable
flag_1is 1, go to a special event" - Drop rates: "A random number; if under 30, drop an item"
The three elements of a formula
A formula is built by joining three elements with dots .:
| Position | Element | Meaning | Example |
|---|---|---|---|
| 1st | Reference | "Whose" value to use | SELF / USER / TGT |
| 2nd | Parameter | "What" value | HP / MP / STR |
| 3rd | Detail | "How to look at it" | MAX (maximum) / NOW (current) / RATE (ratio) |
Examples:
SELF.HP.MAX → own HP maximum
TGT.STR.NOW → target's current STR
USER.MP.RATE → user's MP ratio (0.0 to 1.0)WARNING
What "whose" means depends on where you write the formula. See Meaning by Location for details.
Basic Syntax
Numbers and arithmetic
Just write arithmetic as you normally would.
| Expression | Result | Note |
|---|---|---|
10 + 5 | 15 | Addition |
20 * 2 | 40 | Multiplication |
100 / 3 | 33.33... | Division (may be fractional) |
15 - 8 | 7 | Subtraction |
(10 + 5) * 2 | 30 | Parentheses control the order |
Comparison
Used in conditional branches and hit judgments, among others. The result is true or false.
| Expression | Result | Meaning |
|---|---|---|
5 > 3 | true | Greater than |
10 == 10 | true | Equal (use ==, not =) |
5 != 3 | true | Not equal |
100 >= 100 | true | Greater than or equal |
50 <= 40 | false | Less than or equal |
Logic
For combining conditions:
| Expression | Result | Meaning |
|---|---|---|
5 > 3 and 10 < 20 | true | AND (true only if both are true) |
5 > 3 or 10 > 20 | true | OR (true if either is true) |
not (5 > 3) | false | NOT (invert) |
Ternary (switch between values by condition)
Form:
condition ? value_if_true : value_if_false| Expression | Result | Meaning |
|---|---|---|
10 > 5 ? 100 : 0 | 100 | Condition is true, so the true-value is returned |
5 > 10 ? 100 : 0 | 0 | Condition is false, so the false-value is returned |
SELF.HP.RATE < 0.3 ? 200 : 100 | 200 or 100 | 200 if HP ratio is under 30%, otherwise 100 |
Detail property (.MAX / .NOW / .RATE / omitted)
After the reference and parameter, you can add a detail:
| Notation | Meaning | Example (HP is 60 of 100) |
|---|---|---|
.MAX | Maximum value | 100 |
.NOW | Current value | 60 |
.RATE | Ratio (current / max) | 0.6 |
| Omitted | Same as .NOW | 60 |
For parameters without a current value (such as STR / DEF / AGI, which usually do not fluctuate), .NOW returns the same value as .MAX.
Examples:
SELF.HP.MAX → own HP maximum
SELF.HP.NOW → own HP current value
SELF.HP.RATE → own HP ratio (0.0 to 1.0)
SELF.HP → omitted = .NOW (current value)Rounding (how decimals are handled)
Formulas are evaluated internally as floating-point numbers, but they are automatically converted to integers at the moment they are added to / subtracted from a parameter.
Rounding rule: round the absolute value up, then restore the sign (sign * ceil(abs)).
| Calculation result | After rounding | Explanation |
|---|---|---|
+3.4 | +4 | abs 3.4 ceils to 4, sign (+) restored |
-2.6 | -3 | abs 2.6 ceils to 3, sign (-) restored |
+0.1 | +1 | Any positive amount becomes 1 (so damage never becomes 0) |
-0.1 | -1 | Same |
0 | 0 | No change |
Where rounding occurs (places where parameters are added / subtracted):
| Location | Target |
|---|---|
| Item / skill: target parameter value | Damage / healing |
| Item: user / item consumption value | MP cost, durability loss, etc. |
| State effect: current value add | Poison damage, healing state, etc. |
| State effect: max value add | STR boost, DEF debuff, etc. |
| Class: level-up growth value | STR / INT increase per level |
| Enemy drop: value | EXP / GOLD |
| Shop: payment / income | Purchase cost, sell price |
Where rounding does NOT occur:
| Location | Description |
|---|---|
| Judgment formulas (hit, trigger, appearance) | Result is only true / false |
Variable assignment (Assign Variable, is_calc=on) | Fractional values are stored as-is (user decides how to use them) |
Rounding option on the "Change Parameter" event content
The "Change Parameter" event content offers an additional rounding mode separate from the automatic one above.
| Mode | Behavior | Example: result is 3.5 |
|---|---|---|
| None | Keep as fractional | 3.5 |
| Ceil | Round up | 4 |
| Floor | Round down | 3 |
| Round | Half-up round | 4 |
When passing through a variable before adding to a parameter
Results calculated via "Assign Variable" are stored in the variable as-is (fractional). When later used in a parameter addition, they are automatically rounded at that moment.
| Step | Example | Variable contents | Effect on parameter |
|---|---|---|---|
| 1. Assign calculation to variable | Assign Variable {var_1} = 100 / 3 | var_1 = 33.33 (fractional) | None |
| 2a. Used by Change Parameter (rounding=None) | Change Parameter adds {var_1} | Still 33.33 | Adds 33.33 (float) to parameter |
| 2b. Used by Change Parameter (rounding=Ceil, etc.) | Same | Still 33.33 | Adds per rounding mode (34 / 33 etc.) |
| 2c. Used in item value, drop, etc. | tgt_param.value={var_1} | Still 33.33 | Automatic integer conversion → +34 (abs ceil) |
TIP
- Even if your formula contains division (
100 / 3= 33.33), parameter addition sites round automatically, so there is nothing to worry about - To avoid "damage becomes 0" problems: since the rule is abs-ceil, even
0.1becomes 1 (this is intentional ✅) - Displayed values (HP bar numbers, etc.) also use ceil-rounded integers, so internal data and the display always match
- To chain complex calculations while keeping fractional values in a variable, use "Assign Variable" → auto-rounding at the addition site
Meaning by Location (Important)
What SELF / USER / TGT refer to depends on where the formula is written. This section organizes the meaning per location.
Location summary (reverse lookup)
A quick list of "what is available at the location you are writing in":
| Location | SELF refers to | USER refers to | TGT refers to | Extra references |
|---|---|---|---|---|
| Item: value / hit judgment | That item | The character using the item | Target character or group | PARTY / TROOP / MEMS / OPPS / TGTS |
| Item: consumption value | That item | The character using the item | (unused) | PARTY / TROOP / MEMS / OPPS |
| State: max / current value add | That character | That character | That character (same as SELF) | PARTY / TROOP / MEMS / OPPS |
| Class: level-up growth value | The character that leveled up | Same as SELF | Same as SELF | PARTY / TROOP / MEMS / OPPS |
| Enemy: action pattern (rate / determine) | The enemy itself | Same as SELF | The whole party group | PARTY / TROOP / MEMS / OPPS |
| Enemy: drop (rate / value) | The defeated enemy itself | Same as SELF | The whole party group | PARTY / TROOP / MEMS / OPPS |
| System: first strike / surprise / escape | The whole party group | Same as SELF | The whole enemy group | PARTY / TROOP / MEMS / OPPS |
| System: action order | Each character (evaluated in turn) | Same as SELF | (unused) | ACT_ITEM (the item that character selected) |
| Event: conditional branch / next event condition | The whole party group | Same as SELF | (unused) | PARTY / TROOP / MEMS / OPPS / LOCAL / variables |
| Event: change parameter (character target) | The target character | Same as SELF | (unused) | PARTY / TROOP / MEMS / OPPS |
Special references are available everywhere:
- PARTY / TROOP: Shared parameters of the party / enemy group (absolute reference)
- MEMS / OPPS / CHARS / TGTS: Aggregations over all members (details)
- MEM_0 / OPP_0 etc.: Reference to the N-th member (details)
{variable_name}: Variable value (details)- LOCAL.A – LOCAL.Z: Local flags (details)
{@char.KEY}etc.: Name embedding (details)
Item / skill effect (Item tab "Value" / "Hit Judgment")
What the references point to:
| Reference | Points to |
|---|---|
| SELF | The item itself (usually 0 since items normally do not have STR, etc.) |
| USER | The character using the item |
| TGT | The target character or group |
Examples:
| Location | Expression | Result / Behavior |
|---|---|---|
| Target parameter HP value | -(USER.STR.MAX * 2 - TGT.DEF.MAX) | HP decreases by (user's STR × 2 − target's DEF) |
| Target parameter HP hit judgment | randi() % 100 < 80 | 80% chance of hitting |
| Target parameter HP value | -TGT.HP.MAX * 0.2 | Deal 20% of target's max HP as damage |
| Target parameter HP value | -USER.INT.MAX * 3 / TGTS.COUNT | Full-group attack whose power is split by target count |
WARNING
To use "the user's value", use USER. SELF refers to the item itself, so unless the item carries a parameter like POWER, it will be 0.
Item consumption (Item tab "User Consumption" / "Item Consumption")
What the references point to:
| Reference | Points to |
|---|---|
| SELF | The item itself |
| USER | The character using the item |
Consumption values are written as positive numbers (they are subtracted automatically).
Examples:
| Location | Expression | Result / Behavior |
|---|---|---|
| User consumption MP value | 10 | Consume 10 MP |
| User consumption MP value | USER.MP.MAX * 0.1 | Consume 10% of the user's max MP |
| Item consumption DURABILITY value | 1 | Reduce the item's durability by 1 (requires a DURABILITY parameter) |
State effect (State tab "Max Value Add" / "Current Value Add")
What the references point to:
| Reference | Points to |
|---|---|
| SELF | The character carrying the state |
| USER | Same as SELF (the character itself) |
| TGT | Same as SELF (the character itself) |
Examples:
| Location | Expression | Result / Behavior |
|---|---|---|
| Current value add HP (poison) | -SELF.HP.MAX * 0.05 | 5% of max HP as damage per turn |
| Max value add STR (STR boost) | 10 | +10 STR |
| Current value add HP (curse) | -SELF.LEVEL.MAX * 2 | HP decrease equal to level × 2 |
Class level-up growth (Class tab "Growth Value")
What the references point to:
| Reference | Points to |
|---|---|
| SELF | The character that leveled up |
| USER | Same as SELF (the character itself) |
| TGT | Same as SELF (the character itself) |
Examples:
| Location | Expression | Result / Behavior |
|---|---|---|
| Growth HP value | SELF.LEVEL.MAX * 3 | HP increase of level × 3 |
| Growth STR value | 1 | +1 STR per level |
| Growth AGI value | SELF.LEVEL.MAX / 2 | +1 every 2 levels (integer division) |
Enemy action pattern (Enemy tab "Rate" / "Determine")
What the references point to:
| Reference | Points to |
|---|---|
| SELF | The enemy itself |
| USER | Same as SELF (the enemy itself) |
| TGT | The whole party group |
| GROUP | The enemy group (TROOP, own side) |
| OPP_GROUP | The party group (PARTY, opponent side) |
| MEMS | All members of the enemy group (own side) |
| OPPS | All party members (opponent side) |
Examples for Determine (trigger condition):
| Location | Expression | Result / Behavior |
|---|---|---|
| Determine | SELF.HP.RATE < 0.3 | Triggers when the enemy's own HP is below 30% |
| Determine | {turn_count} % 3 == 0 | Triggers every 3 turns (requires a turn_count variable) |
| Determine | OPPS_AVG.HP.RATE < 0.25 | Triggers when party average HP is under 25% (finisher) |
| Determine | PARTY.HP.RATE < 0.25 | Equivalent to the above (explicit via absolute PARTY reference) |
Examples for Rate (trigger probability):
| Location | Expression | Result / Behavior |
|---|---|---|
| Rate | 100 | Always triggers (100%) |
| Rate | 50 | 50% probability |
| Rate | SELF.HP.RATE < 0.5 ? 100 : 0 | Always trigger when HP ≤ 50%, otherwise never |
Common mistake
Writing MEMS_AVG.HP.RATE < 0.25 in an enemy action pattern does not target the party, because MEMS refers to the enemy group on that side. To target the party, use OPPS_AVG or PARTY.
Enemy drop (Enemy tab "Drop Rate" / "Drop Value")
What the references point to:
| Reference | Points to |
|---|---|
| SELF | The defeated enemy itself |
| USER | Same as SELF (the enemy itself) |
| TGT | The whole party group |
Examples:
| Location | Expression | Result / Behavior |
|---|---|---|
| Drop rate | 20 | 20% drop chance |
| Drop value (EXP) | SELF.HP.MAX * 2 | EXP = enemy's max HP × 2 |
| Drop value (GOLD) | 50 - OPPS_AVG.LEVEL.MAX * 3 | Larger gold reward for lower-level parties |
System battle calculation (System tab "First Strike" / "Surprise" / "Escape")
What the references point to:
| Reference | Points to |
|---|---|
| SELF | The whole party group |
| USER | Same as SELF |
| TGT | The whole enemy group |
| PARTY | Absolute reference (same result as SELF) |
| TROOP | Absolute reference (same result as TGT) |
Examples:
| Location | Expression | Result / Behavior |
|---|---|---|
| First strike judgment | MEMS_AVG.AGI.MAX > OPPS_AVG.AGI.MAX | First strike if party's average AGI exceeds enemies' |
| First strike judgment | randi() % 100 < 50 + (MEMS_AVG.AGI.MAX - OPPS_AVG.AGI.MAX) * 5 | Base 50% + AGI difference × 5% |
| Escape judgment | randi() % 100 < MEMS_MAX.AGI.MAX * 100 / OPPS_MAX.AGI.MAX | Escape success rate from AGI ratio |
System battle calculation (System tab "Action Order")
What the references point to:
| Reference | Points to |
|---|---|
| SELF | Each character (evaluated for every party member and enemy) |
| ACT_ITEM | The item that character selected (special reference available only here) |
Characters act in descending order of the returned value.
Examples:
| Location | Expression | Result / Behavior |
|---|---|---|
| Action order | SELF.AGI.MAX | Order by AGI (simple) |
| Action order | SELF.AGI.MAX + ACT_ITEM.PRIORITY.MAX | AGI plus the chosen item's priority |
| Action order | SELF.AGI.MAX * (0.9 + randf() * 0.2) | AGI with ±10% randomness |
Event condition expressions (Event tab "Conditional Branch" / "Move to Event condition" / "Assign Variable is_calc=on")
What the references point to:
| Reference | Points to |
|---|---|
| SELF | The whole party group (default) |
| USER | Same as SELF |
| TGT | (unused) |
At this location, the stars of the show are {variable_name} and LOCAL.A through LOCAL.Z.
Examples for Conditional Branch / Move to Event condition:
| Location | Expression | Result / Behavior |
|---|---|---|
| Conditional branch | {counter_1} >= 10 | True when variable counter_1 is 10 or more |
| Conditional branch | {flag_1} == 1 | True when variable flag_1 is 1 |
| Conditional branch | LOCAL.A | True when local flag A is true |
| Conditional branch | PARTY.GOLD >= 100 | True when gold is 100 or more |
| Conditional branch | MEMS_AVG.LEVEL.MAX >= 10 | True when average party level is 10 or more |
Examples for Assign Variable (is_calc=on):
| Location | Expression | Result / Behavior |
|---|---|---|
Assign Variable counter_1 | {counter_1} + 1 | Current value + 1 (increment) |
Assign Variable gold_half | PARTY.GOLD / 2 | Assigns half of the gold |
Assign Variable max_lv | MEMS_MAX.LEVEL.MAX | Assigns the highest party level |
Event Change Parameter ("Change Parameter" event content)
What the references point to (by target type):
| Target type | SELF refers to | USER refers to |
|---|---|---|
| Character target (Selected Member / Party All etc.) | The target character | Same as SELF |
| Item target | The whole party group | Same as SELF |
| Group (party-shared) target | The whole party group | Same as SELF |
Examples:
| Location | Expression | Result / Behavior |
|---|---|---|
| Char target HP value (Add) | SELF.HP.MAX * 0.5 | Heal 50% of max HP |
| Char target EXP value (Add) | 100 | +100 EXP |
| Group target GOLD value (Set) | 99999 | Set party's gold to 99999 |
Party / Enemy Group Aggregation
You can compute "sum", "average", "max", and "min" over all party members or all enemies.
MEMS (all members of own group)
| Expression | Result / Behavior |
|---|---|
MEMS.HP.MAX | Sum of all members' max HP |
MEMS_AVG.HP.MAX | Average of all members' max HP |
MEMS_MAX.LEVEL.MAX | Maximum level among all members (strongest member) |
MEMS_MIN.HP.NOW | Minimum current HP among all members (closest to death) |
WARNING
The meaning of "own group" depends on where you write the formula (see Location summary):
- Party-side formulas:
MEMSmeans party members - Enemy action patterns:
MEMSmeans enemy group members
OPPS (all members of the opposing group)
| Expression | Result / Behavior |
|---|---|
OPPS.HP.NOW | Sum of all enemies' current HP (total remaining HP) |
OPPS_MIN.HP.NOW | The lowest current HP among all enemies |
TGTS (all targets)
When there are multiple targets (e.g. full-group attacks), aggregates over all targets:
| Expression | Result / Behavior |
|---|---|
TGTS.HP.NOW | Sum of current HP of all targets |
TGTS_AVG.DEF.MAX | Average DEF of all targets |
CHARS (all party members + all enemies)
Aggregates over all characters in battle:
| Expression | Result / Behavior |
|---|---|
CHARS.HP.NOW | Sum of party + enemies' HP |
Aggregation methods (_AVG / _MAX / _MIN)
| Suffix | Meaning | Example (party of 3 with max HP of 100 / 80 / 60) |
|---|---|---|
none (MEMS, etc.) | Total | MEMS.HP.MAX → 240 |
_AVG | Average | MEMS_AVG.HP.MAX → 80 |
_MAX | Maximum | MEMS_MAX.HP.MAX → 100 |
_MIN | Minimum | MEMS_MIN.HP.MAX → 60 |
Count (.COUNT)
Append .COUNT to an aggregation reference to get the number of members.
| Expression | Result / Behavior |
|---|---|
MEMS.COUNT | Number of own-group members |
OPPS.COUNT | Number of enemies |
TGTS.COUNT | Number of targets (all members for a full-group attack) |
CHARS.COUNT | Total number of party + enemies |
N-th Member Reference
You can refer directly to the N-th character of the party or enemies. Numbers are 0-indexed.
| Reference | Points to |
|---|---|
MEM_0 | 0th (first) character of own group |
MEM_1 | 1st character of own group |
MEM_2 | 2nd character of own group |
OPP_0 | 0th character of enemy group |
OPP_1 | 1st character of enemy group |
Examples:
| Expression | Result / Behavior |
|---|---|
MEM_2.HP.NOW | Current HP of the 3rd party member (0-indexed) |
OPP_0.HP.RATE | HP ratio of the 1st enemy |
When the number exceeds the party size
It is automatically clamped to the last member. For example, if the party has 2 members, MEM_5 refers to the last one (MEM_1).
Variables
How to write {variable_name}
Variables created in the Variable tab can be embedded in a formula. Enclose the name in curly braces: {variable_name}.
| Expression | Result / Behavior |
|---|---|
{counter_1} | Returns the current value of variable counter_1 |
{counter_1} >= 10 | True if counter_1 is 10 or more (for conditional branches) |
{counter_1} + 1 | Returns counter_1 + 1 (for Assign Variable with is_calc=on) |
Where to define variables
Create a new variable in the Variable tab. Any name is allowed. Examples from the sample data:
| Variable name | Use |
|---|---|
counter_1 | Integer |
flag_1 | Flag (0 / 1 for OFF / ON) |
name_1 | Text |
How to set a variable
Use the "Assign Variable" event content.
| Operation mode | Behavior |
|---|---|
| Set | Store the given value as-is |
| Add | Add to the current value |
| Sub | Subtract from the current value |
Special variables
| Variable | Contents |
|---|---|
{c.time} | Play time (string in the format hh:mm:ss) |
Variable initial value and type handling
Immediately after creation, a variable's contents are the empty string "". When the game is reset (back to title), they also return to the empty string.
When used in a formula, variables are handled as follows depending on their value:
| Variable contents | Treatment in a formula | Example {var} + 1 | Example {var} == 1 |
|---|---|---|---|
"" (empty, initial) | Treated as 0 | 0 + 1 = 1 | 0 == 1 = false |
"5" (numeric string) | Treated as 5 | 5 + 1 = 6 | 5 == 1 = false |
"1+1" (formula string) | Expanded as a formula | 1+1 + 1 = 3 | 1+1 == 1 = false |
"hello" (text) | Treated as 0 on error | 0 | false |
Recommended for flag variables
- Explicitly set
0or1with the "Assign Variable" event content - You can write
{flag_1} == 1(ON check) or{flag_1} != 1(OFF check) in a conditional branch - The initial state (empty string) is automatically treated as 0, so
{flag_1} != 1evaluates to true (initial state is treated as OFF)
In "Show Text" event content, the variable value is displayed as-is:
- Displaying an empty-string variable → nothing shown ("Welcome,
{name_1}" → "Welcome, ") - Text display does not apply the formula's "treat as 0" rule (to avoid broken appearance)
Parameter values in text display: decimal point is omitted
When you write references like PARTY.GOLD or MEM_0.HP in a "Show Text", "Add Choice", or "Add Button" event content, if the value is effectively an integer, the decimal point is omitted.
| Actual value | Display |
|---|---|
100.0 | 100 |
1.5 | 1.5 (as-is) |
0.0 | 0 |
Difference from variable values
{variable_name} outputs the stored value as-is, with no decimal omission. If you want to display it as an integer, use int(...) inside "Assign Variable" to convert it.
Local Flags (Event Switches)
What are local flags?
26 ON / OFF flags that each event object (treasure chest, NPC, etc.) can hold. Use them to remember things like "has this chest been opened?" or "has the player talked to this NPC?"
They correspond to what other RPG construction tools call "self switches". Each event object has its own private A–Z 26-slot set.
How to set
Use the "Set Local Flag" event content.
| Setting | Content |
|---|---|
| slot | One of A–Z (26 total) |
| value | true (ON) / false (OFF) |
Example: "Set A to true when a chest is opened"
Set Local Flag: slot=A, value=trueHow to reference
In a formula, write LOCAL.A – LOCAL.Z. The result is true or false.
| Expression | Result / Behavior |
|---|---|
LOCAL.A | True if flag A is true |
not LOCAL.A | True if flag A is false |
LOCAL.A and not LOCAL.B | True if A is true and B is false |
Typical uses
Treasure chest open / closed:
- At the end of the chest-opening event: "Set Local Flag
slot=A, value=true" - In the next conversation, conditional branch:
LOCAL.A→ true shows "it's empty", false gives the contents
NPC conversation state:
- After the first conversation: "Set Local Flag
slot=A, value=true" - Conditional branch:
LOCAL.A→ true shows "nice to see you again", false shows "nice to meet you"
WARNING
LOCAL.* depends on "which event object triggered the event". If you jump to another event via Move to Event, the referenced object may change.
Name Embedding (@ notation)
In formulas and text display, you can embed character names, item names, and so on. Translation is supported too.
Notation
| Form | Use | Example | Display |
|---|---|---|---|
{@char.<char ID>} | Character name | {@char.KANAMI} | Kanami |
{@char.MEM_N} | N-th party member name | {@char.MEM_0} | First member's name |
{@char.OPP_N} | N-th enemy member name | {@char.OPP_0} | First enemy's name |
{@item.<item ID>} | Item name | {@item.IT_POTION} | Potion |
{@state.<state ID>} | State name | {@state.DEAD} | Dead |
{@param.<parameter ID>} | Parameter name | {@param.HP} | HP |
MEM_N / OPP_N clamping
If you specify a number that is too large, such as {@char.MEM_99}, it is clamped to the last member (large numbers are not ignored; the end is returned instead).
Combined with text display
The sweet spot is the body of a "Show Text" event content.
{@char.KANAMI} used {@item.IT_POTION}!
{@char.KANAMI}'s {@param.HP} recovered.Combined with variables: If variable char_id contains KANAMI, then {@char.{char_id}} displays "Kanami".
Unregistered ID: Replaced with the empty string (the raw notation is never shown to the player). During development, a debug message is logged.
Related: Translation / Multi-language
Common Patterns
Battle / damage
| Use | Location | Expression | Behavior |
|---|---|---|---|
| Basic damage calculation | Item target HP value | -(USER.STR.MAX * 2 - TGT.DEF.MAX) | HP decreases by (attacker's STR × 2 − target's DEF) |
| 95% hit judgment | Item target HP hit judgment | randi() % 100 < 95 | 95% hit rate |
| AGI-based hit rate | Item target HP hit judgment | randi() % 100 < 90 + USER.AGI.MAX - TGT.AGI.MAX | Base 90%, ±1% per 1 AGI difference |
| Last-stand power (stronger as HP falls) | Item target HP value | -USER.STR.MAX * (2 - USER.HP.RATE) | 1.0× at full HP, 2.0× at 0 HP |
| Full-group attack split by target count | Item target HP value | -USER.INT.MAX * 3 / TGTS.COUNT | Divides damage by number of targets |
Sign rule
Item values that reduce HP must start with a minus sign.
Enemy action patterns
| Use | Location | Expression | Behavior |
|---|---|---|---|
| Trigger when HP ≤ 30% | Enemy action pattern determine | SELF.HP.RATE < 0.3 | Triggers when the enemy's own HP is low |
| 50% trigger | Enemy action pattern rate | 50 | Always 50% chance |
| HP-dependent rate | Enemy action pattern rate | SELF.HP.RATE < 0.5 ? 80 : 20 | 80% below 50% HP, otherwise 20% |
Event conditional branches
| Use | Location | Expression | Behavior |
|---|---|---|---|
| Gold check | Conditional branch | PARTY.GOLD >= 100 | True at 100 G or more |
| Party average level check | Conditional branch | MEMS_AVG.LEVEL.MAX >= 10 | True at average level 10 or more |
| Local flag check | Conditional branch | LOCAL.A | True after opening a chest, etc. |
Chest pattern
"At the end of the chest-opening event, set local flag A to true → on the next conversation, check LOCAL.A and show an empty message."
Assigning to variables (is_calc=on)
| Use | Location | Expression | Behavior |
|---|---|---|---|
| Increment | Assign Variable counter_1 | {counter_1} + 1 | Current value + 1 |
| Subtract | Assign Variable gold | {gold} - 100 | Current value − 100 |
| Store party max level | Assign Variable max_lv | MEMS_MAX.LEVEL.MAX | Assigns the max level in the party |
FAQ (When Things Go Wrong)
The formula does nothing / always returns 0
First, check for spelling mistakes in reference, parameter, and detail names. They must all be in upper case.
| Verdict | Example | Reason |
|---|---|---|
| ✅ OK | SELF.HP.MAX | All upper case |
| ❌ Wrong | self.hp.max | Lower case is not allowed |
| ❌ Wrong | Self.Hp.Max | Mixed case is not allowed |
| ❌ Wrong | SELF.hp.MAX | Lower-case parameter is not allowed either |
Behavior when the reference is missing
If a referenced character, item, or parameter does not exist, the formula returns 0 (no error).
| Expression | Result | Reason |
|---|---|---|
SELF.NONEXISTENT.MAX | 0 | Nonexistent parameter |
MEM_99.HP.MAX | Value of MEM_(last index) | Overflow is clamped to the last member |
TGT.HP.MAX (no target) | 0 | No target |
Debugging tip: If a value is "always 0", check whether the reference is specified correctly.
Can equipment requirements for an Attach be a formula?
No. The "Equip Requirement" field on the Attach tab accepts a plain number only (10 for a STR of 10). Formulas are not supported.
Case sensitivity
| Target | Rule |
|---|---|
| Reference / parameter / detail | Always upper case (SELF.HP.MAX) |
Variable name ({variable_name}) | Must match the case used in the Variable tab |
| Expression | Verdict | Reason |
|---|---|---|
{counter_1} | ✅ if the variable is defined as counter_1 | Exact-name match |
{COUNTER_1} | ❌ unless defined as COUNTER_1 | Different case is treated as a different variable |
Whitespace / parentheses
- Whitespace is free (
10 + 5and10+5are the same) - Parentheses control the order of evaluation
Order of evaluation (same as ordinary arithmetic):
| Priority | Target |
|---|---|
| 1 | Parentheses |
| 2 | Multiplication / division |
| 3 | Addition / subtraction |
| 4 | Comparison (>, <, ==, etc.) |
| 5 | Logic (and, or, not) |
Examples:
| Expression | Result | Reason |
|---|---|---|
10 + 5 * 2 | 20 | 5 × 2 = 10 first, then 10 + 10 = 20 |
(10 + 5) * 2 | 30 | 10 + 5 = 15 first, then 15 × 2 = 30 |
My item's HP-decreasing formula shows a positive number
To decrease HP, the formula must return a negative value.
| Expression | Verdict | Behavior |
|---|---|---|
-(USER.STR.MAX * 2) | ✅ Correct | Minus sign decreases HP |
USER.STR.MAX * 2 | ❌ Wrong | HP increases (treated as healing) |
I can't tell when to use SELF vs USER
| Location | SELF | USER | Memo |
|---|---|---|---|
| Item calculation | The item itself | The character using it | Use USER for the character's values |
| State calculation | The character carrying the state | Same as SELF | Either works |
| Class growth | The character that leveled up | Same as SELF | Either works |
| Enemy action pattern | The enemy itself | Same as SELF | Either works |
| System battle calculation | The whole party group | Same as SELF | Either works |
When unsure, check the Location summary.
I want "target the party" in an enemy action pattern formula
In enemy action patterns, "own group" and "opposing group" are flipped.
| Reference | Points to |
|---|---|
MEMS | The enemy group (own side) |
OPPS | The party group (opposing side) |
"Party average HP ≤ 30%" check:
| Expression | Verdict | Behavior |
|---|---|---|
OPPS_AVG.HP.RATE < 0.3 | ✅ Correct | Opposing side = party average HP |
PARTY.HP.RATE < 0.3 | ✅ Correct | Explicit via absolute PARTY reference |
MEMS_AVG.HP.RATE < 0.3 | ❌ Wrong | Points to the enemy side, not the party |
Returning different values with the ternary operator
| Expression | Behavior |
|---|---|
(SELF.HP.RATE < 0.3) ? 200 : 100 | 200 if HP ratio is under 30%, otherwise 100 |
Writing a hit rate as a probability
Write it in the hit judgment field.
| Expression | Behavior |
|---|---|
randi() % 100 < 70 | 70% hit rate |
randi() % 100 < 90 + USER.AGI.MAX - TGT.AGI.MAX | Base 90%, ±1% per AGI difference |
Can variables hold negative numbers?
Yes, variables created in the Variable tab can hold negative numbers.
| Expression | Result (when counter_1 is -5) |
|---|---|
{counter_1} | -5 |
{counter_1} + 10 | 5 |
Flag variable checks (initial state / empty string handling)
Immediately after creation, a variable's contents are the empty string "". In formulas, the empty string is automatically treated as 0.
Expression (flag_1 is empty = initial state) | Result | Meaning |
|---|---|---|
{flag_1} == 1 | false | empty → 0; 0 is not equal to 1 |
{flag_1} != 1 | true | empty → 0; 0 is not equal to 1, so true |
{flag_1} == 0 | true | empty → 0; 0 equals 0 |
{flag_1} >= 1 | false | empty → 0; 0 is less than 1 |
Recommended pattern
- "Flag is off" = initial value (empty string = 0), or explicitly set to
0via Assign Variable - "Flag is on" = set to
1via Assign Variable - Checks like
{flag_1} == 1(ON check) or{flag_1} != 1(OFF check) are safe
WARNING
If you use {flag_1} in a "Show Text" event content, in the initial state nothing is displayed (still an empty string). To show it as a number, set it explicitly via Assign Variable.
