Fandom

Pokémon Essentials Wiki

Defining a trainer

228pages on
this wiki
Add New Page
Talk0 Share
For the main page about trainers, see Trainers.

This page describes how to define a trainer. This includes both trainer types and individual trainers.

Defining a trainer type

Every trainer in the game, including the player, has a trainer type. The trainer type defines various pieces of information that are common to all trainers of that type - this includes their title (e.g. Bug Catcher, Hiker, Gym Leader), appearance (i.e. sprite), the amount of money gained from defeating them, and associated battle music.

A trainer type begins with its definition. This means that it is listed in the PBS file "trainertypes.txt", so that it can be recognised by the game as a trainer type.

In addition to this, a trainer type will require a number of graphics files depicting that trainer type in different ways. See below for more information.

PBS file "trainertypes.txt"

The PBS file "trainertypes.txt" lists all the defined trainer types in the game. Each line in this file is one separate trainer type.

Every line in this file follows the same format. Firstly, here are some examples:

1,POKEMONTRAINER_Leaf,Pokémon Trainer,60,,,,Female,,
7,BEAUTY,Beauty,56,,,,Female,,
18,HIKER,Hiker,32,,,,Male,,
51,COOLCOUPLE,Cool Couple,72,,,,Mixed,48,
59,LEADER_Brock,Gym Leader,100,gymleader,,,Male,,
71,CHAMPION,Champion,100,elite,,,Male,,

Each line is structured as follows, with commas separating each part:

Part Information Description
1 ID number This number must be different for each trainer type. It must be a whole number between 0 and 65535. You can skip numbers (e.g. the sequence 23,24,25,197,198,199,... is allowed). The order in which trainer types are numbered is not important.
2 Internal name This is how the scripts refer to the trainer type. Typically this is the trainer type's name, but written in all capital letters and with no spaces or symbols. The internal name is never seen by the player.
3 Display name The name of the trainer type, as seen by the player. Multiple trainer types can have the same display name, although they cannot share ID numbers or internal names.
4 Base money The amount of money earned from defeating a trainer of this type. The base money value is multiplied by the highest Level among all the trainer's Pokémon to produce the actual amount of money gained (assuming no other modifiers). Must be a number between 0 and 255.

Optional. If undefined, the default is 30.

5 Battle BGM The name of a background music (BGM) file in the folder "Audio/BGM" (excluding its file extension). The music that plays during battles against trainers of this type. Typically only defined for Gym Leaders, Elite Four members and rivals.

Optional. If undefined, the default BGM is used.

6 Victory BGM The name of a background music (BGM) file in the folder "Audio/BGM" (excluding its file extension). The victory background music that plays upon defeat of trainers of this type.

Optional. If undefined, the default victory BGM is used.

7 Intro ME The name of a music effect (ME) file in the folder "Audio/ME" (excluding its file extension). The music that plays before the battle begins, while still talking to the trainer.

Optional. If undefined, the default ME is used.

8 Gender The gender of all trainers of this type. Is one of:
  • Male
  • Female
  • Mixed (i.e. if the type shows a pair of trainers)

Optional. If undefined, the default is "Mixed".

9 Skill level The skill level of all trainers of this type, used for battle AI. Higher numbers represent higher skill levels. Must be a number between 0 and 255.

Optional. If undefined, default is equal to the base money value.

10 Skill codes A text field which can be used to modify the AI behaviour of all trainers of this type. No such modifiers are defined by default, and there is no standard format. See the page Battle AI for more details.

Optional. If undefined, the default is blank.

There is no difference between a trainer type used by many trainers (e.g. Bug Catcher), and a trainer type unique to just one NPC (e.g. Gym Leaders). They are all defined in exactly the same way.

It is important to note that the player also has a trainer type, and it is defined in exactly the same way as any other trainer type. Player characters are defined in the PBS file "metadata.txt" to have trainer types. They do not need to be the first trainer types defined in the PBS file "trainertypes.txt", although it may help developers to keep track of them if they are.

Trainer type graphics

Each trainer type must have the following graphics, placed in the "Graphics/Characters" folder with the following names:

  • trainerXXX.png - The trainer type's battle sprite. "XXX" is either the internal name of the trainer type, or its ID number padded to 3 digits (e.g. "018" is the Hiker trainer type).
  • trcharXXX.png - The trainer type's overworld charset. "XXX" is as above.

Certain trainer types will also require back sprites. These include all trainer types which are used by player characters, as well as all trainer types which have NPC trainers who team up with the player and fight alongside them (i.e. partner trainers). Back sprites are also placed in the "Graphics/Characters" folder, with the following name:

  • trbackXXX.png - "XXX" is as above.

The back sprite can either be a square picture (e.g. 128x128 pixels), or it can contain 5 such square pictures arranged horizontally (e.g. 640x128 pixels). The first frame will be the regular back sprite, and the next four depict a throwing animation in order.

Defining an individual trainer

An individual trainer begins with its definition. This means that it is listed in the PBS file "trainers.txt", so that it can be recognised by the game as an individual trainer.

PBS file "trainers.txt"

The PBS file "trainers.txt" lists all the defined individual trainers in the game. Each section in this file is one separate individual trainer, where a section begins with a line containing the internal name of a trainer type and ends when the next section begins.

The first three lines of each section are consistent, and are always present. After those, there are one to six additional lines, each of which defines a Pokémon owned by that trainer.

Firstly, here are three examples:

CAMPER
Liam
5
DIGLETT,10
BONSLY,11
MAGIKARP,12
TEDDIURSA,10
SENTRET,14
TEAMROCKET_M
Grunt,1
1
WEEPINBELL,21
LEADER_Brock
Brock
2,FULLRESTORE,FULLRESTORE
GEODUDE,12,,DEFENSECURL,HEADSMASH,ROCKPOLISH,ROCKTHROW,0,M,,,,20
ONIX,14,SITRUSBERRY,HEADSMASH,ROCKTHROW,RAGE,ROCKTOMB,0,M,,shiny,,20,,Rocky,,19

The line information is as follows:

Line Content
1 The internal name of the trainer's type, as defined above.
2 The trainer's name (e.g. Dave).

Multiple individual trainers can share the same name and trainer type. In that case, each of them must also have a unique ID number (between 0 and 255), which is written on this line after the trainer's name and after a comma.

When creating the trainer's event, you should include the ID number in the appropriate way to show which specific trainer you want to use.

ID numbers are useful for rematches, where they represent different versions of the same trainer changing over time, and for creating groups of "Grunts" (multiple separate trainers with the same name and appearance, e.g. "Team Rocket Grunt", where "Team Rocket" is the trainer type and "Grunt" is the name). Note that there are rules placed on the usage of ID numbers for rematch trainers.

3 There are two main parts to this line, with each part separated by a comma:
  1. The number of Pokémon this trainer has.
  2. A comma-separated list of all the items this trainer has (e.g. Potions). They are the internal names of those items. There is no limit to how many items can be defined, although the trainer Editor only goes up to 8 items.

The Pokémon count is necessary, but the items are all optional. If this trainer does not have any items, the line will simply consist of a single number (no commas).

4, etc. There are a number of lines here, each one corresponding to a single Pokémon owned by this trainer. The total number of Pokémon lines is the Pokémon count number in line 3.

Each Pokémon line has up to 17 parts (only the first two, species and level, are necessary), with each part separated by a comma:

  1. Species - the internal name thereof
  2. Level
  3. Held item - the internal name thereof
  4. Move 1 - the internal name thereof. If at least one move is defined here, then the Pokémon's moveset will consist solely of those move(s), including gaps for undefined move slots. If no moves are defined, then the moveset will be the same as a wild Pokémon of the same species and level.
  5. Move 2 - the internal name thereof
  6. Move 3 - the internal name thereof
  7. Move 4 - the internal name thereof
  8. Ability - either "0" (first natural ability), "1" (second natural ability) or "2" through "5" (hidden abilities). Leave blank to have it be determined by the personal ID normally.
  9. Gender - either "M" (male) or "F" (female). Leave blank to have it be determined by the personal ID normally.
  10. Form - default is 0
  11. Shininess - "shiny" if the Pokémon is shiny, blank if not. Default is blank.
  12. Nature - the internal name thereof. Leave blank to have it be determined by the personal ID normally.
  13. IVs - a single value between 0 and 31. Each of the Pokémon's IVs (HP, Attack, Defense, Speed, Special Attack, Special Defense) will be equal to this number. Default is 10.
  14. Happiness - a value between 0 and 255. Default is 70.
  15. Nickname - up to 10 characters long.
  16. Shadow Pokémon - "true" if the Pokémon is a Shadow Pokémon, blank if not. Default is blank.
  17. Ball type - the Ball number of the type of Poké Ball the Pokémon is kept in

Note that both the number of lines per section (i.e. per trainer), and the lengths of the lines describing individual Pokémon (i.e. how many commas there are in it), vary from trainer to trainer.

The EVs of a trainer's Pokémon depend on its level. They are each automatically set to 1.5 times its level, up to a maximum of 85.

Related tutorials

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.