DoBattleIntro state documentation (#5231)
* DoBattleIntro state documentation * Removed unused state * Update src/battle_main.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Fixed state jumps * BattleStruct state uses enum * Renamed state enums --------- Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
parent
6ac18a6fe5
commit
77148f83a6
2 changed files with 71 additions and 50 deletions
|
@ -607,6 +607,30 @@ struct BattleVideo {
|
|||
};
|
||||
#endif
|
||||
|
||||
enum BattleIntroStates
|
||||
{
|
||||
BATTLE_INTRO_STATE_GET_MON_DATA,
|
||||
BATTLE_INTRO_STATE_LOOP_BATTLER_DATA,
|
||||
BATTLE_INTRO_STATE_PREPARE_BG_SLIDE,
|
||||
BATTLE_INTRO_STATE_WAIT_FOR_BG_SLIDE,
|
||||
BATTLE_INTRO_STATE_DRAW_SPRITES,
|
||||
BATTLE_INTRO_STATE_DRAW_PARTY_SUMMARY,
|
||||
BATTLE_INTRO_STATE_WAIT_FOR_PARTY_SUMMARY,
|
||||
BATTLE_INTRO_STATE_INTRO_TEXT,
|
||||
BATTLE_INTRO_STATE_WAIT_FOR_INTRO_TEXT,
|
||||
BATTLE_INTRO_STATE_TRAINER_SEND_OUT_TEXT,
|
||||
BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT,
|
||||
BATTLE_INTRO_STATE_TRAINER_1_SEND_OUT_ANIM,
|
||||
BATTLE_INTRO_STATE_TRAINER_2_SEND_OUT_ANIM,
|
||||
BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM,
|
||||
BATTLE_INTRO_STATE_WAIT_FOR_WILD_BATTLE_TEXT,
|
||||
BATTLE_INTRO_STATE_PRINT_PLAYER_SEND_OUT_TEXT,
|
||||
BATTLE_INTRO_STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT,
|
||||
BATTLE_INTRO_STATE_PRINT_PLAYER_1_SEND_OUT_TEXT,
|
||||
BATTLE_INTRO_STATE_PRINT_PLAYER_2_SEND_OUT_TEXT,
|
||||
BATTLE_INTRO_STATE_SET_DEX_AND_BATTLE_VARS
|
||||
};
|
||||
|
||||
struct BattleStruct
|
||||
{
|
||||
u8 turnEffectsTracker;
|
||||
|
@ -726,7 +750,7 @@ struct BattleStruct
|
|||
struct BattleGimmickData gimmick;
|
||||
const u8 *trainerSlideMsg;
|
||||
bool8 trainerSlideLowHpMsgDone;
|
||||
u8 introState;
|
||||
enum BattleIntroStates introState:8;
|
||||
u8 ateBerry[2]; // array id determined by side, each party pokemon as bit
|
||||
u8 stolenStats[NUM_BATTLE_STATS]; // hp byte is used for which stats to raise, other inform about by how many stages
|
||||
u8 lastMoveFailed; // as bits for each battler, for the sake of Stomping Tantrum
|
||||
|
|
|
@ -3425,26 +3425,25 @@ static void DoBattleIntro(void)
|
|||
{
|
||||
s32 i;
|
||||
u32 battler;
|
||||
u8 *state = &gBattleStruct->introState;
|
||||
|
||||
switch (*state)
|
||||
switch (gBattleStruct->introState)
|
||||
{
|
||||
case 0: // Get Data of all battlers.
|
||||
case BATTLE_INTRO_STATE_GET_MON_DATA:
|
||||
battler = gBattleCommunication[1];
|
||||
BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, 0);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 1: // Loop through all battlers.
|
||||
case BATTLE_INTRO_STATE_LOOP_BATTLER_DATA:
|
||||
if (!gBattleControllerExecFlags)
|
||||
{
|
||||
if (++gBattleCommunication[1] == gBattlersCount)
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
else
|
||||
*state = 0;
|
||||
gBattleStruct->introState = BATTLE_INTRO_STATE_GET_MON_DATA;
|
||||
}
|
||||
break;
|
||||
case 2: // Start graphical intro slide.
|
||||
case BATTLE_INTRO_STATE_PREPARE_BG_SLIDE:
|
||||
if (!gBattleControllerExecFlags)
|
||||
{
|
||||
battler = GetBattlerAtPosition(0);
|
||||
|
@ -3452,14 +3451,14 @@ static void DoBattleIntro(void)
|
|||
MarkBattlerForControllerExec(battler);
|
||||
gBattleCommunication[0] = 0;
|
||||
gBattleCommunication[1] = 0;
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
}
|
||||
break;
|
||||
case 3: // Wait for intro slide.
|
||||
case BATTLE_INTRO_STATE_WAIT_FOR_BG_SLIDE:
|
||||
if (!gBattleControllerExecFlags)
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 4: // Copy battler data gotten in cases 0 and 1. Draw trainer/mon sprite.
|
||||
case BATTLE_INTRO_STATE_DRAW_SPRITES:
|
||||
for (battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
|
@ -3539,17 +3538,17 @@ static void DoBattleIntro(void)
|
|||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||
{
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
}
|
||||
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.
|
||||
gBattleStruct->introState = BATTLE_INTRO_STATE_INTRO_TEXT; // Don't wait for sprite, print message at the same time.
|
||||
else
|
||||
*state = 6; // Wait for sprite to load.
|
||||
gBattleStruct->introState++; // Wait for sprite to load.
|
||||
}
|
||||
break;
|
||||
case 5: // draw party summary in trainer battles
|
||||
case BATTLE_INTRO_STATE_DRAW_PARTY_SUMMARY:
|
||||
if (!gBattleControllerExecFlags)
|
||||
{
|
||||
struct HpAndStatus hpStatus[PARTY_SIZE];
|
||||
|
@ -3592,48 +3591,48 @@ static void DoBattleIntro(void)
|
|||
BtlController_EmitDrawPartyStatusSummary(battler, BUFFER_A, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
}
|
||||
break;
|
||||
case 6: // wait for previous action to complete
|
||||
case BATTLE_INTRO_STATE_WAIT_FOR_PARTY_SUMMARY:
|
||||
if (!gBattleControllerExecFlags)
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 7: // print battle intro message
|
||||
case BATTLE_INTRO_STATE_INTRO_TEXT:
|
||||
if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)))
|
||||
{
|
||||
PrepareStringBattle(STRINGID_INTROMSG, GetBattlerAtPosition(B_POSITION_PLAYER_LEFT));
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
}
|
||||
break;
|
||||
case 8: // wait for intro message to be printed
|
||||
case BATTLE_INTRO_STATE_WAIT_FOR_INTRO_TEXT:
|
||||
if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)))
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||
{
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (B_FAST_INTRO == TRUE)
|
||||
*state = 15; // Wait for text to be printed.
|
||||
gBattleStruct->introState = BATTLE_INTRO_STATE_WAIT_FOR_WILD_BATTLE_TEXT;
|
||||
else
|
||||
*state = 14; // Wait for text and sprite.
|
||||
gBattleStruct->introState = BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 9: // print opponent sends out
|
||||
case BATTLE_INTRO_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)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 10: // wait for opponent sends out text
|
||||
case BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT:
|
||||
if (!gBattleControllerExecFlags)
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 11: // first opponent's mon send out animation
|
||||
case BATTLE_INTRO_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
|
||||
|
@ -3641,11 +3640,9 @@ static void DoBattleIntro(void)
|
|||
|
||||
BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 12: // nothing
|
||||
(*state)++;
|
||||
case 13: // second opponent's mon send out
|
||||
case BATTLE_INTRO_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))
|
||||
|
@ -3658,19 +3655,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.
|
||||
gBattleStruct->introState = BATTLE_INTRO_STATE_WAIT_FOR_WILD_BATTLE_TEXT; // Print at the same time as trainer sends out second mon.
|
||||
else
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 14: // wait for opponent 2 send out
|
||||
case BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM:
|
||||
if (!gBattleControllerExecFlags)
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 15: // wait for wild battle message
|
||||
case BATTLE_INTRO_STATE_WAIT_FOR_WILD_BATTLE_TEXT:
|
||||
if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)))
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 16: // print player sends out
|
||||
case BATTLE_INTRO_STATE_PRINT_PLAYER_SEND_OUT_TEXT:
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
|
||||
|
@ -3689,9 +3686,9 @@ static void DoBattleIntro(void)
|
|||
|
||||
PrepareStringBattle(STRINGID_INTROSENDOUT, battler);
|
||||
}
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 17: // wait for player send out message
|
||||
case BATTLE_INTRO_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))
|
||||
|
@ -3700,10 +3697,10 @@ static void DoBattleIntro(void)
|
|||
battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
|
||||
if (!IsBattlerMarkedForControllerExec(battler))
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
}
|
||||
break;
|
||||
case 18: // player 1 send out
|
||||
case BATTLE_INTRO_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
|
||||
|
@ -3711,9 +3708,9 @@ static void DoBattleIntro(void)
|
|||
|
||||
BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 19: // player 2 send out
|
||||
case BATTLE_INTRO_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))
|
||||
|
@ -3724,9 +3721,9 @@ static void DoBattleIntro(void)
|
|||
BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
}
|
||||
(*state)++;
|
||||
gBattleStruct->introState++;
|
||||
break;
|
||||
case 20: // set dex and battle vars
|
||||
case BATTLE_INTRO_STATE_SET_DEX_AND_BATTLE_VARS:
|
||||
if (!gBattleControllerExecFlags)
|
||||
{
|
||||
for (battler = 0; battler < gBattlersCount; battler++)
|
||||
|
|
Loading…
Reference in a new issue