Fix trainers having empty movesets (#2890)
This commit is contained in:
commit
5d885b05d0
1 changed files with 25 additions and 6 deletions
|
@ -120,6 +120,7 @@ static void SpriteCB_UnusedBattleInit_Main(struct Sprite *sprite);
|
||||||
static void TrySpecialEvolution(void);
|
static void TrySpecialEvolution(void);
|
||||||
static u32 Crc32B (const u8 *data, u32 size);
|
static u32 Crc32B (const u8 *data, u32 size);
|
||||||
static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i);
|
static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i);
|
||||||
|
static void CustomTrainerPartyAssignMoves(struct Pokemon *mon, const struct TrainerMonCustomized *partyEntry);
|
||||||
|
|
||||||
EWRAM_DATA u16 gBattle_BG0_X = 0;
|
EWRAM_DATA u16 gBattle_BG0_X = 0;
|
||||||
EWRAM_DATA u16 gBattle_BG0_Y = 0;
|
EWRAM_DATA u16 gBattle_BG0_Y = 0;
|
||||||
|
@ -1945,6 +1946,29 @@ u32 GeneratePersonalityForGender(u32 gender, u32 species)
|
||||||
return speciesInfo->genderRatio / 2;
|
return speciesInfo->genderRatio / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CustomTrainerPartyAssignMoves(struct Pokemon *mon, const struct TrainerMonCustomized *partyEntry)
|
||||||
|
{
|
||||||
|
bool32 noMoveSet = TRUE;
|
||||||
|
u32 j;
|
||||||
|
|
||||||
|
for (j = 0; j < MAX_MON_MOVES; ++j)
|
||||||
|
{
|
||||||
|
if (partyEntry->moves[j] != MOVE_NONE)
|
||||||
|
noMoveSet = FALSE;
|
||||||
|
}
|
||||||
|
if (noMoveSet)
|
||||||
|
{
|
||||||
|
// TODO: Figure out a default strategy when moves are not set, to generate a good moveset
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < MAX_MON_MOVES; ++j)
|
||||||
|
{
|
||||||
|
SetMonData(mon, MON_DATA_MOVE1 + j, &partyEntry->moves[j]);
|
||||||
|
SetMonData(mon, MON_DATA_PP1 + j, &gBattleMoves[partyEntry->moves[j]].pp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer *trainer, bool32 firstTrainer, u32 battleTypeFlags)
|
u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer *trainer, bool32 firstTrainer, u32 battleTypeFlags)
|
||||||
{
|
{
|
||||||
u32 personalityValue;
|
u32 personalityValue;
|
||||||
|
@ -2047,12 +2071,7 @@ u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer
|
||||||
CreateMon(&party[i], partyData[i].species, partyData[i].lvl, 0, TRUE, personalityValue, otIdType, fixedOtId);
|
CreateMon(&party[i], partyData[i].species, partyData[i].lvl, 0, TRUE, personalityValue, otIdType, fixedOtId);
|
||||||
SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
||||||
|
|
||||||
// TODO: Figure out a default strategy when moves are not set, to generate a good moveset
|
CustomTrainerPartyAssignMoves(&party[i], &partyData[i]);
|
||||||
for (j = 0; j < MAX_MON_MOVES; ++j)
|
|
||||||
{
|
|
||||||
SetMonData(&party[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]);
|
|
||||||
SetMonData(&party[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp);
|
|
||||||
}
|
|
||||||
SetMonData(&party[i], MON_DATA_IVS, &(partyData[i].iv));
|
SetMonData(&party[i], MON_DATA_IVS, &(partyData[i].iv));
|
||||||
if (partyData[i].ev != NULL)
|
if (partyData[i].ev != NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue