Rewrite GiveBoxMonInitialMoveset_Fast (#4373)
* GiveBoxMonInitialMoveset_Fast rewrite Fix duplicate move bug and change behavior to match GiveBoxMonInitialMoveset results * Fixed issue with learnsets smaller than 4
This commit is contained in:
parent
3b17ce39f7
commit
2d42f72a8a
1 changed files with 26 additions and 8 deletions
|
@ -1689,25 +1689,43 @@ void GiveBoxMonInitialMoveset_Fast(struct BoxPokemon *boxMon) //Credit: Asparagu
|
|||
u16 species = GetBoxMonData(boxMon, MON_DATA_SPECIES, NULL);
|
||||
s32 level = GetLevelFromBoxMonExp(boxMon);
|
||||
s32 i;
|
||||
u16 levelMoveCount = 0;
|
||||
u16 moves[MAX_MON_MOVES] = {0};
|
||||
u8 addedMoves = 0;
|
||||
const struct LevelUpMove *learnset = GetSpeciesLevelUpLearnset(species);
|
||||
|
||||
for (i = 0; learnset[i].move != LEVEL_UP_MOVE_END; i++)
|
||||
levelMoveCount++;
|
||||
|
||||
for (i = levelMoveCount; (i >= 0 && addedMoves < MAX_MON_MOVES); i--)
|
||||
{
|
||||
s32 j;
|
||||
bool32 alreadyKnown = FALSE;
|
||||
|
||||
if (learnset[i].level > level)
|
||||
continue;
|
||||
break;
|
||||
if (learnset[i].level == 0)
|
||||
continue;
|
||||
|
||||
if (moves[addedMoves] != learnset[i].move)
|
||||
moves[addedMoves++] = learnset[i].move;
|
||||
for (j = 0; j < addedMoves + 1; j++)
|
||||
if (moves[j] == learnset[i].move)
|
||||
{
|
||||
alreadyKnown = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!alreadyKnown)
|
||||
{
|
||||
if (addedMoves < MAX_MON_MOVES)
|
||||
{
|
||||
moves[addedMoves] = learnset[i].move;
|
||||
addedMoves++;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < MAX_MON_MOVES - 1; j++)
|
||||
moves[j] = moves[j + 1];
|
||||
moves[MAX_MON_MOVES - 1] = learnset[i].move;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = MAX_MON_MOVES - 1; i >= 0; i--)
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
SetBoxMonData(boxMon, MON_DATA_MOVE1 + i, &moves[i]);
|
||||
SetBoxMonData(boxMon, MON_DATA_PP1 + i, &gMovesInfo[moves[i]].pp);
|
||||
|
|
Loading…
Reference in a new issue