From 678354a4b88c05cde63d83e550a87191d5284996 Mon Sep 17 00:00:00 2001 From: Scyrous <74797764+Scyrous@users.noreply.github.com> Date: Sun, 28 Jul 2024 12:14:48 +0200 Subject: [PATCH] Improved section #5 code --- ...e-Relearner-Teach-Egg-Moves-With-A-Flag.md | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/Make-Move-Relearner-Teach-Egg-Moves-With-A-Flag.md b/Make-Move-Relearner-Teach-Egg-Moves-With-A-Flag.md index 744f1c9..fea5f26 100644 --- a/Make-Move-Relearner-Teach-Egg-Moves-With-A-Flag.md +++ b/Make-Move-Relearner-Teach-Egg-Moves-With-A-Flag.md @@ -108,35 +108,46 @@ We will also create an if/else statement that uses our renamed flag. If the flag ## 5. Exclude invalid Pokémon from list -Now for a little bit of extra polish. Plenty of Pokémon are unable to learn any egg moves. This applies to Pokémon in egg groups `DITTO`, `NO_EGGS_DISCOVERED` and `GENDER UNKNOWN`. The latter doesn't actually exist in Emerald's code, but we can use `MON_GENDERLESS` instead. +Now for a little bit of extra polish! Plenty of Pokémon are unable to learn any egg moves. This applies to egg groups `DITTO`, `NO_EGGS_DISCOVERED` and genderless Pokémon. Furthermore, we need to ensure Pokémon who have already learned every available egg move are unable to be selected from the party screen, similar to how the original move tutor works. Edit `src\pokemon.c`: +Since we want to use GetEggMoves for this edit, we'll need to include `daycare.h`. + ```diff - u8 GetNumberOfRelearnableMoves(struct Pokemon *mon) - { + #include "constants/trainers.h" + #include "constants/union_room.h" ++#include "daycare.h" + + #define DAY_EVO_HOUR_BEGIN 12 + #define DAY_EVO_HOUR_END HOURS_PER_DAY +``` +By checking for `numEggMoves == 0`, we target any Pokémon that meet the criteria mentioned earlier. + +```diff +u8 GetNumberOfRelearnableMoves(struct Pokemon *mon) +{ u16 learnedMoves[MAX_MON_MOVES]; u16 moves[MAX_LEVEL_UP_MOVES]; ++ u16 eggMoves[EGG_MOVES_ARRAY_COUNT]; u8 numMoves = 0; ++ u8 numEggMoves; u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); u8 level = GetMonData(mon, MON_DATA_LEVEL, 0); int i, j, k; + if (FlagGet(FLAG_EGG_MOVES_TUTOR)) + { -+ if (gSpeciesInfo[species].genderRatio == MON_GENDERLESS) ++ numEggMoves = GetEggMoves(mon, eggMoves); ++ ++ if (numEggMoves == 0) + return 0; -+ -+ for (i = 0; i < 2; i++) -+ if (gSpeciesInfo[species].eggGroups[i] == EGG_GROUP_DITTO || -+ gSpeciesInfo[species].eggGroups[i] == EGG_GROUP_NO_EGGS_DISCOVERED) -+ return 0; + } + if (species == SPECIES_EGG) return 0; ``` -If a Pokémon is genderless or belongs to the `DITTO` or `NO_EGGS_DISCOVERED` egg groups, it will now display "NOT ABLE!" in the party selection screen. Since Pokémon can belong to two different egg groups, we make sure to check both slots. +If a Pokémon's egg move list is empty, the game will now correctly display "NOT ABLE!" in the party selection screen. ***