Skip to content

Battle System Reference ​

Complete reference for this tool's battle system. Organized from the game designer's perspective to show how battle progresses, how allies and enemies decide their actions, what happens on victory / defeat / escape, and how various settings control behavior.

Intended audience

This page is intended for tool users (game creators) to reference when designing, tuning, and debugging battle scenes. Explanations are based on "how the player actually experiences it," so refer to the Formula Reference separately for Formula details and fine-grained implementation details.

Two paths of battle occurrence ​

Battles in this tool occur through the following 2 paths. Internally they use the same battle screen, but trigger conditions and post-processing differ.

1. Via encounter (random battle) ​

A "random mob battle" that auto-triggers every certain number of steps as you walk around the map.

  • Define trigger conditions (step range, enemy group, weight) in the map's step encounter settings
  • Battle starts automatically when steps reach a threshold while walking
  • After victory / successful escape, returns to field and normal play resumes
  • On defeat, branches according to the wipeout handling setting in Editor: System (reset to title or dedicated event)

2. Via event (Start Battle) ​

Battle explicitly triggered by Event Content. Used for boss battles and story battles.

  • Executed by placing Start Battle at a specific timing within an event
  • After victory / successful escape, the event continues (Event Content following Start Battle is executed)
  • On defeat, uses the dedicated event specified in Start Battle properties or resets to title

Internal differences ​

BehaviorVia encounterVia event (Start Battle)
Return destination after battleField (normal play)Event Content following Start Battle
Autosave triggerTriggers on victory / successful escapeDelegated to event completion
Behavior on defeatFollows wipeout handling settingSpecified in Start Battle properties

Battle start flow ​

When the battle screen is displayed, first the Fight / Escape prompt appears (common to encounter and event paths).

  • Fight selected: Proceeds to the party's command input phase
  • Escape selected: Proceeds to escape judgement (immediate end on success; only the enemy action phase runs on failure)

Escape-disabled battle

If you turn ON the "Escape Disabled" property of Start Battle, the Escape button becomes inactive. This produces the "cannot escape" feel for boss battles.

Party command input ​

When Fight is selected, command input begins in order from the leading party member. Each member goes through the following 3 stages.

1. Type menu (what to do) ​

  • Attack (BA_ATTACK): Normal attack
  • Defend (BA_DEFEND, when configured as BA_ITEM): Defensive action (attack-power reduction, incoming-damage reduction, etc., user-defined)
  • Magic / Skill / etc. (user-defined): Menus for each itemtype are listed
  • Item (only when the character has BA_ITEM, shown at the end): Opens the item menu

Display condition for the "Item" button

The "Item" button is shown only when the character possesses the reserved BA_ITEM item. A design where "this character cannot use items during battle" is possible.

2. Item menu (specific skill/magic/item) ​

  • A list of specific items within the chosen type is shown
  • Items with insufficient MP or lacking resources are shown as inactive (unusable)
  • Items marked "unusable during battle (ITEM_TIMING)" are also inactive
  • The Back button returns to the type menu

3. Target selection (whom to use on) ​

Depending on the item's target setting, the behavior is one of:

  • Auto-decided (User / Self / Party All / Troop All / Random Member / Random Opponent, etc.): Skips the target selection screen and moves to the next member immediately
  • Manual select (Selected Member / Selected Opponent): The target selection screen is shown and the player clicks to choose

Once a target is decided, command input moves to the next party member. Once all members have finished, the action phase begins.

Back (cancel) operation ​

Press Back / Escape to return to the previous phase:

Current phaseBack destination
Type menuCommand input of the previous party member (not implemented; in the current specification, may not be able to go back)
Item menuType menu
Target selectionPhase before entering target selection (type or item)

Enemy action decision ​

Once all party members finish input, enemy actions are automatically decided. Each enemy is judged by its pattern (behavior pattern) in Editor: Enemy:

  • item: Unique ID of the item (skill, magic) to use
  • turn: "Turn number" condition (USER.TURN > 3 etc., written in Formula)
  • rate: Trigger probability (0-100 numeric Formula; triggers probabilistically)
  • determine: Trigger condition (Formula bool; additional condition)
  • target: Target (can override the item-side target)

Patterns can be registered as an array of multiple entries and are judged from top to bottom. The first pattern that passes both rate and determine becomes that enemy's action for that turn.

Design examples for enemy AI

  • "Use healing magic when HP is 30% or less": determine: USER.HP.RATE < 0.3
  • "Full-party attack once every 3 turns": turn: USER.TURN % 3 == 0
  • "60% chance physical attack, remaining 40% magic": register 2 patterns, first rate: 60, second rate: 100

Action order decision ​

Once all commands are determined, the action order Formula (formula_battle_action_order) is evaluated for each character, and sorted in descending order of the result.

  • Default formula is empty → input order (party head → tail, troop head → tail)
  • Typical formula: USER.AGI.MAX → AGI (speed) order
  • Ties are random

ACT_ITEM reference (references the action the character chose) ​

In the action order Formula, you can use the ACT_ITEM reference. It lets you reference parameters of the "item selected this turn":

  • Example: USER.AGI.MAX + ACT_ITEM.PRIORITY.MAX
  • By setting a large value for a skill's PRIORITY Parameter, you can realize "a character who chose a high-priority skill moves first"
  • "Defensive action" could have PRIORITY=9999 to always move first, etc.

6 timings of State effects ​

States (status ailments, buffs, etc.) have 6 trigger timings, and each timing's effects apply at fixed points in the battle flow.

TimingTrigger locationTypical use
Battle StartImmediately after battle starts (BATTLE_START)Start buffs, initialization
Turn StartAt the start of each turn (TURN_START, depending on settings for turn 1)Sustained damage (poison), sustained healing
Before ActionJust before the character's action (BEFORE_ACT)Paralysis determining action blocking
After ActionJust after the character's action (AFTER_ACT)Recoil damage, counter purposes
Turn EndAfter all actions complete (TURN_END)Turn-sustained damage, state decay
Battle EndOn victory or successful escape (BATTLE_END)State removal on battle end, ending effects

Tune timing behavior via settings

  • battle_first_turn_include_turn_start: Whether to trigger TURN_START on turn 1 (default true)
  • battle_end_include_turn_end: Whether to also trigger TURN_END on battle end (default false)

Configurable in Editor: System.

Flow of 1 action execution ​

After action order sorting, each character acts in the following flow in order:

  1. Survival check: Skip action if already DEAD/ESCAPE (e.g., killed by another character's attack)
  2. Target survival filter: If targets are wiped out, re-draw from survivors of the same side according to settings, or skip action
  3. Title display: Message like "XX's YY!" is shown in the battle window
  4. Seal check: If sealed by State disabled_item_types etc., treat as MISS (sound_miss triggers)
  5. Before-Action State effects (BEFORE_ACT)
  6. Effect playback: Play the effect set on the item (explosion effect, light, etc.)
  7. Apply item effect (Item Use Lifecycle)
  8. UI reflection: Numeric popup (damage, heal), HP bar update, MISS display
  9. DEAD/ESCAPE direction: Characters newly becoming DEAD/ESCAPE play the vanishing effect (specified by battle_dead_effect, default DISAPPEAR)
  10. After-Action State effects (AFTER_ACT)
  11. Victory/defeat check: If VICTORY/DEFEAT, skip remaining actions

Item Use Lifecycle ​

Item (skill, magic) effects are applied in the following order:

  1. consume_self (item consumes itself)
  2. consume_user (user consumes, MP etc.)
  3. add_state_with_use (applies state to target)
  4. add_params_with_use (parameter changes to target, damage, heal)
  5. check_crit_param_zero (deletes the item if it meets the vanish condition)

Results are decided at each stage; you can apply state and damage with the same item ("poison 100 damage + paralyze" etc.).

Auto re-targeting on target wipeout ​

When an action is executed and the target is wiped out, behavior is controlled by the following 2 settings in Editor: System:

  • bi_auto_retarget_enemy: Whether enemies re-draw targets from survivors when allies are wiped out (default true)
  • bi_auto_retarget_ally: Whether allies re-draw targets from survivors when enemies are wiped out (default true)

If turned OFF, it becomes "no target → skip action," making it possible to design so that subsequent attacks don't go to waste when multiple enemies are defeated in one turn.

Victory / defeat / escape branching ​

Victory (VICTORY) ​

When enemies are wiped out by allies, or all enemies have ESCAPEd:

  1. BATTLE_END State effect triggers (TURN_END also triggers simultaneously if battle_end_include_turn_end=true)
  2. BGM change: Switch to bgm_victory
  3. Result display: Battle result window (gained EXP, GOLD, items, etc.)
  4. Apply drops:
    • Each enemy's add_param_defeat (grant parameters like EXP, GOLD)
    • Each enemy's add_drop_table_defeat (lottery-distribute items / Attach via Drop Table)
    • Automatic level-ups chain-trigger from EXP addition
  5. Transition (close): Return to screen via bi_transition_battle_end
  6. Return destination:
    • Via encounter: Return to field (autosave triggers)
    • Via event: Proceed to Event Content following Start Battle

Defeat (DEFEAT) ​

When all allies become DEAD/ESCAPE:

  1. BATTLE_END does not trigger (effects would disappear due to save data rollback)
  2. BGM change: Switch to bgm_defeat
  3. Save data rollback: Restore add_current_param changes from the pre-battle snapshot (damage etc. revert to pre-battle values, but permanent changes like consumed items are not rolled back)
  4. Transition (close)
  5. Branch (encounter_defeat_action in Editor: System):
    • Reset Game (default): Reset to the title screen equivalent
    • Move Event: Move to the event specified by encounter_defeat_event
  6. Via encounter vs. via event:
    • Via encounter: Follows the above setting
    • Via event: Can be individually specified by the defeat_event property of Start Battle

Escape success (ESCAPE SUCCESS) ​

When escape judgement succeeds (party only):

  1. BATTLE_END State effect triggers (party survivors only)
  2. Play sound_escape sound effect
  3. BGM restore: Return to the pre-battle BGM
  4. Transition (close)
  5. Return destination:
    • Via encounter: Return to field (autosave triggers)
    • Via event: Proceed to Event Content following Start Battle

Escape failure (ESCAPE FAIL) ​

  • Party does not act; only the enemy action phase runs
  • After that, proceed normally to the next turn (Fight/Escape prompt shown again)

Configuration items list ​

Main battle-related settings changeable in the Editor: System tab:

Setting keyContentDefault
formula_battle_first_strikeFormula for first-strike check (true = ally first)Empty (no check, battle-start prompt shown immediately)
formula_battle_action_orderFormula for action order calculationEmpty (input order)
battle_first_turn_include_turn_startTrigger TURN_START on turn 1true
battle_end_include_turn_endAlso trigger TURN_END on battle endfalse
bi_auto_retarget_enemyEnemies re-draw targets on ally wipeouttrue
bi_auto_retarget_allyAllies re-draw targets on enemy wipeouttrue
battle_dead_effectEffect ID used for DEAD directionDISAPPEAR
bi_transition_battle_startBattle start transitionDefault
bi_transition_battle_endBattle end transitionDefault
bgm_battleBattle BGM—
bgm_victoryVictory BGM—
bgm_defeatDefeat BGM—
sound_missSE on miss—
sound_escapeSE on successful escape—
encounter_defeat_actionHandling on encounter defeat (Reset Game / Move Event)Reset Game
encounter_defeat_eventDestination event ID when Move Event is selectedEmpty

Reserved items (BASIC_ACTION) ​

There are 4 reserved items that play special roles in battle. They have fixed type=BASIC_ACTION and is_attach=false, and editor changes other than name and icon are restricted.

Reserved IDRoleTool-fixed / user-mutable
BA_ATTACKNormal attack (default action of Fight prompt)Fixed: target=Selected Opponent / timing=Battle
BA_ESCAPEEnemy-only escape action (specified in enemy pattern; unusable by allies)Fixed: target=User / effect=DISAPPEAR
BA_ITEMControl-only, displays the "Item" button on the type menuLabel (name) is user-editable; other properties ignored by runtime
BA_DEFENDDefensive action (freely customizable by users; design possible with PRIORITY for fastest trigger)Mostly user-mutable

Display of the "Item" button

If you want the "Item" button to appear in the battle type menu, include BA_ITEM in that character's items. If not included, the button itself is not shown, resulting in a "no item use during battle" design.

1. Base action order Formula on a PRIORITY expression ​

A design where "priority varies by skill characteristics" is recommended — attack skills depend on AGI, defense is always fastest, etc.:

formula_battle_action_order = USER.AGI.MAX + ACT_ITEM.PRIORITY.MAX
  • Set PRIORITY Parameter per skill
  • Defense skill: PRIORITY=9999 (always fastest)
  • Normal attack: PRIORITY=0 (AGI order)
  • Delayed attack: PRIORITY=-100 (always slowest)

2. Enemy AI distributes multiple patterns by rate ​

A single pattern makes behavior monotonous, so basically distribute 2-4 patterns by rate:

  • Pattern 1: Physical attack (rate: 50)
  • Pattern 2: Magic attack (rate: 100)

3. Design drops via Drop Table ​

Specify item / Attach drops via add_drop_table_defeat. Drop Table supports weighted lottery, so "rare equipment drops at low probability" is naturally expressible.

4. Prepare rescue event on wipeout ​

With encounter_defeat_action=Move Event + a dedicated event, you can provide rescue direction like "revive at the church" or "a comrade comes to help." Default Reset Game sends you directly to the title, which is harsh; Move Event is recommended for casual games.

5. Direct boss battles via Start Battle ​

For boss battles, use Start Battle instead of encounters, and arrange direction events (appearance, victory message, story progression) before and after it to create impressive scenes.

6. Produce the boss feel with escape disabled ​

For boss battles, turning ON the "Escape Disabled" property of Start Battle gives players the tension of being unable to flee.

Limitations and notes ​

BATTLE_END does not trigger on defeat ​

Defeat handling involves save data rollback, so BATTLE_END State effects do not trigger (they would disappear on rollback). The right approach for "direction effects on defeat" is not via State but by arranging them as Event Content inside the event specified by encounter_defeat_event in Editor: System.

Rollback on defeat is partial ​

Rollback on defeat is only add_current_param (changes to "current values" like HP/MP). Consumed items, defeated enemy drops (don't occur because victory phase isn't reached), variable updates, etc. are not rolled back. Do not expect behavior like "variables revert to pre-battle state on defeat."

Save disabled during battle ​

Battle is designed so menus can't be opened, so players cannot save. If a crash occurs during a long battle, play restarts from before the battle (autosave does not trigger during battle either).

Battle does not stop on Formula parse errors ​

If a parse error occurs in a battle-related Formula (formula_battle_action_order etc.), this tool is designed to return 0 and does not stop. If you see symptoms like "action order is off" or "first-strike check always fails," review the Formula.

Target wipeout behavior is per-side ​

bi_auto_retarget_enemy / bi_auto_retarget_ally are controlled per side. Asymmetric settings like "enemies re-draw but allies don't" are possible.

State effect trigger order is fixed by timing ​

The order BATTLE_START → TURN_START → BEFORE_ACT → AFTER_ACT → TURN_END → BATTLE_END is tool-fixed and cannot be changed. Fit requirements like "I want poison damage before action" into this timing system.

Only drops via drop_table are supported ​

Item / Attach drops have been unified under Drop Table (the old add_item_defeat / add_attach_defeat are deprecated). Define them in Editor: Drop Table, then reference the table ID in the enemy's add_drop_table_defeat.