Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented evolution moves #2005

Merged
merged 4 commits into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/evolution_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down
28 changes: 28 additions & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}