Wikia

Pokémon Essentials Wiki

Manipulating Pokémon

Talk12
195pages on
this wiki

This article describes how to manipulate Pokémon during the game. This includes how to give/take Pokémon, choose a Pokémon from the player's party, decide whether a certain species has been seen/captured, and so forth.

For how to change a property (e.g. gender) of a particular Pokémon, see the article Editing a Pokémon.

Adding a Pokémon

There are 4 ways to easily give the player a Pokémon. These are as follows:

Function What it does
pbAddPokemon(:PIKACHU,20) Adds the Pokémon to the player's party (if there is a space). If the player's party is full, the Pokémon is stored in the PC instead.

When it has been given, a message will say the player has received it, and then the player will be allowed to nickname it.

If there is no possible place for the Pokémon to go, this function will return a message saying that there is no space.

pbAddPokemonSilent(:PIKACHU,20) Same as above, except it does not display any messages at all, and does not allow nicknaming.
pbAddToParty(:PIKACHU,20) Adds the Pokémon to the player's party (if there is a space). If the player's party is full, this function will return a message saying that there is no space.

When it has been given, a message will say the player has received it, and then the player will be allowed to nickname it.

pbAddToPartySilent(:PIKACHU,20) Same as above, except it does not display any messages at all, and does not allow nicknaming.

All four methods above will return TRUE if the Pokémon was added, and FALSE if it was not. This means it can be used as the statement in a Conditional Branch, e.g.

@>Conditional Branch: Script: pbAddPokemon(:EEVEE,25)
  @>Text: Pokémon was received...
  @>
 : Else
  @>Text: Sorry, you have no room...
  @>
 : Branch End
@>

The Conditional Branch allows for additional messages, such as "I hope you treat Eevee well" or "Oh, that's too bad."

Alternatively, you can define a Pokémon beforehand, and then add it using the same methods above, like so:

poke=PokeBattle_Pokemon.new(:MAGIKARP,10,$Trainer)
pbAddPokemon(poke)

This allows you to modify the Pokémon before giving it to the player. See the article Editing a Pokémon for how it can be modified.

Each of the four methods listed above have an extra parameter at the end, which determines whether to record the newly-added Pokémon's form in the Pokédex (in addition to seeing/owning it at all). This parameter is TRUE by default, i.e. the form is recorded by default. You should never need to set this to FALSE, as the Pokémon to be added can be edited beforehand (i.e. its gender/form can be set before adding it); however, the option is there.

Adding a Pokémon owned by another trainer

You can have an NPC give the player a Pokémon as a gift. This is different to trading, in which the player swaps one of their Pokémon for the NPC's Pokémon. It is also different to finding a Pokémon in an item ball (in which the player is its original owner).

To do so, use the following script:

pbAddForeignPokemon(:SHUCKLE,20,_I("Kirk"),_I("Shuckie"),0)

"Kirk" and "0" are the original trainer's name and gender (0=male, 1=female, 2=unknown) respectively, where the trainer's name is required and their gender is optional (default is male). "Shuckie" is the Pokémon's nickname (optional). Note that the quotation marks are required (as in the example below).

When the Pokémon is added, it will not allow the player to rename it (and the Name Rater can't rename foreign Pokémon later on either). A random original trainer ID number (different to the player's trainer ID) will be generated for the Pokémon. If the Pokémon is added, a message will say so.

If the player's party is full, this function will return FALSE without any messages. Therefore, you should use it as the statement in a Conditional Branch, so that a failure to add the Pokémon can be mentioned (e.g. with the message "Oh, your party is full.").

This script can only add a Pokémon to the player's party, which means it can be modified after adding it. It will be the last Pokémon in the party, i.e. $Trainer.party[$Trainer.party.length-1]. See the article Editing a Pokémon for how it can be modified.

This method has an extra parameter at the end, which determines whether to record the newly-added Pokémon's form in the Pokédex (in addition to seeing/owning it at all). This parameter is TRUE by default, i.e. the form is recorded by default. Unlike the methods above, this one will not allow you to define a Pokémon beforehand and then add it. Therefore, if you want to change the Pokémon's gender and/or form, you will need to add "false" as an extra final parameter, and then edit the added Pokémon appropriately. Remember to record the Pokémon's form after editing it.

Demo party

The def pbCreatePokemon in the script section PokemonUtilities can be used to give the player a full party of Pokémon (all at level 20), as follows:

  • Pikachu
  • Pidgeotto
  • Kadabra
  • Gyarados
  • Diglett
  • Chansey

Between them, they will know all the moves usable out of battle (except for Milk Drink).

This script exists for demonstration purposes only, and should not be used in any game.

Deleting a Pokémon in the party

To permanently remove a Pokémon from the player's party, use the following script:

pbRemovePokemonAt(index)

"index" is the position of the Pokémon in the party (first place is 0, second place is 1, etc.). This script cannot delete the Pokémon if it is the player's only able Pokémon (i.e. unfainted and not an Egg). The method does not display any messages. It returns TRUE if the Pokémon was deleted, and FALSE if it was not (and thus should be used as the argument of a Conditional Branch).

Note that, after the Pokémon is deleted, any Pokémon lower down in the party list are bumped up to fill the gap. Keep this in mind if you intend to delete multiple Pokémon at once - to be safe, you should always delete Pokémon in reverse order (i.e. starting from the bottom of the party).

A less safe way to remove a Pokémon is to use the script $Trainer.party.delete_at(index), where "index" is as above. This does the same thing as pbRemovePokemonAt, except that it can delete the player's last able Pokémon.

Checking for Pokémon

To see if the player has a Pokémon of a certain species in their party, use pbHasSpecies?(PBSpecies::species).

@>Conditional Branch: Script: pbHasSpecies?(:CELEBI)
  @>Text: There is a Celebi in the party.
 : Else
  @>Text: There are no Celebi in the party.
 : Branch End

To see if the first Pokémon in the player's party is of a certain species, use the following instead:

@>Conditional Branch: Script: $Trainer.pokemonParty[0].species==PBSpecies::CELEBI
  @>Text: The first Pokémon in the party is a Celebi.
 : Else
  @>Text: The first Pokémon in the party is not a Celebi.
 : Branch End

Note that this example uses $Trainer.pokemonParty instead of the usual $Trainer.party. This is because $Trainer.pokemonParty ignores eggs, and just looks at the Pokémon in the party instead (both unfainted and fainted). There is also $Trainer.ablePokemonParty, which is the same except it also ignores fainted Pokémon (and thus only looks at Pokémon which are able to battle).

To find the first able Pokémon in the player's party (i.e. not an egg, and unfainted), use either of the following:

pbFirstAblePokemon(1)
poke=pbFirstAblePokemon(1)

The first example stored the index of the Pokémon in Global Variable 1, while the second also sets "poke" to that Pokémon (i.e. poke.level is that Pokémon's level).

To see if the player has a fatefully encountered Pokémon of a certain species in their party, use pbHasFatefulSpecies?(:species).

Choosing a Pokémon

To make the player choose one of the Pokémon in their party (e.g. so it can then be traded away, to show to the Move Relearner, etc.), use the following script:

pbChoosePokemon(var1,var2)

This opens the party screen, and the player chooses one of the Pokémon therein. The two arguments are as follows:

  • "var1" is the Global Variable to store the party index of the chosen Pokémon in. The number stored will be between 0 and 5, or is -1 if no Pokémon was chosen. Traditionally Global Variable 1 is used for this.
  • "var2" is the Global Variable to store the name (or nickname, if it has one) of the chosen Pokémon in. Traditionally Global Variable 3 is used for this.

There are three possible outcomes of pbChoosePokemon: a Pokémon was chosen, an egg was chosen, and nothing was chosen (i.e. the choice was cancelled).

@>Script: pbChoosePokemon(1,3)
@>Conditional Branch: Variable [0001] < 0
  @>Text: You cancelled the choice.
  @>Jump To Label: Done
 : Branch End
@>Conditional Branch: pbGetPokemon(1).egg?      -- Checks whether the Pokémon recorded in Global Variable 1 is an egg
  @>Text: You chose an egg.
  @>Jump To Label: Done
 : Branch End
@>Text: You chose a \v[3].                      -- Global Variable 3 has the Pokémon's name
@>Script: pbSet(2,pbGetPokemon(1).level)        -- Sets Global Variable 2 to the Pokémon's level
@>Text: It's at level \v[2].
@>Label: Done

This is an example of how to use pbChoosePokemon. It also shows how the chosen Pokémon can be retrieved and information queried from it.

There are two related scripts (both of which have the same two arguments as above):

  • pbChooseAblePokemon - Only allows the player to choose a Pokémon that is not fainted and is not an egg.
  • pbChooseNonEggPokemon - Only allows the player to choose a Pokémon, not an egg (the Pokémon may be fainted).

Other scripts

Script What it does
pbAllFainted Returns TRUE if the player has no able Pokémon left in their party, and FALSE otherwise.
pbCheckAble(0) Ignoring the Pokémon with the party index given, returns TRUE if the player has any able Pokémon, and FALSE if they don't.
$Trainer.pokemonCount Returns the number of Pokémon in the player's party (unfainted and fainted).
$Trainer.ablePokemonCount Returns the number of able Pokémon in the player's party (unfainted only).
pbHealAll Fully heals all Pokémon in the player's party. The event command "Recover All" has the same function.
pbHasSpecies?(:BULBASAUR) Returns TRUE if the player has a Pokémon of the given species in their party (ignoring eggs), and FALSE if they don't.
pbHasFatefulSpecies?(:BULBASAUR) Returns TRUE if the player has a Pokémon of the given species in their party (ignoring eggs) which has been met in a fateful encounter, and FALSE if they don't.
pbCheckMove(PBMoves::TACKLE) Returns the party index number of the first Pokémon in the party that knows the given move (ignoring eggs). Returns nil if none do. Used to determine whether a move can be used outside battle.
pbBalancedLevel($Trainer.pokemonParty) Returns the weighted mean of the levels of all Pokémon in the player's party (ignoring eggs), plus 2. Can be used to modify the levels of wild Pokémon to keep them challenging.
poke.numMoves Returns the number of moves that the given Pokémon (called poke here) knows.
poke.knowsMove?(:TACKLE) Returns TRUE if the given Pokémon (called poke here) knows the given move, and FALSE if it doesn't.
pbHasEgg?(:TOGEPI) Returns TRUE if the given species can be legitimately found as an egg, and FALSE otherwise. This includes Pokémon like Roselia (even though it is an evolved Pokémon, as it can be bred without the required Incense item), and Manaphy (even though it cannot be the result of breeding).
pbGetRegionalNumber(1,PBSpecies::BULBASAUR) Returns the Regional number of the given species for the given Regional Dex (the second one in this example). Returns 0 if the given species does not appear in that Regional Dex.
pbGetNationalNumber(1,135) Returns the National Dex number of the Pokémon which has the given Regional Dex number (135) in the given Regional Dex (1).
pbSize($Trainer.pokemonParty[0]) Returns the Pokémon's "size" in millimetres. Uses the Pokémon's IVs and personal ID number to calculate this value.
$Trainer.seen[PBSpecies::BULBASAUR] Returns TRUE if the given species has been seen, and FALSE if not.
$Trainer.owned[PBSpecies::BULBASAUR] Returns TRUE if the given species has been owned, and FALSE if not.
$Trainer.numFormsSeen[PBSpecies::BULBASAUR] Returns the number of forms of the given species that have been seen. This does not include genders, even if the species has gender differences.


Related tutorials

Around Wikia's network

Random Wiki