Trading Pokémon

*For giving a Pokémon as a gift, see Manipulating Pokémon.*

This page describes **trading a Pokémon with an NPC**.

## In-game trading

Setting up an NPC to trade Pokémon with is relatively straightforward. The NPC event should have two pages to it, the first containing code like in the example on the right. The second page depends on the event's Self Switch A being ON, and is for future interactions after the trade has been performed (typically a brief dialogue to the effect of "I hope you're treating my Pokémon well!").

The event works as follows:

1. The player is asked whether they want to trade Pokémon, having been told what the trade is (e.g. player's Rattata for NPC's Haunter).
2. The player chooses a Pokémon in their party. If the chosen Pokémon is a Rattata (and not an egg or Shadow Pokémon), its party index is stored in Game Variable 1 (and its name in Game Variable 2).
3. The trade is performed. This includes an animation of the Pokémon being swapped. The received Pokémon replaces the traded-away Pokémon. If the received Pokémon would evolve due to being traded, it does so.
4. The event's Self Switch A is turned ON.

The received Pokémon will always have the same level as the traded-away Pokémon. All Pokémon received in a trade should have a nickname. In the example on the right, the received Haunter is nicknamed "HaHa".

### pbStartTrade

This is the method that makes the trade.

```
pbStartTrade(pbGet(1), :HAUNTER, _I("HaHa"), _I("Andrea"), 1)

```

It has a number of parameters, which are as follows:

 New Pokémon's species, or new Pokémon
 New Pokémon's nickname
 New Pokémon's original trainer's name
 New Pokémon's original trainer's gender
This affects the colour of the text used to display the original trainer's information in the Pokémon's summary screens.

The original trainer's ID for the foreign Pokémon will be randomly generated during the trade.

## Modifying the foreign Pokémon

*Main article: Editing a Pokémon*
As mentioned above, you can create a Pokémon prior to the trade and edit its properties, and then start the trade with it.

```
pkmn = Pokemon.new(:HAUNTER, pbGetPokemon(1).level)
pbStartTrade(pbGet(1), pkmn, _I("HaHa"), _I("Andrea"), 1)

```

Note that, if you do this, you will need to set the new Pokémon's level to the appropriate value yourself. The above script is the way to do so. Alternatively, creating a Pokémon prior to the trade is how you can give it a different level to the Pokémon the player is trading away.

Another way to edit the received Pokémon's properties is after the trade, by remembering that it will be in the player's party after the trade, in the same party slot that the traded-away Pokémon was in. This slot's index should still be accessible (typically stored in Game Variable 1), so you can access the new Pokémon with the following code:

```
pkmn = pbGetPokemon(1)

```

From there, see Editing a Pokémon for how to edit a Pokémon's properties.

Note that, as mentioned above, any properties of a Pokémon which alter its appearance (or how it is recorded in the Pokédex) should be edited before the trade, because its sprite is shown during the trade and it is also recorded in the Pokédex as seen/owned during the trade.

The Pokémon's original trainer's ID number is randomly generated during the trade. If you want this to be a particular number, you should edit that property of the Pokémon after the trade.

## Tips

* You can make the trade requirements more specific than just requiring a Pokémon of a particular species. Why not require the player's Pokémon to be a particular gender, or nature, or have good EVs?
* Alternatively, you can make the trade *less* specific, or at least different. Why not require the player to hand over an egg, or a Pokémon in the Water 2 breeding category, or any Fire-type Pokémon?
* You can change the level of the foreign Pokémon if you predefine it before the trade and give it a different level. The trade itself will not change its level if it was predefined.