Defining a trainer

*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 "trainer\_types.txt", or a PBS file named "trainer\_types\_XYZ.txt" (where "XYZ" is any text), 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 "trainer\_types.txt"

The PBS file "trainer\_types.txt" lists all the defined trainer types in the game. Each section in this file is one separate trainer type, where a section begins with a line containing an ID in square brackets and ends when the next section begins. Each line in a section is one separate piece of information about that trainer type.

Aside from the ID line, every line in a section follows the format:

```
XXX = YYY

```

where XXX is a property and YYY is the value or values associated with it (the spaces are optional). For example:

```
[POKEMONTRAINER_Red]
Name = Pokémon Trainer
Gender = Male
BaseMoney = 60
#-------------------------------
[SISANDBRO]
Name = Sis and Bro
Gender = Unknown
BaseMoney = 16
SkillLevel = 48
#-------------------------------
[LEADER_Misty]
Name = Gym Leader
Gender = Female
BaseMoney = 100
BattleBGM = Battle Gym Leader
VictoryBGM = Battle victory leader

```

All pieces of information are optional, but will have default values if they are not defined. The order of the lines does not matter, except for the ID line in square brackets which must be first.

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 "trainer\_types.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:

* In the "Graphics/Characters" folder:
	+ `trainer_XXX.png` - The trainer type's overworld charset. "`XXX`" is the trainer type's ID, e.g. "`trainer_HIKER.png`".
* In the "Graphics/Trainers" folder:
	+ `XXX.png` - The trainer type's battle sprite. "`XXX`" is the trainer type's ID, e.g. "`HIKER.png`".
	+ `XXX_back.png` - The trainer type's back sprite, used in battle. "`XXX`" is the trainer type's ID, e.g. "`HIKER_back.png`".

The overworld charset only needs to follow the above naming convention if a trainer of that type can be registered in the Phone (it is shown in the Phone's screen), appears in a Battle Frontier facility as an opponent, or if using event comments to generate a trainer event. However, you might as well follow this convention for all trainer types.

Only certain trainer types will require back sprites. These include all trainer types which are used by player characters, as well as all trainer types of NPC trainers who team up with the player and fight alongside them (i.e. partner trainers).

The back sprite can either be a square picture of any size (e.g. 128x128 pixels), or it can contain 5 such square pictures arranged horizontally (e.g. 640x128 pixels). If the latter, the first frame will be the regular back sprite and the next four frames will 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", or a PBS file named "trainers\_XYZ.txt" (where "XYZ" is any text), 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 surrounded by square brackets and ends when the next section begins. Each line in a section is one separate piece of information about that trainer or one of their Pokémon.

The section's "header", the line surrounded by square brackets, has a trainer type's ID, followed by a comma and then the name of the individual trainer. If the trainer requires a version number to differentiate it from other trainers with the same type/name (see below), that version number is also included here after another comma.

The rest of the lines in each section are written in the format `XXX = YYY`, where `XXX` is a property and `YYY` is the value or values associated with it (the spaces are optional).

Some lines may be indented, but this makes no difference and is just done to make things more legible. Any line beginning with a `#` (including the lines separating one trainer from the next) are comment lines and are not compiled; again, they are just there to make things more legible.

Here are some examples of defined trainers:

```
[CAMPER,Liam]
LoseText = A very good battle, indeed!
Pokemon = DIGLETT,10
Pokemon = BONSLY,11
#-------------------------------
[LEADER_Brock,Brock]
Items = FULLRESTORE,FULLRESTORE
LoseText = Very good.
Pokemon = GEODUDE,12
    Gender = male
    Moves = DEFENSECURL,HEADSMASH,ROCKPOLISH,ROCKTHROW
    AbilityIndex = 0
    IV = 20,20,20,20,20,20
Pokemon = ONIX,14
    Name = Rocky
    Gender = male
    Shiny = yes
    Moves = HEADSMASH,ROCKTHROW,RAGE,ROCKTOMB
    AbilityIndex = 0
    Item = SITRUSBERRY
    IV = 20,20,20,20,20,20
    Ball = HEAVYBALL
#-------------------------------
[TEAMROCKET_M,Grunt,1]
LoseText = You're too good for me!
Pokemon = WEEPINBELL,21
    Shadow = yes

```

The order in which these properties are written matters to some extent. Some properties relate to the trainer themselves and must be written before the first Pokémon line for that trainer. Other properties relate to an individual Pokémon owned by the trainer, and relate to the most recently defined Pokémon written above those properties.

The properties relating to the trainer are:

1. The ID of the trainer type.
2. This trainer's name.
3. Optional. A version number to distinguish this trainer from other trainers with the same trainer type and name, when a battle against them is called. Default is 0.

 Items
 LoseText
 Pokemon
1. The ID of a Pokémon species.
2. A level number.

A trainer can have multiple Pokémon - simply have multiple "Pokemon = YYY" lines.

The properties which are specific to a single Pokémon are typically indented to make it easier to see which Pokémon they apply to (the most recently defined one). Indentation is not necessary, though. They can be written in any order within the space after the "Pokemon = YYY" line they apply to.

All of the properties below are optional. The available properties are as follows: