Battle Mechanics
The battle system in Pokémon Essentials BES handles all combat interactions between Pokémon, including turn order, damage calculations, type effectiveness, and critical hits.Battle System Architecture
Core Battle Classes
The battle system is organized around several key classes:Represents an individual Pokémon in battle with stats, moves, and status conditions.
Represents a trainer with their party of Pokémon and battle settings.
Manages organized battle formats like Battle Tower, Battle Palace, and Battle Arena.
Battle Initialization
Turn Order and Priority
Priority System
Moves execute based on their priority value defined inPBS/moves.txt. Higher priority moves execute first.
Priority values range from -6 (lowest) to +5 (highest). Most moves have priority 0.
Speed Calculation
When moves have the same priority, the Pokémon with higher Speed stat attacks first.Speed Tie Resolution
Speed Tie Resolution
If two Pokémon have identical Speed stats and priority, the order is determined randomly.
Damage Calculation
Base Damage Formula
The damage calculation uses the following core formula:- Level: Attacker’s level
- Power: Move’s base power
- A: Attacker’s Attack or Special Attack stat
- D: Defender’s Defense or Special Defense stat
Move Data Structure
Each move inPBS/moves.txt contains damage information:
Base damage of the move (0 for status moves)
Physical: Uses Attack vs DefenseSpecial: Uses Special Attack vs Special DefenseStatus: No direct damage
Type Effectiveness
Type Chart System
Type effectiveness is compiled fromPBS/types.txt into Data/types.dat.
Effectiveness Multipliers
Type Effectiveness Chart
Type Effectiveness Chart
- Immune (0x): Ghost immune to Normal/Fighting
- Not Very Effective (0.5x): Fire resists Fire, Grass, Ice, Bug, Steel
- Super Effective (2x): Fire weak to Water, Ground, Rock
- Dual Types: Multipliers stack (4x, 0.25x possible)
Critical Hits
Critical Hit System
Critical hits deal increased damage and ignore stat stage changes. Critical Hit Stages:| Stage | Probability |
|---|---|
| 0 | 1/16 |
| 1 | 1/8 |
| 2 | 1/2 |
| 3+ | Always |
High Critical Ratio Moves
Moves with theh flag have increased critical hit ratios:
Accuracy System
Accuracy Check
Accuracy is checked using:Base accuracy percentage (0 = never miss, 100 = always hits barring evasion)
Move Flags
Move flags inPBS/moves.txt determine special properties:
Common Move Flags
Common Move Flags
- a: Move makes contact
- b: Target can use Protect/Detect
- c: Target can use Magic Coat
- d: Target can use Snatch
- e: Can be used by Mirror Move
- f: Affected by King’s Rock flinch
- h: High critical hit ratio
- i: Affected by Iron Fist ability
- j: Punch-based move
- k: Sound-based move
- m: Pulse-based move
- n: Bomb/ball move
Battle Flow
Turn Structure
- Move Selection: Players and AI choose moves
- Priority Sorting: Moves sorted by priority, then Speed
- Move Execution: Moves execute in calculated order
- Effect Application: Damage, status, stat changes applied
- End of Turn: Weather, status damage, ability effects
Organized Battles
Organized battles like Battle Tower use special rules:Code Examples
Creating a Battle Pokemon
Level Adjustment for Battle Challenges
Related Systems
See also:- Move Effects - Function codes and move implementations
- Ability Effects - How abilities modify battle mechanics
- Data Loading - How battle data is loaded from PBS files