This article describes how Pokémon eggs work, as well as how to give the player an egg and how to customise it.
- Pokémon in the Day Care can breed and produce Pokémon eggs.
- Eggs will eventually hatch into Pokémon.
Why is an egg an egg?
The only difference between a Pokémon and an egg is that an egg has a non-zero number of steps left to hatch. This number is kept in the Pokémon's variable called
eggsteps. For actual Pokémon, this number is zero.
egg? checks whether an entity is an egg; it returns TRUE if it is, and FALSE if it is a Pokémon. It is used as follows:
This looks at the first entity in the player's party, and checks whether it is an egg or not.
Since an egg is exactly the same as a Pokémon (except that one of its variables is non-zero), an egg is generated in exactly the same way as a Pokémon is (with just two differences:
eggsteps is set to a non-zero value, and the egg's nickname is set to "Egg"). An egg's level is automatically set to the level given by the variable
EGGINITIALLEVEL (in the script section Settings).
The generation of an egg is done in the script section PokemonUtilities, in the def
Kernel.pbGenerateEgg - this def also adds the egg to the end of the player's party, if possible. If the player's party is full, nothing happens.
The Pokémon's stats (e.g. nature, gender, IVs, moveset) are determined when the egg is generated, not when it hatches. This is also the reason why an egg can be modified after it is obtained, as explained below.
The above is only true if an egg is being generated out of nowhere (e.g. an NPC spontaneously giving it to the player). Things are a little different if the egg was created through breeding at the Day Care - a different def is used to generate the egg in this case. See the article Breeding for more details.
Egg sprite and icon
The egg sprites and icons go in the same folders as Pokémon sprites and icons ("Graphics/Battlers" and "Graphics/Icons" respectively). The default egg sprite and icon have the following names:
- egg.png - The sprite.
- iconEgg.png - The icon, two 64x64 pictures side by side just like all other Pokémon icons.
Essentials allows for species-specific egg sprites and icons. To do this, name those sprite and icon files the following:
- XXXegg.png - The sprite, where "XXX" is the internal name of the species or its ID number padded to 3 digits.
- XXXeggCracks.png - The crack graphics overlaid onto the egg sprite when it hatches, where "XXX" is the internal name of the species or its ID number padded to 3 digits.
- iconXXXegg.png - The icon, where "XXX" is as above.
An example of a species with custom egg sprites that is already in Essentials is Manaphy. If a species does not have its own egg sprite/cracks/icon, it will use the default ones.
Giving the player an egg
To generate a Pokémon egg, use the def
Kernel.pbGenerateEgg(:PIKACHU). This def will add an egg to the end of the player's party (if there is space; it will do nothing if there isn't), which will hatch into the stated Pokémon.
Kernel.pbGenerateEgg does not show any messages. It returns TRUE if the egg was added, or FALSE if there was no space in the player's party. You should use it like so:
@>Conditional Branch: Script: Kernel.pbGenerateEgg(:TOGEPI) @>Text: Received a Pokémon Egg. : Else @>Text: You have no room to store the Egg... : Branch End
This example creates and adds a Togepi egg. Note the colon before the internal name of the species.
This method allows for a second argument, which is a phrase that overrides the name of the map which the egg was obtained on. This phrase is shown in the summary screen of the egg and the hatched Pokémon. Define this as follows:
Customising the egg
Since the only difference between a Pokémon and an egg is a single variable (
eggsteps), the Pokémon that will hatch from the egg can be modified in any way that a Pokémon can be modified.
While you can predefine a Pokémon egg and then give it to the player via
poke is the predefined egg), it is just as easy to give an egg to the player first and then customise it. This is because
Kernel.pbGenerateEgg can only add an egg to the end of a player's party (i.e. it will not be sent to the PC if there is no room), so the newly obtained egg will always be in an easily accessible place for customising.
Firstly, add the egg as mentioned above. Then, immediately after adding it (i.e. in the Conditional Branch) add some more script lines to the event, such as:
egg=$Trainer.lastParty egg.makeShiny egg.makeFemale egg.pbLearnMove(:HYPERBEAM) egg.calcStats
The first line finds the newly added egg (which will always be at the end of the player's party) and labels it "
egg". It could just as easily label it "
p" or "
sausage" - this is just a way of easily referring to it. This line is necessary.
The last line is only necessary if something has been changed that will affect the Pokémon's stats (e.g. nature, form). However, there is no harm in including it anyway.
The lines in the middle are the modifications made to the egg. In this example, the egg has been made shiny, female, and it will know Hyper Beam. See the article Editing a Pokémon for a list of possible modifications.
Egg summary screen
- Main article: Summary screens
Eggs have a different summary screen to Pokémon. Firstly, there is just one page to it, and secondly, nearly all the information is missing and replaced with a message stating where/when the egg was obtained and how soon the egg will hatch.
The contents of this summary screen can be found in the script section PokemonSummary, in the def
Hatching an egg
An egg requires a certain number of steps to be taken before it will hatch (this number depends on the species - see the
StepsToHatch property of a species in the article Pokémon). Each step taken by the player reduces the egg's
eggsteps variable by 1. When this variable reaches zero, the egg will hatch. The code that does all this is at the bottom of the script section PokemonEggHatching.
There is an animation which plays when an egg hatches, which shows the egg hatching. This animation is in the script section PokemonEggHatching.
After hatching, the player gets a chance to give the Pokémon a nickname.
A newly hatched Pokémon will be at the level given by the variable
EGGINITIALLEVEL (in the script section Settings). This variable can easily be changed to any other (valid) number.
Some abilities change how quickly an egg hatches. Both Flame Body and Magma Armor double the rate at which
eggsteps is reduced; these abilities do not stack with themselves or each other, though.