- For giving a Pokémon as a gift, see Manipulating Pokémon.
This page describes trading a Pokémon with an NPC.
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:
- 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).
- 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).
- 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.
- 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".
This is the method that makes the trade.
It has a number of parameters, which are as follows:
|Player's Pokémon party index||The index in the party of the player's Pokémon (which is being traded away). This should be chosen beforehand. The example assumes the party index of the Pokémon has been stored in Game Variable 1, and is thus referenced here by |
|New Pokémon internal name or object||The internal name of the species of the new Pokémon that the player will receive in the trade. This is typically announced by the NPC beforehand, because it's only fair that you're told what you're getting. Note the colon in front of the internal name.
This may instead be a predefined Pokémon object instead of a species internal name. This allows you to create and modify a Pokémon beforehand (e.g. set its gender/shininess/form) before trading it to the player. This must be done if the changes would affect the Pokémon's sprite (as the sprite is shown during the trading animation), or if you want it to hold an item that would make it evolve because of the trade (or an Everstone which will prevent such an evolution).
|New Pokémon's nickname||The nickname of the new Pokémon that the player will receive in the trade. This cannot be changed by the player afterwards.|
|New Pokémon's original trainer's name||The name of the original trainer of the Pokémon that the player will receive in the trade (i.e. the name of the NPC).|
|New Pokémon's original trainer's gender||Optional. The gender of the original trainer of the Pokémon that the player will receive in the trade (i.e. the gender of the NPC). By default, this is |
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 = pbGenPkmn(:HAUNTER,pbGetPokemon(1).level) pbStartTrade(pbGet(1),pkmn,"HaHa","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 alters 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.
- 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.