Label battle tower link script

This commit is contained in:
GriffinR 2021-03-04 17:48:40 -05:00 committed by huderlem
parent 734a15135f
commit 55a40b901f
7 changed files with 139 additions and 128 deletions

View File

@ -143,7 +143,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_RestoreParty:: @ 8249121
special LoadPlayerParty
frontier_setpartyorder FRONTIER_MULTI_PARTY_SIZE
compare VAR_FRONTIER_BATTLE_MODE, FRONTIER_MODE_LINK_MULTIS
call_if_eq BattleFrontier_BattleTowerMultiBattleRoom_EventScript_249514
call_if_eq BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ReconnectLink
playfanfare MUS_HEAL
waitfanfare
special HealPlayerParty
@ -383,9 +383,8 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_RetireChallengeLink:: @ 82
goto BattleFrontier_BattleTowerMultiBattleRoom_EventScript_WarpToLobbyLost
end
@ Some link function. Sets battle type flags at least
BattleFrontier_BattleTowerMultiBattleRoom_EventScript_249514:: @ 8249514
special sub_813B534
BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ReconnectLink:: @ 8249514
special BattleTowerReconnectLink
return
BattleFrontier_BattleTowerMultiBattleRoom_Movement_PlayerEnterRoom: @ 8249518

View File

@ -514,7 +514,7 @@ gSpecials:: @ 81DBA64
def_special SetMewAboveGrass
def_special ShouldDistributeEonTicket
def_special LinkRetireStatusWithBattleTowerPartner
def_special sub_813B534
def_special BattleTowerReconnectLink
def_special CallTrainerHillFunction
def_special Script_DoRayquazaScene @ Listed twice
def_special LoopWingFlapSE

View File

@ -7,7 +7,7 @@ void CreateTask_EnterCableClubSeat(TaskFunc taskFunc);
u8 CreateTask_ReestablishCableClubLink(void);
void CB2_ReturnFromCableClubBattle(void);
bool32 AreBattleTowerLinkSpeciesSame(u16 *speciesList1, u16 *speciesList2);
void sub_80B3AF8(u8 taskId);
void Task_ReconnectWithLinkPlayers(u8 taskId);
void Task_WaitForLinkPlayerConnection(u8 taskId);
bool32 GetLinkTrainerCardColor(u8 linkPlayerIndex);

View File

@ -33,9 +33,9 @@
#define BATTLE_TOWER_LINK_CONTINUE 0
#define BATTLE_TOWER_LINK_RETIRE 1
#define BATTLE_TOWER_LINKSTAT_CONTINUE 0
#define BATTLE_TOWER_LINKSTAT_BOTH_RETIRE 1
#define BATTLE_TOWER_LINKSTAT_PARTNER_RETIRE 2
#define BATTLE_TOWER_LINKSTAT_PLAYER_RETIRE 3
#define BATTLE_TOWER_LINKSTAT_CONTINUE 0
#define BATTLE_TOWER_LINKSTAT_BOTH_RETIRE 1
#define BATTLE_TOWER_LINKSTAT_MEMBER_RETIRE 2
#define BATTLE_TOWER_LINKSTAT_LEADER_RETIRE 3
#endif //GUARD_CONSTANTS_BATTLE_TOWER_H

View File

@ -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:

View File

@ -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;

View File

@ -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))
{
gTasks[taskId].data[0]++;
}
break;
case 1:
if (IsLinkTaskFinished() == TRUE)
{
if (GetMultiplayerId() == 0)
{
gTasks[taskId].data[0]++;
}
else
{
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_0x8004, 2);
gTasks[taskId].data[0]++;
}
}
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)
{
if (GetMultiplayerId() != 0)
{
gTasks[taskId].data[0]++;
}
else
{
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_Result, 2);
gTasks[taskId].data[0]++;
}
}
break;
case 4:
if ((GetBlockReceivedStatus() & 1) != 0)
{
if (GetMultiplayerId() != 0)
{
gSpecialVar_Result = gBlockRecvBuffer[0][0];
ResetBlockReceivedFlag(0);
gTasks[taskId].data[0]++;
}
else
{
gTasks[taskId].data[0]++;
}
}
break;
case 5:
case 0:
if (!FuncIsActiveTask(Task_ReconnectWithLinkPlayers))
{
gTasks[taskId].tState++;
}
break;
case 1:
if (IsLinkTaskFinished() == TRUE)
{
if (GetMultiplayerId() == 0)
{
if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_PARTNER_RETIRE)
{
ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
}
// Player is link leader, skip sending data
gTasks[taskId].tState++;
}
else
{
if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_PLAYER_RETIRE)
// 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)
{
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)
{
ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
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_MEMBER_RETIRE;
}
else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_CONTINUE)
{
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_LEADER_RETIRE;
}
else
{
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_CONTINUE;
}
}
gTasks[taskId].data[0]++;
break;
case 6:
if (!IsTextPrinterActive(0))
gTasks[taskId].tState++;
}
break;
case 3:
if (IsLinkTaskFinished() == TRUE)
{
if (GetMultiplayerId() != 0)
{
gTasks[taskId].data[0]++;
// Player is not link leader, wait for leader's response
gTasks[taskId].tState++;
}
break;
case 7:
if (IsLinkTaskFinished() == 1)
else
{
SetLinkStandbyCallback();
gTasks[taskId].data[0]++;
// Send whether or not play should continue
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_Result, sizeof(gSpecialVar_Result));
gTasks[taskId].tState++;
}
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)