diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_main.c | 2 | ||||
-rw-r--r-- | src/battle_tower.c | 62 | ||||
-rw-r--r-- | src/pokemon.c | 23 | ||||
-rw-r--r-- | src/recorded_battle.c | 2 |
4 files changed, 51 insertions, 38 deletions
diff --git a/src/battle_main.c b/src/battle_main.c index 5bc80f61e..29a8f560a 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -1357,7 +1357,7 @@ static void CB2_HandleStartMultiPartnerBattle(void) case 16: if (BattleInitAllSprites(&gBattleCommunication[SPRITES_INIT_STATE1], &gBattleCommunication[SPRITES_INIT_STATE2])) { - sub_8166188(); + TrySetLinkBattleTowerEnemyPartyLevel(); gPreBattleCallback1 = gMain.callback1; gMain.callback1 = BattleMainCB1; SetMainCallback2(BattleMainCB2); diff --git a/src/battle_tower.c b/src/battle_tower.c index d7123f3d2..ee75feeb4 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -57,12 +57,12 @@ static void SetTowerBattleWon(void); static void AwardBattleTowerRibbons(void); static void SaveTowerChallenge(void); static void GetOpponentIntroSpeech(void); -static void nullsub_61(void); -static void nullsub_116(void); +static void BattleTowerNop1(void); +static void BattleTowerNop2(void); static void LoadMultiPartnerCandidatesData(void); static void ShowPartnerCandidateMessage(void); static void LoadLinkMultiOpponentsData(void); -static void sub_8164DCC(void); +static void TowerTryCloseLink(void); static void SetMultiPartnerGfx(void); static void SetTowerInterviewData(void); static void ValidateBattleTowerRecordChecksums(void); @@ -811,12 +811,12 @@ static void (* const sBattleTowerFuncs[])(void) = [BATTLE_TOWER_FUNC_GIVE_RIBBONS] = AwardBattleTowerRibbons, [BATTLE_TOWER_FUNC_SAVE] = SaveTowerChallenge, [BATTLE_TOWER_FUNC_GET_OPPONENT_INTRO] = GetOpponentIntroSpeech, - [BATTLE_TOWER_FUNC_NOP] = nullsub_61, - [BATTLE_TOWER_FUNC_NOP2] = nullsub_116, + [BATTLE_TOWER_FUNC_NOP] = BattleTowerNop1, + [BATTLE_TOWER_FUNC_NOP2] = BattleTowerNop2, [BATTLE_TOWER_FUNC_LOAD_PARTNERS] = LoadMultiPartnerCandidatesData, [BATTLE_TOWER_FUNC_PARTNER_MSG] = ShowPartnerCandidateMessage, [BATTLE_TOWER_FUNC_LOAD_LINK_OPPONENTS] = LoadLinkMultiOpponentsData, - [BATTLE_TOWER_FUNC_13] = sub_8164DCC, + [BATTLE_TOWER_FUNC_TRY_CLOSE_LINK] = TowerTryCloseLink, [BATTLE_TOWER_FUNC_SET_PARTNER_GFX] = SetMultiPartnerGfx, [BATTLE_TOWER_FUNC_SET_INTERVIEW_DATA] = SetTowerInterviewData, }; @@ -1547,7 +1547,7 @@ void GetFrontierTrainerName(u8 *dst, u16 trainerId) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { - sub_8186468(dst); + GetRecordedBattleRecordMixFriendName(dst); return; } else @@ -2059,7 +2059,7 @@ void DoSpecialTrainerBattle(void) if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN) FillFrontierTrainerParty(DOME_BATTLE_PARTY_SIZE); CreateTask(Task_StartBattleAfterTransition, 1); - sub_806E694(0); + CreateTask_PlayMapChosenOrBattleBGM(0); BattleTransition_StartOnField(GetSpecialBattleTransition(3)); break; case SPECIAL_BATTLE_PALACE: @@ -2139,7 +2139,7 @@ static void SaveCurrentWinStreak(void) gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] = winStreak; } -static void sub_8163EE4(void) +static void SaveBattleTowerRecord(void) { s32 i; u8 lvlMode, battleMode, class; @@ -2178,7 +2178,7 @@ static void sub_8163EE4(void) for (i = 0; i < MAX_FRONTIER_PARTY_SIZE; i++) { if (gSaveBlock2Ptr->frontier.selectedPartyMons[i] != 0) - sub_80686FC(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], &playerRecord->party[i]); + ConvertPokemonToBattleTowerPokemon(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], &playerRecord->party[i]); } playerRecord->language = gGameLanguage; @@ -2193,7 +2193,7 @@ static void SaveTowerChallenge(void) s32 challengeNum = (signed)(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7); if (gSpecialVar_0x8005 == 0 && (challengeNum > 1 || gSaveBlock2Ptr->frontier.curChallengeBattleNum != 0)) - sub_8163EE4(); + SaveBattleTowerRecord(); gSaveBlock2Ptr->frontier.challengeStatus = gSpecialVar_0x8005; VarSet(VAR_TEMP_0, 0); @@ -2201,12 +2201,12 @@ static void SaveTowerChallenge(void) SaveGameFrontier(); } -static void nullsub_61(void) +static void BattleTowerNop1(void) { } -static void nullsub_116(void) +static void BattleTowerNop2(void) { } @@ -2410,7 +2410,7 @@ static void LoadMultiPartnerCandidatesData(void) } } -static void sub_81646BC(u16 trainerId, u16 monId) +static void GetPotentialPartnerMoveAndSpecies(u16 trainerId, u16 monId) { u16 move = 0; u16 species = 0; @@ -2445,6 +2445,14 @@ static void sub_81646BC(u16 trainerId, u16 monId) StringCopy(gStringVar2, gSpeciesNames[species]); } +// For multi battles in the Battle Tower, the player may choose a partner by talking to them +// These partners can be an NPC or a former/record-mixed Apprentice +// When talked to, their response consists of: +// PARTNER_MSGID_INTRO - A greeting +// PARTNER_MSGID_MON1 - Naming one pokemon on their team, and a move it has +// PARTNER_MSGID_MON2_ASK - Naming a second pokemon on their team, a move it has, and asking if they'd like to be their partner +// PARTNER_MSGID_ACCEPT - If the player agrees to be their partner +// PARTNER_MSGID_REJECT - If the player declines to be their partner static void ShowPartnerCandidateMessage(void) { s32 i, j, partnerId; @@ -2487,11 +2495,11 @@ static void ShowPartnerCandidateMessage(void) break; case PARTNER_MSGID_MON1: monId = gSaveBlock2Ptr->frontier.trainerIds[8 + k * 2]; - sub_81646BC(trainerId, monId); + GetPotentialPartnerMoveAndSpecies(trainerId, monId); break; case PARTNER_MSGID_MON2_ASK: monId = gSaveBlock2Ptr->frontier.trainerIds[9 + k * 2]; - sub_81646BC(trainerId, monId); + GetPotentialPartnerMoveAndSpecies(trainerId, monId); break; case PARTNER_MSGID_ACCEPT: gPartnerTrainerId = trainerId; @@ -2643,7 +2651,7 @@ static void LoadLinkMultiOpponentsData(void) } } -static void sub_8164DCC(void) +static void TowerTryCloseLink(void) { if (gWirelessCommType != 0) SetCloseLinkCallback(); @@ -2838,7 +2846,7 @@ static void FillEReaderTrainerWithPlayerData(void) } for (i = 0; i < 3; i++) - sub_80686FC(&gPlayerParty[i], &ereaderTrainer->party[i]); + ConvertPokemonToBattleTowerPokemon(&gPlayerParty[i], &ereaderTrainer->party[i]); SetEReaderTrainerChecksum(ereaderTrainer); } @@ -3292,16 +3300,16 @@ static u8 GetFrontierTrainerFixedIvs(u16 trainerId) return fixedIv; } -static u16 sub_8165D40(void) +static u16 GetBattleTentTrainerId(void) { u32 facility = VarGet(VAR_FRONTIER_FACILITY); - if (facility == FRONTIER_FACILITY_PALACE) - return Random() % 30; - else if (facility == FRONTIER_FACILITY_ARENA) - return Random() % 30; - else if (facility == FRONTIER_FACILITY_FACTORY) - return Random() % 30; + if (facility == FRONTIER_FACILITY_PALACE) // Verdanturf Tent; uses Palace mechanics + return Random() % NUM_BATTLE_TENT_TRAINERS; + else if (facility == FRONTIER_FACILITY_ARENA) // Fallarbor Tent; uses Arena mechanics + return Random() % NUM_BATTLE_TENT_TRAINERS; + else if (facility == FRONTIER_FACILITY_FACTORY) // Slateport Tent; uses Factory mechanics + return Random() % NUM_BATTLE_TENT_TRAINERS; else if (facility == FRONTIER_FACILITY_TOWER) return 0; else @@ -3348,7 +3356,7 @@ static void SetNextBattleTentOpponent(void) do { - trainerId = sub_8165D40(); + trainerId = GetBattleTentTrainerId(); for (i = 0; i < gSaveBlock2Ptr->frontier.curChallengeBattleNum; i++) { if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId) @@ -3511,7 +3519,7 @@ bool32 ValidateBattleTowerRecord(u8 recordId) // unused } } -void sub_8166188(void) +void TrySetLinkBattleTowerEnemyPartyLevel(void) { if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) { diff --git a/src/pokemon.c b/src/pokemon.c index 475373550..b5eee16b2 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -57,7 +57,7 @@ static u16 CalculateBoxMonChecksum(struct BoxPokemon *boxMon); static union PokemonSubstruct *GetSubstruct(struct BoxPokemon *boxMon, u32 personality, u8 substructType); static void EncryptBoxMon(struct BoxPokemon *boxMon); static void DecryptBoxMon(struct BoxPokemon *boxMon); -static void sub_806E6CC(u8 taskId); +static void Task_PlayMapChosenOrBattleBGM(u8 taskId); static bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId); static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move); static bool8 ShouldSkipFriendshipChange(void); @@ -2578,7 +2578,7 @@ void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, CalculateMonStats(mon); } -void sub_80686FC(struct Pokemon *mon, struct BattleTowerPokemon *dest) +void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest) { s32 i; u16 heldItem; @@ -2587,7 +2587,7 @@ void sub_80686FC(struct Pokemon *mon, struct BattleTowerPokemon *dest) heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); if (heldItem == ITEM_ENIGMA_BERRY) - heldItem = 0; + heldItem = ITEM_NONE; dest->heldItem = heldItem; @@ -6334,26 +6334,31 @@ void PlayMapChosenOrBattleBGM(u16 songId) PlayNewMapMusic(GetBattleBGM()); } -void sub_806E694(u16 songId) +// Identical to PlayMapChosenOrBattleBGM, but uses a task instead +// Only used by Battle Dome +#define tSongId data[0] +void CreateTask_PlayMapChosenOrBattleBGM(u16 songId) { u8 taskId; ResetMapMusic(); m4aMPlayAllStop(); - taskId = CreateTask(sub_806E6CC, 0); - gTasks[taskId].data[0] = songId; + taskId = CreateTask(Task_PlayMapChosenOrBattleBGM, 0); + gTasks[taskId].tSongId = songId; } -static void sub_806E6CC(u8 taskId) +static void Task_PlayMapChosenOrBattleBGM(u8 taskId) { - if (gTasks[taskId].data[0]) - PlayNewMapMusic(gTasks[taskId].data[0]); + if (gTasks[taskId].tSongId) + PlayNewMapMusic(gTasks[taskId].tSongId); else PlayNewMapMusic(GetBattleBGM()); DestroyTask(taskId); } +#undef tSongId + const u32 *GetMonFrontSpritePal(struct Pokemon *mon) { u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); diff --git a/src/recorded_battle.c b/src/recorded_battle.c index 5a0579f70..881c2d3ec 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -846,7 +846,7 @@ bool8 sub_8186450(void) return (sUnknown_0203CCD0 == 0); } -void sub_8186468(u8 *dst) +void GetRecordedBattleRecordMixFriendName(u8 *dst) { s32 i; |