Skip to content

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_1 is 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 .:

PositionElementMeaningExample
1stReference"Whose" value to useSELF / USER / TGT
2ndParameter"What" valueHP / MP / STR
3rdDetail"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.

ExpressionResultNote
10 + 515Addition
20 * 240Multiplication
100 / 333.33...Division (may be fractional)
15 - 87Subtraction
(10 + 5) * 230Parentheses control the order

Comparison ​

Used in conditional branches and hit judgments, among others. The result is true or false.

ExpressionResultMeaning
5 > 3trueGreater than
10 == 10trueEqual (use ==, not =)
5 != 3trueNot equal
100 >= 100trueGreater than or equal
50 <= 40falseLess than or equal

Logic ​

For combining conditions:

ExpressionResultMeaning
5 > 3 and 10 < 20trueAND (true only if both are true)
5 > 3 or 10 > 20trueOR (true if either is true)
not (5 > 3)falseNOT (invert)

Ternary (switch between values by condition) ​

Form:

condition ? value_if_true : value_if_false
ExpressionResultMeaning
10 > 5 ? 100 : 0100Condition is true, so the true-value is returned
5 > 10 ? 100 : 00Condition is false, so the false-value is returned
SELF.HP.RATE < 0.3 ? 200 : 100200 or 100200 if HP ratio is under 30%, otherwise 100

Detail property (.MAX / .NOW / .RATE / omitted) ​

After the reference and parameter, you can add a detail:

NotationMeaningExample (HP is 60 of 100)
.MAXMaximum value100
.NOWCurrent value60
.RATERatio (current / max)0.6
OmittedSame as .NOW60

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 resultAfter roundingExplanation
+3.4+4abs 3.4 ceils to 4, sign (+) restored
-2.6-3abs 2.6 ceils to 3, sign (-) restored
+0.1+1Any positive amount becomes 1 (so damage never becomes 0)
-0.1-1Same
00No change

Where rounding occurs (places where parameters are added / subtracted):

LocationTarget
Item / skill: target parameter valueDamage / healing
Item: user / item consumption valueMP cost, durability loss, etc.
State effect: current value addPoison damage, healing state, etc.
State effect: max value addSTR boost, DEF debuff, etc.
Class: level-up growth valueSTR / INT increase per level
Enemy drop: valueEXP / GOLD
Shop: payment / incomePurchase cost, sell price

Where rounding does NOT occur:

LocationDescription
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.

ModeBehaviorExample: result is 3.5
NoneKeep as fractional3.5
CeilRound up4
FloorRound down3
RoundHalf-up round4

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.

StepExampleVariable contentsEffect on parameter
1. Assign calculation to variableAssign Variable {var_1} = 100 / 3var_1 = 33.33 (fractional)None
2a. Used by Change Parameter (rounding=None)Change Parameter adds {var_1}Still 33.33Adds 33.33 (float) to parameter
2b. Used by Change Parameter (rounding=Ceil, etc.)SameStill 33.33Adds per rounding mode (34 / 33 etc.)
2c. Used in item value, drop, etc.tgt_param.value={var_1}Still 33.33Automatic 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.1 becomes 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":

LocationSELF refers toUSER refers toTGT refers toExtra references
Item: value / hit judgmentThat itemThe character using the itemTarget character or groupPARTY / TROOP / MEMS / OPPS / TGTS
Item: consumption valueThat itemThe character using the item(unused)PARTY / TROOP / MEMS / OPPS
State: max / current value addThat characterThat characterThat character (same as SELF)PARTY / TROOP / MEMS / OPPS
Class: level-up growth valueThe character that leveled upSame as SELFSame as SELFPARTY / TROOP / MEMS / OPPS
Enemy: action pattern (rate / determine)The enemy itselfSame as SELFThe whole party groupPARTY / TROOP / MEMS / OPPS
Enemy: drop (rate / value)The defeated enemy itselfSame as SELFThe whole party groupPARTY / TROOP / MEMS / OPPS
System: first strike / surprise / escapeThe whole party groupSame as SELFThe whole enemy groupPARTY / TROOP / MEMS / OPPS
System: action orderEach character (evaluated in turn)Same as SELF(unused)ACT_ITEM (the item that character selected)
Event: conditional branch / next event conditionThe whole party groupSame as SELF(unused)PARTY / TROOP / MEMS / OPPS / LOCAL / variables
Event: change parameter (character target)The target characterSame 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:

ReferencePoints to
SELFThe item itself (usually 0 since items normally do not have STR, etc.)
USERThe character using the item
TGTThe target character or group

Examples:

LocationExpressionResult / 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 judgmentrandi() % 100 < 8080% chance of hitting
Target parameter HP value-TGT.HP.MAX * 0.2Deal 20% of target's max HP as damage
Target parameter HP value-USER.INT.MAX * 3 / TGTS.COUNTFull-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:

ReferencePoints to
SELFThe item itself
USERThe character using the item

Consumption values are written as positive numbers (they are subtracted automatically).

Examples:

LocationExpressionResult / Behavior
User consumption MP value10Consume 10 MP
User consumption MP valueUSER.MP.MAX * 0.1Consume 10% of the user's max MP
Item consumption DURABILITY value1Reduce 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:

ReferencePoints to
SELFThe character carrying the state
USERSame as SELF (the character itself)
TGTSame as SELF (the character itself)

Examples:

LocationExpressionResult / Behavior
Current value add HP (poison)-SELF.HP.MAX * 0.055% of max HP as damage per turn
Max value add STR (STR boost)10+10 STR
Current value add HP (curse)-SELF.LEVEL.MAX * 2HP decrease equal to level × 2

Class level-up growth (Class tab "Growth Value") ​

What the references point to:

ReferencePoints to
SELFThe character that leveled up
USERSame as SELF (the character itself)
TGTSame as SELF (the character itself)

Examples:

LocationExpressionResult / Behavior
Growth HP valueSELF.LEVEL.MAX * 3HP increase of level × 3
Growth STR value1+1 STR per level
Growth AGI valueSELF.LEVEL.MAX / 2+1 every 2 levels (integer division)

Enemy action pattern (Enemy tab "Rate" / "Determine") ​

What the references point to:

ReferencePoints to
SELFThe enemy itself
USERSame as SELF (the enemy itself)
TGTThe whole party group
GROUPThe enemy group (TROOP, own side)
OPP_GROUPThe party group (PARTY, opponent side)
MEMSAll members of the enemy group (own side)
OPPSAll party members (opponent side)

Examples for Determine (trigger condition):

LocationExpressionResult / Behavior
DetermineSELF.HP.RATE < 0.3Triggers when the enemy's own HP is below 30%
Determine{turn_count} % 3 == 0Triggers every 3 turns (requires a turn_count variable)
DetermineOPPS_AVG.HP.RATE < 0.25Triggers when party average HP is under 25% (finisher)
DeterminePARTY.HP.RATE < 0.25Equivalent to the above (explicit via absolute PARTY reference)

Examples for Rate (trigger probability):

LocationExpressionResult / Behavior
Rate100Always triggers (100%)
Rate5050% probability
RateSELF.HP.RATE < 0.5 ? 100 : 0Always 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:

ReferencePoints to
SELFThe defeated enemy itself
USERSame as SELF (the enemy itself)
TGTThe whole party group

Examples:

LocationExpressionResult / Behavior
Drop rate2020% drop chance
Drop value (EXP)SELF.HP.MAX * 2EXP = enemy's max HP × 2
Drop value (GOLD)50 - OPPS_AVG.LEVEL.MAX * 3Larger gold reward for lower-level parties

System battle calculation (System tab "First Strike" / "Surprise" / "Escape") ​

What the references point to:

ReferencePoints to
SELFThe whole party group
USERSame as SELF
TGTThe whole enemy group
PARTYAbsolute reference (same result as SELF)
TROOPAbsolute reference (same result as TGT)

Examples:

LocationExpressionResult / Behavior
First strike judgmentMEMS_AVG.AGI.MAX > OPPS_AVG.AGI.MAXFirst strike if party's average AGI exceeds enemies'
First strike judgmentrandi() % 100 < 50 + (MEMS_AVG.AGI.MAX - OPPS_AVG.AGI.MAX) * 5Base 50% + AGI difference × 5%
Escape judgmentrandi() % 100 < MEMS_MAX.AGI.MAX * 100 / OPPS_MAX.AGI.MAXEscape success rate from AGI ratio

System battle calculation (System tab "Action Order") ​

What the references point to:

ReferencePoints to
SELFEach character (evaluated for every party member and enemy)
ACT_ITEMThe item that character selected (special reference available only here)

Characters act in descending order of the returned value.

Examples:

LocationExpressionResult / Behavior
Action orderSELF.AGI.MAXOrder by AGI (simple)
Action orderSELF.AGI.MAX + ACT_ITEM.PRIORITY.MAXAGI plus the chosen item's priority
Action orderSELF.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:

ReferencePoints to
SELFThe whole party group (default)
USERSame 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:

LocationExpressionResult / Behavior
Conditional branch{counter_1} >= 10True when variable counter_1 is 10 or more
Conditional branch{flag_1} == 1True when variable flag_1 is 1
Conditional branchLOCAL.ATrue when local flag A is true
Conditional branchPARTY.GOLD >= 100True when gold is 100 or more
Conditional branchMEMS_AVG.LEVEL.MAX >= 10True when average party level is 10 or more

Examples for Assign Variable (is_calc=on):

LocationExpressionResult / Behavior
Assign Variable counter_1{counter_1} + 1Current value + 1 (increment)
Assign Variable gold_halfPARTY.GOLD / 2Assigns half of the gold
Assign Variable max_lvMEMS_MAX.LEVEL.MAXAssigns the highest party level

Event Change Parameter ("Change Parameter" event content) ​

What the references point to (by target type):

Target typeSELF refers toUSER refers to
Character target (Selected Member / Party All etc.)The target characterSame as SELF
Item targetThe whole party groupSame as SELF
Group (party-shared) targetThe whole party groupSame as SELF

Examples:

LocationExpressionResult / Behavior
Char target HP value (Add)SELF.HP.MAX * 0.5Heal 50% of max HP
Char target EXP value (Add)100+100 EXP
Group target GOLD value (Set)99999Set 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) ​

ExpressionResult / Behavior
MEMS.HP.MAXSum of all members' max HP
MEMS_AVG.HP.MAXAverage of all members' max HP
MEMS_MAX.LEVEL.MAXMaximum level among all members (strongest member)
MEMS_MIN.HP.NOWMinimum 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: MEMS means party members
  • Enemy action patterns: MEMS means enemy group members

OPPS (all members of the opposing group) ​

ExpressionResult / Behavior
OPPS.HP.NOWSum of all enemies' current HP (total remaining HP)
OPPS_MIN.HP.NOWThe lowest current HP among all enemies

TGTS (all targets) ​

When there are multiple targets (e.g. full-group attacks), aggregates over all targets:

ExpressionResult / Behavior
TGTS.HP.NOWSum of current HP of all targets
TGTS_AVG.DEF.MAXAverage DEF of all targets

CHARS (all party members + all enemies) ​

Aggregates over all characters in battle:

ExpressionResult / Behavior
CHARS.HP.NOWSum of party + enemies' HP

Aggregation methods (_AVG / _MAX / _MIN) ​

SuffixMeaningExample (party of 3 with max HP of 100 / 80 / 60)
none (MEMS, etc.)TotalMEMS.HP.MAX → 240
_AVGAverageMEMS_AVG.HP.MAX → 80
_MAXMaximumMEMS_MAX.HP.MAX → 100
_MINMinimumMEMS_MIN.HP.MAX → 60

Count (.COUNT) ​

Append .COUNT to an aggregation reference to get the number of members.

ExpressionResult / Behavior
MEMS.COUNTNumber of own-group members
OPPS.COUNTNumber of enemies
TGTS.COUNTNumber of targets (all members for a full-group attack)
CHARS.COUNTTotal 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.

ReferencePoints to
MEM_00th (first) character of own group
MEM_11st character of own group
MEM_22nd character of own group
OPP_00th character of enemy group
OPP_11st character of enemy group

Examples:

ExpressionResult / Behavior
MEM_2.HP.NOWCurrent HP of the 3rd party member (0-indexed)
OPP_0.HP.RATEHP 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}.

ExpressionResult / Behavior
{counter_1}Returns the current value of variable counter_1
{counter_1} >= 10True if counter_1 is 10 or more (for conditional branches)
{counter_1} + 1Returns 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 nameUse
counter_1Integer
flag_1Flag (0 / 1 for OFF / ON)
name_1Text

How to set a variable ​

Use the "Assign Variable" event content.

Operation modeBehavior
SetStore the given value as-is
AddAdd to the current value
SubSubtract from the current value

Special variables ​

VariableContents
{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 contentsTreatment in a formulaExample {var} + 1Example {var} == 1
"" (empty, initial)Treated as 00 + 1 = 10 == 1 = false
"5" (numeric string)Treated as 55 + 1 = 65 == 1 = false
"1+1" (formula string)Expanded as a formula1+1 + 1 = 31+1 == 1 = false
"hello" (text)Treated as 0 on error0false

Recommended for flag variables

  • Explicitly set 0 or 1 with 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} != 1 evaluates 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 valueDisplay
100.0100
1.51.5 (as-is)
0.00

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.

SettingContent
slotOne of A–Z (26 total)
valuetrue (ON) / false (OFF)

Example: "Set A to true when a chest is opened"

Set Local Flag: slot=A, value=true

How to reference ​

In a formula, write LOCAL.A – LOCAL.Z. The result is true or false.

ExpressionResult / Behavior
LOCAL.ATrue if flag A is true
not LOCAL.ATrue if flag A is false
LOCAL.A and not LOCAL.BTrue if A is true and B is false

Typical uses ​

Treasure chest open / closed:

  1. At the end of the chest-opening event: "Set Local Flag slot=A, value=true"
  2. In the next conversation, conditional branch: LOCAL.A → true shows "it's empty", false gives the contents

NPC conversation state:

  1. After the first conversation: "Set Local Flag slot=A, value=true"
  2. 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 ​

FormUseExampleDisplay
{@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 ​

UseLocationExpressionBehavior
Basic damage calculationItem target HP value-(USER.STR.MAX * 2 - TGT.DEF.MAX)HP decreases by (attacker's STR × 2 − target's DEF)
95% hit judgmentItem target HP hit judgmentrandi() % 100 < 9595% hit rate
AGI-based hit rateItem target HP hit judgmentrandi() % 100 < 90 + USER.AGI.MAX - TGT.AGI.MAXBase 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 countItem target HP value-USER.INT.MAX * 3 / TGTS.COUNTDivides damage by number of targets

Sign rule

Item values that reduce HP must start with a minus sign.

Enemy action patterns ​

UseLocationExpressionBehavior
Trigger when HP ≤ 30%Enemy action pattern determineSELF.HP.RATE < 0.3Triggers when the enemy's own HP is low
50% triggerEnemy action pattern rate50Always 50% chance
HP-dependent rateEnemy action pattern rateSELF.HP.RATE < 0.5 ? 80 : 2080% below 50% HP, otherwise 20%

Event conditional branches ​

UseLocationExpressionBehavior
Gold checkConditional branchPARTY.GOLD >= 100True at 100 G or more
Party average level checkConditional branchMEMS_AVG.LEVEL.MAX >= 10True at average level 10 or more
Local flag checkConditional branchLOCAL.ATrue 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) ​

UseLocationExpressionBehavior
IncrementAssign Variable counter_1{counter_1} + 1Current value + 1
SubtractAssign Variable gold{gold} - 100Current value − 100
Store party max levelAssign Variable max_lvMEMS_MAX.LEVEL.MAXAssigns 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.

VerdictExampleReason
✅ OKSELF.HP.MAXAll upper case
❌ Wrongself.hp.maxLower case is not allowed
❌ WrongSelf.Hp.MaxMixed case is not allowed
❌ WrongSELF.hp.MAXLower-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).

ExpressionResultReason
SELF.NONEXISTENT.MAX0Nonexistent parameter
MEM_99.HP.MAXValue of MEM_(last index)Overflow is clamped to the last member
TGT.HP.MAX (no target)0No 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 ​

TargetRule
Reference / parameter / detailAlways upper case (SELF.HP.MAX)
Variable name ({variable_name})Must match the case used in the Variable tab
ExpressionVerdictReason
{counter_1}✅ if the variable is defined as counter_1Exact-name match
{COUNTER_1}❌ unless defined as COUNTER_1Different case is treated as a different variable

Whitespace / parentheses ​

  • Whitespace is free (10 + 5 and 10+5 are the same)
  • Parentheses control the order of evaluation

Order of evaluation (same as ordinary arithmetic):

PriorityTarget
1Parentheses
2Multiplication / division
3Addition / subtraction
4Comparison (>, <, ==, etc.)
5Logic (and, or, not)

Examples:

ExpressionResultReason
10 + 5 * 2205 × 2 = 10 first, then 10 + 10 = 20
(10 + 5) * 23010 + 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.

ExpressionVerdictBehavior
-(USER.STR.MAX * 2)✅ CorrectMinus sign decreases HP
USER.STR.MAX * 2❌ WrongHP increases (treated as healing)

I can't tell when to use SELF vs USER ​

LocationSELFUSERMemo
Item calculationThe item itselfThe character using itUse USER for the character's values
State calculationThe character carrying the stateSame as SELFEither works
Class growthThe character that leveled upSame as SELFEither works
Enemy action patternThe enemy itselfSame as SELFEither works
System battle calculationThe whole party groupSame as SELFEither 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.

ReferencePoints to
MEMSThe enemy group (own side)
OPPSThe party group (opposing side)

"Party average HP ≤ 30%" check:

ExpressionVerdictBehavior
OPPS_AVG.HP.RATE < 0.3✅ CorrectOpposing side = party average HP
PARTY.HP.RATE < 0.3✅ CorrectExplicit via absolute PARTY reference
MEMS_AVG.HP.RATE < 0.3❌ WrongPoints to the enemy side, not the party

Returning different values with the ternary operator ​

ExpressionBehavior
(SELF.HP.RATE < 0.3) ? 200 : 100200 if HP ratio is under 30%, otherwise 100

Writing a hit rate as a probability ​

Write it in the hit judgment field.

ExpressionBehavior
randi() % 100 < 7070% hit rate
randi() % 100 < 90 + USER.AGI.MAX - TGT.AGI.MAXBase 90%, ±1% per AGI difference

Can variables hold negative numbers? ​

Yes, variables created in the Variable tab can hold negative numbers.

ExpressionResult (when counter_1 is -5)
{counter_1}-5
{counter_1} + 105

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)ResultMeaning
{flag_1} == 1falseempty → 0; 0 is not equal to 1
{flag_1} != 1trueempty → 0; 0 is not equal to 1, so true
{flag_1} == 0trueempty → 0; 0 equals 0
{flag_1} >= 1falseempty → 0; 0 is less than 1

Recommended pattern

  • "Flag is off" = initial value (empty string = 0), or explicitly set to 0 via Assign Variable
  • "Flag is on" = set to 1 via 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.