mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 03:04:15 +01:00
replace global usage of gActiveBattler in controller files
This commit is contained in:
parent
b8ba6139cb
commit
ce18df46e6
3
common_syms/battle_controllers.txt
Normal file
3
common_syms/battle_controllers.txt
Normal file
@ -0,0 +1,3 @@
|
||||
gBattlerControllerFuncs
|
||||
gBattleControllerData
|
||||
gBattlerControllerEndFuncs
|
@ -2,8 +2,6 @@ gPreBattleCallback1
|
||||
gBattleMainFunc
|
||||
gBattleResults
|
||||
gLeveledUpInBattle
|
||||
gBattlerControllerFuncs
|
||||
gHealthboxSpriteIds
|
||||
gMultiUsePlayerCursor
|
||||
gNumberOfMovesToChoose
|
||||
gBattleControllerData
|
||||
|
@ -1002,11 +1002,9 @@ extern void (*gPreBattleCallback1)(void);
|
||||
extern void (*gBattleMainFunc)(void);
|
||||
extern struct BattleResults gBattleResults;
|
||||
extern u8 gLeveledUpInBattle;
|
||||
extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
|
||||
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
|
||||
extern u8 gMultiUsePlayerCursor;
|
||||
extern u8 gNumberOfMovesToChoose;
|
||||
extern u8 gBattleControllerData[MAX_BATTLERS_COUNT];
|
||||
extern bool8 gHasFetchedBall;
|
||||
extern u8 gLastUsedBall;
|
||||
extern u16 gLastThrownBall;
|
||||
|
@ -197,7 +197,9 @@ enum
|
||||
};
|
||||
|
||||
extern struct UnusedControllerStruct gUnusedControllerStruct;
|
||||
extern void (*gBattlerControllerEndFuncs[MAX_BATTLERS_COUNT])(void);
|
||||
extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(u32 battler);
|
||||
extern void (*gBattlerControllerEndFuncs[MAX_BATTLERS_COUNT])(u32 battler);
|
||||
extern u8 gBattleControllerData[MAX_BATTLERS_COUNT];
|
||||
|
||||
// general functions
|
||||
void HandleLinkBattleSetup(void);
|
||||
@ -253,87 +255,87 @@ void BtlController_EmitEndLinkBattle(u8 bufferId, u8 battleOutcome);
|
||||
void BtlController_EmitDebugMenu(u8 bufferId);
|
||||
|
||||
void BattleControllerComplete(u32 battler); // Can be used for all the controllers.
|
||||
void BtlController_Empty(void); // Empty command, does nothing, only completes the execution.
|
||||
void BtlController_TerminatorNop(void); // Dummy function at the end of the table.
|
||||
void BtlController_Empty(u32 battler); // Empty command, does nothing, only completes the execution.
|
||||
void BtlController_TerminatorNop(u32 battler); // Dummy function at the end of the table.
|
||||
void BattleControllerDummy(u32 battler);
|
||||
void StartSendOutAnim(u32 battler, bool32 dontClearSubstituteBit);
|
||||
void Controller_WaitForString(void);
|
||||
void Controller_WaitForHealthBar(void);
|
||||
void Controller_WaitForString(u32 battler);
|
||||
void Controller_WaitForHealthBar(u32 battler);
|
||||
|
||||
// handlers
|
||||
void BtlController_HandleGetMonData(void);
|
||||
void BtlController_HandleGetRawMonData(void);
|
||||
void BtlController_HandleSetMonData(void);
|
||||
void BtlController_HandleSetRawMonData(void);
|
||||
void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void (*controllerCallback)(void));
|
||||
void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerCallback)(void));
|
||||
void BtlController_HandleReturnMonToBall(void);
|
||||
void BtlController_HandleGetMonData(u32 battler);
|
||||
void BtlController_HandleGetRawMonData(u32 battler);
|
||||
void BtlController_HandleSetMonData(u32 battler);
|
||||
void BtlController_HandleSetRawMonData(u32 battler);
|
||||
void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void (*controllerCallback)(u32 battler));
|
||||
void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerCallback)(u32 battler));
|
||||
void BtlController_HandleReturnMonToBall(u32 battler);
|
||||
void BtlController_HandleDrawTrainerPic(u32 battlerId, u32 trainerPicId, bool32 isFrontPic, s16 xPos, s16 yPos, s32 subpriority);
|
||||
void BtlController_HandleTrainerSlide(u32 battler, u32 trainerPicId);
|
||||
void BtlController_HandleTrainerSlideBack(u32 battlerId, s16 data0, bool32 startAnim);
|
||||
void BtlController_HandleFaintAnimation(void);
|
||||
void BtlController_HandleFaintAnimation(u32 battler);
|
||||
void BtlController_HandleSuccessBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture);
|
||||
void BtlController_HandleBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture);
|
||||
void BtlController_HandleMoveAnimation(u32 battler, bool32 updateTvData);
|
||||
void BtlController_HandlePrintString(u32 battler, bool32 updateTvData, bool32 arenaPtsDeduct);
|
||||
void BtlController_HandleHealthBarUpdate(u32 battler, bool32 updateHpText);
|
||||
void DoStatusIconUpdate(u32 battler);
|
||||
void BtlController_HandleStatusIconUpdate(void);
|
||||
void BtlController_HandleStatusAnimation(void);
|
||||
void BtlController_HandleClearUnkVar(void);
|
||||
void BtlController_HandleSetUnkVar(void);
|
||||
void BtlController_HandleClearUnkFlag(void);
|
||||
void BtlController_HandleToggleUnkFlag(void);
|
||||
void BtlController_HandleHitAnimation(void);
|
||||
void BtlController_HandlePlaySE(void);
|
||||
void BtlController_HandlePlayFanfareOrBGM(void);
|
||||
void BtlController_HandleFaintingCry(void);
|
||||
void BtlController_HandleIntroSlide(void);
|
||||
void BtlController_HandleSpriteInvisibility(void);
|
||||
void BtlController_HandleStatusIconUpdate(u32 battler);
|
||||
void BtlController_HandleStatusAnimation(u32 battler);
|
||||
void BtlController_HandleClearUnkVar(u32 battler);
|
||||
void BtlController_HandleSetUnkVar(u32 battler);
|
||||
void BtlController_HandleClearUnkFlag(u32 battler);
|
||||
void BtlController_HandleToggleUnkFlag(u32 battler);
|
||||
void BtlController_HandleHitAnimation(u32 battler);
|
||||
void BtlController_HandlePlaySE(u32 battler);
|
||||
void BtlController_HandlePlayFanfareOrBGM(u32 battler);
|
||||
void BtlController_HandleFaintingCry(u32 battler);
|
||||
void BtlController_HandleIntroSlide(u32 battler);
|
||||
void BtlController_HandleSpriteInvisibility(u32 battler);
|
||||
bool32 TwoPlayerIntroMons(u32 battlerId); // Double battle with both player pokemon active.
|
||||
bool32 TwoOpponentIntroMons(u32 battlerId); // Double battle with both opponent pokemon active.
|
||||
void BtlController_HandleIntroTrainerBallThrow(u32 battler, u16 tagTrainerPal, const u32 *trainerPal, s16 framesToWait, void (*controllerCallback)(void));
|
||||
void BtlController_HandleIntroTrainerBallThrow(u32 battler, u16 tagTrainerPal, const u32 *trainerPal, s16 framesToWait, void (*controllerCallback)(u32 battler));
|
||||
void BtlController_HandleDrawPartyStatusSummary(u32 battler, u32 side, bool32 considerDelay);
|
||||
void BtlController_HandleHidePartyStatusSummary(void);
|
||||
void BtlController_HandleHidePartyStatusSummary(u32 battler);
|
||||
void BtlController_HandleBattleAnimation(u32 battler, bool32 ignoreSE, bool32 updateTvData);
|
||||
|
||||
// player controller
|
||||
void SetControllerToPlayer(void);
|
||||
void BattleControllerDummy(void);
|
||||
void SetBattleEndCallbacks(void);
|
||||
void PlayerHandleExpUpdate(void);
|
||||
void SetControllerToPlayer(u32 battler);
|
||||
void SetBattleEndCallbacks(u32 battler);
|
||||
void PlayerHandleExpUpdate(u32 battler);
|
||||
u32 LinkPlayerGetTrainerPicId(u32 multiplayerId);
|
||||
void CB2_SetUpReshowBattleScreenAfterMenu(void);
|
||||
void CB2_SetUpReshowBattleScreenAfterMenu2(void);
|
||||
void Task_PlayerController_RestoreBgmAfterCry(u8 taskId);
|
||||
void ActionSelectionCreateCursorAt(u8 cursorPos, u8 unused);
|
||||
void ActionSelectionDestroyCursorAt(u8 cursorPos);
|
||||
void InitMoveSelectionsVarsAndStrings(void);
|
||||
void InitMoveSelectionsVarsAndStrings(u32 battler);
|
||||
void MoveSelectionCreateCursorAt(u8 cursorPos, u8 arg1);
|
||||
void MoveSelectionDestroyCursorAt(u8 cursorPosition);
|
||||
|
||||
// recorded player controller
|
||||
void SetControllerToRecordedPlayer(void);
|
||||
void SetControllerToRecordedPlayer(u32 battler);
|
||||
|
||||
// opponent controller
|
||||
void SetControllerToOpponent(void);
|
||||
void SetControllerToOpponent(u32 battler);
|
||||
|
||||
// player partner controller
|
||||
void Controller_PlayerPartnerShowIntroHealthbox(void); // Also used by the link partner.
|
||||
void SetControllerToPlayerPartner(void);
|
||||
void Controller_PlayerPartnerShowIntroHealthbox(u32 battler); // Also used by the link partner.
|
||||
void SetControllerToPlayerPartner(u32 battler);
|
||||
|
||||
// safari controller
|
||||
void SetControllerToSafari(void);
|
||||
void SetControllerToSafari(u32 battler);
|
||||
|
||||
// wally controller
|
||||
void SetControllerToWally(void);
|
||||
void SetControllerToWally(u32 battler);
|
||||
|
||||
// recorded opponent controller
|
||||
void SetControllerToRecordedOpponent(void);
|
||||
void SetControllerToRecordedOpponent(u32 battler);
|
||||
|
||||
// link opponent
|
||||
void SetControllerToLinkOpponent(void);
|
||||
void SetControllerToLinkOpponent(u32 battler);
|
||||
|
||||
// link partner
|
||||
void SetControllerToLinkPartner(void);
|
||||
void SetControllerToLinkPartner(u32 battler);
|
||||
|
||||
#endif // GUARD_BATTLE_CONTROLLERS_H
|
||||
|
@ -29,25 +29,25 @@
|
||||
#include "constants/trainers.h"
|
||||
#include "recorded_battle.h"
|
||||
|
||||
static void LinkOpponentHandleLoadMonSprite(void);
|
||||
static void LinkOpponentHandleSwitchInAnim(void);
|
||||
static void LinkOpponentHandleDrawTrainerPic(void);
|
||||
static void LinkOpponentHandleTrainerSlide(void);
|
||||
static void LinkOpponentHandleTrainerSlideBack(void);
|
||||
static void LinkOpponentHandleMoveAnimation(void);
|
||||
static void LinkOpponentHandlePrintString(void);
|
||||
static void LinkOpponentHandleHealthBarUpdate(void);
|
||||
static void LinkOpponentHandleIntroTrainerBallThrow(void);
|
||||
static void LinkOpponentHandleDrawPartyStatusSummary(void);
|
||||
static void LinkOpponentHandleBattleAnimation(void);
|
||||
static void LinkOpponentHandleLinkStandbyMsg(void);
|
||||
static void LinkOpponentHandleEndLinkBattle(void);
|
||||
static void LinkOpponentHandleLoadMonSprite(u32 battler);
|
||||
static void LinkOpponentHandleSwitchInAnim(u32 battler);
|
||||
static void LinkOpponentHandleDrawTrainerPic(u32 battler);
|
||||
static void LinkOpponentHandleTrainerSlide(u32 battler);
|
||||
static void LinkOpponentHandleTrainerSlideBack(u32 battler);
|
||||
static void LinkOpponentHandleMoveAnimation(u32 battler);
|
||||
static void LinkOpponentHandlePrintString(u32 battler);
|
||||
static void LinkOpponentHandleHealthBarUpdate(u32 battler);
|
||||
static void LinkOpponentHandleIntroTrainerBallThrow(u32 battler);
|
||||
static void LinkOpponentHandleDrawPartyStatusSummary(u32 battler);
|
||||
static void LinkOpponentHandleBattleAnimation(u32 battler);
|
||||
static void LinkOpponentHandleLinkStandbyMsg(u32 battler);
|
||||
static void LinkOpponentHandleEndLinkBattle(u32 battler);
|
||||
|
||||
static void LinkOpponentBufferRunCommand(void);
|
||||
static void LinkOpponentBufferExecCompleted(void);
|
||||
static void SwitchIn_HandleSoundAndEnd(void);
|
||||
static void LinkOpponentBufferRunCommand(u32 battler);
|
||||
static void LinkOpponentBufferExecCompleted(u32 battler);
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler);
|
||||
|
||||
static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
|
||||
{
|
||||
[CONTROLLER_GETMONDATA] = BtlController_HandleGetMonData,
|
||||
[CONTROLLER_GETRAWMONDATA] = BtlController_Empty,
|
||||
@ -109,46 +109,46 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
|
||||
};
|
||||
|
||||
void SetControllerToLinkOpponent(void)
|
||||
void SetControllerToLinkOpponent(u32 battler)
|
||||
{
|
||||
gBattlerControllerEndFuncs[gActiveBattler] = LinkOpponentBufferExecCompleted;
|
||||
gBattlerControllerFuncs[gActiveBattler] = LinkOpponentBufferRunCommand;
|
||||
gBattlerControllerEndFuncs[battler] = LinkOpponentBufferExecCompleted;
|
||||
gBattlerControllerFuncs[battler] = LinkOpponentBufferRunCommand;
|
||||
}
|
||||
|
||||
static void LinkOpponentBufferRunCommand(void)
|
||||
static void LinkOpponentBufferRunCommand(u32 battler)
|
||||
{
|
||||
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
||||
if (gBattleControllerExecFlags & gBitTable[battler])
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkOpponentBufferCommands))
|
||||
sLinkOpponentBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
|
||||
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sLinkOpponentBufferCommands))
|
||||
sLinkOpponentBufferCommands[gBattleResources->bufferA[battler][0]](battler);
|
||||
else
|
||||
LinkOpponentBufferExecCompleted();
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_DelayAndEnd(void)
|
||||
static void Intro_DelayAndEnd(u32 battler)
|
||||
{
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay == (u8)-1)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
|
||||
LinkOpponentBufferExecCompleted();
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 0;
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(void)
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
|
||||
{
|
||||
bool32 healthboxAnimDone = FALSE;
|
||||
bool32 twoMons = FALSE;
|
||||
|
||||
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
healthboxAnimDone = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
healthboxAnimDone = TRUE;
|
||||
}
|
||||
@ -157,87 +157,87 @@ static void Intro_WaitForShinyAnimAndHealthbox(void)
|
||||
|
||||
if (healthboxAnimDone)
|
||||
{
|
||||
if (twoMons || !IsBattlerSpriteVisible(BATTLE_PARTNER(gActiveBattler)))
|
||||
if (twoMons || !IsBattlerSpriteVisible(BATTLE_PARTNER(battler)))
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
return;
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim)
|
||||
return;
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
return;
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT)
|
||||
if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT)
|
||||
{
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
}
|
||||
}
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[battler] = Intro_DelayAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
static void Intro_TryShinyAnimShowHealthbox(u32 battler)
|
||||
{
|
||||
bool32 bgmRestored = FALSE;
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
TryShinyAnimation(battler, &gEnemyParty[gBattlerPartyIndexes[battler]]);
|
||||
}
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim)
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim)
|
||||
{
|
||||
TryShinyAnimation(BATTLE_PARTNER(gActiveBattler), &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
TryShinyAnimation(BATTLE_PARTNER(battler), &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]);
|
||||
}
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted)
|
||||
{
|
||||
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
{
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(battler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(battler)]);
|
||||
}
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted = TRUE;
|
||||
}
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].waitForCry
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].waitForCry
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].waitForCry
|
||||
&& !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT)
|
||||
if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_LEFT)
|
||||
m4aMPlayContinue(&gMPlayInfo_BGM);
|
||||
}
|
||||
else
|
||||
@ -246,189 +246,189 @@ static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
}
|
||||
}
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored = TRUE;
|
||||
bgmRestored = TRUE;
|
||||
}
|
||||
|
||||
if (bgmRestored)
|
||||
{
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT)
|
||||
{
|
||||
if (++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == 1)
|
||||
if (++gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay == 1)
|
||||
return;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 0;
|
||||
}
|
||||
|
||||
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
SetBattlerShadowSpriteCallback(BATTLE_PARTNER(gActiveBattler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], MON_DATA_SPECIES));
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(battler)]]);
|
||||
SetBattlerShadowSpriteCallback(BATTLE_PARTNER(battler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], MON_DATA_SPECIES));
|
||||
}
|
||||
|
||||
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES));
|
||||
|
||||
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted = FALSE;
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
gBattlerControllerFuncs[battler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void TryShinyAnimAfterMonAnim(void)
|
||||
static void TryShinyAnimAfterMonAnim(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].x2 == 0)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
{
|
||||
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
TryShinyAnimation(battler, &gEnemyParty[gBattlerPartyIndexes[battler]]);
|
||||
}
|
||||
else if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
else if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
LinkOpponentBufferExecCompleted();
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowSubstitute(void)
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd;
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_HandleSoundAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_HandleSoundAndEnd(void)
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy_2)
|
||||
{
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
LinkOpponentBufferExecCompleted();
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(void)
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
CopyBattleSpriteInvisibility(gActiveBattler);
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(void)
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
{
|
||||
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
TryShinyAnimation(battler, &gEnemyParty[gBattlerPartyIndexes[battler]]);
|
||||
}
|
||||
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES));
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void LinkOpponentBufferExecCompleted(void)
|
||||
static void LinkOpponentBufferExecCompleted(u32 battler)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = LinkOpponentBufferRunCommand;
|
||||
gBattlerControllerFuncs[battler] = LinkOpponentBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
||||
gBattleControllerExecFlags &= ~gBitTable[battler];
|
||||
}
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleLoadMonSprite(void)
|
||||
static void LinkOpponentHandleLoadMonSprite(u32 battler)
|
||||
{
|
||||
BtlController_HandleLoadMonSprite(gActiveBattler, gEnemyParty, TryShinyAnimAfterMonAnim);
|
||||
BtlController_HandleLoadMonSprite(battler, gEnemyParty, TryShinyAnimAfterMonAnim);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleSwitchInAnim(void)
|
||||
static void LinkOpponentHandleSwitchInAnim(u32 battler)
|
||||
{
|
||||
BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim);
|
||||
BtlController_HandleSwitchInAnim(battler, FALSE, SwitchIn_TryShinyAnim);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleDrawTrainerPic(void)
|
||||
static void LinkOpponentHandleDrawTrainerPic(u32 battler)
|
||||
{
|
||||
s16 xPos;
|
||||
u32 trainerPicId;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
{
|
||||
if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon
|
||||
if ((GetBattlerPosition(battler) & BIT_FLANK) != 0) // second mon
|
||||
xPos = 152;
|
||||
else // first mon
|
||||
xPos = 200;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER)
|
||||
{
|
||||
if (gActiveBattler == B_POSITION_OPPONENT_LEFT)
|
||||
if (battler == B_POSITION_OPPONENT_LEFT)
|
||||
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
|
||||
else
|
||||
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED
|
||||
|| (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN)
|
||||
if ((gLinkPlayers[GetBattlerMultiplayerId(battler)].version & 0xFF) == VERSION_FIRE_RED
|
||||
|| (gLinkPlayers[GetBattlerMultiplayerId(battler)].version & 0xFF) == VERSION_LEAF_GREEN)
|
||||
{
|
||||
if (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender != MALE)
|
||||
if (gLinkPlayers[GetBattlerMultiplayerId(battler)].gender != MALE)
|
||||
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_LEAF];
|
||||
else
|
||||
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_RED];
|
||||
}
|
||||
else if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY
|
||||
|| (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE)
|
||||
else if ((gLinkPlayers[GetBattlerMultiplayerId(battler)].version & 0xFF) == VERSION_RUBY
|
||||
|| (gLinkPlayers[GetBattlerMultiplayerId(battler)].version & 0xFF) == VERSION_SAPPHIRE)
|
||||
{
|
||||
if (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender != MALE)
|
||||
if (gLinkPlayers[GetBattlerMultiplayerId(battler)].gender != MALE)
|
||||
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_RS_MAY];
|
||||
else
|
||||
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_RS_BRENDAN];
|
||||
}
|
||||
else
|
||||
{
|
||||
trainerPicId = PlayerGenderToFrontTrainerPicId(gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender);
|
||||
trainerPicId = PlayerGenderToFrontTrainerPicId(gLinkPlayers[GetBattlerMultiplayerId(battler)].gender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -461,77 +461,77 @@ static void LinkOpponentHandleDrawTrainerPic(void)
|
||||
}
|
||||
}
|
||||
|
||||
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, TRUE,
|
||||
BtlController_HandleDrawTrainerPic(battler, trainerPicId, TRUE,
|
||||
xPos, 40 + 4 * (8 - gTrainerFrontPicCoords[trainerPicId].size),
|
||||
-1);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleTrainerSlide(void)
|
||||
static void LinkOpponentHandleTrainerSlide(u32 battler)
|
||||
{
|
||||
u32 trainerPicId;
|
||||
|
||||
if (gActiveBattler == 1)
|
||||
if (battler == B_POSITION_OPPONENT_LEFT)
|
||||
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
|
||||
else
|
||||
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B);
|
||||
|
||||
BtlController_HandleTrainerSlide(gActiveBattler, trainerPicId);
|
||||
LinkOpponentBufferExecCompleted(); // Possibly a bug, because execution should be completed after the slide in finishes. See Controller_WaitForTrainerPic.
|
||||
BtlController_HandleTrainerSlide(battler, trainerPicId);
|
||||
LinkOpponentBufferExecCompleted(battler); // Possibly a bug, because execution should be completed after the slide in finishes. See Controller_WaitForTrainerPic.
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleTrainerSlideBack(void)
|
||||
static void LinkOpponentHandleTrainerSlideBack(u32 battler)
|
||||
{
|
||||
BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
|
||||
BtlController_HandleTrainerSlideBack(battler, 35, FALSE);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleMoveAnimation(void)
|
||||
static void LinkOpponentHandleMoveAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleMoveAnimation(gActiveBattler, TRUE);
|
||||
BtlController_HandleMoveAnimation(battler, TRUE);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandlePrintString(void)
|
||||
static void LinkOpponentHandlePrintString(u32 battler)
|
||||
{
|
||||
BtlController_HandlePrintString(gActiveBattler, TRUE, FALSE);
|
||||
BtlController_HandlePrintString(battler, TRUE, FALSE);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleHealthBarUpdate(void)
|
||||
static void LinkOpponentHandleHealthBarUpdate(u32 battler)
|
||||
{
|
||||
BtlController_HandleHealthBarUpdate(gActiveBattler, FALSE);
|
||||
BtlController_HandleHealthBarUpdate(battler, FALSE);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleIntroTrainerBallThrow(void)
|
||||
static void LinkOpponentHandleIntroTrainerBallThrow(u32 battler)
|
||||
{
|
||||
BtlController_HandleIntroTrainerBallThrow(gActiveBattler, 0, NULL, 0, Intro_TryShinyAnimShowHealthbox);
|
||||
BtlController_HandleIntroTrainerBallThrow(battler, 0, NULL, 0, Intro_TryShinyAnimShowHealthbox);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleDrawPartyStatusSummary(void)
|
||||
static void LinkOpponentHandleDrawPartyStatusSummary(u32 battler)
|
||||
{
|
||||
BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_OPPONENT, TRUE);
|
||||
BtlController_HandleDrawPartyStatusSummary(battler, B_SIDE_OPPONENT, TRUE);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleBattleAnimation(void)
|
||||
static void LinkOpponentHandleBattleAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleBattleAnimation(gActiveBattler, FALSE, TRUE);
|
||||
BtlController_HandleBattleAnimation(battler, FALSE, TRUE);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleLinkStandbyMsg(void)
|
||||
static void LinkOpponentHandleLinkStandbyMsg(u32 battler)
|
||||
{
|
||||
RecordedBattle_RecordAllBattlerData(&gBattleResources->bufferA[gActiveBattler][2]);
|
||||
LinkOpponentBufferExecCompleted();
|
||||
RecordedBattle_RecordAllBattlerData(&gBattleResources->bufferA[battler][2]);
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleEndLinkBattle(void)
|
||||
static void LinkOpponentHandleEndLinkBattle(u32 battler)
|
||||
{
|
||||
RecordedBattle_RecordAllBattlerData(&gBattleResources->bufferA[gActiveBattler][4]);
|
||||
RecordedBattle_RecordAllBattlerData(&gBattleResources->bufferA[battler][4]);
|
||||
|
||||
if (gBattleResources->bufferA[gActiveBattler][1] == B_OUTCOME_DREW)
|
||||
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1];
|
||||
if (gBattleResources->bufferA[battler][1] == B_OUTCOME_DREW)
|
||||
gBattleOutcome = gBattleResources->bufferA[battler][1];
|
||||
else
|
||||
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1] ^ B_OUTCOME_DREW;
|
||||
gBattleOutcome = gBattleResources->bufferA[battler][1] ^ B_OUTCOME_DREW;
|
||||
|
||||
gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleResources->bufferA[gActiveBattler][2];
|
||||
gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleResources->bufferA[battler][2];
|
||||
FadeOutMapMusic(5);
|
||||
BeginFastPaletteFade(3);
|
||||
LinkOpponentBufferExecCompleted();
|
||||
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
gBattlerControllerFuncs[battler] = SetBattleEndCallbacks;
|
||||
}
|
||||
|
@ -29,24 +29,24 @@
|
||||
#include "constants/trainers.h"
|
||||
#include "recorded_battle.h"
|
||||
|
||||
static void LinkPartnerHandleLoadMonSprite(void);
|
||||
static void LinkPartnerHandleSwitchInAnim(void);
|
||||
static void LinkPartnerHandleDrawTrainerPic(void);
|
||||
static void LinkPartnerHandleTrainerSlideBack(void);
|
||||
static void LinkPartnerHandleMoveAnimation(void);
|
||||
static void LinkPartnerHandlePrintString(void);
|
||||
static void LinkPartnerHandleHealthBarUpdate(void);
|
||||
static void LinkPartnerHandleIntroTrainerBallThrow(void);
|
||||
static void LinkPartnerHandleDrawPartyStatusSummary(void);
|
||||
static void LinkPartnerHandleBattleAnimation(void);
|
||||
static void LinkPartnerHandleLinkStandbyMsg(void);
|
||||
static void LinkPartnerHandleEndLinkBattle(void);
|
||||
static void LinkPartnerHandleLoadMonSprite(u32 battler);
|
||||
static void LinkPartnerHandleSwitchInAnim(u32 battler);
|
||||
static void LinkPartnerHandleDrawTrainerPic(u32 battler);
|
||||
static void LinkPartnerHandleTrainerSlideBack(u32 battler);
|
||||
static void LinkPartnerHandleMoveAnimation(u32 battler);
|
||||
static void LinkPartnerHandlePrintString(u32 battler);
|
||||
static void LinkPartnerHandleHealthBarUpdate(u32 battler);
|
||||
static void LinkPartnerHandleIntroTrainerBallThrow(u32 battler);
|
||||
static void LinkPartnerHandleDrawPartyStatusSummary(u32 battler);
|
||||
static void LinkPartnerHandleBattleAnimation(u32 battler);
|
||||
static void LinkPartnerHandleLinkStandbyMsg(u32 battler);
|
||||
static void LinkPartnerHandleEndLinkBattle(u32 battler);
|
||||
|
||||
static void LinkPartnerBufferRunCommand(void);
|
||||
static void LinkPartnerBufferExecCompleted(void);
|
||||
static void SwitchIn_WaitAndEnd(void);
|
||||
static void LinkPartnerBufferRunCommand(u32 battler);
|
||||
static void LinkPartnerBufferExecCompleted(u32 battler);
|
||||
static void SwitchIn_WaitAndEnd(u32 battler);
|
||||
|
||||
static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
|
||||
{
|
||||
[CONTROLLER_GETMONDATA] = BtlController_HandleGetMonData,
|
||||
[CONTROLLER_GETRAWMONDATA] = BtlController_Empty,
|
||||
@ -108,121 +108,121 @@ static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
|
||||
};
|
||||
|
||||
void SetControllerToLinkPartner(void)
|
||||
void SetControllerToLinkPartner(u32 battler)
|
||||
{
|
||||
gBattlerControllerEndFuncs[gActiveBattler] = LinkPartnerBufferExecCompleted;
|
||||
gBattlerControllerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand;
|
||||
gBattlerControllerEndFuncs[battler] = LinkPartnerBufferExecCompleted;
|
||||
gBattlerControllerFuncs[battler] = LinkPartnerBufferRunCommand;
|
||||
}
|
||||
|
||||
static void LinkPartnerBufferRunCommand(void)
|
||||
static void LinkPartnerBufferRunCommand(u32 battler)
|
||||
{
|
||||
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
||||
if (gBattleControllerExecFlags & gBitTable[battler])
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkPartnerBufferCommands))
|
||||
sLinkPartnerBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
|
||||
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sLinkPartnerBufferCommands))
|
||||
sLinkPartnerBufferCommands[gBattleResources->bufferA[battler][0]](battler);
|
||||
else
|
||||
LinkPartnerBufferExecCompleted();
|
||||
LinkPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void WaitForMonAnimAfterLoad(void)
|
||||
static void WaitForMonAnimAfterLoad(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
|
||||
LinkPartnerBufferExecCompleted();
|
||||
if (gSprites[gBattlerSpriteIds[battler]].animEnded && gSprites[gBattlerSpriteIds[battler]].x2 == 0)
|
||||
LinkPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowSubstitute(void)
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
CopyBattleSpriteInvisibility(gActiveBattler);
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_WaitAndEnd;
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_WaitAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_WaitAndEnd(void)
|
||||
static void SwitchIn_WaitAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
LinkPartnerBufferExecCompleted();
|
||||
LinkPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(void)
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(void)
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
TryShinyAnimation(battler, &gPlayerParty[gBattlerPartyIndexes[battler]]);
|
||||
}
|
||||
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void LinkPartnerBufferExecCompleted(void)
|
||||
static void LinkPartnerBufferExecCompleted(u32 battler)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand;
|
||||
gBattlerControllerFuncs[battler] = LinkPartnerBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
||||
gBattleControllerExecFlags &= ~gBitTable[battler];
|
||||
}
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleLoadMonSprite(void)
|
||||
static void LinkPartnerHandleLoadMonSprite(u32 battler)
|
||||
{
|
||||
BtlController_HandleLoadMonSprite(gActiveBattler, gPlayerParty, WaitForMonAnimAfterLoad);
|
||||
BtlController_HandleLoadMonSprite(battler, gPlayerParty, WaitForMonAnimAfterLoad);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleSwitchInAnim(void)
|
||||
static void LinkPartnerHandleSwitchInAnim(u32 battler)
|
||||
{
|
||||
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
|
||||
BtlController_HandleSwitchInAnim(battler, TRUE, SwitchIn_TryShinyAnim);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleDrawTrainerPic(void)
|
||||
static void LinkPartnerHandleDrawTrainerPic(u32 battler)
|
||||
{
|
||||
s16 xPos;
|
||||
u32 trainerPicId;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
{
|
||||
if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon
|
||||
if ((GetBattlerPosition(battler) & BIT_FLANK) != 0) // second mon
|
||||
xPos = 90;
|
||||
else // first mon
|
||||
xPos = 32;
|
||||
@ -232,76 +232,63 @@ static void LinkPartnerHandleDrawTrainerPic(void)
|
||||
xPos = 80;
|
||||
}
|
||||
|
||||
trainerPicId = LinkPlayerGetTrainerPicId(GetBattlerMultiplayerId(gActiveBattler));
|
||||
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, FALSE,
|
||||
trainerPicId = LinkPlayerGetTrainerPicId(GetBattlerMultiplayerId(battler));
|
||||
BtlController_HandleDrawTrainerPic(battler, trainerPicId, FALSE,
|
||||
xPos, 80 + 4 * (8 - gTrainerBackPicCoords[trainerPicId].size),
|
||||
-1);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleTrainerSlideBack(void)
|
||||
static void LinkPartnerHandleTrainerSlideBack(u32 battler)
|
||||
{
|
||||
BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
|
||||
BtlController_HandleTrainerSlideBack(battler, 35, FALSE);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleMoveAnimation(void)
|
||||
static void LinkPartnerHandleMoveAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleMoveAnimation(gActiveBattler, TRUE);
|
||||
BtlController_HandleMoveAnimation(battler, TRUE);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandlePrintString(void)
|
||||
static void LinkPartnerHandlePrintString(u32 battler)
|
||||
{
|
||||
BtlController_HandlePrintString(gActiveBattler, TRUE, FALSE);
|
||||
BtlController_HandlePrintString(battler, TRUE, FALSE);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleHealthBarUpdate(void)
|
||||
static void LinkPartnerHandleHealthBarUpdate(u32 battler)
|
||||
{
|
||||
BtlController_HandleHealthBarUpdate(gActiveBattler, FALSE);
|
||||
BtlController_HandleHealthBarUpdate(battler, FALSE);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleIntroTrainerBallThrow(void)
|
||||
static void LinkPartnerHandleIntroTrainerBallThrow(u32 battler)
|
||||
{
|
||||
u32 trainerPicId;
|
||||
u8 gameVersion, playerGender;
|
||||
const u32 *trainerPal;
|
||||
|
||||
gameVersion = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF;
|
||||
playerGender = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender;
|
||||
|
||||
if (gameVersion == VERSION_FIRE_RED || gameVersion == VERSION_LEAF_GREEN)
|
||||
trainerPicId = playerGender + TRAINER_BACK_PIC_RED;
|
||||
else if (gameVersion == VERSION_RUBY || gameVersion == VERSION_SAPPHIRE)
|
||||
trainerPicId = playerGender + TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN;
|
||||
else
|
||||
trainerPicId = playerGender + TRAINER_BACK_PIC_BRENDAN;
|
||||
|
||||
trainerPal = gTrainerBackPicPaletteTable[trainerPicId].data;
|
||||
u32 trainerPicId = LinkPlayerGetTrainerPicId(GetBattlerMultiplayerId(battler));
|
||||
const u32 *trainerPal = gTrainerBackPicPaletteTable[trainerPicId].data;
|
||||
// Link partner uses the same intro sequence as the player partner.
|
||||
BtlController_HandleIntroTrainerBallThrow(gActiveBattler, 0xD6F9, trainerPal, 24, Controller_PlayerPartnerShowIntroHealthbox);
|
||||
BtlController_HandleIntroTrainerBallThrow(battler, 0xD6F9, trainerPal, 24, Controller_PlayerPartnerShowIntroHealthbox);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleDrawPartyStatusSummary(void)
|
||||
static void LinkPartnerHandleDrawPartyStatusSummary(u32 battler)
|
||||
{
|
||||
BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_PLAYER, TRUE);
|
||||
BtlController_HandleDrawPartyStatusSummary(battler, B_SIDE_PLAYER, TRUE);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleBattleAnimation(void)
|
||||
static void LinkPartnerHandleBattleAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleBattleAnimation(gActiveBattler, FALSE, TRUE);
|
||||
BtlController_HandleBattleAnimation(battler, FALSE, TRUE);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleLinkStandbyMsg(void)
|
||||
static void LinkPartnerHandleLinkStandbyMsg(u32 battler)
|
||||
{
|
||||
RecordedBattle_RecordAllBattlerData(&gBattleResources->bufferA[gActiveBattler][2]);
|
||||
LinkPartnerBufferExecCompleted();
|
||||
RecordedBattle_RecordAllBattlerData(&gBattleResources->bufferA[battler][2]);
|
||||
LinkPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleEndLinkBattle(void)
|
||||
static void LinkPartnerHandleEndLinkBattle(u32 battler)
|
||||
{
|
||||
RecordedBattle_RecordAllBattlerData(&gBattleResources->bufferA[gActiveBattler][4]);
|
||||
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1];
|
||||
gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleResources->bufferA[gActiveBattler][2];
|
||||
RecordedBattle_RecordAllBattlerData(&gBattleResources->bufferA[battler][4]);
|
||||
gBattleOutcome = gBattleResources->bufferA[battler][1];
|
||||
gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleResources->bufferA[battler][2];
|
||||
FadeOutMapMusic(5);
|
||||
BeginFastPaletteFade(3);
|
||||
LinkPartnerBufferExecCompleted();
|
||||
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
|
||||
LinkPartnerBufferExecCompleted(battler);
|
||||
gBattlerControllerFuncs[battler] = SetBattleEndCallbacks;
|
||||
}
|
||||
|
@ -39,29 +39,29 @@
|
||||
#include "constants/trainers.h"
|
||||
#include "trainer_hill.h"
|
||||
|
||||
static void OpponentHandleLoadMonSprite(void);
|
||||
static void OpponentHandleSwitchInAnim(void);
|
||||
static void OpponentHandleDrawTrainerPic(void);
|
||||
static void OpponentHandleTrainerSlide(void);
|
||||
static void OpponentHandleTrainerSlideBack(void);
|
||||
static void OpponentHandleMoveAnimation(void);
|
||||
static void OpponentHandlePrintString(void);
|
||||
static void OpponentHandleChooseAction(void);
|
||||
static void OpponentHandleChooseMove(void);
|
||||
static void OpponentHandleChooseItem(void);
|
||||
static void OpponentHandleChoosePokemon(void);
|
||||
static void OpponentHandleHealthBarUpdate(void);
|
||||
static void OpponentHandleIntroTrainerBallThrow(void);
|
||||
static void OpponentHandleDrawPartyStatusSummary(void);
|
||||
static void OpponentHandleBattleAnimation(void);
|
||||
static void OpponentHandleEndLinkBattle(void);
|
||||
static void OpponentHandleLoadMonSprite(u32 battler);
|
||||
static void OpponentHandleSwitchInAnim(u32 battler);
|
||||
static void OpponentHandleDrawTrainerPic(u32 battler);
|
||||
static void OpponentHandleTrainerSlide(u32 battler);
|
||||
static void OpponentHandleTrainerSlideBack(u32 battler);
|
||||
static void OpponentHandleMoveAnimation(u32 battler);
|
||||
static void OpponentHandlePrintString(u32 battler);
|
||||
static void OpponentHandleChooseAction(u32 battler);
|
||||
static void OpponentHandleChooseMove(u32 battler);
|
||||
static void OpponentHandleChooseItem(u32 battler);
|
||||
static void OpponentHandleChoosePokemon(u32 battler);
|
||||
static void OpponentHandleHealthBarUpdate(u32 battler);
|
||||
static void OpponentHandleIntroTrainerBallThrow(u32 battler);
|
||||
static void OpponentHandleDrawPartyStatusSummary(u32 battler);
|
||||
static void OpponentHandleBattleAnimation(u32 battler);
|
||||
static void OpponentHandleEndLinkBattle(u32 battler);
|
||||
static u8 CountAIAliveNonEggMonsExcept(u8 slotToIgnore);
|
||||
|
||||
static void OpponentBufferRunCommand(void);
|
||||
static void OpponentBufferExecCompleted(void);
|
||||
static void SwitchIn_HandleSoundAndEnd(void);
|
||||
static void OpponentBufferRunCommand(u32 battler);
|
||||
static void OpponentBufferExecCompleted(u32 battler);
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler);
|
||||
|
||||
static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
|
||||
{
|
||||
[CONTROLLER_GETMONDATA] = BtlController_HandleGetMonData,
|
||||
[CONTROLLER_GETRAWMONDATA] = BtlController_HandleGetRawMonData,
|
||||
@ -123,78 +123,78 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
|
||||
};
|
||||
|
||||
void SetControllerToOpponent(void)
|
||||
void SetControllerToOpponent(u32 battler)
|
||||
{
|
||||
gBattlerControllerEndFuncs[gActiveBattler] = OpponentBufferExecCompleted;
|
||||
gBattlerControllerFuncs[gActiveBattler] = OpponentBufferRunCommand;
|
||||
gBattlerControllerEndFuncs[battler] = OpponentBufferExecCompleted;
|
||||
gBattlerControllerFuncs[battler] = OpponentBufferRunCommand;
|
||||
}
|
||||
|
||||
static void OpponentBufferRunCommand(void)
|
||||
static void OpponentBufferRunCommand(u32 battler)
|
||||
{
|
||||
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
||||
if (gBattleControllerExecFlags & gBitTable[battler])
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sOpponentBufferCommands))
|
||||
sOpponentBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
|
||||
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sOpponentBufferCommands))
|
||||
sOpponentBufferCommands[gBattleResources->bufferA[battler][0]](battler);
|
||||
else
|
||||
OpponentBufferExecCompleted();
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_DelayAndEnd(void)
|
||||
static void Intro_DelayAndEnd(u32 battler)
|
||||
{
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay == (u8)-1)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
|
||||
OpponentBufferExecCompleted();
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 0;
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(void)
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
|
||||
{
|
||||
bool8 healthboxAnimDone = FALSE;
|
||||
bool8 twoMons;
|
||||
|
||||
twoMons = TwoOpponentIntroMons(gActiveBattler);
|
||||
twoMons = TwoOpponentIntroMons(battler);
|
||||
if (!twoMons || ((twoMons && (gBattleTypeFlags & BATTLE_TYPE_MULTI) && !BATTLE_TWO_VS_ONE_OPPONENT) || (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)))
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
healthboxAnimDone = TRUE;
|
||||
twoMons = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy)
|
||||
healthboxAnimDone = TRUE;
|
||||
twoMons = TRUE;
|
||||
}
|
||||
|
||||
gBattleControllerOpponentHealthboxData = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler];
|
||||
gBattleControllerOpponentFlankHealthboxData = &gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)];
|
||||
gBattleControllerOpponentHealthboxData = &gBattleSpritesDataPtr->healthBoxesData[battler];
|
||||
gBattleControllerOpponentFlankHealthboxData = &gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)];
|
||||
|
||||
if (healthboxAnimDone)
|
||||
{
|
||||
if (twoMons == TRUE)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
else if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
else if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
if (GetBattlerPosition(gActiveBattler) == 3)
|
||||
if (GetBattlerPosition(battler) == 3)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim)
|
||||
{
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
@ -202,87 +202,87 @@ static void Intro_WaitForShinyAnimAndHealthbox(void)
|
||||
else
|
||||
return;
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[battler] = Intro_DelayAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
static void Intro_TryShinyAnimShowHealthbox(u32 battler)
|
||||
{
|
||||
bool32 bgmRestored = FALSE;
|
||||
bool32 battlerAnimsDone = FALSE;
|
||||
bool32 twoMons;
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
TryShinyAnimation(battler, &gEnemyParty[gBattlerPartyIndexes[battler]]);
|
||||
|
||||
twoMons = TwoOpponentIntroMons(gActiveBattler);
|
||||
twoMons = TwoOpponentIntroMons(battler);
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
|
||||
&& (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) || BATTLE_TWO_VS_ONE_OPPONENT)
|
||||
&& twoMons
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim)
|
||||
TryShinyAnimation(BATTLE_PARTNER(gActiveBattler), &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim)
|
||||
TryShinyAnimation(BATTLE_PARTNER(battler), &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]);
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted)
|
||||
{
|
||||
if (twoMons && (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) || BATTLE_TWO_VS_ONE_OPPONENT))
|
||||
{
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(battler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(battler)]);
|
||||
}
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted = TRUE;
|
||||
}
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].waitForCry
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].waitForCry
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].waitForCry
|
||||
&& !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
if (GetBattlerPosition(gActiveBattler) == 1)
|
||||
if (GetBattlerPosition(battler) == 1)
|
||||
m4aMPlayContinue(&gMPlayInfo_BGM);
|
||||
}
|
||||
else
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored = TRUE;
|
||||
bgmRestored = TRUE;
|
||||
}
|
||||
|
||||
if (!twoMons || (twoMons && gBattleTypeFlags & BATTLE_TYPE_MULTI && !BATTLE_TWO_VS_ONE_OPPONENT))
|
||||
{
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
battlerAnimsDone = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattleControllerData[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
battlerAnimsDone = TRUE;
|
||||
}
|
||||
@ -292,119 +292,119 @@ static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
{
|
||||
if (twoMons && (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) || BATTLE_TWO_VS_ONE_OPPONENT))
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
SetBattlerShadowSpriteCallback(BATTLE_PARTNER(gActiveBattler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], MON_DATA_SPECIES));
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(battler)]]);
|
||||
SetBattlerShadowSpriteCallback(BATTLE_PARTNER(battler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], MON_DATA_SPECIES));
|
||||
}
|
||||
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES));
|
||||
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted = FALSE;
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
gBattlerControllerFuncs[battler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void TryShinyAnimAfterMonAnim(void)
|
||||
static void TryShinyAnimAfterMonAnim(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
if (gSprites[gBattlerSpriteIds[battler]].x2 == 0
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
TryShinyAnimation(battler, &gEnemyParty[gBattlerPartyIndexes[battler]]);
|
||||
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
OpponentBufferExecCompleted();
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowSubstitute(void)
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd;
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_HandleSoundAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_HandleSoundAndEnd(void)
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy_2)
|
||||
{
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
OpponentBufferExecCompleted();
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(void)
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
CopyBattleSpriteInvisibility(gActiveBattler);
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(void)
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
TryShinyAnimation(battler, &gEnemyParty[gBattlerPartyIndexes[battler]]);
|
||||
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES));
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void OpponentBufferExecCompleted(void)
|
||||
static void OpponentBufferExecCompleted(u32 battler)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = OpponentBufferRunCommand;
|
||||
gBattlerControllerFuncs[battler] = OpponentBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
||||
gBattleControllerExecFlags &= ~gBitTable[battler];
|
||||
}
|
||||
}
|
||||
|
||||
static void OpponentHandleLoadMonSprite(void)
|
||||
static void OpponentHandleLoadMonSprite(u32 battler)
|
||||
{
|
||||
BtlController_HandleLoadMonSprite(gActiveBattler, gEnemyParty, TryShinyAnimAfterMonAnim);
|
||||
BtlController_HandleLoadMonSprite(battler, gEnemyParty, TryShinyAnimAfterMonAnim);
|
||||
}
|
||||
|
||||
static void OpponentHandleSwitchInAnim(void)
|
||||
static void OpponentHandleSwitchInAnim(u32 battler)
|
||||
{
|
||||
gBattleStruct->monToSwitchIntoId[gActiveBattler] = PARTY_SIZE;
|
||||
BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim);
|
||||
gBattleStruct->monToSwitchIntoId[battler] = PARTY_SIZE;
|
||||
BtlController_HandleSwitchInAnim(battler, FALSE, SwitchIn_TryShinyAnim);
|
||||
}
|
||||
|
||||
static u32 OpponentGetTrainerPicId(u32 battlerId)
|
||||
@ -466,14 +466,14 @@ static u32 OpponentGetTrainerPicId(u32 battlerId)
|
||||
return trainerPicId;
|
||||
}
|
||||
|
||||
static void OpponentHandleDrawTrainerPic(void)
|
||||
static void OpponentHandleDrawTrainerPic(u32 battler)
|
||||
{
|
||||
s16 xPos;
|
||||
u32 trainerPicId = OpponentGetTrainerPicId(gActiveBattler);
|
||||
u32 trainerPicId = OpponentGetTrainerPicId(battler);
|
||||
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT)
|
||||
{
|
||||
if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon
|
||||
if ((GetBattlerPosition(battler) & BIT_FLANK) != 0) // second mon
|
||||
xPos = 152;
|
||||
else // first mon
|
||||
xPos = 200;
|
||||
@ -483,42 +483,42 @@ static void OpponentHandleDrawTrainerPic(void)
|
||||
xPos = 176;
|
||||
}
|
||||
|
||||
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, TRUE,
|
||||
BtlController_HandleDrawTrainerPic(battler, trainerPicId, TRUE,
|
||||
xPos, 40 + 4 * (8 - gTrainerFrontPicCoords[trainerPicId].size),
|
||||
-1);
|
||||
}
|
||||
|
||||
static void OpponentHandleTrainerSlide(void)
|
||||
static void OpponentHandleTrainerSlide(u32 battler)
|
||||
{
|
||||
u32 trainerPicId = OpponentGetTrainerPicId(gActiveBattler);
|
||||
BtlController_HandleTrainerSlide(gActiveBattler, trainerPicId);
|
||||
u32 trainerPicId = OpponentGetTrainerPicId(battler);
|
||||
BtlController_HandleTrainerSlide(battler, trainerPicId);
|
||||
}
|
||||
|
||||
static void OpponentHandleTrainerSlideBack(void)
|
||||
static void OpponentHandleTrainerSlideBack(u32 battler)
|
||||
{
|
||||
BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
|
||||
BtlController_HandleTrainerSlideBack(battler, 35, FALSE);
|
||||
}
|
||||
|
||||
static void OpponentHandleMoveAnimation(void)
|
||||
static void OpponentHandleMoveAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleMoveAnimation(gActiveBattler, FALSE);
|
||||
BtlController_HandleMoveAnimation(battler, FALSE);
|
||||
}
|
||||
|
||||
static void OpponentHandlePrintString(void)
|
||||
static void OpponentHandlePrintString(u32 battler)
|
||||
{
|
||||
BtlController_HandlePrintString(gActiveBattler, FALSE, TRUE);
|
||||
BtlController_HandlePrintString(battler, FALSE, TRUE);
|
||||
}
|
||||
|
||||
static void OpponentHandleChooseAction(void)
|
||||
static void OpponentHandleChooseAction(u32 battler)
|
||||
{
|
||||
AI_TrySwitchOrUseItem();
|
||||
OpponentBufferExecCompleted();
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void OpponentHandleChooseMove(void)
|
||||
static void OpponentHandleChooseMove(u32 battler)
|
||||
{
|
||||
u8 chosenMoveId;
|
||||
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
|
||||
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
|
||||
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER)
|
||||
|| IsWildMonSmart())
|
||||
@ -529,8 +529,8 @@ static void OpponentHandleChooseMove(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
|
||||
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
|
||||
chosenMoveId = gBattleStruct->aiMoveOrAction[battler];
|
||||
gBattlerTarget = gBattleStruct->aiChosenTarget[battler];
|
||||
switch (chosenMoveId)
|
||||
{
|
||||
case AI_CHOICE_WATCH:
|
||||
@ -549,17 +549,17 @@ static void OpponentHandleChooseMove(void)
|
||||
{
|
||||
u16 chosenMove = moveInfo->moves[chosenMoveId];
|
||||
|
||||
if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
|
||||
gBattlerTarget = gActiveBattler;
|
||||
if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & MOVE_TARGET_BOTH)
|
||||
if (GetBattlerMoveTargetType(battler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
|
||||
gBattlerTarget = battler;
|
||||
if (GetBattlerMoveTargetType(battler, chosenMove) & MOVE_TARGET_BOTH)
|
||||
{
|
||||
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
|
||||
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
||||
}
|
||||
if (ShouldUseZMove(gActiveBattler, gBattlerTarget, chosenMove))
|
||||
QueueZMove(gActiveBattler, chosenMove);
|
||||
if (CanMegaEvolve(gActiveBattler)) // If opponent can mega evolve, do it.
|
||||
if (ShouldUseZMove(battler, gBattlerTarget, chosenMove))
|
||||
QueueZMove(battler, chosenMove);
|
||||
if (CanMegaEvolve(battler)) // If opponent can mega evolve, do it.
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||
@ -567,7 +567,7 @@ static void OpponentHandleChooseMove(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
OpponentBufferExecCompleted();
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
else // Wild pokemon - use random move
|
||||
{
|
||||
@ -579,13 +579,13 @@ static void OpponentHandleChooseMove(void)
|
||||
move = moveInfo->moves[chosenMoveId];
|
||||
} while (move == MOVE_NONE);
|
||||
|
||||
if (GetBattlerMoveTargetType(gActiveBattler, move) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gActiveBattler << 8));
|
||||
if (GetBattlerMoveTargetType(battler, move) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (battler << 8));
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
do {
|
||||
target = GetBattlerAtPosition(Random() & 2);
|
||||
} while (!CanTargetBattler(gActiveBattler, target, move));
|
||||
} while (!CanTargetBattler(battler, target, move));
|
||||
|
||||
#if B_WILD_NATURAL_ENEMIES == TRUE
|
||||
// Don't bother to loop through table if the move can't attack ally
|
||||
@ -602,8 +602,8 @@ static void OpponentHandleChooseMove(void)
|
||||
{SPECIES_SABLEYE, SPECIES_CARBINK},
|
||||
{SPECIES_MAREANIE, SPECIES_CORSOLA},
|
||||
};
|
||||
speciesAttacker = gBattleMons[gActiveBattler].species;
|
||||
speciesTarget = gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler))].species;
|
||||
speciesAttacker = gBattleMons[battler].species;
|
||||
speciesTarget = gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(battler))].species;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(naturalEnemies); i++)
|
||||
{
|
||||
@ -613,8 +613,8 @@ static void OpponentHandleChooseMove(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isPartnerEnemy && CanTargetBattler(gActiveBattler, target, move))
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler)) << 8));
|
||||
if (isPartnerEnemy && CanTargetBattler(battler, target, move))
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(battler)) << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8));
|
||||
}
|
||||
@ -625,28 +625,28 @@ static void OpponentHandleChooseMove(void)
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));
|
||||
|
||||
OpponentBufferExecCompleted();
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void OpponentHandleChooseItem(void)
|
||||
static void OpponentHandleChooseItem(u32 battler)
|
||||
{
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]);
|
||||
OpponentBufferExecCompleted();
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[battler]);
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void OpponentHandleChoosePokemon(void)
|
||||
static void OpponentHandleChoosePokemon(u32 battler)
|
||||
{
|
||||
s32 chosenMonId;
|
||||
s32 pokemonInBattle = 1;
|
||||
|
||||
// Choosing Revival Blessing target
|
||||
if ((gBattleResources->bufferA[gActiveBattler][1] & 0xF) == PARTY_ACTION_CHOOSE_FAINTED_MON)
|
||||
if ((gBattleResources->bufferA[battler][1] & 0xF) == PARTY_ACTION_CHOOSE_FAINTED_MON)
|
||||
{
|
||||
chosenMonId = gSelectedMonPartyId = GetFirstFaintedPartyIndex(gActiveBattler);
|
||||
chosenMonId = gSelectedMonPartyId = GetFirstFaintedPartyIndex(battler);
|
||||
}
|
||||
// Switching out
|
||||
else if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == PARTY_SIZE)
|
||||
else if (*(gBattleStruct->AI_monToSwitchIntoId + battler) == PARTY_SIZE)
|
||||
{
|
||||
chosenMonId = GetMostSuitableMonToSwitchInto();
|
||||
|
||||
@ -666,7 +666,7 @@ static void OpponentHandleChoosePokemon(void)
|
||||
|
||||
}
|
||||
|
||||
GetAIPartyIndexes(gActiveBattler, &firstId, &lastId);
|
||||
GetAIPartyIndexes(battler, &firstId, &lastId);
|
||||
|
||||
for (chosenMonId = (lastId-1); chosenMonId >= firstId; chosenMonId--)
|
||||
{
|
||||
@ -681,16 +681,16 @@ static void OpponentHandleChoosePokemon(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId;
|
||||
*(gBattleStruct->monToSwitchIntoId + battler) = chosenMonId;
|
||||
}
|
||||
else
|
||||
{
|
||||
chosenMonId = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler);
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId;
|
||||
chosenMonId = *(gBattleStruct->AI_monToSwitchIntoId + battler);
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + battler) = PARTY_SIZE;
|
||||
*(gBattleStruct->monToSwitchIntoId + battler) = chosenMonId;
|
||||
}
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL);
|
||||
OpponentBufferExecCompleted();
|
||||
OpponentBufferExecCompleted(battler);
|
||||
|
||||
}
|
||||
|
||||
@ -701,9 +701,7 @@ static u8 CountAIAliveNonEggMonsExcept(u8 slotToIgnore)
|
||||
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (i != slotToIgnore
|
||||
&& GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG)
|
||||
&& GetMonData(&gEnemyParty[i], MON_DATA_HP) != 0)
|
||||
&& IsValidForBattle(&gEnemyParty[i]))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
@ -712,27 +710,27 @@ static u8 CountAIAliveNonEggMonsExcept(u8 slotToIgnore)
|
||||
return count;
|
||||
}
|
||||
|
||||
static void OpponentHandleHealthBarUpdate(void)
|
||||
static void OpponentHandleHealthBarUpdate(u32 battler)
|
||||
{
|
||||
BtlController_HandleHealthBarUpdate(gActiveBattler, FALSE);
|
||||
BtlController_HandleHealthBarUpdate(battler, FALSE);
|
||||
}
|
||||
|
||||
static void OpponentHandleIntroTrainerBallThrow(void)
|
||||
static void OpponentHandleIntroTrainerBallThrow(u32 battler)
|
||||
{
|
||||
BtlController_HandleIntroTrainerBallThrow(gActiveBattler, 0, NULL, 0, Intro_TryShinyAnimShowHealthbox);
|
||||
BtlController_HandleIntroTrainerBallThrow(battler, 0, NULL, 0, Intro_TryShinyAnimShowHealthbox);
|
||||
}
|
||||
|
||||
static void OpponentHandleDrawPartyStatusSummary(void)
|
||||
static void OpponentHandleDrawPartyStatusSummary(u32 battler)
|
||||
{
|
||||
BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_OPPONENT, TRUE);
|
||||
BtlController_HandleDrawPartyStatusSummary(battler, B_SIDE_OPPONENT, TRUE);
|
||||
}
|
||||
|
||||
static void OpponentHandleBattleAnimation(void)
|
||||
static void OpponentHandleBattleAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleBattleAnimation(gActiveBattler, FALSE, FALSE);
|
||||
BtlController_HandleBattleAnimation(battler, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void OpponentHandleEndLinkBattle(void)
|
||||
static void OpponentHandleEndLinkBattle(u32 battler)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK && !(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
|
||||
{
|
||||
@ -740,5 +738,5 @@ static void OpponentHandleEndLinkBattle(void)
|
||||
gMain.callback1 = gPreBattleCallback1;
|
||||
SetMainCallback2(gMain.savedCallback);
|
||||
}
|
||||
OpponentBufferExecCompleted();
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,31 +31,26 @@
|
||||
#include "constants/party_menu.h"
|
||||
#include "constants/trainers.h"
|
||||
|
||||
static void PlayerPartnerHandleLoadMonSprite(void);
|
||||
static void PlayerPartnerHandleSwitchInAnim(void);
|
||||
static void PlayerPartnerHandleDrawTrainerPic(void);
|
||||
static void PlayerPartnerHandleTrainerSlideBack(void);
|
||||
static void PlayerPartnerHandleMoveAnimation(void);
|
||||
static void PlayerPartnerHandlePrintString(void);
|
||||
static void PlayerPartnerHandleChooseAction(void);
|
||||
static void PlayerPartnerHandleChooseMove(void);
|
||||
static void PlayerPartnerHandleChoosePokemon(void);
|
||||
static void PlayerPartnerHandleHealthBarUpdate(void);
|
||||
static void PlayerPartnerHandleIntroTrainerBallThrow(void);
|
||||
static void PlayerPartnerHandleDrawPartyStatusSummary(void);
|
||||
static void PlayerPartnerHandleBattleAnimation(void);
|
||||
static void PlayerPartnerHandleEndLinkBattle(void);
|
||||
static void PlayerPartnerHandleLoadMonSprite(u32 battler);
|
||||
static void PlayerPartnerHandleSwitchInAnim(u32 battler);
|
||||
static void PlayerPartnerHandleDrawTrainerPic(u32 battler);
|
||||
static void PlayerPartnerHandleTrainerSlideBack(u32 battler);
|
||||
static void PlayerPartnerHandleMoveAnimation(u32 battler);
|
||||
static void PlayerPartnerHandlePrintString(u32 battler);
|
||||
static void PlayerPartnerHandleChooseAction(u32 battler);
|
||||
static void PlayerPartnerHandleChooseMove(u32 battler);
|
||||
static void PlayerPartnerHandleChoosePokemon(u32 battler);
|
||||
static void PlayerPartnerHandleHealthBarUpdate(u32 battler);
|
||||
static void PlayerPartnerHandleIntroTrainerBallThrow(u32 battler);
|
||||
static void PlayerPartnerHandleDrawPartyStatusSummary(u32 battler);
|
||||
static void PlayerPartnerHandleBattleAnimation(u32 battler);
|
||||
static void PlayerPartnerHandleEndLinkBattle(u32 battler);
|
||||
|
||||
static void PlayerPartnerBufferRunCommand(void);
|
||||
static void PlayerPartnerBufferExecCompleted(void);
|
||||
static void Task_LaunchLvlUpAnim(u8 taskId);
|
||||
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId);
|
||||
static void Task_PrepareToGiveExpWithExpBar(u8 taskId);
|
||||
static void Task_GiveExpWithExpBar(u8 taskId);
|
||||
static void Task_UpdateLvlInHealthbox(u8 taskId);
|
||||
static void SwitchIn_WaitAndEnd(void);
|
||||
static void PlayerPartnerBufferRunCommand(u32 battler);
|
||||
static void PlayerPartnerBufferExecCompleted(u32 battler);
|
||||
static void SwitchIn_WaitAndEnd(u32 battler);
|
||||
|
||||
static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
|
||||
{
|
||||
[CONTROLLER_GETMONDATA] = BtlController_HandleGetMonData,
|
||||
[CONTROLLER_GETRAWMONDATA] = BtlController_Empty,
|
||||
@ -117,45 +112,45 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
|
||||
};
|
||||
|
||||
void SetControllerToPlayerPartner(void)
|
||||
void SetControllerToPlayerPartner(u32 battler)
|
||||
{
|
||||
gBattlerControllerEndFuncs[gActiveBattler] = PlayerPartnerBufferExecCompleted;
|
||||
gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand;
|
||||
gBattlerControllerEndFuncs[battler] = PlayerPartnerBufferExecCompleted;
|
||||
gBattlerControllerFuncs[battler] = PlayerPartnerBufferRunCommand;
|
||||
}
|
||||
|
||||
static void PlayerPartnerBufferRunCommand(void)
|
||||
static void PlayerPartnerBufferRunCommand(u32 battler)
|
||||
{
|
||||
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
||||
if (gBattleControllerExecFlags & gBitTable[battler])
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands))
|
||||
sPlayerPartnerBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
|
||||
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands))
|
||||
sPlayerPartnerBufferCommands[gBattleResources->bufferA[battler][0]](battler);
|
||||
else
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_DelayAndEnd(void)
|
||||
static void Intro_DelayAndEnd(u32 battler)
|
||||
{
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay == (u8)-1)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 0;
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_WaitForHealthbox(void)
|
||||
static void Intro_WaitForHealthbox(u32 battler)
|
||||
{
|
||||
bool32 finished = FALSE;
|
||||
|
||||
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
finished = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
finished = TRUE;
|
||||
}
|
||||
@ -166,135 +161,135 @@ static void Intro_WaitForHealthbox(void)
|
||||
|
||||
if (finished)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[battler] = Intro_DelayAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
// Also used by the link partner.
|
||||
void Controller_PlayerPartnerShowIntroHealthbox(void)
|
||||
void Controller_PlayerPartnerShowIntroHealthbox(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive
|
||||
&& gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay != 1)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive
|
||||
&& gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& ++gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay != 1)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 0;
|
||||
|
||||
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]);
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(battler)]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battler)], &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(battler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(battler)]);
|
||||
}
|
||||
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForHealthbox;
|
||||
gBattlerControllerFuncs[battler] = Intro_WaitForHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void WaitForMonAnimAfterLoad(void)
|
||||
static void WaitForMonAnimAfterLoad(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
if (gSprites[gBattlerSpriteIds[battler]].animEnded && gSprites[gBattlerSpriteIds[battler]].x2 == 0)
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowSubstitute(void)
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
CopyBattleSpriteInvisibility(gActiveBattler);
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_WaitAndEnd;
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_WaitAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_WaitAndEnd(void)
|
||||
static void SwitchIn_WaitAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(void)
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(void)
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
TryShinyAnimation(battler, &gPlayerParty[gBattlerPartyIndexes[battler]]);
|
||||
}
|
||||
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void PlayerPartnerBufferExecCompleted(void)
|
||||
static void PlayerPartnerBufferExecCompleted(u32 battler)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand;
|
||||
gBattlerControllerFuncs[battler] = PlayerPartnerBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
||||
gBattleControllerExecFlags &= ~gBitTable[battler];
|
||||
}
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleLoadMonSprite(void)
|
||||
static void PlayerPartnerHandleLoadMonSprite(u32 battler)
|
||||
{
|
||||
BtlController_HandleLoadMonSprite(gActiveBattler, gPlayerParty, WaitForMonAnimAfterLoad);
|
||||
BtlController_HandleLoadMonSprite(battler, gPlayerParty, WaitForMonAnimAfterLoad);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleSwitchInAnim(void)
|
||||
static void PlayerPartnerHandleSwitchInAnim(u32 battler)
|
||||
{
|
||||
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
|
||||
BtlController_HandleSwitchInAnim(battler, TRUE, SwitchIn_TryShinyAnim);
|
||||
}
|
||||
|
||||
// some explanation here
|
||||
// in emerald it's possible to have a tag battle in the battle frontier facilities with AI
|
||||
// which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven) that use the back pic as well as animate it
|
||||
static void PlayerPartnerHandleDrawTrainerPic(void)
|
||||
static void PlayerPartnerHandleDrawTrainerPic(u32 battler)
|
||||
{
|
||||
bool32 isFrontPic;
|
||||
s16 xPos, yPos;
|
||||
@ -325,40 +320,40 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
|
||||
else
|
||||
isFrontPic = TRUE;
|
||||
|
||||
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, isFrontPic, xPos, yPos, -1);
|
||||
BtlController_HandleDrawTrainerPic(battler, trainerPicId, isFrontPic, xPos, yPos, -1);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleTrainerSlideBack(void)
|
||||
static void PlayerPartnerHandleTrainerSlideBack(u32 battler)
|
||||
{
|
||||
BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
|
||||
BtlController_HandleTrainerSlideBack(battler, 35, FALSE);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleMoveAnimation(void)
|
||||
static void PlayerPartnerHandleMoveAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleMoveAnimation(gActiveBattler, FALSE);
|
||||
BtlController_HandleMoveAnimation(battler, FALSE);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandlePrintString(void)
|
||||
static void PlayerPartnerHandlePrintString(u32 battler)
|
||||
{
|
||||
BtlController_HandlePrintString(gActiveBattler, FALSE, FALSE);
|
||||
BtlController_HandlePrintString(battler, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleChooseAction(void)
|
||||
static void PlayerPartnerHandleChooseAction(u32 battler)
|
||||
{
|
||||
AI_TrySwitchOrUseItem();
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleChooseMove(void)
|
||||
static void PlayerPartnerHandleChooseMove(u32 battler)
|
||||
{
|
||||
u8 chosenMoveId;
|
||||
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
|
||||
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
|
||||
|
||||
chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
|
||||
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
|
||||
chosenMoveId = gBattleStruct->aiMoveOrAction[battler];
|
||||
gBattlerTarget = gBattleStruct->aiChosenTarget[battler];
|
||||
|
||||
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED))
|
||||
gBattlerTarget = gActiveBattler;
|
||||
gBattlerTarget = battler;
|
||||
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
|
||||
{
|
||||
gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
@ -366,25 +361,25 @@ static void PlayerPartnerHandleChooseMove(void)
|
||||
gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
}
|
||||
|
||||
if (ShouldUseZMove(gActiveBattler, gBattlerTarget, moveInfo->moves[chosenMoveId]))
|
||||
QueueZMove(gActiveBattler, moveInfo->moves[chosenMoveId]);
|
||||
if (ShouldUseZMove(battler, gBattlerTarget, moveInfo->moves[chosenMoveId]))
|
||||
QueueZMove(battler, moveInfo->moves[chosenMoveId]);
|
||||
|
||||
// If partner can mega evolve, do it.
|
||||
if (CanMegaEvolve(gActiveBattler))
|
||||
if (CanMegaEvolve(battler))
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleChoosePokemon(void)
|
||||
static void PlayerPartnerHandleChoosePokemon(u32 battler)
|
||||
{
|
||||
s32 chosenMonId;
|
||||
// Choosing Revival Blessing target
|
||||
if ((gBattleResources->bufferA[gActiveBattler][1] & 0xF) == PARTY_ACTION_CHOOSE_FAINTED_MON)
|
||||
if ((gBattleResources->bufferA[battler][1] & 0xF) == PARTY_ACTION_CHOOSE_FAINTED_MON)
|
||||
{
|
||||
chosenMonId = gSelectedMonPartyId = GetFirstFaintedPartyIndex(gActiveBattler);
|
||||
chosenMonId = gSelectedMonPartyId = GetFirstFaintedPartyIndex(battler);
|
||||
}
|
||||
// Switching out
|
||||
else
|
||||
@ -405,18 +400,18 @@ static void PlayerPartnerHandleChoosePokemon(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId;
|
||||
*(gBattleStruct->monToSwitchIntoId + battler) = chosenMonId;
|
||||
}
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL);
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleHealthBarUpdate(void)
|
||||
static void PlayerPartnerHandleHealthBarUpdate(u32 battler)
|
||||
{
|
||||
BtlController_HandleHealthBarUpdate(gActiveBattler, FALSE);
|
||||
BtlController_HandleHealthBarUpdate(battler, FALSE);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleIntroTrainerBallThrow(void)
|
||||
static void PlayerPartnerHandleIntroTrainerBallThrow(u32 battler)
|
||||
{
|
||||
const u32 *trainerPal;
|
||||
|
||||
@ -427,24 +422,24 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void)
|
||||
else
|
||||
trainerPal = gTrainerFrontPicPaletteTable[GetFrontierTrainerFrontSpriteId(gPartnerTrainerId)].data; // 2 vs 2 multi battle in Battle Frontier, load front sprite and pal.
|
||||
|
||||
BtlController_HandleIntroTrainerBallThrow(gActiveBattler, 0xD6F9, trainerPal, 24, Controller_PlayerPartnerShowIntroHealthbox);
|
||||
BtlController_HandleIntroTrainerBallThrow(battler, 0xD6F9, trainerPal, 24, Controller_PlayerPartnerShowIntroHealthbox);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleDrawPartyStatusSummary(void)
|
||||
static void PlayerPartnerHandleDrawPartyStatusSummary(u32 battler)
|
||||
{
|
||||
BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_PLAYER, TRUE);
|
||||
BtlController_HandleDrawPartyStatusSummary(battler, B_SIDE_PLAYER, TRUE);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleBattleAnimation(void)
|
||||
static void PlayerPartnerHandleBattleAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleBattleAnimation(gActiveBattler, FALSE, FALSE);
|
||||
BtlController_HandleBattleAnimation(battler, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleEndLinkBattle(void)
|
||||
static void PlayerPartnerHandleEndLinkBattle(u32 battler)
|
||||
{
|
||||
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1];
|
||||
gBattleOutcome = gBattleResources->bufferA[battler][1];
|
||||
FadeOutMapMusic(5);
|
||||
BeginFastPaletteFade(3);
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
gBattlerControllerFuncs[battler] = SetBattleEndCallbacks;
|
||||
}
|
||||
|
@ -32,29 +32,29 @@
|
||||
#include "constants/songs.h"
|
||||
#include "constants/trainers.h"
|
||||
|
||||
static void RecordedOpponentHandleLoadMonSprite(void);
|
||||
static void RecordedOpponentHandleSwitchInAnim(void);
|
||||
static void RecordedOpponentHandleDrawTrainerPic(void);
|
||||
static void RecordedOpponentHandleTrainerSlideBack(void);
|
||||
static void RecordedOpponentHandleMoveAnimation(void);
|
||||
static void RecordedOpponentHandlePrintString(void);
|
||||
static void RecordedOpponentHandleChooseAction(void);
|
||||
static void RecordedOpponentHandleChooseMove(void);
|
||||
static void RecordedOpponentHandleChooseItem(void);
|
||||
static void RecordedOpponentHandleChoosePokemon(void);
|
||||
static void RecordedOpponentHandleHealthBarUpdate(void);
|
||||
static void RecordedOpponentHandleStatusIconUpdate(void);
|
||||
static void RecordedOpponentHandleStatusAnimation(void);
|
||||
static void RecordedOpponentHandleIntroTrainerBallThrow(void);
|
||||
static void RecordedOpponentHandleDrawPartyStatusSummary(void);
|
||||
static void RecordedOpponentHandleBattleAnimation(void);
|
||||
static void RecordedOpponentHandleEndLinkBattle(void);
|
||||
static void RecordedOpponentHandleLoadMonSprite(u32 battler);
|
||||
static void RecordedOpponentHandleSwitchInAnim(u32 battler);
|
||||
static void RecordedOpponentHandleDrawTrainerPic(u32 battler);
|
||||
static void RecordedOpponentHandleTrainerSlideBack(u32 battler);
|
||||
static void RecordedOpponentHandleMoveAnimation(u32 battler);
|
||||
static void RecordedOpponentHandlePrintString(u32 battler);
|
||||
static void RecordedOpponentHandleChooseAction(u32 battler);
|
||||
static void RecordedOpponentHandleChooseMove(u32 battler);
|
||||
static void RecordedOpponentHandleChooseItem(u32 battler);
|
||||
static void RecordedOpponentHandleChoosePokemon(u32 battler);
|
||||
static void RecordedOpponentHandleHealthBarUpdate(u32 battler);
|
||||
static void RecordedOpponentHandleStatusIconUpdate(u32 battler);
|
||||
static void RecordedOpponentHandleStatusAnimation(u32 battler);
|
||||
static void RecordedOpponentHandleIntroTrainerBallThrow(u32 battler);
|
||||
static void RecordedOpponentHandleDrawPartyStatusSummary(u32 battler);
|
||||
static void RecordedOpponentHandleBattleAnimation(u32 battler);
|
||||
static void RecordedOpponentHandleEndLinkBattle(u32 battler);
|
||||
|
||||
static void RecordedOpponentBufferRunCommand(void);
|
||||
static void RecordedOpponentBufferExecCompleted(void);
|
||||
static void SwitchIn_HandleSoundAndEnd(void);
|
||||
static void RecordedOpponentBufferRunCommand(u32 battler);
|
||||
static void RecordedOpponentBufferExecCompleted(u32 battler);
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler);
|
||||
|
||||
static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
|
||||
{
|
||||
[CONTROLLER_GETMONDATA] = BtlController_HandleGetMonData,
|
||||
[CONTROLLER_GETRAWMONDATA] = BtlController_Empty,
|
||||
@ -116,120 +116,130 @@ static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void
|
||||
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
|
||||
};
|
||||
|
||||
void SetControllerToRecordedOpponent(void)
|
||||
void SetControllerToRecordedOpponent(u32 battler)
|
||||
{
|
||||
gBattlerControllerEndFuncs[gActiveBattler] = RecordedOpponentBufferExecCompleted;
|
||||
gBattlerControllerFuncs[gActiveBattler] = RecordedOpponentBufferRunCommand;
|
||||
gBattlerControllerEndFuncs[battler] = RecordedOpponentBufferExecCompleted;
|
||||
gBattlerControllerFuncs[battler] = RecordedOpponentBufferRunCommand;
|
||||
}
|
||||
|
||||
static void RecordedOpponentBufferRunCommand(void)
|
||||
static void RecordedOpponentBufferRunCommand(u32 battler)
|
||||
{
|
||||
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
||||
if (gBattleControllerExecFlags & gBitTable[battler])
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedOpponentBufferCommands))
|
||||
sRecordedOpponentBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
|
||||
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sRecordedOpponentBufferCommands))
|
||||
sRecordedOpponentBufferCommands[gBattleResources->bufferA[battler][0]](battler);
|
||||
else
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void CompleteOnBankSpriteCallbackDummy2(void)
|
||||
static void RecordedOpponentBufferExecCompleted(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
}
|
||||
gBattlerControllerFuncs[battler] = RecordedOpponentBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
static void Intro_DelayAndEnd(void)
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
gBattleControllerExecFlags &= ~gBitTable[battler];
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(void)
|
||||
static void Intro_DelayAndEnd(u32 battler)
|
||||
{
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay == (u8)-1)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 0;
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
|
||||
{
|
||||
bool8 healthboxAnimDone = FALSE;
|
||||
|
||||
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].animEnded)
|
||||
healthboxAnimDone = TRUE;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded
|
||||
&& gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gActiveBattler)]].animEnded)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].animEnded
|
||||
&& gSprites[gBattlerSpriteIds[BATTLE_PARTNER(battler)]].animEnded)
|
||||
healthboxAnimDone = TRUE;
|
||||
}
|
||||
|
||||
if (healthboxAnimDone)
|
||||
{
|
||||
if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT)
|
||||
if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_LEFT)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
return;
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim)
|
||||
return;
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
}
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[battler] = Intro_DelayAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
static void Intro_TryShinyAnimShowHealthbox(u32 battler)
|
||||
{
|
||||
bool32 bgmRestored = FALSE;
|
||||
bool32 battlerAnimsDone = FALSE;
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
TryShinyAnimation(battler, &gEnemyParty[gBattlerPartyIndexes[battler]]);
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
|
||||
TryShinyAnimation(BATTLE_PARTNER(gActiveBattler), &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive)
|
||||
TryShinyAnimation(BATTLE_PARTNER(battler), &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]);
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted)
|
||||
{
|
||||
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
{
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(battler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(battler)]);
|
||||
}
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted = TRUE;
|
||||
}
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].waitForCry
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].waitForCry
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].waitForCry
|
||||
&& !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT)
|
||||
if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_LEFT)
|
||||
m4aMPlayContinue(&gMPlayInfo_BGM);
|
||||
}
|
||||
else
|
||||
@ -237,24 +247,24 @@ static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
}
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored = TRUE;
|
||||
bgmRestored = TRUE;
|
||||
}
|
||||
|
||||
if (!IsDoubleBattle())
|
||||
{
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
battlerAnimsDone = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattleControllerData[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
battlerAnimsDone = TRUE;
|
||||
}
|
||||
@ -264,146 +274,130 @@ static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
{
|
||||
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
SetBattlerShadowSpriteCallback(BATTLE_PARTNER(gActiveBattler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], MON_DATA_SPECIES));
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(battler)]]);
|
||||
SetBattlerShadowSpriteCallback(BATTLE_PARTNER(battler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], MON_DATA_SPECIES));
|
||||
}
|
||||
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES));
|
||||
|
||||
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted = FALSE;
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
gBattlerControllerFuncs[battler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void TryShinyAnimAfterMonAnim(void)
|
||||
static void TryShinyAnimAfterMonAnim(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].x2 == 0)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
{
|
||||
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
TryShinyAnimation(battler, &gEnemyParty[gBattlerPartyIndexes[battler]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowSubstitute(void)
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd;
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_HandleSoundAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_HandleSoundAndEnd(void)
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy_2)
|
||||
{
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(void)
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
CopyBattleSpriteInvisibility(gActiveBattler);
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(void)
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim)
|
||||
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
TryShinyAnimation(battler, &gEnemyParty[gBattlerPartyIndexes[battler]]);
|
||||
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES));
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void RecordedOpponentBufferExecCompleted(void)
|
||||
static void RecordedOpponentHandleLoadMonSprite(u32 battler)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = RecordedOpponentBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
||||
}
|
||||
BtlController_HandleLoadMonSprite(battler, gEnemyParty, TryShinyAnimAfterMonAnim);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleLoadMonSprite(void)
|
||||
static void RecordedOpponentHandleSwitchInAnim(u32 battler)
|
||||
{
|
||||
BtlController_HandleLoadMonSprite(gActiveBattler, gEnemyParty, TryShinyAnimAfterMonAnim);
|
||||
BtlController_HandleSwitchInAnim(battler, FALSE, SwitchIn_TryShinyAnim);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleSwitchInAnim(void)
|
||||
{
|
||||
BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleDrawTrainerPic(void)
|
||||
static void RecordedOpponentHandleDrawTrainerPic(u32 battler)
|
||||
{
|
||||
s16 xPos;
|
||||
u32 trainerPicId;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
{
|
||||
if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon
|
||||
if ((GetBattlerPosition(battler) & BIT_FLANK) != 0) // second mon
|
||||
xPos = 152;
|
||||
else // first mon
|
||||
xPos = 200;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER)
|
||||
{
|
||||
if (gActiveBattler == 1)
|
||||
if (battler == B_POSITION_OPPONENT_LEFT)
|
||||
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
|
||||
else
|
||||
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B);
|
||||
@ -426,28 +420,28 @@ static void RecordedOpponentHandleDrawTrainerPic(void)
|
||||
}
|
||||
}
|
||||
|
||||
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, TRUE,
|
||||
BtlController_HandleDrawTrainerPic(battler, trainerPicId, TRUE,
|
||||
xPos, 40 + 4 * (8 - gTrainerFrontPicCoords[trainerPicId].size),
|
||||
-1);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleTrainerSlideBack(void)
|
||||
static void RecordedOpponentHandleTrainerSlideBack(u32 battler)
|
||||
{
|
||||
BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
|
||||
BtlController_HandleTrainerSlideBack(battler, 35, FALSE);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleMoveAnimation(void)
|
||||
static void RecordedOpponentHandleMoveAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleMoveAnimation(gActiveBattler, FALSE);
|
||||
BtlController_HandleMoveAnimation(battler, FALSE);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandlePrintString(void)
|
||||
static void RecordedOpponentHandlePrintString(u32 battler)
|
||||
{
|
||||
u16 *stringId;
|
||||
|
||||
gBattle_BG0_X = 0;
|
||||
gBattle_BG0_Y = 0;
|
||||
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
|
||||
stringId = (u16 *)(&gBattleResources->bufferA[battler][2]);
|
||||
BufferStringBattle(*stringId);
|
||||
|
||||
if (gTestRunnerEnabled)
|
||||
@ -455,22 +449,22 @@ static void RecordedOpponentHandlePrintString(void)
|
||||
TestRunner_Battle_RecordMessage(gDisplayedStringBattle);
|
||||
if (gTestRunnerHeadless)
|
||||
{
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
|
||||
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForString;
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForString;
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleChooseAction(void)
|
||||
static void RecordedOpponentHandleChooseAction(u32 battler)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, gActiveBattler), 0);
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleChooseMove(void)
|
||||
static void RecordedOpponentHandleChooseMove(u32 battler)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
{
|
||||
@ -478,97 +472,97 @@ static void RecordedOpponentHandleChooseMove(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 moveId = RecordedBattle_GetBattlerAction(RECORDED_MOVE_SLOT, gActiveBattler);
|
||||
u8 target = RecordedBattle_GetBattlerAction(RECORDED_MOVE_TARGET, gActiveBattler);
|
||||
u8 moveId = RecordedBattle_GetBattlerAction(RECORDED_MOVE_SLOT, battler);
|
||||
u8 target = RecordedBattle_GetBattlerAction(RECORDED_MOVE_TARGET, battler);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, moveId | (target << 8));
|
||||
}
|
||||
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleChooseItem(void)
|
||||
static void RecordedOpponentHandleChooseItem(u32 battler)
|
||||
{
|
||||
u8 byte1 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler);
|
||||
u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler);
|
||||
gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2;
|
||||
gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler);
|
||||
gBattleStruct->itemMoveIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler);
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]);
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
u8 byte1 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, battler);
|
||||
u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, battler);
|
||||
gBattleStruct->chosenItem[battler] = (byte1 << 8) | byte2;
|
||||
gBattleStruct->itemPartyIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, battler);
|
||||
gBattleStruct->itemMoveIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, battler);
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[battler]);
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleChoosePokemon(void)
|
||||
static void RecordedOpponentHandleChoosePokemon(u32 battler)
|
||||
{
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, gActiveBattler);
|
||||
gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[gActiveBattler]; // Revival Blessing
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL);
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
*(gBattleStruct->monToSwitchIntoId + battler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler);
|
||||
gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[battler]; // Revival Blessing
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleHealthBarUpdate(void)
|
||||
static void RecordedOpponentHandleHealthBarUpdate(u32 battler)
|
||||
{
|
||||
s16 hpVal;
|
||||
s32 maxHP, curHP;
|
||||
|
||||
LoadBattleBarGfx(0);
|
||||
hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
|
||||
hpVal = gBattleResources->bufferA[battler][2] | (gBattleResources->bufferA[battler][3] << 8);
|
||||
|
||||
maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
|
||||
curHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
|
||||
maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_MAX_HP);
|
||||
curHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP);
|
||||
|
||||
if (hpVal != INSTANT_HP_BAR_DROP)
|
||||
{
|
||||
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
|
||||
TestRunner_Battle_RecordHP(gActiveBattler, curHP, min(maxHP, max(0, curHP - hpVal)));
|
||||
SetBattleBarStruct(battler, gHealthboxSpriteIds[battler], maxHP, curHP, hpVal);
|
||||
TestRunner_Battle_RecordHP(battler, curHP, min(maxHP, max(0, curHP - hpVal)));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
|
||||
TestRunner_Battle_RecordHP(gActiveBattler, curHP, 0);
|
||||
SetBattleBarStruct(battler, gHealthboxSpriteIds[battler], maxHP, 0, hpVal);
|
||||
TestRunner_Battle_RecordHP(battler, curHP, 0);
|
||||
}
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForHealthBar;
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForHealthBar;
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleStatusIconUpdate(void)
|
||||
static void RecordedOpponentHandleStatusIconUpdate(u32 battler)
|
||||
{
|
||||
if (!IsBattleSEPlaying(gActiveBattler))
|
||||
if (!IsBattleSEPlaying(battler))
|
||||
{
|
||||
DoStatusIconUpdate(gActiveBattler);
|
||||
DoStatusIconUpdate(battler);
|
||||
if (gTestRunnerEnabled)
|
||||
TestRunner_Battle_RecordStatus1(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_STATUS));
|
||||
TestRunner_Battle_RecordStatus1(battler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_STATUS));
|
||||
}
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleStatusAnimation(void)
|
||||
static void RecordedOpponentHandleStatusAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleStatusAnimation();
|
||||
BtlController_HandleStatusAnimation(battler);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleIntroTrainerBallThrow(void)
|
||||
static void RecordedOpponentHandleIntroTrainerBallThrow(u32 battler)
|
||||
{
|
||||
BtlController_HandleIntroTrainerBallThrow(gActiveBattler, 0, NULL, 0, Intro_TryShinyAnimShowHealthbox);
|
||||
BtlController_HandleIntroTrainerBallThrow(battler, 0, NULL, 0, Intro_TryShinyAnimShowHealthbox);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleDrawPartyStatusSummary(void)
|
||||
static void RecordedOpponentHandleDrawPartyStatusSummary(u32 battler)
|
||||
{
|
||||
BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_OPPONENT, TRUE);
|
||||
BtlController_HandleDrawPartyStatusSummary(battler, B_SIDE_OPPONENT, TRUE);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleBattleAnimation(void)
|
||||
static void RecordedOpponentHandleBattleAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleBattleAnimation(gActiveBattler, FALSE, FALSE);
|
||||
BtlController_HandleBattleAnimation(battler, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleEndLinkBattle(void)
|
||||
static void RecordedOpponentHandleEndLinkBattle(u32 battler)
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][1] == B_OUTCOME_DREW)
|
||||
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1];
|
||||
if (gBattleResources->bufferA[battler][1] == B_OUTCOME_DREW)
|
||||
gBattleOutcome = gBattleResources->bufferA[battler][1];
|
||||
else
|
||||
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1] ^ B_OUTCOME_DREW;
|
||||
gBattleOutcome = gBattleResources->bufferA[battler][1] ^ B_OUTCOME_DREW;
|
||||
|
||||
FadeOutMapMusic(5);
|
||||
BeginFastPaletteFade(3);
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
gBattlerControllerFuncs[battler] = SetBattleEndCallbacks;
|
||||
}
|
||||
|
@ -29,29 +29,29 @@
|
||||
#include "constants/songs.h"
|
||||
#include "constants/trainers.h"
|
||||
|
||||
static void RecordedPlayerHandleLoadMonSprite(void);
|
||||
static void RecordedPlayerHandleSwitchInAnim(void);
|
||||
static void RecordedPlayerHandleDrawTrainerPic(void);
|
||||
static void RecordedPlayerHandleTrainerSlideBack(void);
|
||||
static void RecordedPlayerHandleMoveAnimation(void);
|
||||
static void RecordedPlayerHandlePrintString(void);
|
||||
static void RecordedPlayerHandleChooseAction(void);
|
||||
static void RecordedPlayerHandleChooseMove(void);
|
||||
static void RecordedPlayerHandleChooseItem(void);
|
||||
static void RecordedPlayerHandleChoosePokemon(void);
|
||||
static void RecordedPlayerHandleHealthBarUpdate(void);
|
||||
static void RecordedPlayerHandleStatusIconUpdate(void);
|
||||
static void RecordedPlayerHandleStatusAnimation(void);
|
||||
static void RecordedPlayerHandleIntroTrainerBallThrow(void);
|
||||
static void RecordedPlayerHandleDrawPartyStatusSummary(void);
|
||||
static void RecordedPlayerHandleBattleAnimation(void);
|
||||
static void RecordedPlayerHandleEndLinkBattle(void);
|
||||
static void RecordedPlayerHandleLoadMonSprite(u32 battler);
|
||||
static void RecordedPlayerHandleSwitchInAnim(u32 battler);
|
||||
static void RecordedPlayerHandleDrawTrainerPic(u32 battler);
|
||||
static void RecordedPlayerHandleTrainerSlideBack(u32 battler);
|
||||
static void RecordedPlayerHandleMoveAnimation(u32 battler);
|
||||
static void RecordedPlayerHandlePrintString(u32 battler);
|
||||
static void RecordedPlayerHandleChooseAction(u32 battler);
|
||||
static void RecordedPlayerHandleChooseMove(u32 battler);
|
||||
static void RecordedPlayerHandleChooseItem(u32 battler);
|
||||
static void RecordedPlayerHandleChoosePokemon(u32 battler);
|
||||
static void RecordedPlayerHandleHealthBarUpdate(u32 battler);
|
||||
static void RecordedPlayerHandleStatusIconUpdate(u32 battler);
|
||||
static void RecordedPlayerHandleStatusAnimation(u32 battler);
|
||||
static void RecordedPlayerHandleIntroTrainerBallThrow(u32 battler);
|
||||
static void RecordedPlayerHandleDrawPartyStatusSummary(u32 battler);
|
||||
static void RecordedPlayerHandleBattleAnimation(u32 battler);
|
||||
static void RecordedPlayerHandleEndLinkBattle(u32 battler);
|
||||
|
||||
static void RecordedPlayerBufferRunCommand(void);
|
||||
static void RecordedPlayerBufferExecCompleted(void);
|
||||
static void SwitchIn_WaitAndEnd(void);
|
||||
static void RecordedPlayerBufferRunCommand(u32 battler);
|
||||
static void RecordedPlayerBufferExecCompleted(u32 battler);
|
||||
static void SwitchIn_WaitAndEnd(u32 battler);
|
||||
|
||||
static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
|
||||
{
|
||||
[CONTROLLER_GETMONDATA] = BtlController_HandleGetMonData,
|
||||
[CONTROLLER_GETRAWMONDATA] = BtlController_Empty,
|
||||
@ -113,83 +113,83 @@ static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void)
|
||||
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
|
||||
};
|
||||
|
||||
void SetControllerToRecordedPlayer(void)
|
||||
void SetControllerToRecordedPlayer(u32 battler)
|
||||
{
|
||||
gBattlerControllerEndFuncs[gActiveBattler] = RecordedPlayerBufferExecCompleted;
|
||||
gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand;
|
||||
gBattlerControllerEndFuncs[battler] = RecordedPlayerBufferExecCompleted;
|
||||
gBattlerControllerFuncs[battler] = RecordedPlayerBufferRunCommand;
|
||||
}
|
||||
|
||||
static void RecordedPlayerBufferRunCommand(void)
|
||||
static void RecordedPlayerBufferRunCommand(u32 battler)
|
||||
{
|
||||
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
||||
if (gBattleControllerExecFlags & gBitTable[battler])
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands))
|
||||
sRecordedPlayerBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
|
||||
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands))
|
||||
sRecordedPlayerBufferCommands[gBattleResources->bufferA[battler][0]](battler);
|
||||
else
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_DelayAndEnd(void)
|
||||
static void Intro_DelayAndEnd(u32 battler)
|
||||
{
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
|
||||
if (--gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay == (u8)-1)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 0;
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(void)
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
|
||||
{
|
||||
bool32 healthboxAnimDone = FALSE;
|
||||
|
||||
if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT)
|
||||
if (GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT)
|
||||
{
|
||||
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
healthboxAnimDone = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
healthboxAnimDone = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (healthboxAnimDone && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim)
|
||||
if (healthboxAnimDone && gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
|
||||
if (IsDoubleBattle())
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], BATTLE_PARTNER(gActiveBattler));
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], BATTLE_PARTNER(battler));
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[battler] = Intro_DelayAndEnd;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
healthboxAnimDone = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(battler)]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
healthboxAnimDone = TRUE;
|
||||
}
|
||||
@ -200,55 +200,55 @@ static void Intro_WaitForShinyAnimAndHealthbox(void)
|
||||
|
||||
if (healthboxAnimDone)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 3;
|
||||
gBattlerControllerFuncs[battler] = Intro_DelayAndEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
static void Intro_TryShinyAnimShowHealthbox(u32 battler)
|
||||
{
|
||||
bool32 bgmRestored = FALSE;
|
||||
|
||||
if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT)
|
||||
if (GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
TryShinyAnimation(battler, &gPlayerParty[gBattlerPartyIndexes[battler]]);
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
|
||||
TryShinyAnimation(BATTLE_PARTNER(gActiveBattler), &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive)
|
||||
TryShinyAnimation(BATTLE_PARTNER(battler), &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]);
|
||||
}
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted)
|
||||
{
|
||||
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
{
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battler)], &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(battler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(battler)]);
|
||||
}
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted = TRUE;
|
||||
}
|
||||
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].waitForCry
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].waitForCry
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].waitForCry
|
||||
&& !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored)
|
||||
{
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && (gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
{
|
||||
if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT)
|
||||
if (GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT)
|
||||
m4aMPlayContinue(&gMPlayInfo_BGM);
|
||||
}
|
||||
else
|
||||
@ -257,115 +257,115 @@ static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
}
|
||||
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored = TRUE;
|
||||
bgmRestored = TRUE;
|
||||
}
|
||||
|
||||
if (bgmRestored && gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (bgmRestored && gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(battler)]]);
|
||||
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].bgmRestored = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].healthboxSlideInStarted = FALSE;
|
||||
gBattlerControllerFuncs[battler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void WaitForMonAnimAfterLoad(void)
|
||||
static void WaitForMonAnimAfterLoad(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
if (gSprites[gBattlerSpriteIds[battler]].animEnded && gSprites[gBattlerSpriteIds[battler]].x2 == 0)
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowSubstitute(void)
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
CopyBattleSpriteInvisibility(gActiveBattler);
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_WaitAndEnd;
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_WaitAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_WaitAndEnd(void)
|
||||
static void SwitchIn_WaitAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(void)
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(void)
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
TryShinyAnimation(battler, &gPlayerParty[gBattlerPartyIndexes[battler]]);
|
||||
}
|
||||
|
||||
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void RecordedPlayerBufferExecCompleted(void)
|
||||
static void RecordedPlayerBufferExecCompleted(u32 battler)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand;
|
||||
gBattlerControllerFuncs[battler] = RecordedPlayerBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
||||
gBattleControllerExecFlags &= ~gBitTable[battler];
|
||||
}
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleLoadMonSprite(void)
|
||||
static void RecordedPlayerHandleLoadMonSprite(u32 battler)
|
||||
{
|
||||
BtlController_HandleLoadMonSprite(gActiveBattler, gPlayerParty, WaitForMonAnimAfterLoad);
|
||||
BtlController_HandleLoadMonSprite(battler, gPlayerParty, WaitForMonAnimAfterLoad);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleSwitchInAnim(void)
|
||||
static void RecordedPlayerHandleSwitchInAnim(u32 battler)
|
||||
{
|
||||
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
|
||||
BtlController_HandleSwitchInAnim(battler, TRUE, SwitchIn_TryShinyAnim);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleDrawTrainerPic(void)
|
||||
static void RecordedPlayerHandleDrawTrainerPic(u32 battler)
|
||||
{
|
||||
bool32 isFrontPic;
|
||||
s16 xPos, yPos;
|
||||
@ -385,7 +385,7 @@ static void RecordedPlayerHandleDrawTrainerPic(void)
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
{
|
||||
if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon
|
||||
if ((GetBattlerPosition(battler) & BIT_FLANK) != 0) // second mon
|
||||
xPos = 90;
|
||||
else // first mon
|
||||
xPos = 32;
|
||||
@ -412,26 +412,26 @@ static void RecordedPlayerHandleDrawTrainerPic(void)
|
||||
else
|
||||
isFrontPic = FALSE;
|
||||
|
||||
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, isFrontPic, xPos, yPos, -1);
|
||||
BtlController_HandleDrawTrainerPic(battler, trainerPicId, isFrontPic, xPos, yPos, -1);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleTrainerSlideBack(void)
|
||||
static void RecordedPlayerHandleTrainerSlideBack(u32 battler)
|
||||
{
|
||||
BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
|
||||
BtlController_HandleTrainerSlideBack(battler, 35, FALSE);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleMoveAnimation(void)
|
||||
static void RecordedPlayerHandleMoveAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleMoveAnimation(gActiveBattler, FALSE);
|
||||
BtlController_HandleMoveAnimation(battler, FALSE);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandlePrintString(void)
|
||||
static void RecordedPlayerHandlePrintString(u32 battler)
|
||||
{
|
||||
u16 *stringId;
|
||||
|
||||
gBattle_BG0_X = 0;
|
||||
gBattle_BG0_Y = 0;
|
||||
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
|
||||
stringId = (u16 *)(&gBattleResources->bufferA[battler][2]);
|
||||
BufferStringBattle(*stringId);
|
||||
|
||||
if (gTestRunnerEnabled)
|
||||
@ -439,38 +439,38 @@ static void RecordedPlayerHandlePrintString(void)
|
||||
TestRunner_Battle_RecordMessage(gDisplayedStringBattle);
|
||||
if (gTestRunnerHeadless)
|
||||
{
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
|
||||
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForString;
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForString;
|
||||
}
|
||||
|
||||
static void ChooseActionInBattlePalace(void)
|
||||
static void ChooseActionInBattlePalace(u32 battler)
|
||||
{
|
||||
if (gBattleCommunication[4] >= gBattlersCount / 2)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_BATTLE_PALACE_ACTION, gActiveBattler), 0);
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_BATTLE_PALACE_ACTION, battler), 0);
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleChooseAction(void)
|
||||
static void RecordedPlayerHandleChooseAction(u32 battler)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = ChooseActionInBattlePalace;
|
||||
gBattlerControllerFuncs[battler] = ChooseActionInBattlePalace;
|
||||
}
|
||||
else
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, gActiveBattler), 0);
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleChooseMove(void)
|
||||
static void RecordedPlayerHandleChooseMove(u32 battler)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
{
|
||||
@ -478,103 +478,103 @@ static void RecordedPlayerHandleChooseMove(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 moveId = RecordedBattle_GetBattlerAction(RECORDED_MOVE_SLOT, gActiveBattler);
|
||||
u8 target = RecordedBattle_GetBattlerAction(RECORDED_MOVE_TARGET, gActiveBattler);
|
||||
u8 moveId = RecordedBattle_GetBattlerAction(RECORDED_MOVE_SLOT, battler);
|
||||
u8 target = RecordedBattle_GetBattlerAction(RECORDED_MOVE_TARGET, battler);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, moveId | (target << 8));
|
||||
}
|
||||
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleChooseItem(void)
|
||||
static void RecordedPlayerHandleChooseItem(u32 battler)
|
||||
{
|
||||
u8 byte1 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler);
|
||||
u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler);
|
||||
gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2;
|
||||
gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler);
|
||||
gBattleStruct->itemMoveIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler);
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]);
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
u8 byte1 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, battler);
|
||||
u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, battler);
|
||||
gBattleStruct->chosenItem[battler] = (byte1 << 8) | byte2;
|
||||
gBattleStruct->itemPartyIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, battler);
|
||||
gBattleStruct->itemMoveIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, battler);
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[battler]);
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleChoosePokemon(void)
|
||||
static void RecordedPlayerHandleChoosePokemon(u32 battler)
|
||||
{
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, gActiveBattler);
|
||||
gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[gActiveBattler]; // Revival Blessing
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL);
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
*(gBattleStruct->monToSwitchIntoId + battler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler);
|
||||
gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[battler]; // Revival Blessing
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleHealthBarUpdate(void)
|
||||
static void RecordedPlayerHandleHealthBarUpdate(u32 battler)
|
||||
{
|
||||
s16 hpVal;
|
||||
s32 maxHP, curHP;
|
||||
|
||||
LoadBattleBarGfx(0);
|
||||
hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
|
||||
hpVal = gBattleResources->bufferA[battler][2] | (gBattleResources->bufferA[battler][3] << 8);
|
||||
|
||||
maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
|
||||
curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
|
||||
maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_MAX_HP);
|
||||
curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP);
|
||||
|
||||
if (hpVal != INSTANT_HP_BAR_DROP)
|
||||
{
|
||||
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
|
||||
TestRunner_Battle_RecordHP(gActiveBattler, curHP, min(maxHP, max(0, curHP - hpVal)));
|
||||
SetBattleBarStruct(battler, gHealthboxSpriteIds[battler], maxHP, curHP, hpVal);
|
||||
TestRunner_Battle_RecordHP(battler, curHP, min(maxHP, max(0, curHP - hpVal)));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
|
||||
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, 0, maxHP);
|
||||
TestRunner_Battle_RecordHP(gActiveBattler, curHP, 0);
|
||||
SetBattleBarStruct(battler, gHealthboxSpriteIds[battler], maxHP, 0, hpVal);
|
||||
UpdateHpTextInHealthbox(gHealthboxSpriteIds[battler], HP_CURRENT, 0, maxHP);
|
||||
TestRunner_Battle_RecordHP(battler, curHP, 0);
|
||||
}
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForHealthBar;
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForHealthBar;
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleStatusIconUpdate(void)
|
||||
static void RecordedPlayerHandleStatusIconUpdate(u32 battler)
|
||||
{
|
||||
if (!IsBattleSEPlaying(gActiveBattler))
|
||||
if (!IsBattleSEPlaying(battler))
|
||||
{
|
||||
DoStatusIconUpdate(gActiveBattler);
|
||||
DoStatusIconUpdate(battler);
|
||||
if (gTestRunnerEnabled)
|
||||
TestRunner_Battle_RecordStatus1(gActiveBattler, GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_STATUS));
|
||||
TestRunner_Battle_RecordStatus1(battler, GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_STATUS));
|
||||
}
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleStatusAnimation(void)
|
||||
static void RecordedPlayerHandleStatusAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleStatusAnimation();
|
||||
BtlController_HandleStatusAnimation(battler);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleIntroTrainerBallThrow(void)
|
||||
static void RecordedPlayerHandleIntroTrainerBallThrow(u32 battler)
|
||||
{
|
||||
u32 trainerPicId;
|
||||
const u32 *trainerPal;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK)
|
||||
trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender + TRAINER_BACK_PIC_BRENDAN;
|
||||
trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(battler)].gender + TRAINER_BACK_PIC_BRENDAN;
|
||||
else
|
||||
trainerPicId = gSaveBlock2Ptr->playerGender + TRAINER_BACK_PIC_BRENDAN;
|
||||
|
||||
trainerPal = gTrainerFrontPicPaletteTable[trainerPicId].data;
|
||||
BtlController_HandleIntroTrainerBallThrow(gActiveBattler, 0xD6F9, trainerPal, 24, Intro_TryShinyAnimShowHealthbox);
|
||||
BtlController_HandleIntroTrainerBallThrow(battler, 0xD6F9, trainerPal, 24, Intro_TryShinyAnimShowHealthbox);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleDrawPartyStatusSummary(void)
|
||||
static void RecordedPlayerHandleDrawPartyStatusSummary(u32 battler)
|
||||
{
|
||||
BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_PLAYER, TRUE);
|
||||
BtlController_HandleDrawPartyStatusSummary(battler, B_SIDE_PLAYER, TRUE);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleBattleAnimation(void)
|
||||
static void RecordedPlayerHandleBattleAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleBattleAnimation(gActiveBattler, FALSE, FALSE);
|
||||
BtlController_HandleBattleAnimation(battler, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleEndLinkBattle(void)
|
||||
static void RecordedPlayerHandleEndLinkBattle(u32 battler)
|
||||
{
|
||||
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1];
|
||||
gBattleOutcome = gBattleResources->bufferA[battler][1];
|
||||
FadeOutMapMusic(5);
|
||||
BeginFastPaletteFade(3);
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
gBattlerControllerFuncs[battler] = SetBattleEndCallbacks;
|
||||
}
|
||||
|
@ -25,24 +25,24 @@
|
||||
#include "constants/trainers.h"
|
||||
#include "constants/rgb.h"
|
||||
|
||||
static void SafariHandleDrawTrainerPic(void);
|
||||
static void SafariHandleSuccessBallThrowAnim(void);
|
||||
static void SafariHandleBallThrowAnim(void);
|
||||
static void SafariHandlePrintString(void);
|
||||
static void SafariHandlePrintSelectionString(void);
|
||||
static void SafariHandleChooseAction(void);
|
||||
static void SafariHandleChooseItem(void);
|
||||
static void SafariHandleStatusIconUpdate(void);
|
||||
static void SafariHandleFaintingCry(void);
|
||||
static void SafariHandleIntroTrainerBallThrow(void);
|
||||
static void SafariHandleBattleAnimation(void);
|
||||
static void SafariHandleEndLinkBattle(void);
|
||||
static void SafariHandleDrawTrainerPic(u32 battler);
|
||||
static void SafariHandleSuccessBallThrowAnim(u32 battler);
|
||||
static void SafariHandleBallThrowAnim(u32 battler);
|
||||
static void SafariHandlePrintString(u32 battler);
|
||||
static void SafariHandlePrintSelectionString(u32 battler);
|
||||
static void SafariHandleChooseAction(u32 battler);
|
||||
static void SafariHandleChooseItem(u32 battler);
|
||||
static void SafariHandleStatusIconUpdate(u32 battler);
|
||||
static void SafariHandleFaintingCry(u32 battler);
|
||||
static void SafariHandleIntroTrainerBallThrow(u32 battler);
|
||||
static void SafariHandleBattleAnimation(u32 battler);
|
||||
static void SafariHandleEndLinkBattle(u32 battler);
|
||||
|
||||
static void SafariBufferRunCommand(void);
|
||||
static void SafariBufferExecCompleted(void);
|
||||
static void CompleteWhenChosePokeblock(void);
|
||||
static void SafariBufferRunCommand(u32 battler);
|
||||
static void SafariBufferExecCompleted(u32 battler);
|
||||
static void CompleteWhenChosePokeblock(u32 battler);
|
||||
|
||||
static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
|
||||
{
|
||||
[CONTROLLER_GETMONDATA] = BtlController_Empty,
|
||||
[CONTROLLER_GETRAWMONDATA] = BtlController_Empty,
|
||||
@ -104,30 +104,30 @@ static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
|
||||
};
|
||||
|
||||
void SetControllerToSafari(void)
|
||||
void SetControllerToSafari(u32 battler)
|
||||
{
|
||||
gBattlerControllerEndFuncs[gActiveBattler] = SafariBufferExecCompleted;
|
||||
gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
|
||||
gBattlerControllerEndFuncs[battler] = SafariBufferExecCompleted;
|
||||
gBattlerControllerFuncs[battler] = SafariBufferRunCommand;
|
||||
}
|
||||
|
||||
static void SafariBufferRunCommand(void)
|
||||
static void SafariBufferRunCommand(u32 battler)
|
||||
{
|
||||
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
||||
if (gBattleControllerExecFlags & gBitTable[battler])
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sSafariBufferCommands))
|
||||
sSafariBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
|
||||
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sSafariBufferCommands))
|
||||
sSafariBufferCommands[gBattleResources->bufferA[battler][0]](battler);
|
||||
else
|
||||
SafariBufferExecCompleted();
|
||||
SafariBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void HandleInputChooseAction(void)
|
||||
static void HandleInputChooseAction(u32 battler)
|
||||
{
|
||||
if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
switch (gActionSelectionCursor[gActiveBattler])
|
||||
switch (gActionSelectionCursor[battler])
|
||||
{
|
||||
case 0:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_BALL, 0);
|
||||
@ -142,57 +142,57 @@ static void HandleInputChooseAction(void)
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_RUN, 0);
|
||||
break;
|
||||
}
|
||||
SafariBufferExecCompleted();
|
||||
SafariBufferExecCompleted(battler);
|
||||
}
|
||||
else if (JOY_NEW(DPAD_LEFT))
|
||||
{
|
||||
if (gActionSelectionCursor[gActiveBattler] & 1)
|
||||
if (gActionSelectionCursor[battler] & 1)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
||||
gActionSelectionCursor[gActiveBattler] ^= 1;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[battler]);
|
||||
gActionSelectionCursor[battler] ^= 1;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
||||
}
|
||||
}
|
||||
else if (JOY_NEW(DPAD_RIGHT))
|
||||
{
|
||||
if (!(gActionSelectionCursor[gActiveBattler] & 1))
|
||||
if (!(gActionSelectionCursor[battler] & 1))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
||||
gActionSelectionCursor[gActiveBattler] ^= 1;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[battler]);
|
||||
gActionSelectionCursor[battler] ^= 1;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
||||
}
|
||||
}
|
||||
else if (JOY_NEW(DPAD_UP))
|
||||
{
|
||||
if (gActionSelectionCursor[gActiveBattler] & 2)
|
||||
if (gActionSelectionCursor[battler] & 2)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
||||
gActionSelectionCursor[gActiveBattler] ^= 2;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[battler]);
|
||||
gActionSelectionCursor[battler] ^= 2;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
||||
}
|
||||
}
|
||||
else if (JOY_NEW(DPAD_DOWN))
|
||||
{
|
||||
if (!(gActionSelectionCursor[gActiveBattler] & 2))
|
||||
if (!(gActionSelectionCursor[battler] & 2))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
||||
gActionSelectionCursor[gActiveBattler] ^= 2;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[battler]);
|
||||
gActionSelectionCursor[battler] ^= 2;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Controller_WaitForHealthbox(void)
|
||||
static void Controller_WaitForHealthbox(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
SafariBufferExecCompleted();
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
SafariBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SafariSetBattleEndCallbacks(void)
|
||||
static void SafariSetBattleEndCallbacks(u32 battler)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
@ -202,140 +202,141 @@ static void SafariSetBattleEndCallbacks(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void SafariOpenPokeblockCase(void)
|
||||
static void SafariOpenPokeblockCase(u32 battler)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = CompleteWhenChosePokeblock;
|
||||
gBattlerControllerFuncs[battler] = CompleteWhenChosePokeblock;
|
||||
FreeAllWindowBuffers();
|
||||
OpenPokeblockCaseInBattle();
|
||||
}
|
||||
}
|
||||
|
||||
static void CompleteWhenChosePokeblock(void)
|
||||
static void CompleteWhenChosePokeblock(u32 battler)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId);
|
||||
SafariBufferExecCompleted();
|
||||
SafariBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void SafariBufferExecCompleted(void)
|
||||
static void SafariBufferExecCompleted(u32 battler)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
|
||||
gBattlerControllerFuncs[battler] = SafariBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
||||
gBattleControllerExecFlags &= ~gBitTable[battler];
|
||||
}
|
||||
}
|
||||
|
||||
static void SafariHandleDrawTrainerPic(void)
|
||||
static void SafariHandleDrawTrainerPic(u32 battler)
|
||||
{
|
||||
u32 trainerPicId = gSaveBlock2Ptr->playerGender + TRAINER_BACK_PIC_BRENDAN;
|
||||
|
||||
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, FALSE,
|
||||
BtlController_HandleDrawTrainerPic(battler, trainerPicId, FALSE,
|
||||
80, 80 + 4 * (8 - gTrainerBackPicCoords[trainerPicId].size),
|
||||
30);
|
||||
}
|
||||
|
||||
static void SafariHandleSuccessBallThrowAnim(void)
|
||||
static void SafariHandleSuccessBallThrowAnim(u32 battler)
|
||||
{
|
||||
BtlController_HandleSuccessBallThrowAnim(gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
||||
BtlController_HandleSuccessBallThrowAnim(battler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
||||
}
|
||||
|
||||
static void SafariHandleBallThrowAnim(void)
|
||||
static void SafariHandleBallThrowAnim(u32 battler)
|
||||
{
|
||||
BtlController_HandleBallThrowAnim(gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
||||
BtlController_HandleBallThrowAnim(battler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
||||
}
|
||||
|
||||
static void SafariHandlePrintString(void)
|
||||
static void SafariHandlePrintString(u32 battler)
|
||||
{
|
||||
BtlController_HandlePrintString(gActiveBattler, FALSE, FALSE);
|
||||
BtlController_HandlePrintString(battler, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void SafariHandlePrintSelectionString(void)
|
||||
static void SafariHandlePrintSelectionString(u32 battler)
|
||||
{
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
SafariHandlePrintString();
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
SafariHandlePrintString(battler);
|
||||
else
|
||||
SafariBufferExecCompleted();
|
||||
SafariBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void HandleChooseActionAfterDma3(void)
|
||||
static void HandleChooseActionAfterDma3(u32 battler)
|
||||
{
|
||||
if (!IsDma3ManagerBusyWithBgCopy())
|
||||
{
|
||||
gBattle_BG0_X = 0;
|
||||
gBattle_BG0_Y = DISPLAY_HEIGHT;
|
||||
gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseAction;
|
||||
gBattlerControllerFuncs[battler] = HandleInputChooseAction;
|
||||
}
|
||||
}
|
||||
|
||||
static void SafariHandleChooseAction(void)
|
||||
static void SafariHandleChooseAction(u32 battler)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3;
|
||||
gBattlerControllerFuncs[battler] = HandleChooseActionAfterDma3;
|
||||
BattlePutTextOnWindow(gText_SafariZoneMenu, B_WIN_ACTION_MENU);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
ActionSelectionDestroyCursorAt(i);
|
||||
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
||||
BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo2);
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_ACTION_PROMPT);
|
||||
}
|
||||
|
||||
static void SafariHandleChooseItem(void)
|
||||
static void SafariHandleChooseItem(u32 battler)
|
||||
{
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
||||
gBattlerControllerFuncs[gActiveBattler] = SafariOpenPokeblockCase;
|
||||
gBattlerInMenuId = gActiveBattler;
|
||||
gBattlerControllerFuncs[battler] = SafariOpenPokeblockCase;
|
||||
gBattlerInMenuId = battler;
|
||||
}
|
||||
|
||||
static void SafariHandleStatusIconUpdate(void)
|
||||
static void SafariHandleStatusIconUpdate(u32 battler)
|
||||
{
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_BALLS_TEXT);
|
||||
SafariBufferExecCompleted();
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_SAFARI_BALLS_TEXT);
|
||||
SafariBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
// All of the other controllers(except Wally's) use CRY_MODE_FAINT.
|
||||
// Player is not a pokemon, so it can't really faint in the Safari anyway.
|
||||
static void SafariHandleFaintingCry(void)
|
||||
static void SafariHandleFaintingCry(u32 battler)
|
||||
{
|
||||
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
|
||||
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
|
||||
|
||||
PlayCry_Normal(species, 25);
|
||||
SafariBufferExecCompleted();
|
||||
SafariBufferExecCompleted(battler);
|
||||
SafariBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SafariHandleIntroTrainerBallThrow(void)
|
||||
static void SafariHandleIntroTrainerBallThrow(u32 battler)
|
||||
{
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForHealthbox;
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_SAFARI_ALL_TEXT);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForHealthbox;
|
||||
}
|
||||
|
||||
static void SafariHandleBattleAnimation(void)
|
||||
static void SafariHandleBattleAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleBattleAnimation(gActiveBattler, TRUE, FALSE);
|
||||
BtlController_HandleBattleAnimation(battler, TRUE, FALSE);
|
||||
}
|
||||
|
||||
static void SafariHandleEndLinkBattle(void)
|
||||
static void SafariHandleEndLinkBattle(u32 battler)
|
||||
{
|
||||
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1];
|
||||
gBattleOutcome = gBattleResources->bufferA[battler][1];
|
||||
FadeOutMapMusic(5);
|
||||
BeginFastPaletteFade(3);
|
||||
SafariBufferExecCompleted();
|
||||
SafariBufferExecCompleted(battler);
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
|
||||
gBattlerControllerFuncs[gActiveBattler] = SafariSetBattleEndCallbacks;
|
||||
gBattlerControllerFuncs[battler] = SafariSetBattleEndCallbacks;
|
||||
}
|
||||
|
@ -32,30 +32,30 @@
|
||||
#include "constants/trainers.h"
|
||||
#include "constants/rgb.h"
|
||||
|
||||
static void WallyHandleDrawTrainerPic(void);
|
||||
static void WallyHandleTrainerSlide(void);
|
||||
static void WallyHandleSuccessBallThrowAnim(void);
|
||||
static void WallyHandleBallThrowAnim(void);
|
||||
static void WallyHandleMoveAnimation(void);
|
||||
static void WallyHandlePrintString(void);
|
||||
static void WallyHandlePrintSelectionString(void);
|
||||
static void WallyHandleChooseAction(void);
|
||||
static void WallyHandleChooseMove(void);
|
||||
static void WallyHandleChooseItem(void);
|
||||
static void WallyHandleHealthBarUpdate(void);
|
||||
static void WallyHandlePlaySE(void);
|
||||
static void WallyHandleFaintingCry(void);
|
||||
static void WallyHandleIntroTrainerBallThrow(void);
|
||||
static void WallyHandleDrawPartyStatusSummary(void);
|
||||
static void WallyHandleBattleAnimation(void);
|
||||
static void WallyHandleEndLinkBattle(void);
|
||||
static void WallyHandleDrawTrainerPic(u32 battler);
|
||||
static void WallyHandleTrainerSlide(u32 battler);
|
||||
static void WallyHandleSuccessBallThrowAnim(u32 battler);
|
||||
static void WallyHandleBallThrowAnim(u32 battler);
|
||||
static void WallyHandleMoveAnimation(u32 battler);
|
||||
static void WallyHandlePrintString(u32 battler);
|
||||
static void WallyHandlePrintSelectionString(u32 battler);
|
||||
static void WallyHandleChooseAction(u32 battler);
|
||||
static void WallyHandleChooseMove(u32 battler);
|
||||
static void WallyHandleChooseItem(u32 battler);
|
||||
static void WallyHandleHealthBarUpdate(u32 battler);
|
||||
static void WallyHandlePlaySE(u32 battler);
|
||||
static void WallyHandleFaintingCry(u32 battler);
|
||||
static void WallyHandleIntroTrainerBallThrow(u32 battler);
|
||||
static void WallyHandleDrawPartyStatusSummary(u32 battler);
|
||||
static void WallyHandleBattleAnimation(u32 battler);
|
||||
static void WallyHandleEndLinkBattle(u32 battler);
|
||||
|
||||
static void WallyBufferRunCommand(void);
|
||||
static void WallyBufferExecCompleted(void);
|
||||
static void CompleteOnChosenItem(void);
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(void);
|
||||
static void WallyBufferRunCommand(u32 battler);
|
||||
static void WallyBufferExecCompleted(u32 battler);
|
||||
static void CompleteOnChosenItem(u32 battler);
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(u32 battler);
|
||||
|
||||
static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
|
||||
{
|
||||
[CONTROLLER_GETMONDATA] = BtlController_HandleGetMonData,
|
||||
[CONTROLLER_GETRAWMONDATA] = BtlController_HandleGetRawMonData,
|
||||
@ -117,28 +117,28 @@ static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
|
||||
};
|
||||
|
||||
void SetControllerToWally(void)
|
||||
void SetControllerToWally(u32 battler)
|
||||
{
|
||||
gBattlerControllerEndFuncs[gActiveBattler] = WallyBufferExecCompleted;
|
||||
gBattlerControllerFuncs[gActiveBattler] = WallyBufferRunCommand;
|
||||
gBattlerControllerEndFuncs[battler] = WallyBufferExecCompleted;
|
||||
gBattlerControllerFuncs[battler] = WallyBufferRunCommand;
|
||||
gBattleStruct->wallyBattleState = 0;
|
||||
gBattleStruct->wallyMovesState = 0;
|
||||
gBattleStruct->wallyWaitFrames = 0;
|
||||
gBattleStruct->wallyMoveFrames = 0;
|
||||
}
|
||||
|
||||
static void WallyBufferRunCommand(void)
|
||||
static void WallyBufferRunCommand(u32 battler)
|
||||
{
|
||||
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
||||
if (gBattleControllerExecFlags & gBitTable[battler])
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sWallyBufferCommands))
|
||||
sWallyBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
|
||||
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sWallyBufferCommands))
|
||||
sWallyBufferCommands[gBattleResources->bufferA[battler][0]](battler);
|
||||
else
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void WallyHandleActions(void)
|
||||
static void WallyHandleActions(u32 battler)
|
||||
{
|
||||
switch (gBattleStruct->wallyBattleState)
|
||||
{
|
||||
@ -150,7 +150,7 @@ static void WallyHandleActions(void)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0);
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
gBattleStruct->wallyBattleState++;
|
||||
gBattleStruct->wallyMovesState = 0;
|
||||
gBattleStruct->wallyWaitFrames = B_WAIT_TIME_LONG;
|
||||
@ -161,7 +161,7 @@ static void WallyHandleActions(void)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0);
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
gBattleStruct->wallyBattleState++;
|
||||
gBattleStruct->wallyMovesState = 0;
|
||||
gBattleStruct->wallyWaitFrames = B_WAIT_TIME_LONG;
|
||||
@ -171,7 +171,7 @@ static void WallyHandleActions(void)
|
||||
if (--gBattleStruct->wallyWaitFrames == 0)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_WALLY_THROW, 0);
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
gBattleStruct->wallyBattleState++;
|
||||
gBattleStruct->wallyMovesState = 0;
|
||||
gBattleStruct->wallyWaitFrames = B_WAIT_TIME_LONG;
|
||||
@ -192,187 +192,181 @@ static void WallyHandleActions(void)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0);
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void CompleteOnBattlerSpriteCallbackDummy(void)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
WallyBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void OpenBagAfterPaletteFade(void)
|
||||
static void OpenBagAfterPaletteFade(u32 battler)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = CompleteOnChosenItem;
|
||||
gBattlerControllerFuncs[battler] = CompleteOnChosenItem;
|
||||
ReshowBattleScreenDummy();
|
||||
FreeAllWindowBuffers();
|
||||
DoWallyTutorialBagMenu();
|
||||
}
|
||||
}
|
||||
|
||||
static void CompleteOnChosenItem(void)
|
||||
static void CompleteOnChosenItem(u32 battler)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId);
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_TryShinyAnimShowHealthbox(void)
|
||||
static void Intro_TryShinyAnimShowHealthbox(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
TryShinyAnimation(battler, &gPlayerParty[gBattlerPartyIndexes[battler]]);
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
|
||||
TryShinyAnimation(BATTLE_PARTNER(gActiveBattler), &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive)
|
||||
TryShinyAnimation(BATTLE_PARTNER(battler), &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]);
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive
|
||||
&& gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].ballAnimActive
|
||||
&& gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]);
|
||||
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(battler)]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battler)], &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(BATTLE_PARTNER(battler));
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(battler)]);
|
||||
}
|
||||
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
|
||||
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
gBattlerControllerFuncs[battler] = Intro_WaitForShinyAnimAndHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(void)
|
||||
static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
|
||||
{
|
||||
bool32 healthboxAnimDone = FALSE;
|
||||
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
healthboxAnimDone = TRUE;
|
||||
|
||||
if (healthboxAnimDone && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim)
|
||||
if (healthboxAnimDone && gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
&& gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
|
||||
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void WallyBufferExecCompleted(void)
|
||||
static void WallyBufferExecCompleted(u32 battler)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = WallyBufferRunCommand;
|
||||
gBattlerControllerFuncs[battler] = WallyBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
||||
gBattleControllerExecFlags &= ~gBitTable[battler];
|
||||
}
|
||||
}
|
||||
|
||||
#define sSpeedX data[0]
|
||||
|
||||
static void WallyHandleDrawTrainerPic(void)
|
||||
static void WallyHandleDrawTrainerPic(u32 battler)
|
||||
{
|
||||
BtlController_HandleDrawTrainerPic(gActiveBattler, TRAINER_BACK_PIC_WALLY, FALSE,
|
||||
BtlController_HandleDrawTrainerPic(battler, TRAINER_BACK_PIC_WALLY, FALSE,
|
||||
80, 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size),
|
||||
30);
|
||||
}
|
||||
|
||||
static void WallyHandleTrainerSlide(void)
|
||||
static void WallyHandleTrainerSlide(u32 battler)
|
||||
{
|
||||
BtlController_HandleTrainerSlide(gActiveBattler, TRAINER_BACK_PIC_WALLY);
|
||||
BtlController_HandleTrainerSlide(battler, TRAINER_BACK_PIC_WALLY);
|
||||
}
|
||||
|
||||
#undef sSpeedX
|
||||
|
||||
static void WallyHandleSuccessBallThrowAnim(void)
|
||||
static void WallyHandleSuccessBallThrowAnim(u32 battler)
|
||||
{
|
||||
BtlController_HandleSuccessBallThrowAnim(gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
||||
BtlController_HandleSuccessBallThrowAnim(battler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
||||
}
|
||||
|
||||
static void WallyHandleBallThrowAnim(void)
|
||||
static void WallyHandleBallThrowAnim(u32 battler)
|
||||
{
|
||||
BtlController_HandleBallThrowAnim(gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
||||
BtlController_HandleBallThrowAnim(battler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
||||
}
|
||||
|
||||
static void WallyHandleMoveAnimation(void)
|
||||
static void WallyHandleMoveAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleMoveAnimation(gActiveBattler, FALSE);
|
||||
BtlController_HandleMoveAnimation(battler, FALSE);
|
||||
}
|
||||
|
||||
static void WallyHandlePrintString(void)
|
||||
static void WallyHandlePrintString(u32 battler)
|
||||
{
|
||||
BtlController_HandlePrintString(gActiveBattler, FALSE, FALSE);
|
||||
BtlController_HandlePrintString(battler, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void WallyHandlePrintSelectionString(void)
|
||||
static void WallyHandlePrintSelectionString(u32 battler)
|
||||
{
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
WallyHandlePrintString();
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
WallyHandlePrintString(battler);
|
||||
else
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void HandleChooseActionAfterDma3(void)
|
||||
static void HandleChooseActionAfterDma3(u32 battler)
|
||||
{
|
||||
if (!IsDma3ManagerBusyWithBgCopy())
|
||||
{
|
||||
gBattle_BG0_X = 0;
|
||||
gBattle_BG0_Y = DISPLAY_HEIGHT;
|
||||
gBattlerControllerFuncs[gActiveBattler] = WallyHandleActions;
|
||||
gBattlerControllerFuncs[battler] = WallyHandleActions;
|
||||
}
|
||||
}
|
||||
|
||||
static void WallyHandleChooseAction(void)
|
||||
static void WallyHandleChooseAction(u32 battler)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3;
|
||||
gBattlerControllerFuncs[battler] = HandleChooseActionAfterDma3;
|
||||
BattlePutTextOnWindow(gText_BattleMenu, B_WIN_ACTION_MENU);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
ActionSelectionDestroyCursorAt(i);
|
||||
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
||||
BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillWallyDo);
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_ACTION_PROMPT);
|
||||
}
|
||||
|
||||
static void WallyHandleChooseMove(void)
|
||||
static void WallyHandleChooseMove(u32 battler)
|
||||
{
|
||||
switch (gBattleStruct->wallyMovesState)
|
||||
{
|
||||
case 0:
|
||||
InitMoveSelectionsVarsAndStrings();
|
||||
InitMoveSelectionsVarsAndStrings(battler);
|
||||
gBattleStruct->wallyMovesState++;
|
||||
gBattleStruct->wallyMoveFrames = 80;
|
||||
break;
|
||||
@ -389,64 +383,64 @@ static void WallyHandleChooseMove(void)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0x100);
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void WallyHandleChooseItem(void)
|
||||
static void WallyHandleChooseItem(u32 battler)
|
||||
{
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
||||
gBattlerControllerFuncs[gActiveBattler] = OpenBagAfterPaletteFade;
|
||||
gBattlerInMenuId = gActiveBattler;
|
||||
gBattlerControllerFuncs[battler] = OpenBagAfterPaletteFade;
|
||||
gBattlerInMenuId = battler;
|
||||
}
|
||||
|
||||
static void WallyHandleHealthBarUpdate(void)
|
||||
static void WallyHandleHealthBarUpdate(u32 battler)
|
||||
{
|
||||
BtlController_HandleHealthBarUpdate(gActiveBattler, TRUE);
|
||||
BtlController_HandleHealthBarUpdate(battler, TRUE);
|
||||
}
|
||||
|
||||
// For some reason Wally's SE don't take side into account and pan is always the same. Possibly a bug
|
||||
static void WallyHandlePlaySE(void)
|
||||
static void WallyHandlePlaySE(u32 battler)
|
||||
{
|
||||
PlaySE(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8));
|
||||
WallyBufferExecCompleted();
|
||||
PlaySE(gBattleResources->bufferA[battler][1] | (gBattleResources->bufferA[battler][2] << 8));
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
// All of the other controllers use CRY_MODE_FAINT.
|
||||
// Wally's Pokémon during the tutorial is never intended to faint, so that's probably why it's different here.
|
||||
static void WallyHandleFaintingCry(void)
|
||||
static void WallyHandleFaintingCry(u32 battler)
|
||||
{
|
||||
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
|
||||
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
|
||||
|
||||
PlayCry_Normal(species, 25);
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void WallyHandleIntroTrainerBallThrow(void)
|
||||
static void WallyHandleIntroTrainerBallThrow(u32 battler)
|
||||
{
|
||||
const u32 *trainerPal = gTrainerBackPicPaletteTable[TRAINER_BACK_PIC_WALLY].data;
|
||||
BtlController_HandleIntroTrainerBallThrow(gActiveBattler, 0xD6F8, trainerPal, 31, Intro_TryShinyAnimShowHealthbox);
|
||||
BtlController_HandleIntroTrainerBallThrow(battler, 0xD6F8, trainerPal, 31, Intro_TryShinyAnimShowHealthbox);
|
||||
}
|
||||
|
||||
static void WallyHandleDrawPartyStatusSummary(void)
|
||||
static void WallyHandleDrawPartyStatusSummary(u32 battler)
|
||||
{
|
||||
BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_PLAYER, FALSE);
|
||||
BtlController_HandleDrawPartyStatusSummary(battler, B_SIDE_PLAYER, FALSE);
|
||||
}
|
||||
|
||||
static void WallyHandleBattleAnimation(void)
|
||||
static void WallyHandleBattleAnimation(u32 battler)
|
||||
{
|
||||
BtlController_HandleBattleAnimation(gActiveBattler, TRUE, FALSE);
|
||||
BtlController_HandleBattleAnimation(battler, TRUE, FALSE);
|
||||
}
|
||||
|
||||
static void WallyHandleEndLinkBattle(void)
|
||||
static void WallyHandleEndLinkBattle(u32 battler)
|
||||
{
|
||||
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1];
|
||||
gBattleOutcome = gBattleResources->bufferA[battler][1];
|
||||
FadeOutMapMusic(5);
|
||||
BeginFastPaletteFade(3);
|
||||
WallyBufferExecCompleted();
|
||||
WallyBufferExecCompleted(battler);
|
||||
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER) && gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
|
||||
gBattlerControllerFuncs[battler] = SetBattleEndCallbacks;
|
||||
}
|
||||
|
@ -25,10 +25,13 @@
|
||||
|
||||
static EWRAM_DATA u8 sLinkSendTaskId = 0;
|
||||
static EWRAM_DATA u8 sLinkReceiveTaskId = 0;
|
||||
EWRAM_DATA void (*gBattlerControllerEndFuncs[MAX_BATTLERS_COUNT])(void) = {NULL}; // Controller's buffer complete function for each battler
|
||||
EWRAM_DATA struct UnusedControllerStruct gUnusedControllerStruct = {}; // Debug? Unused code that writes to it, never read
|
||||
static EWRAM_DATA u8 sBattleBuffersTransferData[0x100] = {};
|
||||
|
||||
void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(u32 battler);
|
||||
u8 gBattleControllerData[MAX_BATTLERS_COUNT]; // Used by the battle controllers to store misc sprite/task IDs for each battler
|
||||
void (*gBattlerControllerEndFuncs[MAX_BATTLERS_COUNT])(u32 battler); // Controller's buffer complete function for each battler
|
||||
|
||||
static void CreateTasksForSendRecvLinkBuffers(void);
|
||||
static void InitLinkBtlControllers(void);
|
||||
static void InitSinglePlayerBtlControllers(void);
|
||||
@ -1562,7 +1565,7 @@ void BtlController_EmitDebugMenu(u8 bufferId)
|
||||
// Can be used for all the controllers.
|
||||
void BattleControllerComplete(u32 battler)
|
||||
{
|
||||
gBattlerControllerEndFuncs[battler]();
|
||||
gBattlerControllerEndFuncs[battler](battler);
|
||||
}
|
||||
|
||||
static u32 GetBattlerMonData(u32 battler, struct Pokemon *party, u32 monId, u8 *dst)
|
||||
@ -2133,186 +2136,186 @@ static void FreeMonSprite(u32 battler)
|
||||
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[battler]);
|
||||
}
|
||||
|
||||
static void Controller_ReturnMonToBall2(void)
|
||||
static void Controller_ReturnMonToBall2(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive)
|
||||
{
|
||||
FreeMonSprite(gActiveBattler);
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
FreeMonSprite(battler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Controller_ReturnMonToBall(void)
|
||||
static void Controller_ReturnMonToBall(u32 battler)
|
||||
{
|
||||
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
|
||||
switch (gBattleSpritesDataPtr->healthBoxesData[battler].animationState)
|
||||
{
|
||||
case 0:
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_SUBSTITUTE_TO_MON);
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].animationState = 1;
|
||||
break;
|
||||
case 1:
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) ? B_ANIM_SWITCH_OUT_OPPONENT_MON : B_ANIM_SWITCH_OUT_PLAYER_MON);
|
||||
gBattlerControllerFuncs[gActiveBattler] = Controller_ReturnMonToBall2;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].animationState = 0;
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, (GetBattlerSide(battler) == B_SIDE_OPPONENT) ? B_ANIM_SWITCH_OUT_OPPONENT_MON : B_ANIM_SWITCH_OUT_PLAYER_MON);
|
||||
gBattlerControllerFuncs[battler] = Controller_ReturnMonToBall2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void Controller_FaintPlayerMon(void)
|
||||
static void Controller_FaintPlayerMon(u32 battler)
|
||||
{
|
||||
u32 spriteId = gBattlerSpriteIds[gActiveBattler];
|
||||
u32 spriteId = gBattlerSpriteIds[battler];
|
||||
if (gSprites[spriteId].y + gSprites[spriteId].y2 > DISPLAY_HEIGHT)
|
||||
{
|
||||
BattleGfxSfxDummy2(GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
|
||||
BattleGfxSfxDummy2(GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES));
|
||||
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
|
||||
DestroySprite(&gSprites[spriteId]);
|
||||
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[battler]);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Controller_FaintOpponentMon(void)
|
||||
static void Controller_FaintOpponentMon(u32 battler)
|
||||
{
|
||||
if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse)
|
||||
if (!gSprites[gBattlerSpriteIds[battler]].inUse)
|
||||
{
|
||||
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[battler]);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Controller_DoMoveAnimation(void)
|
||||
static void Controller_DoMoveAnimation(u32 battler)
|
||||
{
|
||||
u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8);
|
||||
u16 move = gBattleResources->bufferA[battler][1] | (gBattleResources->bufferA[battler][2] << 8);
|
||||
|
||||
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
|
||||
switch (gBattleSpritesDataPtr->healthBoxesData[battler].animationState)
|
||||
{
|
||||
case 0:
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
|
||||
&& !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute
|
||||
&& !gBattleSpritesDataPtr->battlerData[battler].flag_x8)
|
||||
{
|
||||
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
|
||||
gBattleSpritesDataPtr->battlerData[battler].flag_x8 = 1;
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_SUBSTITUTE_TO_MON);
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].animationState = 1;
|
||||
break;
|
||||
case 1:
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive)
|
||||
{
|
||||
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
|
||||
DoMoveAnim(move);
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].animationState = 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
gAnimScriptCallback();
|
||||
if (!gAnimScriptActive)
|
||||
{
|
||||
u8 multihit = gBattleResources->bufferA[gActiveBattler][11];
|
||||
u8 multihit = gBattleResources->bufferA[battler][11];
|
||||
|
||||
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute && multihit < 2)
|
||||
{
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
gBattleSpritesDataPtr->battlerData[battler].flag_x8 = 0;
|
||||
}
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].animationState = 3;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive)
|
||||
{
|
||||
CopyAllBattleSpritesInvisibilities();
|
||||
TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8));
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
TrySetBehindSubstituteSpriteBit(battler, gBattleResources->bufferA[battler][1] | (gBattleResources->bufferA[battler][2] << 8));
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].animationState = 0;
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void Controller_HandleTrainerSlideBack(void)
|
||||
static void Controller_HandleTrainerSlideBack(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT)
|
||||
FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam);
|
||||
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
|
||||
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
|
||||
FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[battler]].oam.affineParam);
|
||||
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[battler]]);
|
||||
DestroySprite(&gSprites[gBattlerSpriteIds[battler]]);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
}
|
||||
|
||||
void Controller_WaitForHealthBar(void)
|
||||
void Controller_WaitForHealthBar(u32 battler)
|
||||
{
|
||||
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
|
||||
s16 hpValue = MoveBattleBar(battler, gHealthboxSpriteIds[battler], HEALTH_BAR, 0);
|
||||
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
if (hpValue != -1)
|
||||
{
|
||||
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
|
||||
UpdateHpTextInHealthbox(gHealthboxSpriteIds[battler], HP_CURRENT, hpValue, gBattleMons[battler].maxHP);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Controller_WaitForBallThrow(void)
|
||||
static void Controller_WaitForBallThrow(u32 battler)
|
||||
{
|
||||
if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive)
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
static void Controller_WaitForBattleAnimation(void)
|
||||
static void Controller_WaitForBattleAnimation(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive)
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].animFromTableActive)
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
static void Controller_WaitForStatusAnimation(void)
|
||||
static void Controller_WaitForStatusAnimation(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive)
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].statusAnimActive)
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
static void Controller_WaitForTrainerPic(void)
|
||||
static void Controller_WaitForTrainerPic(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void Controller_WaitForString(void)
|
||||
void Controller_WaitForString(u32 battler)
|
||||
{
|
||||
if (!IsTextPrinterActive(B_WIN_MSG))
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
static void Controller_WaitForPartyStatusSummary(void)
|
||||
static void Controller_WaitForPartyStatusSummary(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].partyStatusDelayTimer++ > 92)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].partyStatusDelayTimer = 0;
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void Controller_HitAnimation(void)
|
||||
static void Controller_HitAnimation(u32 battler)
|
||||
{
|
||||
u32 spriteId = gBattlerSpriteIds[gActiveBattler];
|
||||
u32 spriteId = gBattlerSpriteIds[battler];
|
||||
|
||||
if (gSprites[spriteId].data[1] == 32)
|
||||
{
|
||||
gSprites[spriteId].data[1] = 0;
|
||||
gSprites[spriteId].invisible = FALSE;
|
||||
gDoingBattleAnim = FALSE;
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2323,21 +2326,24 @@ static void Controller_HitAnimation(void)
|
||||
}
|
||||
|
||||
// Used for all the commands which do nothing.
|
||||
void BtlController_Empty(void)
|
||||
void BtlController_Empty(u32 battler)
|
||||
{
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
// Dummy function at the end of the table.
|
||||
void BtlController_TerminatorNop(void)
|
||||
void BtlController_TerminatorNop(u32 battler)
|
||||
{
|
||||
}
|
||||
|
||||
void BattleControllerDummy(u32 battler)
|
||||
{
|
||||
}
|
||||
|
||||
// Handlers of the controller commands
|
||||
void BtlController_HandleGetMonData(void)
|
||||
void BtlController_HandleGetMonData(u32 battler)
|
||||
{
|
||||
u8 monData[sizeof(struct Pokemon) * 2 + 56]; // this allows to get full data of two pokemon, trying to get more will result in overwriting data
|
||||
u32 battler = gActiveBattler;
|
||||
struct Pokemon *party = GetBattlerParty(battler);
|
||||
u32 size = 0;
|
||||
u8 monToCheck;
|
||||
@ -2361,10 +2367,9 @@ void BtlController_HandleGetMonData(void)
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleGetRawMonData(void)
|
||||
void BtlController_HandleGetRawMonData(u32 battler)
|
||||
{
|
||||
struct BattlePokemon battleMon;
|
||||
u32 battler = gActiveBattler;
|
||||
struct Pokemon *party = GetBattlerParty(battler);
|
||||
|
||||
u8 *src = (u8 *)&party[gBattlerPartyIndexes[battler]] + gBattleResources->bufferA[battler][1];
|
||||
@ -2378,9 +2383,8 @@ void BtlController_HandleGetRawMonData(void)
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleSetMonData(void)
|
||||
void BtlController_HandleSetMonData(u32 battler)
|
||||
{
|
||||
u32 battler = gActiveBattler;
|
||||
struct Pokemon *party = GetBattlerParty(battler);
|
||||
u32 i, monToCheck;
|
||||
|
||||
@ -2401,10 +2405,9 @@ void BtlController_HandleSetMonData(void)
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleSetRawMonData(void)
|
||||
void BtlController_HandleSetRawMonData(u32 battler)
|
||||
{
|
||||
u32 i;
|
||||
u32 battler = gActiveBattler;
|
||||
struct Pokemon *party = GetBattlerParty(battler);
|
||||
u8 *dst = (u8 *)&party[gBattlerPartyIndexes[battler]] + gBattleResources->bufferA[battler][1];
|
||||
|
||||
@ -2414,7 +2417,7 @@ void BtlController_HandleSetRawMonData(void)
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void (*controllerCallback)(void))
|
||||
void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void (*controllerCallback)(u32 battler))
|
||||
{
|
||||
u16 species = GetMonData(&party[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
|
||||
|
||||
@ -2437,7 +2440,7 @@ void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void
|
||||
gBattlerControllerFuncs[battler] = controllerCallback;
|
||||
}
|
||||
|
||||
void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerCallback)(void))
|
||||
void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerCallback)(u32 battler))
|
||||
{
|
||||
if (isPlayerSide)
|
||||
ClearTemporarySpeciesSpriteData(battler, gBattleResources->bufferA[battler][2]);
|
||||
@ -2448,17 +2451,17 @@ void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*c
|
||||
gBattlerControllerFuncs[battler] = controllerCallback;
|
||||
}
|
||||
|
||||
void BtlController_HandleReturnMonToBall(void)
|
||||
void BtlController_HandleReturnMonToBall(u32 battler)
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][1] == 0)
|
||||
if (gBattleResources->bufferA[battler][1] == 0)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
|
||||
gBattlerControllerFuncs[gActiveBattler] = Controller_ReturnMonToBall;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].animationState = 0;
|
||||
gBattlerControllerFuncs[battler] = Controller_ReturnMonToBall;
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeMonSprite(gActiveBattler);
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
FreeMonSprite(battler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2578,9 +2581,8 @@ void BtlController_HandleTrainerSlideBack(u32 battlerId, s16 data0, bool32 start
|
||||
#define sSpeedX data[1]
|
||||
#define sSpeedY data[2]
|
||||
|
||||
void BtlController_HandleFaintAnimation(void)
|
||||
void BtlController_HandleFaintAnimation(u32 battler)
|
||||
{
|
||||
u32 battler = gActiveBattler;
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].animationState == 0)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
@ -2711,92 +2713,92 @@ void DoStatusIconUpdate(u32 battler)
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForStatusAnimation;
|
||||
}
|
||||
|
||||
void BtlController_HandleStatusIconUpdate(void)
|
||||
void BtlController_HandleStatusIconUpdate(u32 battler)
|
||||
{
|
||||
if (!IsBattleSEPlaying(gActiveBattler))
|
||||
if (!IsBattleSEPlaying(battler))
|
||||
{
|
||||
DoStatusIconUpdate(gActiveBattler);
|
||||
DoStatusIconUpdate(battler);
|
||||
}
|
||||
}
|
||||
|
||||
void BtlController_HandleStatusAnimation(void)
|
||||
void BtlController_HandleStatusAnimation(u32 battler)
|
||||
{
|
||||
if (!IsBattleSEPlaying(gActiveBattler))
|
||||
if (!IsBattleSEPlaying(battler))
|
||||
{
|
||||
InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1],
|
||||
gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24));
|
||||
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForStatusAnimation;
|
||||
InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[battler][1],
|
||||
gBattleResources->bufferA[battler][2] | (gBattleResources->bufferA[battler][3] << 8) | (gBattleResources->bufferA[battler][4] << 16) | (gBattleResources->bufferA[battler][5] << 24));
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForStatusAnimation;
|
||||
}
|
||||
}
|
||||
|
||||
void BtlController_HandleClearUnkVar(void)
|
||||
void BtlController_HandleClearUnkVar(u32 battler)
|
||||
{
|
||||
gUnusedControllerStruct.unk = 0;
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleSetUnkVar(void)
|
||||
void BtlController_HandleSetUnkVar(u32 battler)
|
||||
{
|
||||
gUnusedControllerStruct.unk = gBattleResources->bufferA[gActiveBattler][1];
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
gUnusedControllerStruct.unk = gBattleResources->bufferA[battler][1];
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleClearUnkFlag(void)
|
||||
void BtlController_HandleClearUnkFlag(u32 battler)
|
||||
{
|
||||
gUnusedControllerStruct.flag = 0;
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleToggleUnkFlag(void)
|
||||
void BtlController_HandleToggleUnkFlag(u32 battler)
|
||||
{
|
||||
gUnusedControllerStruct.flag ^= 1;
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleHitAnimation(void)
|
||||
void BtlController_HandleHitAnimation(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
|
||||
if (gSprites[gBattlerSpriteIds[battler]].invisible == TRUE)
|
||||
{
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
else
|
||||
{
|
||||
gDoingBattleAnim = TRUE;
|
||||
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
|
||||
DoHitAnimHealthboxEffect(gActiveBattler);
|
||||
gBattlerControllerFuncs[gActiveBattler] = Controller_HitAnimation;
|
||||
gSprites[gBattlerSpriteIds[battler]].data[1] = 0;
|
||||
DoHitAnimHealthboxEffect(battler);
|
||||
gBattlerControllerFuncs[battler] = Controller_HitAnimation;
|
||||
}
|
||||
}
|
||||
|
||||
void BtlController_HandlePlaySE(void)
|
||||
void BtlController_HandlePlaySE(u32 battler)
|
||||
{
|
||||
s8 pan = (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) ? SOUND_PAN_ATTACKER : SOUND_PAN_TARGET;
|
||||
s8 pan = (GetBattlerSide(battler) == B_SIDE_PLAYER) ? SOUND_PAN_ATTACKER : SOUND_PAN_TARGET;
|
||||
|
||||
PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan);
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
PlaySE12WithPanning(gBattleResources->bufferA[battler][1] | (gBattleResources->bufferA[battler][2] << 8), pan);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandlePlayFanfareOrBGM(void)
|
||||
void BtlController_HandlePlayFanfareOrBGM(u32 battler)
|
||||
{
|
||||
if (gBattleResources->bufferA[gActiveBattler][3])
|
||||
if (gBattleResources->bufferA[battler][3])
|
||||
{
|
||||
BattleStopLowHpSound();
|
||||
PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8));
|
||||
PlayBGM(gBattleResources->bufferA[battler][1] | (gBattleResources->bufferA[battler][2] << 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8));
|
||||
PlayFanfare(gBattleResources->bufferA[battler][1] | (gBattleResources->bufferA[battler][2] << 8));
|
||||
}
|
||||
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleFaintingCry(void)
|
||||
void BtlController_HandleFaintingCry(u32 battler)
|
||||
{
|
||||
struct Pokemon *party;
|
||||
s8 pan;
|
||||
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
{
|
||||
party = gPlayerParty;
|
||||
pan = -25;
|
||||
@ -2807,25 +2809,25 @@ void BtlController_HandleFaintingCry(void)
|
||||
pan = 25;
|
||||
}
|
||||
|
||||
PlayCry_ByMode(GetMonData(&party[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES), pan, CRY_MODE_FAINT);
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
PlayCry_ByMode(GetMonData(&party[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), pan, CRY_MODE_FAINT);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleIntroSlide(void)
|
||||
void BtlController_HandleIntroSlide(u32 battler)
|
||||
{
|
||||
HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]);
|
||||
HandleIntroSlide(gBattleResources->bufferA[battler][1]);
|
||||
gIntroSlideFlags |= 1;
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleSpriteInvisibility(void)
|
||||
void BtlController_HandleSpriteInvisibility(u32 battler)
|
||||
{
|
||||
if (IsBattlerSpritePresent(gActiveBattler))
|
||||
if (IsBattlerSpritePresent(battler))
|
||||
{
|
||||
gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleResources->bufferA[gActiveBattler][1];
|
||||
CopyBattleSpriteInvisibility(gActiveBattler);
|
||||
gSprites[gBattlerSpriteIds[battler]].invisible = gBattleResources->bufferA[battler][1];
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
}
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
bool32 TwoPlayerIntroMons(u32 battler) // Double battle with both player pokemon active.
|
||||
@ -2850,7 +2852,7 @@ bool32 TwoOpponentIntroMons(u32 battler) // Double battle with both opponent pok
|
||||
// Sprite data for SpriteCB_FreePlayerSpriteLoadMonSprite
|
||||
#define sBattlerId data[5]
|
||||
|
||||
void BtlController_HandleIntroTrainerBallThrow(u32 battler, u16 tagTrainerPal, const u32 *trainerPal, s16 framesToWait, void (*controllerCallback)(void))
|
||||
void BtlController_HandleIntroTrainerBallThrow(u32 battler, u16 tagTrainerPal, const u32 *trainerPal, s16 framesToWait, void (*controllerCallback)(u32 battler))
|
||||
{
|
||||
u8 paletteNum, taskId;
|
||||
u32 side = GetBattlerSide(battler);
|
||||
@ -2863,8 +2865,8 @@ void BtlController_HandleIntroTrainerBallThrow(u32 battler, u16 tagTrainerPal, c
|
||||
}
|
||||
else
|
||||
{
|
||||
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
|
||||
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
|
||||
gSprites[gBattlerSpriteIds[battler]].data[0] = 35;
|
||||
gSprites[gBattlerSpriteIds[battler]].data[2] = 280;
|
||||
}
|
||||
|
||||
gSprites[gBattlerSpriteIds[battler]].data[4] = gSprites[gBattlerSpriteIds[battler]].y;
|
||||
@ -3014,11 +3016,11 @@ void BtlController_HandleDrawPartyStatusSummary(u32 battler, u32 side, bool32 co
|
||||
}
|
||||
}
|
||||
|
||||
void BtlController_HandleHidePartyStatusSummary(void)
|
||||
void BtlController_HandleHidePartyStatusSummary(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
|
||||
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
|
||||
BattleControllerComplete(gActiveBattler);
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].partyStatusSummaryShown)
|
||||
gTasks[gBattlerStatusSummaryTaskId[battler]].func = Task_HidePartyStatusSummary;
|
||||
BattleControllerComplete(battler);
|
||||
}
|
||||
|
||||
void BtlController_HandleBattleAnimation(u32 battler, bool32 ignoreSE, bool32 updateTvData)
|
||||
|
@ -249,11 +249,9 @@ void (*gPreBattleCallback1)(void);
|
||||
void (*gBattleMainFunc)(void);
|
||||
struct BattleResults gBattleResults;
|
||||
u8 gLeveledUpInBattle;
|
||||
void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
|
||||
u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
|
||||
u8 gMultiUsePlayerCursor;
|
||||
u8 gNumberOfMovesToChoose;
|
||||
u8 gBattleControllerData[MAX_BATTLERS_COUNT]; // Used by the battle controllers to store misc sprite/task IDs for each battler
|
||||
|
||||
static const struct ScanlineEffectParams sIntroScanlineParams16Bit =
|
||||
{
|
||||
@ -3076,7 +3074,7 @@ static void BattleMainCB1(void)
|
||||
gBattleMainFunc();
|
||||
|
||||
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
|
||||
gBattlerControllerFuncs[gActiveBattler]();
|
||||
gBattlerControllerFuncs[gActiveBattler](gActiveBattler);
|
||||
}
|
||||
|
||||
static void BattleStartClearSetData(void)
|
||||
|
@ -37,6 +37,7 @@ gReservedSpritePaletteCount:
|
||||
.include "link_rfu_2.o"
|
||||
.include "rtc.o"
|
||||
.include "battle_main.o"
|
||||
.include "battle_controllers.o"
|
||||
.include "random.o"
|
||||
.include "load_save.o"
|
||||
.include "berry_blender.o"
|
||||
|
Loading…
Reference in New Issue
Block a user