diff options
-rw-r--r-- | Learn-moves-upon-evolution.md | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Learn-moves-upon-evolution.md b/Learn-moves-upon-evolution.md index b08851a..0f745f6 100644 --- a/Learn-moves-upon-evolution.md +++ b/Learn-moves-upon-evolution.md @@ -13,8 +13,7 @@ u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove) { u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); u8 level = GetMonData(mon, MON_DATA_LEVEL, NULL); - s32 i; - u32 retVal = 0; + // 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 @@ -23,18 +22,19 @@ u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove) { sLearningMoveTableID = 0; } - for (i = 0; gLevelUpLearnsets[species][i] != LEVEL_UP_END; i++) + while(gLevelUpLearnsets[species][sLearningMoveTableID] != LEVEL_UP_END) { - moveLevel = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_LV; + u16 moveLevel; + moveLevel = (gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_LV); while (moveLevel == 0 || moveLevel == (level << 9)) { - gMoveToLearn = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID; + gMoveToLearn = (gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_ID); sLearningMoveTableID++; - retVal = GiveMoveToMon(mon, gMoveToLearn); + return GiveMoveToMon(mon, gMoveToLearn); } sLearningMoveTableID++; } - return retVal; + return 0; } ``` This iterates through the mon's level up learnset and attempts to teach all the moves that are either level 0 or the same level as the mon. |