From d6a78f386f8151136badb2619e5c87ca0ef2302d Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 16 Jul 2020 10:02:06 -0300 Subject: [PATCH 1/4] Implemented evolution moves Thanks to UltimaSoul and Sagiri/Zeturic --- include/pokemon.h | 1 + src/evolution_scene.c | 4 ++-- src/pokemon.c | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index af36217739..1dc3ed461b 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 e5d628140e..a0adb4b465 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 0a0b837eac..7108c3d235 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8259,3 +8259,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 || gLevelUpLearnsets[species][sLearningMoveTableID].level == level) + { + gMoveToLearn = gLevelUpLearnsets[species][sLearningMoveTableID].move; + sLearningMoveTableID++; + return GiveMoveToMon(mon, gMoveToLearn); + } + sLearningMoveTableID++; + } + return 0; +} From 96012ba06581cb3acaa8a06f367f2e2d924e6ea1 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 26 Dec 2021 12:39:45 -0300 Subject: [PATCH 2/4] Update src/pokemon.c Co-authored-by: Eduardo Quezada D'Ottone --- src/pokemon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 7108c3d235..0c41026395 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8265,10 +8265,10 @@ 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 + // 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 + // you to learn the same move over and over again. if (firstMove) { sLearningMoveTableID = 0; From 86ed53997b351817e45e741c03999f6b9981014b Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 26 Dec 2021 12:39:56 -0300 Subject: [PATCH 3/4] Update src/pokemon.c Co-authored-by: Eduardo Quezada D'Ottone --- src/pokemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pokemon.c b/src/pokemon.c index 0c41026395..a176db3116 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8275,7 +8275,7 @@ u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove) } while(gLevelUpLearnsets[species][sLearningMoveTableID].move != LEVEL_UP_END) { - while (!gLevelUpLearnsets[species][sLearningMoveTableID].level || gLevelUpLearnsets[species][sLearningMoveTableID].level == level) + while (gLevelUpLearnsets[species][sLearningMoveTableID].level == 0 || gLevelUpLearnsets[species][sLearningMoveTableID].level == level) { gMoveToLearn = gLevelUpLearnsets[species][sLearningMoveTableID].move; sLearningMoveTableID++; From 3f010d9aa8ea40c6481e4e90120db48c2ec8766c Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 26 Dec 2021 17:11:51 -0300 Subject: [PATCH 4/4] =?UTF-8?q?Tweaked=20GiveBoxMonInitialMoveset=20Otherw?= =?UTF-8?q?ise,=20Pok=C3=A9mon=20would=20be=20generated=20with=20their=20e?= =?UTF-8?q?vo=20moves=20learned.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pokemon.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pokemon.c b/src/pokemon.c index a176db3116..96ea4798bb 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); }