diff --git a/include/pokemon.h b/include/pokemon.h index af3621773..1dc3ed461 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -456,5 +456,6 @@ u16 GetFormSpeciesId(u16 speciesId, u8 formId); u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId); u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg); u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg); +u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove); #endif // GUARD_POKEMON_H diff --git a/src/evolution_scene.c b/src/evolution_scene.c index e5d628140..a0adb4b46 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -780,7 +780,7 @@ static void Task_EvolutionScene(u8 taskId) case EVOSTATE_TRY_LEARN_MOVE: if (!IsTextPrinterActive(0)) { - var = MonTryLearningNewMove(mon, gTasks[taskId].tLearnsFirstMove); + var = MonTryLearningNewMoveEvolution(mon, gTasks[taskId].tLearnsFirstMove); if (var != MOVE_NONE && !gTasks[taskId].tEvoWasStopped) { u8 text[20]; @@ -1201,7 +1201,7 @@ static void Task_TradeEvolutionScene(u8 taskId) case T_EVOSTATE_TRY_LEARN_MOVE: if (!IsTextPrinterActive(0) && IsFanfareTaskInactive() == TRUE) { - var = MonTryLearningNewMove(mon, gTasks[taskId].tLearnsFirstMove); + var = MonTryLearningNewMoveEvolution(mon, gTasks[taskId].tLearnsFirstMove); if (var != MOVE_NONE && !gTasks[taskId].tEvoWasStopped) { u8 text[20]; diff --git a/src/pokemon.c b/src/pokemon.c index 0a0b837ea..96ea4798b 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3940,6 +3940,8 @@ void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon) { if (gLevelUpLearnsets[species][i].level > level) break; + if (gLevelUpLearnsets[species][i].level == 0) + continue; if (GiveMoveToBoxMon(boxMon, gLevelUpLearnsets[species][i].move) == MON_HAS_MAX_MOVES) DeleteFirstMoveAndGiveMoveToBoxMon(boxMon, gLevelUpLearnsets[species][i].move); } @@ -8259,3 +8261,29 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg return species != targetSpecies ? targetSpecies : SPECIES_NONE; } + +u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove) +{ + u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); + u8 level = GetMonData(mon, MON_DATA_LEVEL, NULL); + + // Since you can learn more than one move per level, + // the game needs to know whether you decided to + // learn it or keep the old set to avoid asking + // you to learn the same move over and over again. + if (firstMove) + { + sLearningMoveTableID = 0; + } + while(gLevelUpLearnsets[species][sLearningMoveTableID].move != LEVEL_UP_END) + { + while (gLevelUpLearnsets[species][sLearningMoveTableID].level == 0 || gLevelUpLearnsets[species][sLearningMoveTableID].level == level) + { + gMoveToLearn = gLevelUpLearnsets[species][sLearningMoveTableID].move; + sLearningMoveTableID++; + return GiveMoveToMon(mon, gMoveToLearn); + } + sLearningMoveTableID++; + } + return 0; +}