diff --git a/include/battle.h b/include/battle.h index 5a9e74528..95606eeea 100644 --- a/include/battle.h +++ b/include/battle.h @@ -574,6 +574,13 @@ struct LostItem u16 stolen:1; }; +#if HQ_RANDOM == TRUE +struct BattleVideo { + u32 battleTypeFlags; + rng_value_t rngSeed; +}; +#endif + struct BattleStruct { u8 turnEffectsTracker; @@ -643,7 +650,12 @@ struct BattleStruct u16 lastTakenMoveFrom[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT]; // a 2-D array [target][attacker] union { struct LinkBattlerHeader linkBattlerHeader; - struct MultiPartnerMenuPokemon multiBattleMons[3]; + + #if HQ_RANDOM == FALSE + u32 battleVideo[2]; + #else + struct BattleVideo battleVideo; + #endif } multiBuffer; u8 wishPerishSongState; u8 wishPerishSongBattlerId; @@ -1061,7 +1073,6 @@ extern u16 gLastPrintedMoves[MAX_BATTLERS_COUNT]; extern u8 gActionsByTurnOrder[MAX_BATTLERS_COUNT]; extern u8 gChosenActionByBattler[MAX_BATTLERS_COUNT]; extern u8 gBattleTerrain; -extern struct MultiPartnerMenuPokemon gMultiPartnerParty[MULTI_PARTY_SIZE]; extern u8 gPartyCriticalHits[PARTY_SIZE]; extern const struct BattleMoveEffect gBattleMoveEffects[]; extern u32 gFieldStatuses; diff --git a/include/battle_main.h b/include/battle_main.h index 9e9f06e05..9b752dd4d 100644 --- a/include/battle_main.h +++ b/include/battle_main.h @@ -57,20 +57,6 @@ enum { FIRST_TURN_EVENTS_END, }; -extern const struct OamData gOamData_BattlerOpponent; -extern const struct OamData gOamData_BattlerPlayer; -extern const struct TypeInfo gTypesInfo[NUMBER_OF_MON_TYPES]; -extern const uq4_12_t gTypeEffectivenessTable[NUMBER_OF_MON_TYPES][NUMBER_OF_MON_TYPES]; - -extern const u8 gStatusConditionString_PoisonJpn[8]; -extern const u8 gStatusConditionString_SleepJpn[8]; -extern const u8 gStatusConditionString_ParalysisJpn[8]; -extern const u8 gStatusConditionString_BurnJpn[8]; -extern const u8 gStatusConditionString_IceJpn[8]; -extern const u8 gStatusConditionString_ConfusionJpn[8]; -extern const u8 gStatusConditionString_LoveJpn[8]; -extern const u8 *const gStatusConditionStringsTable[7][2]; - void CB2_InitBattle(void); void BattleMainCB2(void); void CB2_QuitRecordedBattle(void); @@ -121,8 +107,23 @@ void ModifyPersonalityForNature(u32 *personality, u32 newNature); u32 GeneratePersonalityForGender(u32 gender, u32 species); void CustomTrainerPartyAssignMoves(struct Pokemon *mon, const struct TrainerMon *partyEntry); +extern struct MultiPartnerMenuPokemon gMultiPartnerParty[MULTI_PARTY_SIZE]; +extern const struct OamData gOamData_BattlerOpponent; +extern const struct OamData gOamData_BattlerPlayer; +extern const struct TypeInfo gTypesInfo[NUMBER_OF_MON_TYPES]; +extern const uq4_12_t gTypeEffectivenessTable[NUMBER_OF_MON_TYPES][NUMBER_OF_MON_TYPES]; extern const struct TypeInfo gTypesInfo[NUMBER_OF_MON_TYPES]; +extern const u8 gStatusConditionString_PoisonJpn[8]; +extern const u8 gStatusConditionString_SleepJpn[8]; +extern const u8 gStatusConditionString_ParalysisJpn[8]; +extern const u8 gStatusConditionString_BurnJpn[8]; +extern const u8 gStatusConditionString_IceJpn[8]; +extern const u8 gStatusConditionString_ConfusionJpn[8]; +extern const u8 gStatusConditionString_LoveJpn[8]; + +extern const u8 *const gStatusConditionStringsTable[7][2]; + #endif // GUARD_BATTLE_MAIN_H diff --git a/src/battle_main.c b/src/battle_main.c index 5209b3349..2af2be746 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -964,34 +964,253 @@ static void CB2_HandleStartBattle(void) } } -static void PrepareOwnMultiPartnerBuffer(void) +static void CB2_HandleStartMultiPartnerBattle(void) { - s32 i, j; - u8 *nick, *cur; + u8 playerMultiplayerId; + u8 partnerMultiplayerId; - for (i = 0; i < 3; i++) + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + + playerMultiplayerId = GetMultiplayerId(); + gBattleScripting.multiplayerId = playerMultiplayerId; + partnerMultiplayerId = playerMultiplayerId ^ BIT_SIDE; + + switch (gBattleCommunication[MULTIUSE_STATE]) { - gMultiPartnerParty[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES); - gMultiPartnerParty[i].heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); - nick = gMultiPartnerParty[i].nickname; - GetMonData(&gPlayerParty[i], MON_DATA_NICKNAME, nick); - gMultiPartnerParty[i].level = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); - gMultiPartnerParty[i].hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); - gMultiPartnerParty[i].maxhp = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); - gMultiPartnerParty[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); - gMultiPartnerParty[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); - gMultiPartnerParty[i].gender = GetMonGender(&gPlayerParty[i]); - StripExtCtrlCodes(nick); - if (GetMonData(&gPlayerParty[i], MON_DATA_LANGUAGE) != LANGUAGE_JAPANESE) + case 0: + if (!IsDma3ManagerBusyWithBgCopy()) { - for (cur = nick, j = 0; cur[j] != EOS; j++) - ; - while (j < 6) - cur[j++] = 0; - cur[j] = EOS; + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + BattleInterfaceSetWindowPals(); + gBattleCommunication[MULTIUSE_STATE] = 1; } + if (gWirelessCommType) + LoadWirelessStatusIndicatorSpriteGfx(); + // fall through + case 1: + // if (gBattleTypeFlags & BATTLE_TYPE_LINK) + // { + // if (gReceivedRemoteLinkPlayers) + // { + // u8 language; + + // gLinkPlayers[0].id = 0; + // gLinkPlayers[1].id = 2; + // gLinkPlayers[2].id = 1; + // gLinkPlayers[3].id = 3; + // GetFrontierTrainerName(gLinkPlayers[2].name, gTrainerBattleOpponent_A); + // GetFrontierTrainerName(gLinkPlayers[3].name, gTrainerBattleOpponent_B); + // GetBattleTowerTrainerLanguage(&language, gTrainerBattleOpponent_A); + // gLinkPlayers[2].language = language; + // GetBattleTowerTrainerLanguage(&language, gTrainerBattleOpponent_B); + // gLinkPlayers[3].language = language; + + // if (IsLinkTaskFinished()) + // { + // // 0x300 + // *(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureLo) = 0; + // *(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureHi) = 3; + // BufferPartyVsScreenHealth_AtStart(); + // SetPlayerBerryDataInBattleStruct(); + // SendBlock(BitmaskAllOtherLinkPlayers(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader)); + // gBattleCommunication[MULTIUSE_STATE] = 2; + // } + + // if (gWirelessCommType) + // CreateWirelessStatusIndicatorSprite(0, 0); + // } + // } + // else + // { + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + gBattleTypeFlags |= BATTLE_TYPE_IS_MASTER; + gBattleCommunication[MULTIUSE_STATE] = 13; + SetAllPlayersBerryData(); + // } + break; + case 2: + if ((GetBlockReceivedStatus() & 3) == 3) + { + u8 taskId; + + ResetBlockReceivedFlags(); + LinkBattleComputeBattleTypeFlags(2, playerMultiplayerId); + SetAllPlayersBerryData(); + taskId = CreateTask(InitLinkBattleVsScreen, 0); + gTasks[taskId].data[1] = 0x10E; + gTasks[taskId].data[2] = 0x5A; + gTasks[taskId].data[5] = 0; + gTasks[taskId].data[3] = 0x145; + gTasks[taskId].data[4] = 0x145; + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 3: + // Link battle, send/receive party Pokémon in groups + if (IsLinkTaskFinished()) + { + // Send Pokémon 1-2 + SendBlock(BitmaskAllOtherLinkPlayers(), gPlayerParty, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 4: + if ((GetBlockReceivedStatus() & 3) == 3) + { + // Recv partner's Pokémon 1-2, and copy partner's and own Pokémon into party positions + ResetBlockReceivedFlags(); + if (gLinkPlayers[playerMultiplayerId].id != 0) + { + memcpy(gPlayerParty, gBlockRecvBuffer[partnerMultiplayerId], sizeof(struct Pokemon) * 2); + memcpy(&gPlayerParty[MULTI_PARTY_SIZE], gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon) * 2); + } + else + { + memcpy(gPlayerParty, gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon) * 2); + memcpy(&gPlayerParty[MULTI_PARTY_SIZE], gBlockRecvBuffer[partnerMultiplayerId], sizeof(struct Pokemon) * 2); + } + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 5: + if (IsLinkTaskFinished()) + { + // Send Pokémon 3 + SendBlock(BitmaskAllOtherLinkPlayers(), &gPlayerParty[2], sizeof(struct Pokemon)); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 6: + if ((GetBlockReceivedStatus() & 3) == 3) + { + // Recv partner's Pokémon 3, and copy partner's and own Pokémon into party positions + ResetBlockReceivedFlags(); + if (gLinkPlayers[playerMultiplayerId].id != 0) + { + memcpy(&gPlayerParty[2], gBlockRecvBuffer[partnerMultiplayerId], sizeof(struct Pokemon)); + memcpy(&gPlayerParty[2 + MULTI_PARTY_SIZE], gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon)); + } + else + { + memcpy(&gPlayerParty[2], gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon)); + memcpy(&gPlayerParty[2 + MULTI_PARTY_SIZE], gBlockRecvBuffer[partnerMultiplayerId], sizeof(struct Pokemon)); + } + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 7: + if (IsLinkTaskFinished()) + { + // Send enemy Pokémon 1-2 to partner + SendBlock(BitmaskAllOtherLinkPlayers(), gEnemyParty, sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 8: + if ((GetBlockReceivedStatus() & 3) == 3) + { + // Recv enemy Pokémon 1-2 (if not master) + ResetBlockReceivedFlags(); + if (GetMultiplayerId() != 0) + memcpy(gEnemyParty, gBlockRecvBuffer[0], sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 9: + if (IsLinkTaskFinished()) + { + // Send enemy Pokémon 3-4 to partner + SendBlock(BitmaskAllOtherLinkPlayers(), &gEnemyParty[2], sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 10: + if ((GetBlockReceivedStatus() & 3) == 3) + { + // Recv enemy Pokémon 3-4 (if not master) + ResetBlockReceivedFlags(); + if (GetMultiplayerId() != 0) + memcpy(&gEnemyParty[2], gBlockRecvBuffer[0], sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 11: + if (IsLinkTaskFinished()) + { + // Send enemy Pokémon 5-6 to partner + SendBlock(BitmaskAllOtherLinkPlayers(), &gEnemyParty[4], sizeof(struct Pokemon) * 2); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 12: + if ((GetBlockReceivedStatus() & 3) == 3) + { + // Recv enemy Pokémon 5-6 (if not master) + ResetBlockReceivedFlags(); + if (GetMultiplayerId() != 0) + memcpy(&gEnemyParty[4], gBlockRecvBuffer[0], sizeof(struct Pokemon) * 2); + + TryCorrectShedinjaLanguage(&gPlayerParty[0]); + TryCorrectShedinjaLanguage(&gPlayerParty[1]); + TryCorrectShedinjaLanguage(&gPlayerParty[2]); + TryCorrectShedinjaLanguage(&gPlayerParty[3]); + TryCorrectShedinjaLanguage(&gPlayerParty[4]); + TryCorrectShedinjaLanguage(&gPlayerParty[5]); + TryCorrectShedinjaLanguage(&gEnemyParty[0]); + TryCorrectShedinjaLanguage(&gEnemyParty[1]); + TryCorrectShedinjaLanguage(&gEnemyParty[2]); + TryCorrectShedinjaLanguage(&gEnemyParty[3]); + TryCorrectShedinjaLanguage(&gEnemyParty[4]); + TryCorrectShedinjaLanguage(&gEnemyParty[5]); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 13: + InitBattleControllers(); + RecordedBattle_SetTrainerInfo(); + gBattleCommunication[SPRITES_INIT_STATE1] = 0; + gBattleCommunication[SPRITES_INIT_STATE2] = 0; + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + gBattleCommunication[MULTIUSE_STATE] = 14; + else + gBattleCommunication[MULTIUSE_STATE] = 16; + break; + case 14: + // Send rng seed for recorded battle + if (IsLinkTaskFinished()) + { + SendBlock(BitmaskAllOtherLinkPlayers(), &gRecordedBattleRngSeed, sizeof(gRecordedBattleRngSeed)); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 15: + // Receive rng seed for recorded battle (only read it if partner is the link master) + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER)) + memcpy(&gRecordedBattleRngSeed, gBlockRecvBuffer[partnerMultiplayerId], sizeof(gRecordedBattleRngSeed)); + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 16: + // Finish, start battle + if (BattleInitAllSprites(&gBattleCommunication[SPRITES_INIT_STATE1], &gBattleCommunication[SPRITES_INIT_STATE2])) + { + // TrySetLinkBattleTowerEnemyPartyLevel(); + gPreBattleCallback1 = gMain.callback1; + gMain.callback1 = BattleMainCB1; + SetMainCallback2(BattleMainCB2); + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + gBattleTypeFlags |= BATTLE_TYPE_LINK_IN_BATTLE; + } + break; } - memcpy(gBattleStruct->multiBuffer.multiBattleMons, gMultiPartnerParty, sizeof(gMultiPartnerParty)); } static void SetMultiPartnerMenuParty(u8 offset) @@ -1044,8 +1263,9 @@ static void CB2_PreInitMultiBattle(void) case 0: if (gReceivedRemoteLinkPlayers && IsLinkTaskFinished()) { - PrepareOwnMultiPartnerBuffer(); - SendBlock(BitmaskAllOtherLinkPlayers(), gBattleStruct->multiBuffer.multiBattleMons, sizeof(gBattleStruct->multiBuffer.multiBattleMons)); + sMultiPartnerPartyBuffer = Alloc(sizeof(gMultiPartnerParty)); + SetMultiPartnerMenuParty(0); + SendBlock(BitmaskAllOtherLinkPlayers(), sMultiPartnerPartyBuffer, sizeof(gMultiPartnerParty)); gBattleCommunication[MULTIUSE_STATE]++; } break; @@ -1086,6 +1306,7 @@ static void CB2_PreInitMultiBattle(void) gBattleTypeFlags = *savedBattleTypeFlags; gMain.savedCallback = *savedCallback; SetMainCallback2(CB2_InitBattleInternal); + FREE_AND_SET_NULL(sMultiPartnerPartyBuffer); } } else if (!gReceivedRemoteLinkPlayers) @@ -1093,6 +1314,7 @@ static void CB2_PreInitMultiBattle(void) gBattleTypeFlags = *savedBattleTypeFlags; gMain.savedCallback = *savedCallback; SetMainCallback2(CB2_InitBattleInternal); + FREE_AND_SET_NULL(sMultiPartnerPartyBuffer); } break; } @@ -1397,255 +1619,6 @@ static void CB2_HandleStartMultiBattle(void) } } -static void CB2_HandleStartMultiPartnerBattle(void) -{ - u8 playerMultiplayerId; - u8 partnerMultiplayerId; - - RunTasks(); - AnimateSprites(); - BuildOamBuffer(); - - playerMultiplayerId = GetMultiplayerId(); - gBattleScripting.multiplayerId = playerMultiplayerId; - partnerMultiplayerId = playerMultiplayerId ^ BIT_SIDE; - - switch (gBattleCommunication[MULTIUSE_STATE]) - { - case 0: - if (!IsDma3ManagerBusyWithBgCopy()) - { - ShowBg(0); - ShowBg(1); - ShowBg(2); - ShowBg(3); - BattleInterfaceSetWindowPals(); - gBattleCommunication[MULTIUSE_STATE] = 1; - } - if (gWirelessCommType) - LoadWirelessStatusIndicatorSpriteGfx(); - // fall through - case 1: - // if (gBattleTypeFlags & BATTLE_TYPE_LINK) - // { - // if (gReceivedRemoteLinkPlayers) - // { - // u8 language; - - // gLinkPlayers[0].id = 0; - // gLinkPlayers[1].id = 2; - // gLinkPlayers[2].id = 1; - // gLinkPlayers[3].id = 3; - // GetFrontierTrainerName(gLinkPlayers[2].name, gTrainerBattleOpponent_A); - // GetFrontierTrainerName(gLinkPlayers[3].name, gTrainerBattleOpponent_B); - // GetBattleTowerTrainerLanguage(&language, gTrainerBattleOpponent_A); - // gLinkPlayers[2].language = language; - // GetBattleTowerTrainerLanguage(&language, gTrainerBattleOpponent_B); - // gLinkPlayers[3].language = language; - - // if (IsLinkTaskFinished()) - // { - // // 0x300 - // *(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureLo) = 0; - // *(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureHi) = 3; - // BufferPartyVsScreenHealth_AtStart(); - // SetPlayerBerryDataInBattleStruct(); - // SendBlock(BitmaskAllOtherLinkPlayers(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader)); - // gBattleCommunication[MULTIUSE_STATE] = 2; - // } - - // if (gWirelessCommType) - // CreateWirelessStatusIndicatorSprite(0, 0); - // } - // } - // else - // { - if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) - gBattleTypeFlags |= BATTLE_TYPE_IS_MASTER; - gBattleCommunication[MULTIUSE_STATE] = 13; - SetAllPlayersBerryData(); - // } - break; - case 2: - if ((GetBlockReceivedStatus() & 3) == 3) - { - u8 taskId; - - ResetBlockReceivedFlags(); - LinkBattleComputeBattleTypeFlags(2, playerMultiplayerId); - SetAllPlayersBerryData(); - taskId = CreateTask(InitLinkBattleVsScreen, 0); - gTasks[taskId].data[1] = 0x10E; - gTasks[taskId].data[2] = 0x5A; - gTasks[taskId].data[5] = 0; - gTasks[taskId].data[3] = 0x145; - gTasks[taskId].data[4] = 0x145; - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 3: - // Link battle, send/receive party Pokémon in groups - if (IsLinkTaskFinished()) - { - // Send Pokémon 1-2 - SendBlock(BitmaskAllOtherLinkPlayers(), gPlayerParty, sizeof(struct Pokemon) * 2); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 4: - if ((GetBlockReceivedStatus() & 3) == 3) - { - // Recv partner's Pokémon 1-2, and copy partner's and own Pokémon into party positions - ResetBlockReceivedFlags(); - if (gLinkPlayers[playerMultiplayerId].id != 0) - { - memcpy(gPlayerParty, gBlockRecvBuffer[partnerMultiplayerId], sizeof(struct Pokemon) * 2); - memcpy(&gPlayerParty[MULTI_PARTY_SIZE], gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon) * 2); - } - else - { - memcpy(gPlayerParty, gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon) * 2); - memcpy(&gPlayerParty[MULTI_PARTY_SIZE], gBlockRecvBuffer[partnerMultiplayerId], sizeof(struct Pokemon) * 2); - } - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 5: - if (IsLinkTaskFinished()) - { - // Send Pokémon 3 - SendBlock(BitmaskAllOtherLinkPlayers(), &gPlayerParty[2], sizeof(struct Pokemon)); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 6: - if ((GetBlockReceivedStatus() & 3) == 3) - { - // Recv partner's Pokémon 3, and copy partner's and own Pokémon into party positions - ResetBlockReceivedFlags(); - if (gLinkPlayers[playerMultiplayerId].id != 0) - { - memcpy(&gPlayerParty[2], gBlockRecvBuffer[partnerMultiplayerId], sizeof(struct Pokemon)); - memcpy(&gPlayerParty[2 + MULTI_PARTY_SIZE], gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon)); - } - else - { - memcpy(&gPlayerParty[2], gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon)); - memcpy(&gPlayerParty[2 + MULTI_PARTY_SIZE], gBlockRecvBuffer[partnerMultiplayerId], sizeof(struct Pokemon)); - } - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 7: - if (IsLinkTaskFinished()) - { - // Send enemy Pokémon 1-2 to partner - SendBlock(BitmaskAllOtherLinkPlayers(), gEnemyParty, sizeof(struct Pokemon) * 2); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 8: - if ((GetBlockReceivedStatus() & 3) == 3) - { - // Recv enemy Pokémon 1-2 (if not master) - ResetBlockReceivedFlags(); - if (GetMultiplayerId() != 0) - memcpy(gEnemyParty, gBlockRecvBuffer[0], sizeof(struct Pokemon) * 2); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 9: - if (IsLinkTaskFinished()) - { - // Send enemy Pokémon 3-4 to partner - SendBlock(BitmaskAllOtherLinkPlayers(), &gEnemyParty[2], sizeof(struct Pokemon) * 2); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 10: - if ((GetBlockReceivedStatus() & 3) == 3) - { - // Recv enemy Pokémon 3-4 (if not master) - ResetBlockReceivedFlags(); - if (GetMultiplayerId() != 0) - memcpy(&gEnemyParty[2], gBlockRecvBuffer[0], sizeof(struct Pokemon) * 2); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 11: - if (IsLinkTaskFinished()) - { - // Send enemy Pokémon 5-6 to partner - SendBlock(BitmaskAllOtherLinkPlayers(), &gEnemyParty[4], sizeof(struct Pokemon) * 2); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 12: - if ((GetBlockReceivedStatus() & 3) == 3) - { - // Recv enemy Pokémon 5-6 (if not master) - ResetBlockReceivedFlags(); - if (GetMultiplayerId() != 0) - memcpy(&gEnemyParty[4], gBlockRecvBuffer[0], sizeof(struct Pokemon) * 2); - - TryCorrectShedinjaLanguage(&gPlayerParty[0]); - TryCorrectShedinjaLanguage(&gPlayerParty[1]); - TryCorrectShedinjaLanguage(&gPlayerParty[2]); - TryCorrectShedinjaLanguage(&gPlayerParty[3]); - TryCorrectShedinjaLanguage(&gPlayerParty[4]); - TryCorrectShedinjaLanguage(&gPlayerParty[5]); - TryCorrectShedinjaLanguage(&gEnemyParty[0]); - TryCorrectShedinjaLanguage(&gEnemyParty[1]); - TryCorrectShedinjaLanguage(&gEnemyParty[2]); - TryCorrectShedinjaLanguage(&gEnemyParty[3]); - TryCorrectShedinjaLanguage(&gEnemyParty[4]); - TryCorrectShedinjaLanguage(&gEnemyParty[5]); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 13: - InitBattleControllers(); - RecordedBattle_SetTrainerInfo(); - gBattleCommunication[SPRITES_INIT_STATE1] = 0; - gBattleCommunication[SPRITES_INIT_STATE2] = 0; - if (gBattleTypeFlags & BATTLE_TYPE_LINK) - gBattleCommunication[MULTIUSE_STATE] = 14; - else - gBattleCommunication[MULTIUSE_STATE] = 16; - break; - case 14: - // Send rng seed for recorded battle - if (IsLinkTaskFinished()) - { - SendBlock(BitmaskAllOtherLinkPlayers(), &gRecordedBattleRngSeed, sizeof(gRecordedBattleRngSeed)); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 15: - // Receive rng seed for recorded battle (only read it if partner is the link master) - if ((GetBlockReceivedStatus() & 3) == 3) - { - ResetBlockReceivedFlags(); - if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER)) - memcpy(&gRecordedBattleRngSeed, gBlockRecvBuffer[partnerMultiplayerId], sizeof(gRecordedBattleRngSeed)); - gBattleCommunication[MULTIUSE_STATE]++; - } - break; - case 16: - // Finish, start battle - if (BattleInitAllSprites(&gBattleCommunication[SPRITES_INIT_STATE1], &gBattleCommunication[SPRITES_INIT_STATE2])) - { - // TrySetLinkBattleTowerEnemyPartyLevel(); - gPreBattleCallback1 = gMain.callback1; - gMain.callback1 = BattleMainCB1; - SetMainCallback2(BattleMainCB2); - if (gBattleTypeFlags & BATTLE_TYPE_LINK) - gBattleTypeFlags |= BATTLE_TYPE_LINK_IN_BATTLE; - } - break; - } -} - void BattleMainCB2(void) { AnimateSprites();