Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DoBattleIntro state documentation #5231

Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 50 additions & 28 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3421,6 +3421,30 @@ const u8* FaintClearSetData(u32 battler)
return result;
}

enum BattleIntroStates
{
STATE_GET_MON_DATA,
STATE_LOOP_BATTLER_DATA,
STATE_PREPARE_BG_SLIDE,
STATE_WAIT_FOR_BG_SLIDE,
STATE_DRAW_SPRITES,
STATE_DRAW_PARTY_SUMMARY,
STATE_WAIT_FOR_PARTY_SUMMARY,
STATE_INTRO_TEXT,
STATE_WAIT_FOR_INTRO_TEXT,
STATE_TRAINER_SEND_OUT_TEXT,
STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT,
STATE_TRAINER_1_SEND_OUT_ANIM,
STATE_TRAINER_2_SEND_OUT_ANIM,
STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM,
STATE_WAIT_FOR_WILD_BATTLE_TEXT,
STATE_PRINT_PLAYER_SEND_OUT_TEXT,
STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT,
STATE_PRINT_PLAYER_1_SEND_OUT_TEXT,
STATE_PRINT_PLAYER_2_SEND_OUT_TEXT,
STATE_SET_DEX_AND_BATTLE_VARS
};

static void DoBattleIntro(void)
{
s32 i;
Expand All @@ -3429,22 +3453,22 @@ static void DoBattleIntro(void)

switch (*state)
{
case 0: // Get Data of all battlers.
case STATE_GET_MON_DATA:
battler = gBattleCommunication[1];
BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, 0);
MarkBattlerForControllerExec(battler);
(*state)++;
break;
case 1: // Loop through all battlers.
case STATE_LOOP_BATTLER_DATA:
if (!gBattleControllerExecFlags)
{
if (++gBattleCommunication[1] == gBattlersCount)
(*state)++;
else
*state = 0;
*state = STATE_GET_MON_DATA;
}
break;
case 2: // Start graphical intro slide.
case STATE_PREPARE_BG_SLIDE:
if (!gBattleControllerExecFlags)
{
battler = GetBattlerAtPosition(0);
Expand All @@ -3455,11 +3479,11 @@ static void DoBattleIntro(void)
(*state)++;
}
break;
case 3: // Wait for intro slide.
case STATE_WAIT_FOR_BG_SLIDE:
if (!gBattleControllerExecFlags)
(*state)++;
break;
case 4: // Copy battler data gotten in cases 0 and 1. Draw trainer/mon sprite.
case STATE_DRAW_SPRITES:
for (battler = 0; battler < gBattlersCount; battler++)
{
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && GetBattlerSide(battler) == B_SIDE_PLAYER)
Expand Down Expand Up @@ -3544,12 +3568,12 @@ static void DoBattleIntro(void)
else // Skip party summary since it is a wild battle.
{
if (B_FAST_INTRO == TRUE)
*state = 7; // Don't wait for sprite, print message at the same time.
*state = STATE_INTRO_TEXT; // Don't wait for sprite, print message at the same time.
else
*state = 6; // Wait for sprite to load.
*state = STATE_WAIT_FOR_PARTY_SUMMARY; // Wait for sprite to load.
}
break;
case 5: // draw party summary in trainer battles
case STATE_DRAW_PARTY_SUMMARY:
if (!gBattleControllerExecFlags)
{
struct HpAndStatus hpStatus[PARTY_SIZE];
Expand Down Expand Up @@ -3595,18 +3619,18 @@ static void DoBattleIntro(void)
(*state)++;
}
break;
case 6: // wait for previous action to complete
case STATE_WAIT_FOR_PARTY_SUMMARY:
if (!gBattleControllerExecFlags)
(*state)++;
break;
case 7: // print battle intro message
case STATE_INTRO_TEXT:
if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)))
{
PrepareStringBattle(STRINGID_INTROMSG, GetBattlerAtPosition(B_POSITION_PLAYER_LEFT));
(*state)++;
}
break;
case 8: // wait for intro message to be printed
case STATE_WAIT_FOR_INTRO_TEXT:
if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)))
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
Expand All @@ -3616,24 +3640,24 @@ static void DoBattleIntro(void)
else
{
if (B_FAST_INTRO == TRUE)
*state = 15; // Wait for text to be printed.
*state = STATE_WAIT_FOR_WILD_BATTLE_TEXT;
else
*state = 14; // Wait for text and sprite.
*state = STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM;
}
}
break;
case 9: // print opponent sends out
case STATE_TRAINER_SEND_OUT_TEXT:
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(B_POSITION_PLAYER_LEFT));
else
PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT));
(*state)++;
break;
case 10: // wait for opponent sends out text
case STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT:
if (!gBattleControllerExecFlags)
(*state)++;
break;
case 11: // first opponent's mon send out animation
case STATE_TRAINER_1_SEND_OUT_ANIM:
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
else
Expand All @@ -3643,9 +3667,7 @@ static void DoBattleIntro(void)
MarkBattlerForControllerExec(battler);
(*state)++;
break;
case 12: // nothing
(*state)++;
case 13: // second opponent's mon send out
case STATE_TRAINER_2_SEND_OUT_ANIM:
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT)
{
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
Expand All @@ -3658,19 +3680,19 @@ static void DoBattleIntro(void)
}
if (B_FAST_INTRO == TRUE
&& !(gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_RECORDED_IS_MASTER | BATTLE_TYPE_LINK)))
*state = 15; // Print at the same time as trainer sends out second mon.
*state = STATE_WAIT_FOR_WILD_BATTLE_TEXT; // Print at the same time as trainer sends out second mon.
else
(*state)++;
break;
case 14: // wait for opponent 2 send out
case STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM:
if (!gBattleControllerExecFlags)
(*state)++;
break;
case 15: // wait for wild battle message
case STATE_WAIT_FOR_WILD_BATTLE_TEXT:
if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)))
(*state)++;
break;
case 16: // print player sends out
case STATE_PRINT_PLAYER_SEND_OUT_TEXT:
if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
{
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
Expand All @@ -3691,7 +3713,7 @@ static void DoBattleIntro(void)
}
(*state)++;
break;
case 17: // wait for player send out message
case STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT:
if (!(gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleControllerExecFlags))
{
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
Expand All @@ -3703,7 +3725,7 @@ static void DoBattleIntro(void)
(*state)++;
}
break;
case 18: // player 1 send out
case STATE_PRINT_PLAYER_1_SEND_OUT_TEXT:
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
else
Expand All @@ -3713,7 +3735,7 @@ static void DoBattleIntro(void)
MarkBattlerForControllerExec(battler);
(*state)++;
break;
case 19: // player 2 send out
case STATE_PRINT_PLAYER_2_SEND_OUT_TEXT:
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER))
{
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
Expand All @@ -3726,7 +3748,7 @@ static void DoBattleIntro(void)
}
(*state)++;
break;
case 20: // set dex and battle vars
case STATE_SET_DEX_AND_BATTLE_VARS:
if (!gBattleControllerExecFlags)
{
for (battler = 0; battler < gBattlersCount; battler++)
Expand Down
Loading