Revised section #2, list now excludes already learned moves

Scyrous 2024-07-28 12:43:18 +02:00
parent 678354a4b8
commit 0c4fc862ac
1 changed files with 54 additions and 4 deletions

@ -33,7 +33,7 @@ Naturally, you can use any flag you want here. Just make sure it's unused and yo
## 2. Change static function and GetEggMoves
We want to use `GetEggMoves` in an upcoming step, but the function is a static one. This means it's only accessible within the file it's defined in (`src/daycare.c`). We'll remove the static part so that it can be used anywhere, and also adjust a line of code.
We want to use `GetEggMoves` in an upcoming step, but the function is a static one. This means it's only accessible within the file it's defined in (`src/daycare.c`). We'll remove the static part so that it can be used anywhere, and also make it so that egg moves already learned are excluded from the list.
Edit `src/daycare.c`:
@ -43,18 +43,68 @@ Edit `src/daycare.c`:
-static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves)
+u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves)
{
+ u16 learnedMoves[MAX_MON_MOVES];
u16 eggMoveIdx;
u16 numEggMoves;
u16 species;
u16 i;
- u16 i;
+ u16 i, j, k;
numEggMoves = 0;
eggMoveIdx = 0;
- species = GetMonData(pokemon, MON_DATA_SPECIES);
+ species = GetEggSpecies(GetMonData(pokemon, MON_DATA_SPECIES));
for (i = 0; i < ARRAY_COUNT(gEggMoves) - 1; i++)
{
if (gEggMoves[i] == species + EGG_MOVES_SPECIES_OFFSET)
{
eggMoveIdx = i + 1;
break;
}
}
+ if (FlagGet(FLAG_EGG_MOVES_TUTOR))
+ {
+ for (i = 0; i < MAX_MON_MOVES; i++)
+ learnedMoves[i] = GetMonData(pokemon, MON_DATA_MOVE1 + i, 0);
+ }
+
for (i = 0; i < EGG_MOVES_ARRAY_COUNT; i++)
{
- if (gEggMoves[eggMoveIdx + i] > EGG_MOVES_SPECIES_OFFSET)
+ u16 eggMoveId = gEggMoves[eggMoveIdx + i];
+
+ if (eggMoveId > EGG_MOVES_SPECIES_OFFSET)
break;
- eggMoves[i] = gEggMoves[eggMoveIdx + i];
- numEggMoves++;
+ if (FlagGet(FLAG_EGG_MOVES_TUTOR))
+ {
+ for (j = 0; j < MAX_MON_MOVES && learnedMoves[j] != eggMoveId; j++);
+
+ if (j == MAX_MON_MOVES)
+ {
+ for (k = 0; k < numEggMoves && eggMoves[k] != eggMoveId; k++);
+
+ if (k == numEggMoves)
+ eggMoves[numEggMoves++] = eggMoveId;
+ }
+ }
+ else
+ {
+ for (k = 0; k < numEggMoves && eggMoves[k] != eggMoveId; k++);
+
+ if (k == numEggMoves)
+ eggMoves[numEggMoves++] = eggMoveId;
+ }
}
return numEggMoves;
}
```
We have now made it so that `species` looks at the evolutionary family as a whole, rather than individual Pokémon.
We have now made it so that `species` looks at the evolutionary family as a whole, rather than individual Pokémon. Additionally, egg moves already learned by the chosen Pokemon are now excluded from the list.
***