This is a modified version of [the original tutorial about adding new Pokémon species available in Pokeemerald's wiki](https://github.com/pret/pokeemerald/wiki/How-to-add-a-new-Pokémon-species).
Despite the persistent rumors about an incredibly strong third form of Mew hiding somewhere, it actually wasn't possible to catch it... OR WAS IT?
In this tutorial, we will add a new Pokémon species to the game.
## IMPORTANT: This tutorial applies to 1.9.x versions.
- [Version 1.8.x](how_to_new_pokemon_1_8_0.md)
- [Version 1.7.x](how_to_new_pokemon_1_7_0.md)
- [Version 1.6.x](how_to_new_pokemon_1_6_0.md)
# Changes compared to vanilla
The main things that the Expansion changes are listed here.
* Still Front Pics *(`gMonStillFrontPic_YourPokemon`)* and by extension `src/anim_mon_front_pics.c` have been removed.
Oh, I know! We need to add the rest of the data! Normally, the vanilla game would crash if we try to look up anything about Mewthree in this state, but the expansion defaults all of its data to `SPECIES_NONE`.
Now, let's see what needs to be done.
## 2. `SpeciesInfo`'s structure
Now, to better understand Mewtwo, we also need to understand Mew. Let's look at its data.
The `.` is the structure reference operator in C to refer to the member object of the structure SpeciesInfo.
-`baseHP`, `baseAttack`, `baseDefense`, `baseSpeed`, `baseSpAttack` and `baseSpDefense` are the base stats. They can't go higher than 255.
- You may be confused as to why `types` has `TYPE_PSYCHIC` twice. This is because the way the game determines single-type mon is to define both types the same.
- If we don't, it defaults to Normal due to it being the first type defined.
-`catchRate` is how likely it is to catch a Pokémon, the lower the value, the harder it is to catch. Legendaries generally have a catch rate of 3, so we put that here.
-`expYield` is the base amount of experience that a Pokémon gives when defeated/caught. In vanilla, this value caps at 255, but we've increased it to a maximum of 65535 accomodate later gen's higher experience yields. (The highest official value is Blissey's with 608, so going beyond this point may cause exponential gains that could break the system 😱)
- If you noticed, Mew's had some `#if`s, `#elif`s and `#endif` around it. This is because its yield has changed over time, and we let you choose which ones you want. This is not relevant to our Mewthree however, so we can just put a single `.expYield = 255,` line here.
-`evYield_HP`, `evYield_Attack`, `evYield_Defense`, `evYield_Speed`, `evYield_SpAttack` and `evYield_SpDefense` are how many EVs does the Pokémon give when they're caught. Each of these fields can have a value of 3 at most. Officially, no Pokémon give out more than 3 EVs total, with them being determined by their evolution stage (eg, Pichu, Pikachu and Raichu give 1, 2 and 3 Speed EVs respectively), and they tend to be associated with its higher stats. Since our Mewthree is a Special Attack monster, we'll be consistent and make it give out 3 Special Attack EVs, but you're always free to assign whatever you feel like :)
- Notice that the other `evYield` fields are not there. In C, numbers in a struct default to 0, so if we don't specify them, they'll be 0 all around! Less lines to worry about :D
-`itemCommon` and `itemRare` are used to determine what items is the Pokémon holding when encountering it in the wild.
- 50% for `itemCommon` and 5% for `itemRare` (boosted to 60%/20% when the first mon in the party has Compound Grass or Super Luck)
- If they're both set as the same item, the item has a 100% chance of appearing.
-`genderRatio` is a fun one.
- There are 4 ways of handling this
-`PERCENT_FEMALE` is what most Pokémon use, where you define how likely it's gonna be female. It supports decimals, so you can put `PERCENT_FEMALE(12.5)` to have a 1 in 8 chance of your mon to be female.
-`MON_MALE` guarantees that all mon of this species will be male (eg. Tauros)
-`MON_FEMALE` guarantees that all mon of this species will be female (eg. Miltank)
-`MON_GENDERLESS` makes your species genderless, unable to breed with anything but Ditto to produce eggs. Most Legendaries are this, so we'll be chosing this as Mewthree's gender ratio.
- When working with evolution lines and don't want their genders to change after evolving, be sure that their gender ratios match their stages and evolution methods. Azurill is the only case where there's a mismatch, causing 1/3 of all Azurill to change from Female to Male. <!--Trans rights :)-->
- You might be wondering why some species have multiple defines for their genders, like `SPECIES_MEOWSTIC_(FE)MALE`. This is because those species have different stats and data from each other, so they're defined internally as different forms with `MON_MALE` and `MON_FEMALE` as gender ratios. If your species evolves depending on its gender and the evolutions have different stats, be sure to apply the correct evolution method!
-`eggCycles` determines how fast an egg of this species will hatch. Doesn't matter much for evolved species or those that can't lay eggs, but we add the field here just in case.
-`friendship` determines the amount of friendship of the mon when you catch it. Most Pokémon use `STANDARD_FRIENDSHIP`, but this creature of chaos does not want to be your friend, starting with 0.
-`growthRate` determines the amounts of experience required to reach each level. Go [here](https://bulbapedia.bulbagarden.net/wiki/Experience) for more info.
-`eggGroups` are used for breed compatibility. Most Legendaries and Mythicals have the `EGG_GROUP_NO_EGGS_DISCOVERED` group, and so does our Mewthree. Go [here](https://bulbapedia.bulbagarden.net/wiki/Egg_Group) for more info.
-`abilities` determines the potential abilites of our species. Notice how I also set the ability to `ABILITY_INSOMNIA`, so our little monster doesn't even need to sleep anymore. You can find the abilities for example here [include/constants/abilities.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/include/constants/abilities.h).
- When both slot 1 and 2 are defined as not being `ABILITY_NONE`, their starting ability will be decided on a coin flip using their personality. They can later be changed using an Ability Capsule.
- Certain Pokémon such as Zygarde and Rockruff have different forms to add additional abilities. As such, they cannot be changed using an Ability Capsule (though the Zygarde Cube can change Zygarde's ability by changing them to their corresponding form)
- The 3rd slot is for Hidden Abilities. If defined as `ABILITY_NONE`, it will default to Slot 1 (eg. Metapod doesn't have a Hidden Ability, but Caterpie and Butterfree do). Go [here](https://bulbapedia.bulbagarden.net/wiki/Ability#Hidden_Abilities) and [here](https://bulbapedia.bulbagarden.net/wiki/Ability_Patch) for more info.
- If the array is defined as `{ABILITY_1, ABILITY_2}`, the Hidden Ability is set as `ABILITY_NONE`.
-`bodyColor` is used in the Pokédex as a search filter.
-`noFlip` is used in to prevent front sprites from being flipped horizontally and cause weird issues, like Clawitzer's big claw changing sides.
That's all the basic fields present in vanilla emerald, so now let's take a look at the new fields added by the expansion.
The `_()` underscore function doesn't really exist - it's a convention borrowed from GNU gettext to let `preproc` know this is text to be converted to the custom encoding used by the Gen 3 Pokemon games.
## 5. Define its cry
Time for audio!
We first need to convert an existing audio file to the format supported by the expansion.
Most formats are supported for conversion, but for simplicity's sake, we're gonna use an mp3 file.
Now, let's copy the file to the `sound/direct_sound_samples/cries` folder.
Once that's done, let's run the following command:
This will convert your audio file to .aif, which is what's read by the compiler.
Let's add the cry to the ROM via [sound/direct_sound_data.inc](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/sound/direct_sound_data.inc).
Then we add the cry ID to [include/constants/cries.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/include/constants/cries.h):
```diff
enum {
CRY_NONE,
...
#if P_FAMILY_TERAPAGOS
CRY_TERAPAGOS,
#endif //P_FAMILY_TERAPAGOS
#if P_FAMILY_PECHARUNT
CRY_PECHARUNT,
#endif //P_FAMILY_PECHARUNT
+ CRY_MEWTHREE,
CRY_COUNT,
};
```
And then link it in [sound/cry_tables.inc](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/sound/cry_tables.inc). `cry_reverse` in particular is for reversed cries used by moves such as Growl. The order of these two tables should match the order of the cry IDs, otherwise they'll be shifted.
You can now delete the mp3 from the cries folder now once you made sure that the cry sounds like how you want it to.
## 6. Define its Pokédex entry
First, we will need to add new index constants for its Pokédex entry. The index constants are divided into the Hoenn Pokédex, which contains all Pokémon native to the Hoenn region, and the National Pokédex containing all known Pokémon, which can be received after entering the hall of fame for the first time.
`height` and `weight` are specified in decimeters and hectograms respectively (which are meters and kilograms multiplied by 10, so 2.5 meters are 25 decimeters).
In Pokémon Emerald, you can sort the Pokédex by name, height or weight. Apparently, the Pokémon order is hardcoded in the game files and not calculated from their data. Therefore we have to include our new Pokémon species at the right places. While the correct position for the alphabetical order is easy to find, it can become quite tedious for height and weight, so we added comments to the listings in order help out were they should fit.
We aren't copying Mewtwo's folder because he has those pesky Mega Evolutions that will get in the way of what we're doing, so our sample will need to be pure from the source.
## 1. Edit the sprites
Let's edit the sprites. Start your favourite image editor (I recommend Aseprite or its free alternative, Libresprite) and change `anim_front.png` and `back.png` to meet your expectations.
__Make sure that you are using the indexed mode and you have limited yourself to 15 colors!__
Put the RGB values of your colors into `normal.pal` between the first and the last color and the RGB values for the shiny version into `shiny.pal`.
Edit `footprint.png` using two colors in indexed mode, black and white.
Finally, edit `icon.png`. Notice, that the icon will use one of 6 predefined palettes instead of `normal.pal`.
## 2. Add the sprites to the rom
Sadly, just putting the image files into the graphics folder is not enough. To use the sprites we have to register them, which is kind of tedious.
First, create constants for the file paths. You'll want to add the constants for your species after the constants for the last valid species.
Please note that Pecharunt, the Pokémon that should be above your insertion for the time being, reads a `front.png` sprite instead of an `anim_front.png` sprite. This is because currently, Pecharunt lacks a 2nd frame. If the front sprite sheet of your species uses 2 frames, you should use `anim_front`.
It is also worth to mention that Pecharunt's sprites are commented out simply because they're currently missing.
## 3. Add the animations to the rom
You can define the animation order, in which the sprites will be shown. The first number is the sprite index (so 0 or 1) and the second number is the number of frames the sprite will be visible.
You might be wondering what `PLACEHOLDER_ANIM_SINGLE_FRAME` is. Well, since Pecharun only has 1 frame, we use what's called a preprocessor *macro* to have in a single line what otherwise would've been this in the C file:
```c
static const union AnimCmd sAnim_Pecharunt_1[] =
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
}
```
Instead, we can use the already established macro that does the same thing, replacing the value in parenthesis with what we want (in this case, `Pecharunt`):
```c
#define PLACEHOLDER_ANIM_SINGLE_FRAME(name) \
static const union AnimCmd sAnim_##name##_1[] = \
{ \
ANIMCMD_FRAME(0, 1), \
ANIMCMD_END, \
}
```
## 4. Linking graphic information to our Pokémon
Now that we have all the external data ready, we just need to add it to `gSpeciesInfo` plus the rest of the animation and graphical data that we want to use:
- Used to reference the front sprite, so in this case, we call for `gMonFrontPic_Mewthree`.
-`frontPicSize`:
- The two values (`width` and `height`) are used for defining the non-empty size of the front sprite, which is used in move animations. If you're unsure of the values, you can leave them both as 64.
-`frontPicYOffset`:
- Used to define what Y position the sprite sits at. This is used to set where they'd be "grounded". For the shadow, see `enemyMonElevation`.
-`frontAnimFrames`:
- We link our animation frame animations that we defined earlier here.
-`frontAnimId`:
- Because you are limited to two frames, there are already [predefined front sprite animations](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/include/pokemon_animation.h), describing translations, rotations, scalings or color changes.
-`frontAnimDelay`:
- Sets a delay in frame count between when the Pokémon appears and when the animation starts.
-`enemyMonElevation`:
- Used to determine the altitude from the ground. Any value above 0 will show a shadow under the Pokémon, to signify that they're floating.
-`backPic`:
- Used to reference the back sprite, so in this case, we call for `gMonBackPic_Mewthree`.
-`backPicSize`:
- The two values (`width` and `height`) are used for defining the non-empty size of the back sprite, which is used in move animations. If you're unsure of the values, you can leave them both as 64.
-`backPicYOffset`:
- Used to define what Y position of the back sprite. When working with the animation debug menu, we recommend aligning the back sprite to the white background, as it was designed to properyly align with the real battle layout.
-`backAnimId`:
- Like `frontAnimId` except for the back sprites and them being a single frame. The IDs listed [here](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/include/pokemon_animation.h) are used to represent 3 different animations that happen based on the the Pokémon's nature.
-`palette`:
- Used to reference the non-shiny palette, so in this case, we call for `gMonPalette_Mewthree`.
-`shinyPalette`:
- Used to reference the shiny palette, so in this case, we call for `gMonShinyPalette_Mewthree`.
-`iconSprite`:
- Used to reference the icon sprite, so in this case, we call for `gMonIcon_Mewthree`.
-`iconPalIndex`:
-`ICON`
- Here, you can choose between the six icon palettes; 0, 1, 2, 3, 4 and 5. All of them located in `graphics/pokemon/icon_palettes`.
Open an icon sprite and load one of the palettes to find out which palette suits your icon sprite best.
-`FOOTPRINT`
- We made this single field into a macro so that they can be ignored when `P_FOOTPRINTS` is set to false. It's also why we don't have an "," after calling it like the other macros (we add it as part of the macro itself).
- In the future, these will be used to determine breeding offspring from different based on their region.
-`cannotBeTraded`:
- This species cannot be traded away (like Black/White Kyurem).
-`allPerfectIVs`:
- Guarantees 6 perfect IVs upon generating the Pokémon (like LGPE's Partner Pikachu and Eevee).
-`tmIlliterate`:
- This species will be unable to learn the universal moves.
-`isFrontierBanned`:
- This species will be unable to enter Battle Frontier facilities. Replaces `gFrontierBannedSpecies`.
*: As long as `P_LEGENDARY_PERFECT_IVS` is set to `GEN_6` or higher.
## 2. Delimit the moveset
Let's begin with the moves that can be learned by leveling up.
Append to [src/data/pokemon/level_up_learnsets.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/data/pokemon/level_up_learnsets.h):
Next we need to specify which moves can be taught via TM, HM, or Move Tutor.
Append to [src/data/pokemon/teachable_learnsets.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/data/pokemon/teachable_learnsets.h):
If you want to create a Pokémon which can breed, you will need to edit [src/data/pokemon/egg_moves.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/data/pokemon/egg_moves.h).
## 3. Define the Evolutions
We want Mewthree to evolve from Mewtwo by reaching level 100.
Now Mewthree really does slumber in the games code - but we won't know until we make him appear somewhere! The legend tells that Mewthree is hiding somewhere in Petalburg Woods...
Congratulations, you have created your own personal pocket monster! You may call yourself a mad scientist now.
# Optional data
Now that you now have all the essential pieces to create a base species, there are some aspects that you might want to know if you want to do other stuff with your custom Pokémon.
## 1. Form tables
Found in `src/data/pokemon/form_species_tables.h`.
These are introduced to have a reference of what forms correspond to what Species of Pokémon. For example, we have Pikachu's table:
```c
#if P_FAMILY_PIKACHU
static const u16 sPikachuFormSpeciesIdTable[] = {
SPECIES_PIKACHU,
SPECIES_PIKACHU_COSPLAY,
SPECIES_PIKACHU_ROCK_STAR,
SPECIES_PIKACHU_BELLE,
SPECIES_PIKACHU_POP_STAR,
SPECIES_PIKACHU_PH_D,
SPECIES_PIKACHU_LIBRE,
SPECIES_PIKACHU_ORIGINAL_CAP,
SPECIES_PIKACHU_HOENN_CAP,
SPECIES_PIKACHU_SINNOH_CAP,
SPECIES_PIKACHU_UNOVA_CAP,
SPECIES_PIKACHU_KALOS_CAP,
SPECIES_PIKACHU_ALOLA_CAP,
SPECIES_PIKACHU_PARTNER_CAP,
SPECIES_PIKACHU_WORLD_CAP,
FORM_SPECIES_END,
};
#endif //P_FAMILY_PIKACHU
```
We register the table each form entry in `gSpeciesInfo`.
In addition, we have the `GET_BASE_SPECIES_ID` macro, which returns the first entry of the table (or return the species itself if it doesn't have a table registered). With this, you can check if a Pokémon is any form of a species. For example, making it so that the Light Ball affects all Pikachu forms:
```c
case HOLD_EFFECT_LIGHT_BALL:
if (GET_BASE_SPECIES_ID(gBattleMons[battlerAtk].species) == SPECIES_PIKACHU && IS_MOVE_SPECIAL(move))
The first value is the type of form change. In the case of Gengar, we have both Mega Evolution and Gigantamax form changes.
The second value is the target form, to which the Pokémon will change into.
Values after that are referred as arguments, and needs to be put there depends on the type of form change, detailed in `include/constants/form_change_types.h`.
These are used to change the graphics of the Pokémon if they're female. If they're not registered, they default to the male values.
However, `iconPalIndexFemale` is a special case, where it's *doesn't* read the male icon palette if its `iconSpriteFemale` is set, so if you're setting a female icon, be sure to set their palette index as well.
If you have `OW_POKEMON_OBJECT_EVENTS` in your hack, you can add Overworld of your new species by following these steps:
First, since you copied the contents from Mew's folder previously, you should also have copied its overworld sprites. Edit those to your liking, as we have done before, making sure to update the palettes
Secondly, in [src/data/graphics/pokemon.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/data/graphics/pokemon.h), add the following:
Fourthly, in [src/data/object_events/object_event_pic_tables_followers.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/data/object_events/object_event_pic_tables_followers.h):
Depending on your species, you might want to use different sizes for it. For example, certain species known for being big like Steelix use sprites that fit a 64x64 frame instead of 32x32, and as such have `SIZE_64x64` in their data instead of `SIZE_32x32` to accomodate for them.
Also, in `spritesheet_rules.mk`, `-mwidth` and `-mheight` need to be set to 8 instead of 4 for such cases.
### Shadows
You have 4 options for their shadow, between Small, Medium, Large and None: