Consolidates a bunch of battle controller functions (#6838)
This commit is contained in:
parent
34918f5f0d
commit
e42890e954
@ -336,4 +336,13 @@ void SetControllerToLinkOpponent(u32 battler);
|
||||
// link partner
|
||||
void SetControllerToLinkPartner(u32 battler);
|
||||
|
||||
void TrySetBattlerShadowSpriteCallback(u32 battler);
|
||||
|
||||
bool32 TryShinyAnimAfterMonAnimUtil(u32 battler);
|
||||
bool32 SwitchIn_ShowSubstituteUtil(u32 battler);
|
||||
bool32 SwitchIn_WaitAndEndUtil(u32 battler);
|
||||
bool32 SwitchIn_HandleSoundAndEndUtil(u32 battler);
|
||||
bool32 SwitchIn_ShowHealthboxUtil(u32 battler);
|
||||
bool32 SwitchIn_TryShinyAnimUtil(u32 battler);
|
||||
|
||||
#endif // GUARD_BATTLE_CONTROLLERS_H
|
||||
|
||||
@ -280,84 +280,32 @@ static void Intro_TryShinyAnimShowHealthbox(u32 battler)
|
||||
|
||||
static void TryShinyAnimAfterMonAnim(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].x2 == 0)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
{
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
}
|
||||
else if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
if (TryShinyAnimAfterMonAnimUtil(battler))
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
if (SwitchIn_ShowSubstituteUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_HandleSoundAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy_2)
|
||||
{
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
if (SwitchIn_HandleSoundAndEndUtil(battler))
|
||||
LinkOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], GetBattlerMon(battler), HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
if (SwitchIn_ShowHealthboxUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
{
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
}
|
||||
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(GetBattlerMon(battler), MON_DATA_SPECIES));
|
||||
if (SwitchIn_TryShinyAnimUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void LinkOpponentBufferExecCompleted(u32 battler)
|
||||
|
||||
@ -130,60 +130,26 @@ static void WaitForMonAnimAfterLoad(u32 battler)
|
||||
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
if (SwitchIn_ShowSubstituteUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_WaitAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_WaitAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (SwitchIn_WaitAndEndUtil(battler))
|
||||
LinkPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
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(GetBattlerMon(battler), battler);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], GetBattlerMon(battler), HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
if (SwitchIn_ShowHealthboxUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
}
|
||||
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
if (SwitchIn_TryShinyAnimUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void LinkPartnerBufferExecCompleted(u32 battler)
|
||||
|
||||
@ -212,19 +212,6 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
|
||||
}
|
||||
}
|
||||
|
||||
static void TrySetBattlerShadowSpriteCallback(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteIdPrimary].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (B_ENEMY_MON_SHADOW_STYLE <= GEN_3
|
||||
|| P_GBA_STYLE_SPECIES_GFX == TRUE
|
||||
|| gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteIdSecondary].callback == SpriteCallbackDummy)
|
||||
{
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(GetBattlerMon(battler), MON_DATA_SPECIES));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_TryShinyAnimShowHealthbox(u32 battler)
|
||||
{
|
||||
bool32 bgmRestored = FALSE;
|
||||
@ -343,58 +330,26 @@ static void TryShinyAnimAfterMonAnim(u32 battler)
|
||||
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
if (SwitchIn_ShowSubstituteUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_HandleSoundAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy_2)
|
||||
{
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
if (SwitchIn_HandleSoundAndEndUtil(battler))
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], GetBattlerMon(battler), HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
if (SwitchIn_ShowHealthboxUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(GetBattlerMon(battler), MON_DATA_SPECIES));
|
||||
if (SwitchIn_TryShinyAnimUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void OpponentBufferExecCompleted(u32 battler)
|
||||
|
||||
@ -1384,10 +1384,8 @@ static void SwitchIn_CleanShinyAnimShowSubstitute(u32 battler)
|
||||
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& !IsCryPlayingOrClearCrySongs())
|
||||
if (SwitchIn_HandleSoundAndEndUtil(battler))
|
||||
{
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
HandleLowHpMusicChange(GetBattlerMon(battler), battler);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
@ -1395,16 +1393,8 @@ static void SwitchIn_HandleSoundAndEnd(u32 battler)
|
||||
|
||||
static void SwitchIn_TryShinyAnimShowHealthbox(u32 battler)
|
||||
{
|
||||
// Start shiny animation if applicable
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
|
||||
// Wait for ball anim, then show healthbox
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
if (SwitchIn_TryShinyAnimUtil(battler))
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], GetBattlerMon(battler), HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
@ -202,60 +202,26 @@ static void WaitForMonAnimAfterLoad(u32 battler)
|
||||
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
if (SwitchIn_ShowSubstituteUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_WaitAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_WaitAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (SwitchIn_WaitAndEndUtil(battler))
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
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(GetBattlerMon(battler), battler);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], GetBattlerMon(battler), HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
if (SwitchIn_ShowHealthboxUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
}
|
||||
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
if (SwitchIn_TryShinyAnimUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void PlayerPartnerBufferExecCompleted(u32 battler)
|
||||
|
||||
@ -196,20 +196,6 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
|
||||
}
|
||||
}
|
||||
|
||||
static void TrySetBattlerShadowSpriteCallback(u32 battler)
|
||||
{
|
||||
|
||||
if (gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteIdPrimary].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (B_ENEMY_MON_SHADOW_STYLE <= GEN_3
|
||||
|| P_GBA_STYLE_SPECIES_GFX == TRUE
|
||||
|| gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteIdSecondary].callback == SpriteCallbackDummy)
|
||||
{
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(GetBattlerMon(battler), MON_DATA_SPECIES));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Intro_TryShinyAnimShowHealthbox(u32 battler)
|
||||
{
|
||||
bool32 bgmRestored = FALSE;
|
||||
@ -302,86 +288,32 @@ static void Intro_TryShinyAnimShowHealthbox(u32 battler)
|
||||
|
||||
static void TryShinyAnimAfterMonAnim(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].x2 == 0)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
{
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TryShinyAnimAfterMonAnimUtil(battler))
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
if (SwitchIn_ShowSubstituteUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_HandleSoundAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_HandleSoundAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& !IsCryPlayingOrClearCrySongs())
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy_2)
|
||||
{
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
if (SwitchIn_HandleSoundAndEndUtil(battler))
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], GetBattlerMon(battler), HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
if (SwitchIn_ShowHealthboxUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(GetBattlerMon(battler), MON_DATA_SPECIES));
|
||||
if (SwitchIn_TryShinyAnimUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleLoadMonSprite(u32 battler)
|
||||
|
||||
@ -279,60 +279,26 @@ static void WaitForMonAnimAfterLoad(u32 battler)
|
||||
|
||||
static void SwitchIn_ShowSubstitute(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
if (SwitchIn_ShowSubstituteUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_WaitAndEnd;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_WaitAndEnd(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
if (SwitchIn_WaitAndEndUtil(battler))
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_ShowHealthbox(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
{
|
||||
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(GetBattlerMon(battler), battler);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], GetBattlerMon(battler), HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
if (SwitchIn_ShowHealthboxUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowSubstitute;
|
||||
}
|
||||
}
|
||||
|
||||
static void SwitchIn_TryShinyAnim(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
}
|
||||
|
||||
if (gSprites[gBattleControllerData[battler]].callback == SpriteCallbackDummy
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
{
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
if (SwitchIn_TryShinyAnimUtil(battler))
|
||||
gBattlerControllerFuncs[battler] = SwitchIn_ShowHealthbox;
|
||||
}
|
||||
}
|
||||
|
||||
static void RecordedPlayerBufferExecCompleted(u32 battler)
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "event_object_movement.h"
|
||||
#include "link.h"
|
||||
#include "link_rfu.h"
|
||||
#include "m4a.h"
|
||||
#include "palette.h"
|
||||
#include "party_menu.h"
|
||||
#include "recorded_battle.h"
|
||||
@ -3081,3 +3082,115 @@ static u32 ReturnAnimIdForBattler(bool32 wasPlayerSideKnockedOut, u32 specificBa
|
||||
return GetSpeciesBackAnimSet(species);
|
||||
}
|
||||
|
||||
void TrySetBattlerShadowSpriteCallback(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteIdPrimary].callback == SpriteCallbackDummy
|
||||
&& (B_ENEMY_MON_SHADOW_STYLE <= GEN_3 || P_GBA_STYLE_SPECIES_GFX == TRUE
|
||||
|| gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteIdSecondary].callback == SpriteCallbackDummy))
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(GetBattlerMon(battler), MON_DATA_SPECIES));
|
||||
}
|
||||
|
||||
bool32 TryShinyAnimAfterMonAnimUtil(u32 battler)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback != SpriteCallbackDummy
|
||||
|| gSprites[gBattlerSpriteIds[battler]].x2 != 0)
|
||||
return FALSE;
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
{
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim)
|
||||
return FALSE;
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 SwitchIn_ShowSubstituteUtil(u32 battler)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[battler]].callback != SpriteCallbackDummy)
|
||||
return FALSE;
|
||||
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
|
||||
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_MON_TO_SUBSTITUTE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 SwitchIn_WaitAndEndUtil(u32 battler)
|
||||
{
|
||||
return !gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy;
|
||||
}
|
||||
|
||||
bool32 SwitchIn_HandleSoundAndEndUtil(u32 battler)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive || IsCryPlayingOrClearCrySongs())
|
||||
return FALSE;
|
||||
|
||||
if (gSprites[gBattlerSpriteIds[battler]].callback != SpriteCallbackDummy
|
||||
&& gSprites[gBattlerSpriteIds[battler]].callback != SpriteCallbackDummy_2
|
||||
&& GetBattlerSide(battler) == B_SIDE_OPPONENT)
|
||||
return FALSE;
|
||||
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 SwitchIn_ShowHealthboxUtil(u32 battler)
|
||||
{
|
||||
u32 side = GetBattlerSide(battler);
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim
|
||||
|| (side == B_SIDE_OPPONENT && gSprites[gBattlerSpriteIds[battler]].callback != SpriteCallbackDummy))
|
||||
return FALSE;
|
||||
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
|
||||
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
|
||||
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
|
||||
|
||||
if (side == B_SIDE_PLAYER)
|
||||
{
|
||||
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
|
||||
HandleLowHpMusicChange(GetBattlerMon(battler), battler);
|
||||
}
|
||||
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], GetBattlerMon(battler), HEALTHBOX_ALL);
|
||||
StartHealthboxSlideIn(battler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
|
||||
if (side == B_SIDE_OPPONENT)
|
||||
CopyBattleSpriteInvisibility(battler);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 SwitchIn_TryShinyAnimUtil(u32 battler)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
|
||||
TryShinyAnimation(battler, GetBattlerMon(battler));
|
||||
|
||||
if (gSprites[gBattleControllerData[battler]].callback != SpriteCallbackDummy
|
||||
|| gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive)
|
||||
return FALSE;
|
||||
|
||||
DestroySprite(&gSprites[gBattleControllerData[battler]]);
|
||||
|
||||
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
|
||||
SetBattlerShadowSpriteCallback(battler, GetMonData(GetBattlerMon(battler), MON_DATA_SPECIES));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user