diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c50d801b18..b1ce7f964b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7504,6 +7504,12 @@ static u32 GetTrainerMoneyToGive(u16 trainerId) lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl; } break; + case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED: + { + const struct TrainerMonCustomized *party = gTrainers[trainerId].party.EverythingCustomized; + lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl; + } + break; } for (; gTrainerMoneyTable[i].classId != 0xFF; i++) diff --git a/src/battle_setup.c b/src/battle_setup.c index 220edd394a..2b8e63e766 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -798,6 +798,14 @@ static u8 GetSumOfEnemyPartyLevel(u16 opponentId, u8 numMons) sum += party[i].lvl; } break; + case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED: + { + const struct TrainerMonCustomized *party; + party = gTrainers[opponentId].party.EverythingCustomized; + for (i = 0; i < count; i++) + sum += party[i].lvl; + } + break; } return sum; diff --git a/src/battle_tower.c b/src/battle_tower.c index 9300756561..a4758b9304 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -23,6 +23,7 @@ #include "field_message_box.h" #include "tv.h" #include "battle_factory.h" +#include "constants/abilities.h" #include "constants/apprentice.h" #include "constants/battle_dome.h" #include "constants/battle_frontier.h" @@ -3007,6 +3008,7 @@ static void FillPartnerParty(u16 trainerId) u16 monId; u32 otID; u8 trainerName[(PLAYER_NAME_LENGTH * 3) + 1]; + s32 ball = -1; SetFacilityPtrsGetLevel(); if (trainerId == TRAINER_STEVEN_PARTNER) @@ -3098,6 +3100,53 @@ static void FillPartnerParty(u16 trainerId) } break; } + case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED: + { + const struct TrainerMonCustomized *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.EverythingCustomized; + + CreateMon(&gPlayerParty[i], partyData[i].species, partyData[i].lvl, 0, TRUE, j, TRUE, otID); + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem); + + // TODO: Figure out a default strategy when moves are not set, to generate a good moveset + for (j = 0; j < MAX_MON_MOVES; ++j) + { + SetMonData(&gPlayerParty[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]); + SetMonData(&gPlayerParty[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp); + } + SetMonData(&gPlayerParty[i], MON_DATA_IVS, &(partyData[i].iv)); + if (partyData[i].ev != NULL) + { + SetMonData(&gPlayerParty[i], MON_DATA_HP_EV, &(partyData[i].ev[0])); + SetMonData(&gPlayerParty[i], MON_DATA_ATK_EV, &(partyData[i].ev[1])); + SetMonData(&gPlayerParty[i], MON_DATA_DEF_EV, &(partyData[i].ev[2])); + SetMonData(&gPlayerParty[i], MON_DATA_SPATK_EV, &(partyData[i].ev[3])); + SetMonData(&gPlayerParty[i], MON_DATA_SPDEF_EV, &(partyData[i].ev[4])); + SetMonData(&gPlayerParty[i], MON_DATA_SPEED_EV, &(partyData[i].ev[5])); + } + if (partyData[i].ability != ABILITY_NONE) + { + const struct SpeciesInfo *speciesInfo = &gSpeciesInfo[partyData[i].species]; + u32 maxAbilities = ARRAY_COUNT(speciesInfo->abilities); + for (j = 0; j < maxAbilities; ++j) + { + if (speciesInfo->abilities[j] == partyData[i].ability) + break; + } + if (j < maxAbilities) + SetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM, &j); + } + SetMonData(&gPlayerParty[i], MON_DATA_FRIENDSHIP, &(partyData[i].friendship)); + if (partyData[i].ball != ITEM_NONE) + { + ball = partyData[i].ball; + SetMonData(&gPlayerParty[i], MON_DATA_POKEBALL, &ball); + } + if (partyData[i].nickname != NULL) + { + SetMonData(&gPlayerParty[i], MON_DATA_NICKNAME, partyData[i].nickname); + } + CalculateMonStats(&gPlayerParty[i]); + } } StringCopy(trainerName, gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].trainerName); diff --git a/src/match_call.c b/src/match_call.c index a9d18b3477..c3378040e3 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1812,6 +1812,9 @@ static void PopulateSpeciesFromTrainerParty(int matchCallId, u8 *destStr) case F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM: speciesName = gSpeciesNames[party.ItemCustomMoves[monId].species]; break; + case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED: + speciesName = gSpeciesNames[party.EverythingCustomized[monId].species]; + break; } StringCopy(destStr, speciesName);