Trainer Classes
All trainer classes are defined inconstants/trainer_constants.asm:
There are 48 trainer classes (
NUM_TRAINERS = 47, excluding NOBODY). The trainer_const macro automatically generates both the class ID and an opponent ID offset of 200.Trainer Constant Macro
The macro creates two constants per trainer:YOUNGSTER becomes:
YOUNGSTER = $01(trainer class)OPP_YOUNGSTER = 201(opponent ID for battle system)
Trainer Data Structure
Trainer parties are defined indata/trainers/parties.asm with two formats:
Format 1: Same Level
All Pokémon at the same level:Format 2: Custom Levels
Each Pokémon has individual level:Format 2 (starting with
$FF) is typically used for Gym Leaders, Elite Four, and your Rival, where Pokémon have carefully balanced levels.Trainer Data Pointers
Each trainer class has a pointer to its party data:Party Selection
Within each class’s data, the game selects the specific trainer by index (e.g., “Youngster #3”).
Trainer Names
Trainer names are stored indata/trainers/names.asm as null-terminated strings.
Each class gets:
- A class name (“YOUNGSTER”, “LASS”, etc.)
- Optional individual names for important trainers
Most regular trainers share a class name. Only significant trainers (Gym Leaders, Elite Four, Rival) have unique names.
Prize Money
Prize money calculation uses base values fromdata/trainers/pic_pointers_money.asm:
Trainer AI System
AI behavior is controlled byengine/battle/trainer_ai.asm with class-specific modifications.
AI Pointers
- Evaluate type matchups
- Prefer status moves in certain situations
- Switch Pokémon strategically
- Use healing items (some trainers only)
Move Choice Modifications
Fromdata/trainers/move_choices.asm:
AI Flag Meanings
AI Flag Meanings
- Bit 0 (1): Prefer moves that are super effective
- Bit 1 (2): Avoid moves that are not very effective
- Bit 2 (4): Prefer status moves when appropriate
- Bit 3 (8): Prefer moves with high power
Trainer DVs
Fromconstants/battle_constants.asm, trainer Pokémon use fixed DVs:
- Attack DV: 9
- Defense DV: 8
- Speed DV: 8
- Special DV: 8
- HP DV: 8 (calculated from other DVs)
Trainer Pokémon have slightly above-average DVs (8-9 out of 15), making them stronger than typical wild Pokémon but not perfect.
Rival Battles
The Rival is special, with three separate class IDs for different points in the game:- Which starter the player chose
- Current point in the story
- Location of the battle
Rival Party Structure
The Rival’s team adapts based on the player’s starter:- If player chose Bulbasaur, Rival has Charmander
- If player chose Charmander, Rival has Squirtle
- If player chose Squirtle, Rival has Bulbasaur
Special Trainers
Professor Oak
Giovanni
- Team Rocket Hideout
- Silph Co.
- Viridian Gym (final battle)
Team Rocket Grunts
Trainer Encounter Flags
Each trainer has a unique event flag that tracks whether they’ve been defeated. This prevents re-battling and is used to give rewards. When a trainer is defeated:- Their event flag is set
- Prize money is awarded
- Their dialogue changes to post-battle text
- They no longer trigger battles when approached
Battle Engine
How trainer battles work
Pokémon
Trainer Pokémon stats
Reference
Trainer constants
Data Structures
Trainer party formats
Key Files
constants/trainer_constants.asm- Trainer class IDsdata/trainers/parties.asm- All trainer party datadata/trainers/names.asm- Trainer class namesdata/trainers/pic_pointers_money.asm- Sprites and prize moneydata/trainers/ai_pointers.asm- AI routine pointersdata/trainers/move_choices.asm- AI behavior flagsengine/battle/trainer_ai.asm- AI implementation