The RPGReact battle system is a collection of React components that work together to render battles using data from RPG Maker MZ's battle engine. This guide explains the architecture, component relationships, and how to customize the battle UI.
Architecture Overview
The battle system uses a single-direction data flow from RMMZ to React:
React components never modify game state directly. They only:
Observe MobX-wrapped game objects
Render UI based on that state
Call RMMZ commands through pageData.commands
Core Components
BattleMain.tsx
Location:menus/src/views/battle/BattleMain.tsx
The root battle component that orchestrates all battle UI elements.
Key responsibilities:
Mounts all battle sub-components
Manages battle phase transitions
Handles battle end/victory/defeat
Coordinates between input, display, and results screens
Structure:
Props: Standard BaseMenuScreenProps
BattleParty.tsx
Location:menus/src/views/battle/BattleParty.tsx
Displays all party members' HP/MP/TP gauges and status.
Features:
Real-time HP/MP updates using MobX observers
Status ailment icons
ATB gauge integration
Click-to-target (if target selection active)
Key code pattern:
BattleInput.tsx
Location:menus/src/views/battle/BattleInput.tsx
Handles command input for the active battler (Attack, Skill, Guard, Item, etc.).
Flow:
Shows when BattleManager.isInputting() is true
Displays commands for current actor
Calls pageData.commands.battleCommand(commandName) on selection
May trigger SubSelectionWindow for skills/items
May trigger target selection
Command types:
Attack → Target selection
Skill → Skill list → Target selection
Guard → Immediate action
Item → Item list → Target selection
Layout note:
Ensure the command window stacks above the party panel (z-index on the battle input container) so the full width remains clickable even with 3D transforms.
// User selects "Attack"
props.pageData.commands.battleCommand('attack');
// User selects target
props.pageData.commands.selectTarget(enemyIndex);
// User confirms action
props.pageData.commands.confirmAction();
1. Battle Start
↓
2. Turn Start → Input Phase
- BattleInput shows for active actor
- Player selects command
- Player selects target (if needed)
↓
3. Action Execution Phase
- Actions execute in speed order
- BattleLog updates with results
- HP/MP/TP bars animate
↓
4. Turn End
- Check for victory/defeat/escape
- If battle continues, go to step 2
↓
5. Battle End
- BattleResults shows (if victory)
- OR GameOver screen (if defeat)
1. Battle Start
- All ATB gauges begin filling
↓
2. Continuous Loop
- ATB gauges fill based on agility
- When gauge full → Input Phase for that actor
- Time continues (Active) or pauses (Wait)
- Player selects command/target
- Action executes immediately after input
- BattleLog updates
↓
3. Battle End (same as turn-based)