This page describes how Pokémon eggs work, as well as how to give the player an egg and how to customise it.
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
steps_to_hatch. For actual Pokémon, this number is 0.
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 example looks at the first entity in the player's party, and checks whether it is an egg.
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:
steps_to_hatch 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 setting
The generation of an egg is done in
def pbGenerateEgg - this method 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 properties (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 method is used to generate the egg in this case. See the page Breeding for more details.
Egg sprite and icon
The egg sprites and icons both go in the folder "Graphics/Pokemon/Eggs". The default egg graphics have the following names:
000.png- The sprite.
000_icon.png- The icon, two 64x64 pictures side-by-side just like all other Pokémon icons.
000_cracks.png- The crack graphic overlaid on the egg sprite while it hatches.
Essentials allows for species-specific egg sprites and icons. To do this, name those sprite and icon files the following:
XXX.png- The sprite.
XXX_icon.png- The icon.
XXX_cracks.png- The crack graphic.
In all cases, "
XXX" is the ID of the species (e.g. "MANAPHY.png" and "MANAPHY_icon.png").
An example of a species with custom egg graphics that is already in Essentials is Manaphy. If a species does not have its own egg sprite/cracks/icon, it will use the default one(s).
Giving the player an egg
To generate a Pokémon egg, use
pbGenerateEgg(:PICHU). This 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.
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: 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 ID of the species.
This method has an optional second parameter, 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:
pbGenerateEgg(:TOGEPI, _I("Mr. Pokémon"))
An egg obtained from the Day Care will have the phrase "Day-Care Couple".
Customising the egg
- Main article: Editing a Pokémon
Since the only difference between a Pokémon and an egg is a single variable (
steps_to_hatch), 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
pkmn is the predefined egg), it is just as easy to give an egg to the player first and then customise it after it has been added to the party. This is because
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 next to the message stating the egg was given) add a script event command which says something like:
egg = $player.last_party egg.shiny = true egg.makeFemale egg.learn_move(:HYPERBEAM) egg.calc_stats
The first line finds the newly added egg (which will always be at the end of the player's party) and temporarily labels it "
egg". It could just as easily label it "
p" or "
sausage" - this is just a way of easily referring to it, because "
egg" is a shorter word than "
$player.last_party". This line is necessary.
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 Editing a Pokémon for a list of possible modifications.
The last line (
egg.calc_stats) 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.
Egg summary screen
- Main article: Summary screens
Eggs have a different summary screen to Pokémon. There is just one page to it, and nearly all of its information is missing and replaced with a message stating where/when the egg was obtained and how soon it will hatch.
The contents of this summary screen can be found in
def drawPageOneEgg in
class PokemonSummary_Scene in the script section UI_Summary.
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
HatchSteps property of a species in the page Defining a species). Each step taken by the player reduces the egg's
steps_to_hatch variable by 1. When this variable reaches zero, the egg will hatch. The code that does all this in an
EventHandlers proc named
:hatch_eggs at the bottom of the script section UI_EggHatching.
There is an animation which plays when an egg hatches, which shows the egg hatching. This animation is defined in the script section UI_EggHatching.
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 setting
EGG_LEVEL. This level is set when the egg is generated, not when it hatches.
Some abilities change how quickly an egg hatches. Both Flame Body and Magma Armor double the rate at which
steps_to_hatch is reduced for all eggs in the party; these abilities do not stack with themselves or each other, though. This effect happens for any ability with the "FasterEggHatching" flag.