Essentials Docs Wiki

The Essentials wiki has moved and is now at: Essentials Engine wiki

This wiki will no longer be updated.

READ MORE

Essentials Docs Wiki
Maruno (talk | contribs)
No edit summary
Line 1: Line 1:
  +
{{for|changing the properties of a given Pokémon|Editing a Pokémon}}
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.
+
This page 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 ==
 
== Adding a Pokémon ==
  +
There are 4 ways to easily give the player a Pokémon. These are as follows:
+
There are four ways to easily give the [[player]] a Pokémon, all of which will treat the Pokémon as originally belonging to the player. These are as follows:
{|
 
  +
!Function
 
  +
{| class="article-table" border="1"
!What it does
 
 
! Function
 
! What it does
 
|-
 
|-
|<code>pbAddPokemon(:PIKACHU,20)</code>
+
| <code>pbAddPokemon(:PIKACHU,20)</code>
|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.
+
| 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 [[Pokémon storage|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.
 
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.
 
If there is no possible place for the Pokémon to go, this function will return a message saying that there is no space.
 
|-
 
|-
|<code>pbAddPokemonSilent(:PIKACHU,20)</code>
+
| <code>pbAddPokemonSilent(:PIKACHU,20)</code>
|Same as above, except it does not display any messages at all, and does not allow nicknaming.
+
| Same as above, except it does not display any messages at all and does not allow nicknaming.
 
|-
 
|-
|<code>pbAddToParty(:PIKACHU,20)</code>
+
| <code>pbAddToParty(:PIKACHU,20)</code>
|Adds the Pokémon to the player's party (if there is a space). If the player's partyis full, this function will return a message saying that there is no space.
+
| 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.
 
When it has been given, a message will say the player has received it, and then the player will be allowed to nickname it.
 
|-
 
|-
|<code>pbAddToPartySilent(:PIKACHU,20)</code>
+
| <code>pbAddToPartySilent(:PIKACHU,20)</code>
|Same as above, except it does not display any messages at all, and does not allow nicknaming.
+
| 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.
 
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)
 
@>Conditional Branch: Script: pbAddPokemon(:EEVEE,25)
 
@>Text: Pokémon was received...
 
@>Text: Pokémon was received...
Line 34: Line 39:
 
 : Branch End
 
 : Branch End
 
@>
 
@>
  +
 
The Conditional Branch allows for additional messages, such as "I hope you treat Eevee well" or "Oh, that's too bad."
 
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:
 
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.
 
   
  +
pkmn = pbGenPkmn(:MAGIKARP,10)
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.
 
 
pbAddPokemon(pkmn)
   
 
This allows you to modify the Pokémon before giving it to the player. See [[Editing a Pokémon]] for how it can be modified.
=== 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).
 
 
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, but the option is there.
  +
 
=== Adding a gift Pokémon ===
  +
  +
A gift Pokémon is one which originally belonged to an NPC rather than the [[player]], and is thus a foreign Pokémon once the player has it (foreign Pokémon gain Exp faster, can disobey the player's orders depending on its level, and cannot change its nickname).
  +
 
Obtaining a gift Pokémon is not the same as [[Trading Pokémon|trading]], as the player doesn't have to swap one of their Pokémon for the gift Pokémon. It is also different to finding a Pokémon in an [[Item balls|item ball]], as that would make the player its original owner and would use <code>pbAddToParty</code> as described above.
  +
 
To give the player a gift Pokémon, use the following script:
   
To do so, use the following script:
 
 
pbAddForeignPokemon(:SHUCKLE,20,_I("Kirk"),_I("Shuckie"),0)
 
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).
 
   
 
"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).
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.").
+
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 (see above), so that a failure to add the Pokémon can be mentioned (e.g. with the message "Oh, your party is full.").
   
  +
Alternatively, you can define a Pokémon beforehand and then add it, like so:
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. <code>$Trainer.party[$Trainer.party.length-1]</code>. See the article Editing a Pokémon for how it can be modified.
 
   
  +
pkmn = pbGenPkmn(:MAGIKARP,10)
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.
 
  +
pbAddForeignPokemon(pkmn)
  +
  +
This allows you to [[Editing a Pokémon|edit the Pokémon]] before giving it to the player, e.g. giving it specific original trainer information. Although, since this function can only add a Pokémon to the player's [[party]], it will be readily accessible as <code>$Trainer.lastParty</code>, so you can edit the Pokémon after obtaining it instead. See [[Editing a Pokémon]] for how to edit a Pokémon's properties.
  +
 
When the Pokémon is added, the [[player]] will not be allowed to rename it. A random original trainer ID number (different to the player's trainer ID) will be generated for the Pokémon (unless it has already been changed before adding it). If the Pokémon is added, a message will say so.
  +
 
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. You should never need to set this to FALSE, but the option is there.
   
 
=== Demo party ===
 
=== Demo party ===
  +
The def <code>pbCreatePokemon</code> in the script section '''PokemonUtilities''' can be used to give the player a full party of Pokémon (all at level 20), as follows:
+
The <code>def pbCreatePokemon</code> in the script section '''Debug_Actions''' can be used to give the player a full [[party]] of Pokémon (all at level 20), as follows:
  +
 
* Pikachu
 
* Pikachu
 
* Pidgeotto
 
* Pidgeotto
Line 66: Line 86:
 
* Diglett
 
* Diglett
 
* Chansey
 
* Chansey
Between them, they will know all the moves usable out of battle (except for Milk Drink).
 
   
 
Between them, they will know all the [[Using moves outside battle|moves usable out of battle]] (except for Milk Drink).
This script exists for demonstration purposes only, and should not be used in any game.
 
  +
 
This script exists for [[Debug mode|demonstration purposes]] only, and should not be used in any game.
   
 
== Deleting a Pokémon in the party ==
 
== Deleting a Pokémon in the party ==
  +
To permanently remove a Pokémon from the player's party, use the following script:
+
To permanently remove a Pokémon from the player's [[party]], use the following script:
  +
 
<code>pbRemovePokemonAt(''index'')</code>
 
<code>pbRemovePokemonAt(''index'')</code>
  +
"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).
+
"<code>index</code>" 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).
 
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 <code>$Trainer.party.delete_at(''index'')</code>, where "index" is as above. This does the same thing as <code>pbRemovePokemonAt</code>, except that it can delete the player's last able Pokémon.
+
A less safe way to remove a Pokémon is to use the following script:
  +
  +
<code>$Trainer.party.delete_at(''index'')</code>
  +
  +
"<code>index</code>" is as above. This does the same thing as <code>pbRemovePokemonAt</code>, except that it can delete the player's last able Pokémon.
   
 
== Checking for Pokémon ==
 
== Checking for Pokémon ==
  +
To see if the player has a Pokémon of a certain species in their party, use <code>pbHasSpecies?(PBSpecies::''species'')</code>.
+
To see if the player has a Pokémon of a certain species in their party, use <code>pbHasSpecies?(:CELEBI)</code> (replacing the species name with the one you're checking for). Note that this ignores [[Eggs]].
  +
 
@>Conditional Branch: Script: pbHasSpecies?(:CELEBI)
 
@>Conditional Branch: Script: pbHasSpecies?(:CELEBI)
 
@>Text: There is a Celebi in the party.
 
@>Text: There is a Celebi in the party.
Line 86: Line 116:
 
@>Text: There are no Celebi in the party.
 
@>Text: There are no Celebi in the party.
 
 : Branch End
 
 : Branch End
  +
 
To see if the first Pokémon in the player's party is of a certain species, use the following instead:
 
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
+
@>Conditional Branch: Script: isConst?($Trainer.firstPokemon.species,PBSpecies,:CELEBI)
 
@>Text: The first Pokémon in the party is a Celebi.
 
@>Text: The first Pokémon in the party is a Celebi.
 
 : Else
 
 : Else
 
@>Text: The first Pokémon in the party is not a Celebi.
 
@>Text: The first Pokémon in the party is not a Celebi.
 
 : Branch End
 
 : Branch End
Note that this example uses <code>$Trainer.pokemonParty</code> instead of the usual <code>$Trainer.party</code>. This is because <code>$Trainer.pokemonParty</code> ignores eggs, and just looks at the Pokémon in the party instead (both unfainted and fainted). There is also <code>$Trainer.ablePokemonParty</code>, 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:
+
Note that <code>$Trainer.firstPokemon</code> is specifically the first Pokémon in the player's [[party]], i.e. it ignores [[Eggs]]. The first unfainted Pokémon in the player's [[party]] will be <code>$Trainer.firstAblePokemon</code>.
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. <code>poke.level</code> 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 <code>pbHasFatefulSpecies?(:''species'')</code>.
+
To see if the player has a fatefully encountered Pokémon of a certain species in their party, use <code>pbHasFatefulSpecies?(:CELEBI)</code> in the same way as above.
   
 
== Choosing a Pokémon ==
 
== 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:
+
To make the player choose one of the Pokémon in their [[party]] for whatever reason, use the following script:
  +
 
pbChoosePokemon(''var1'',''var2'')
 
pbChoosePokemon(''var1'',''var2'')
  +
This opens the party screen, and the player chooses one of the Pokémon therein. The two arguments are as follows:
+
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.
 
 
* "<code>var1</code>" is the [[Events|Game Variable]] in which to store the [[party]] index of the chosen Pokémon. The number stored will be between 0 and 5 inclusive, or is -1 if no Pokémon was chosen. Traditionally Game Variable 1 is used for this.
There are three possible outcomes of <code>pbChoosePokemon</code>: a Pokémon was chosen, an egg was chosen, and nothing was chosen (i.e. the choice was cancelled).
 
 
* "<code>var2</code>" is the [[Events|Game Variable]] in which to store the name (or nickname, if it has one) of the chosen Pokémon. Traditionally Game Variable 3 is used for this.
  +
 
There are three possible outcomes of <code>pbChoosePokemon</code>: a Pokémon was chosen, an egg was chosen, or nothing was chosen (i.e. the choice was cancelled).
  +
 
@>Script: pbChoosePokemon(1,3)
 
@>Script: pbChoosePokemon(1,3)
 
@>Conditional Branch: Variable [0001] < 0
 
@>Conditional Branch: Variable [0001] < 0
Line 121: Line 155:
 
@>Text: It's at level \v[2].
 
@>Text: It's at level \v[2].
 
@>Label: Done
 
@>Label: Done
  +
 
This is an example of how to use <code>pbChoosePokemon</code>. It also shows how the chosen Pokémon can be retrieved and information queried from it.
 
This is an example of how to use <code>pbChoosePokemon</code>. 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):
 
There are two related scripts (both of which have the same two arguments as above):
  +
  +
* <code>pbChooseNonEggPokemon</code> - Only allows the player to choose a Pokémon, not an egg (the Pokémon may be fainted).
 
* <code>pbChooseAblePokemon</code> - Only allows the player to choose a Pokémon that is not fainted and is not an egg.
 
* <code>pbChooseAblePokemon</code> - Only allows the player to choose a Pokémon that is not fainted and is not an egg.
* <code>pbChooseNonEggPokemon</code> - Only allows the player to choose a Pokémon, not an egg (the Pokémon may be fainted).
+
* <code>pbChooseTradablePokemon</code> - Only allows the player to choose a Pokémon that is not an egg and is not a [[Shadow Pokémon]].
   
 
== Other scripts ==
 
== Other scripts ==
  +
{|
 
  +
{| class="article-table" border="1"
!Script
+
! Script
!What it does
+
! What it does
 
|-
 
|-
|<code>pbAllFainted</code>
+
| <code>pbAllFainted</code>
|Returns TRUE if the player has no able Pokémon left in their party, and FALSE otherwise.
+
| Returns TRUE if the player has no able Pokémon left in their party, and FALSE otherwise.
 
|-
 
|-
|<code>pbCheckAble(0)</code>
+
| <code>pbCheckAble(0)</code>
|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.
+
| 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.
 
|-
 
|-
|<code>$Trainer.pokemonCount</code>
+
| <code>$Trainer.partyCount</code>
|Returns the number of Pokémon in the player's party (unfainted and fainted).
+
| Returns the number of Pokémon and eggs in the player's party (unfainted and fainted).
 
|-
 
|-
|<code>$Trainer.ablePokemonCount</code>
+
| <code>$Trainer.pokemonCount</code>
|Returns the number of able Pokémon in the player's party (unfainted only).
+
| Returns the number of Pokémon in the player's party (unfainted and fainted).
 
|-
 
|-
|<code>pbHealAll</code>
+
| <code>$Trainer.ablePokemonCount</code>
|Fully heals all Pokémon in the player's party. The event command "Recover All" has the same function.
+
| Returns the number of able Pokémon in the player's party (unfainted only).
 
|-
 
|-
|<code>pbHasSpecies?(:BULBASAUR)</code>
+
| <code>pbHealAll</code>
|Returns TRUE if the player has a Pokémon of the given species in their party (ignoring eggs), and FALSE if they don't.
+
| Fully heals all Pokémon in the player's party. The event command "Recover All" has the same function.
 
|-
 
|-
|<code>pbHasFatefulSpecies?(:BULBASAUR)</code>
+
| <code>pbHasType?(:FIRE)</code>
|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.
+
| Returns TRUE if any Pokémon in the party (ignoring Eggs) is at least partially the type specified, and FALSE otherwise.
 
|-
 
|-
|<code>pbCheckMove(PBMoves::TACKLE)</code>
+
| <code>pbCheckMove(:TACKLE)</code>
|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.
+
| Returns the party index number of the first Pokémon in the party that knows the given move (ignoring Eggs). Returns ''nil'' if none know the move. Used to determine whether a move can be used outside battle.
 
|-
 
|-
|<code>pbBalancedLevel($Trainer.pokemonParty)</code>
+
| <code>pbBalancedLevel($Trainer.pokemonParty)</code>
|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.
+
| 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.
 
|-
 
|-
|<code>poke.numMoves</code>
+
| <code>pbSize(pkmn)</code>
|Returns the number of moves that the given Pokémon (called <code>poke</code> here) knows.
+
| Using the personal ID and IVs of the given Pokémon (called <code>pkmn</code> here), calculates and returns a number which represents the Pokémon's size in mm. A Fishing Guru at the Lake of Rage in Johto measures Magikarp this way.
 
|-
 
|-
|<code>poke.knowsMove?(:TACKLE)</code>
+
| <code>pkmn.numMoves</code>
|Returns TRUE if the given Pokémon (called <code>poke</code> here) knows the given move, and FALSE if it doesn't.
+
| Returns the number of moves known by the given Pokémon (called <code>pkmn</code> here).
 
|-
 
|-
|<code>pbHasEgg?(:TOGEPI)</code>
+
| <code>pkmn.hasMove?(:TACKLE)</code>
  +
| Returns TRUE if the given Pokémon (called <code>pkmn</code> here) knows the given move, and FALSE if it doesn't.
|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).
 
 
|-
 
|-
|<code>pbGetRegionalNumber(1,PBSpecies::BULBASAUR)</code>
+
| <code>pbHasEgg?(:TOGEPI)</code>
 
| 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).
|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.
 
 
|-
 
|-
|<code>pbGetNationalNumber(1,135)</code>
+
| <code>pbGetRegionalNumber(1,PBSpecies::BULBASAUR)</code>
|Returns the National Dex number of the Pokémon which has the given Regional Dex number (135) in the given Regional Dex (1).
+
| For the given Pokémon species, returns its Regional Dex number from the given Regional Dex (1 in this example is the second Regional Dex). Returns 0 if the given species does not appear in that Regional Dex.
 
|-
 
|-
|<code>pbSize($Trainer.pokemonParty[0])</code>
+
| <code>pbGetNationalNumber(1,135)</code>
|Returns the Pokémon's "size" in millimetres. Uses the Pokémon's IVs and personal ID number to calculate this value.
+
| Returns the National Dex number of the Pokémon species which has the given Regional Dex number (135) in the given Regional Dex (1).
 
|-
 
|-
|<code>$Trainer.seen[PBSpecies::BULBASAUR]</code>
+
| <code>$Trainer.hasSeen?(:BULBASAUR)</code>
|Returns TRUE if the given species has been seen, and FALSE if not.
+
| Returns TRUE if the given Pokémon species has been seen, and FALSE if not.
 
|-
 
|-
|<code>$Trainer.owned[PBSpecies::BULBASAUR]</code>
+
| <code>$Trainer.hasOwned?(:BULBASAUR)</code>
|Returns TRUE if the given species has been owned, and FALSE if not.
+
| Returns TRUE if the given Pokémon species has been owned, and FALSE if not.
 
|-
 
|-
|<code>$Trainer.numFormsSeen[PBSpecies::BULBASAUR]</code>
+
| <code>$Trainer.numFormsSeen[PBSpecies::BULBASAUR]</code>
|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.
+
| Returns the number of forms of the given Pokémon species that have been seen. This does not include genders, even if the species has gender differences.
 
|}
 
|}

Revision as of 17:51, 1 January 2019

For changing the properties of a given Pokémon, see Editing a Pokémon.

This page 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.

Adding a Pokémon

There are four ways to easily give the player a Pokémon, all of which will treat the Pokémon as originally belonging to the player. 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:

pkmn = pbGenPkmn(:MAGIKARP,10)
pbAddPokemon(pkmn)

This allows you to modify the Pokémon before giving it to the player. See 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, but the option is there.

Adding a gift Pokémon

A gift Pokémon is one which originally belonged to an NPC rather than the player, and is thus a foreign Pokémon once the player has it (foreign Pokémon gain Exp faster, can disobey the player's orders depending on its level, and cannot change its nickname).

Obtaining a gift Pokémon is not the same as trading, as the player doesn't have to swap one of their Pokémon for the gift Pokémon. It is also different to finding a Pokémon in an item ball, as that would make the player its original owner and would use pbAddToParty as described above.

To give the player a gift Pokémon, 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).

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 (see above), so that a failure to add the Pokémon can be mentioned (e.g. with the message "Oh, your party is full.").

Alternatively, you can define a Pokémon beforehand and then add it, like so:

pkmn = pbGenPkmn(:MAGIKARP,10)
pbAddForeignPokemon(pkmn)

This allows you to edit the Pokémon before giving it to the player, e.g. giving it specific original trainer information. Although, since this function can only add a Pokémon to the player's party, it will be readily accessible as $Trainer.lastParty, so you can edit the Pokémon after obtaining it instead. See Editing a Pokémon for how to edit a Pokémon's properties.

When the Pokémon is added, the player will not be allowed to rename it. A random original trainer ID number (different to the player's trainer ID) will be generated for the Pokémon (unless it has already been changed before adding it). If the Pokémon is added, a message will say so.

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. You should never need to set this to FALSE, but the option is there.

Demo party

The def pbCreatePokemon in the script section Debug_Actions 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 following script:

$Trainer.party.delete_at(index)

"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?(:CELEBI) (replacing the species name with the one you're checking for). Note that this ignores Eggs.

@>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: isConst?($Trainer.firstPokemon.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 $Trainer.firstPokemon is specifically the first Pokémon in the player's party, i.e. it ignores Eggs. The first unfainted Pokémon in the player's party will be $Trainer.firstAblePokemon.

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

Choosing a Pokémon

To make the player choose one of the Pokémon in their party for whatever reason, 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 Game Variable in which to store the party index of the chosen Pokémon. The number stored will be between 0 and 5 inclusive, or is -1 if no Pokémon was chosen. Traditionally Game Variable 1 is used for this.
  • "var2" is the Game Variable in which to store the name (or nickname, if it has one) of the chosen Pokémon. Traditionally Game Variable 3 is used for this.

There are three possible outcomes of pbChoosePokemon: a Pokémon was chosen, an egg was chosen, or 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?      
  @>Text: You chose an egg.
  @>Jump To Label: Done
 : Branch End
@>Text: You chose a \v[3].                      
@>Script: pbSet(2,pbGetPokemon(1).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):

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

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.partyCount Returns the number of Pokémon and eggs in the player's party (unfainted and fainted).
$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.
pbHasType?(:FIRE) Returns TRUE if any Pokémon in the party (ignoring Eggs) is at least partially the type specified, and FALSE otherwise.
pbCheckMove(: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 know the move. 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.
pbSize(pkmn) Using the personal ID and IVs of the given Pokémon (called pkmn here), calculates and returns a number which represents the Pokémon's size in mm. A Fishing Guru at the Lake of Rage in Johto measures Magikarp this way.
pkmn.numMoves Returns the number of moves known by the given Pokémon (called pkmn here).
pkmn.hasMove?(:TACKLE) Returns TRUE if the given Pokémon (called pkmn 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) For the given Pokémon species, returns its Regional Dex number from the given Regional Dex (1 in this example is the second Regional Dex). 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 species which has the given Regional Dex number (135) in the given Regional Dex (1).
$Trainer.hasSeen?(:BULBASAUR) Returns TRUE if the given Pokémon species has been seen, and FALSE if not.
$Trainer.hasOwned?(:BULBASAUR) Returns TRUE if the given Pokémon species has been owned, and FALSE if not.
$Trainer.numFormsSeen[PBSpecies::BULBASAUR] Returns the number of forms of the given Pokémon species that have been seen. This does not include genders, even if the species has gender differences.