Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/battle_controllers.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,6 @@ bool32 SwitchIn_HandleSoundAndEndUtil(u32 battler);
bool32 SwitchIn_ShowHealthboxUtil(u32 battler);
bool32 SwitchIn_TryShinyAnimUtil(u32 battler);

void FreeShinyStars(void);

#endif // GUARD_BATTLE_CONTROLLERS_H
6 changes: 2 additions & 4 deletions src/battle_controller_link_opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim = FALSE;

FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();
}
else
{
Expand All @@ -180,8 +179,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)

if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT)
{
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();
}
}

Expand Down
9 changes: 3 additions & 6 deletions src/battle_controller_opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
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);
FreeShinyStars();
}
else
{
Expand All @@ -191,8 +190,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim)
{
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();
}
else
{
Expand Down Expand Up @@ -322,8 +320,7 @@ static void TryShinyAnimAfterMonAnim(u32 battler)
{
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();
OpponentBufferExecCompleted(battler);
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
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);
FreeShinyStars();

HandleLowHpMusicChange(GetBattlerMon(battler), battler);

Expand Down Expand Up @@ -1371,8 +1370,7 @@ static void SwitchIn_CleanShinyAnimShowSubstitute(u32 battler)
// Reset shiny anim (even if it didn't occur)
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();

// Check if Substitute should be shown
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
Expand Down Expand Up @@ -1891,8 +1889,7 @@ static void TryShinyAnimAfterMonAnim(u32 battler)
{
gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();
PlayerBufferExecCompleted(battler);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/battle_controller_recorded_opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
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);
FreeShinyStars();
}

gBattleSpritesDataPtr->healthBoxesData[battler].introEndDelay = 3;
Expand Down
3 changes: 1 addition & 2 deletions src/battle_controller_recorded_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim = FALSE;

FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();

HandleLowHpMusicChange(GetBattlerMon(battler), battler);
if (IsDoubleBattle())
Expand Down
3 changes: 1 addition & 2 deletions src/battle_controller_wally.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(u32 battler)
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(battler)].finishedShinyMonAnim = FALSE;

FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();

CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(GetBattlerMon(battler), battler);
Expand Down
17 changes: 13 additions & 4 deletions src/battle_controllers.c
Original file line number Diff line number Diff line change
Expand Up @@ -3226,8 +3226,7 @@ bool32 TryShinyAnimAfterMonAnimUtil(u32 battler)

gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();

return TRUE;
}
Expand Down Expand Up @@ -3276,8 +3275,7 @@ bool32 SwitchIn_ShowHealthboxUtil(u32 battler)

gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[battler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
FreeShinyStars();

if (side == B_SIDE_PLAYER)
{
Expand Down Expand Up @@ -3313,3 +3311,14 @@ bool32 SwitchIn_TryShinyAnimUtil(u32 battler)

return TRUE;
}

void FreeShinyStars(void)
{
for (u32 battler = 0; battler < MAX_BATTLERS_COUNT; battler++)
{
if (gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim)
return;
}
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
}
Loading