Skip to content

Adding a New Trainer Class

Tyler Scarff edited this page Jul 22, 2022 · 1 revision

Create a Constant

Open /include/constants/trainers.h. Around line 290 should be a long list of lines that look something like

#define TRAINER_CLASS_PKMN_TRAINER 0x0.

This is where you will add the constant for your new trainer class. You can add a new line to the end of the list, or change the name of the first two entries to suit your needs.

For this tutorial, I'm adding #define TRAINER_CLASS_KING 0x42 to the end of the list.

Setting the Trainer Class Display Name

We will want to see the class name in game, so let's do that here. Open src/data/text/trainer_class_names.h. Add a new entry to the gTrainerClassNames array for your trainer. For the King trainer class, I'll add the following to the end of the array: [TRAINER_CLASS_KING] = _("{PKMN} KING"), The value of the name cannot be longer than 13 characters by default!

Setting the Trainer Money

Now let's determine how much the trainer class will reward the player after being defeated! Open src/battle_main.c and navigate to the line

const struct TrainerMoney gTrainerMoneyTable[] =

This should be 331 in a vanilla ROM

Somewhere in the struct, add an entry for your trainer class. Adding an entry for TRAINER_CLASS_KING could look like: {TRAINER_CLASS_KING, 50},

A higher number leads to more money given to the player on victory. The formula to determine the exact amount of money given is located in src/battle_script_commands.c in the "GetTrainerMoneyToGive" method. The last few lines of the method utilize the trainer class.

NOTE IF you do not set the TrainerMoney value, the game will default the trainer money value to 5.

Victory Music

Some trainer classes, such as Elite Four Members, play custom music after they are defeated by the player. Lines 4902 through 4921 in src/battle_main.c handle this. Add a case statement for your trainer class if you want to use any of the music available in game. For the King trainer class to play the gym leader victory theme, this section of code could look like:

 switch (gTrainers[gTrainerBattleOpponent_A].trainerClass)
        {
        ...
        case TRAINER_CLASS_LEADER:
        case TRAINER_CLASS_KING:
            PlayBGM(MUS_VICTORY_GYM_LEADER);
            break;
        default:
            PlayBGM(MUS_VICTORY_TRAINER);
            break;
        }

This guide does not cover creating custom music.

Clone this wiki locally