diff options
author | GriffinR <griffin.g.richards@gmail.com> | 2021-03-04 17:48:40 -0500 |
---|---|---|
committer | huderlem <huderlem@gmail.com> | 2021-03-04 19:30:19 -0600 |
commit | 55a40b901f82483411931f6cf137fa344ba12dd8 (patch) | |
tree | a500713bc3d4c34023ceaec18bc74456acd3c941 /src | |
parent | 734a15135f8f0b23541b4c2bb2af27ffa560a8dc (diff) |
Label battle tower link script
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_main.c | 8 | ||||
-rw-r--r-- | src/cable_club.c | 3 | ||||
-rw-r--r-- | src/field_specials.c | 221 |
3 files changed, 122 insertions, 110 deletions
diff --git a/src/battle_main.c b/src/battle_main.c index 75e74fe54..a1bc6ae7b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2276,7 +2276,7 @@ static void EndLinkBattleInSteps(void) } else if (gReceivedRemoteLinkPlayers == 0) { - CreateTask(sub_80B3AF8, 5); + CreateTask(Task_ReconnectWithLinkPlayers, 5); gBattleCommunication[MULTIUSE_STATE]++; } else @@ -2307,7 +2307,7 @@ static void EndLinkBattleInSteps(void) gBattleCommunication[MULTIUSE_STATE]++; break; case 5: - if (!FuncIsActiveTask(sub_80B3AF8)) + if (!FuncIsActiveTask(Task_ReconnectWithLinkPlayers)) gBattleCommunication[MULTIUSE_STATE]++; break; case 6: @@ -2430,11 +2430,11 @@ static void sub_803939C(void) break; case 1: if (gMain.field_439_x4 && gReceivedRemoteLinkPlayers == 0) - CreateTask(sub_80B3AF8, 5); + CreateTask(Task_ReconnectWithLinkPlayers, 5); gBattleCommunication[MULTIUSE_STATE]++; break; case 2: - if (!FuncIsActiveTask(sub_80B3AF8)) + if (!FuncIsActiveTask(Task_ReconnectWithLinkPlayers)) gBattleCommunication[MULTIUSE_STATE]++; break; case 3: diff --git a/src/cable_club.c b/src/cable_club.c index 77cb0465c..8b321d670 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -1267,7 +1267,8 @@ static void sub_80B3AD0(u8 taskId) #define tTimer data[1] -void sub_80B3AF8(u8 taskId) +// Confirm that all cabled link players are connected +void Task_ReconnectWithLinkPlayers(u8 taskId) { s16 *data = gTasks[taskId].data; diff --git a/src/field_specials.c b/src/field_specials.c index 9e944a384..86be21eda 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -3735,14 +3735,17 @@ bool32 ShouldDistributeEonTicket(void) return TRUE; } -void sub_813B534(void) +#define tState data[0] + +void BattleTowerReconnectLink(void) { + // Save battle type, restored at end + // of Task_LinkRetireStatusWithBattleTowerPartner sBattleTowerMultiBattleTypeFlags = gBattleTypeFlags; gBattleTypeFlags = 0; + if (!gReceivedRemoteLinkPlayers) - { - CreateTask(sub_80B3AF8, 5); - } + CreateTask(Task_ReconnectWithLinkPlayers, 5); } void LinkRetireStatusWithBattleTowerPartner(void) @@ -3750,137 +3753,145 @@ void LinkRetireStatusWithBattleTowerPartner(void) CreateTask(Task_LinkRetireStatusWithBattleTowerPartner, 5); } +// Communicate with a Battle Tower link partner to tell them +// whether or not the player chose to continue or retire, +// and determine what the partner chose to do +// gSpecialVar_0x8004: Player's choice +// gSpecialVar_0x8005: Partner's choice (read from gBlockRecvBuffer[1][0]) static void Task_LinkRetireStatusWithBattleTowerPartner(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 0: - if (!FuncIsActiveTask(sub_80B3AF8)) + case 0: + if (!FuncIsActiveTask(Task_ReconnectWithLinkPlayers)) + { + gTasks[taskId].tState++; + } + break; + case 1: + if (IsLinkTaskFinished() == TRUE) + { + if (GetMultiplayerId() == 0) { - gTasks[taskId].data[0]++; + // Player is link leader, skip sending data + gTasks[taskId].tState++; } - break; - case 1: - if (IsLinkTaskFinished() == TRUE) + else { - if (GetMultiplayerId() == 0) - { - gTasks[taskId].data[0]++; - } - else - { - SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_0x8004, 2); - gTasks[taskId].data[0]++; - } + // Send value of gSpecialVar_0x8004 to leader + // Will either be BATTLE_TOWER_LINK_CONTINUE or BATTLE_TOWER_LINK_RETIRE + SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_0x8004, sizeof(gSpecialVar_0x8004)); + gTasks[taskId].tState++; } - break; - case 2: - if ((GetBlockReceivedStatus() & 2) != 0) - { - if (GetMultiplayerId() == 0) - { - gSpecialVar_0x8005 = gBlockRecvBuffer[1][0]; - ResetBlockReceivedFlag(1); - if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE - && gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE) - { - gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_BOTH_RETIRE; - } - else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_CONTINUE - && gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE) - { - gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_PARTNER_RETIRE; - } - else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE - && gSpecialVar_0x8005 == BATTLE_TOWER_LINK_CONTINUE) - { - gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_PLAYER_RETIRE; - } - else - { - gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_CONTINUE; - } - } - gTasks[taskId].data[0]++; - } - break; - case 3: - if (IsLinkTaskFinished() == TRUE) + } + break; + case 2: + if (GetBlockReceivedStatus() & 2) + { + if (GetMultiplayerId() == 0) { - if (GetMultiplayerId() != 0) + // Player is leader, read partner's choice + // and determine if play should continue + gSpecialVar_0x8005 = gBlockRecvBuffer[1][0]; + ResetBlockReceivedFlag(1); + + if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE + && gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE) { - gTasks[taskId].data[0]++; + gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_BOTH_RETIRE; } - else + else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_CONTINUE + && gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE) { - SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_Result, 2); - gTasks[taskId].data[0]++; + gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_MEMBER_RETIRE; } - } - break; - case 4: - if ((GetBlockReceivedStatus() & 1) != 0) - { - if (GetMultiplayerId() != 0) + else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE + && gSpecialVar_0x8005 == BATTLE_TOWER_LINK_CONTINUE) { - gSpecialVar_Result = gBlockRecvBuffer[0][0]; - ResetBlockReceivedFlag(0); - gTasks[taskId].data[0]++; + gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_LEADER_RETIRE; } else { - gTasks[taskId].data[0]++; + gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_CONTINUE; } } - break; - case 5: - if (GetMultiplayerId() == 0) + gTasks[taskId].tState++; + } + break; + case 3: + if (IsLinkTaskFinished() == TRUE) + { + if (GetMultiplayerId() != 0) { - if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_PARTNER_RETIRE) - { - ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired); - } + // Player is not link leader, wait for leader's response + gTasks[taskId].tState++; } else { - if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_PLAYER_RETIRE) - { - ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired); - } + // Send whether or not play should continue + SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_Result, sizeof(gSpecialVar_Result)); + gTasks[taskId].tState++; } - gTasks[taskId].data[0]++; - break; - case 6: - if (!IsTextPrinterActive(0)) - { - gTasks[taskId].data[0]++; - } - break; - case 7: - if (IsLinkTaskFinished() == 1) - { - SetLinkStandbyCallback(); - gTasks[taskId].data[0]++; - } - break; - case 8: - if (IsLinkTaskFinished() == 1) + } + break; + case 4: + if (GetBlockReceivedStatus() & 1) + { + if (GetMultiplayerId() != 0) { - gTasks[taskId].data[0]++; + // Player is not link leader, read leader's response + gSpecialVar_Result = gBlockRecvBuffer[0][0]; + ResetBlockReceivedFlag(0); + gTasks[taskId].tState++; } - break; - case 9: - if (gWirelessCommType == 0) + else { - SetCloseLinkCallback(); + gTasks[taskId].tState++; } - gBattleTypeFlags = sBattleTowerMultiBattleTypeFlags; - EnableBothScriptContexts(); - DestroyTask(taskId); - break; + } + break; + case 5: + // Print message if partner chose to retire (and player didn't) + if (GetMultiplayerId() == 0) + { + if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_MEMBER_RETIRE) + ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired); + } + else + { + if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_LEADER_RETIRE) + ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired); + } + gTasks[taskId].tState++; + break; + case 6: + if (!IsTextPrinterActive(0)) + gTasks[taskId].tState++; + break; + case 7: + if (IsLinkTaskFinished() == TRUE) + { + SetLinkStandbyCallback(); + gTasks[taskId].tState++; + } + break; + case 8: + if (IsLinkTaskFinished() == TRUE) + gTasks[taskId].tState++; + break; + case 9: + if (gWirelessCommType == 0) + SetCloseLinkCallback(); + + gBattleTypeFlags = sBattleTowerMultiBattleTypeFlags; + EnableBothScriptContexts(); + DestroyTask(taskId); + break; } } +#undef tState + void Script_DoRayquazaScene(void) { if (!gSpecialVar_0x8004) |