diff options
Diffstat (limited to 'src/battle_controller_link_opponent.c')
-rw-r--r-- | src/battle_controller_link_opponent.c | 222 |
1 files changed, 113 insertions, 109 deletions
diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 718fe30c9..dd44bc91b 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -51,7 +51,7 @@ static void LinkOpponentHandleMoveAnimation(void); static void LinkOpponentHandlePrintString(void); static void LinkOpponentHandlePrintSelectionString(void); static void LinkOpponentHandleChooseAction(void); -static void LinkOpponentHandleUnknownYesNoBox(void); +static void LinkOpponentHandleYesNoBox(void); static void LinkOpponentHandleChooseMove(void); static void LinkOpponentHandleChooseItem(void); static void LinkOpponentHandleChoosePokemon(void); @@ -87,20 +87,20 @@ static void LinkOpponentHandleSpriteInvisibility(void); static void LinkOpponentHandleBattleAnimation(void); static void LinkOpponentHandleLinkStandbyMsg(void); static void LinkOpponentHandleResetActionMoveSelection(void); -static void LinkOpponentHandleCmd55(void); +static void LinkOpponentHandleEndLinkBattle(void); static void LinkOpponentCmdEnd(void); static void LinkOpponentBufferRunCommand(void); static void LinkOpponentBufferExecCompleted(void); -static void sub_8064DD0(void); +static void SwitchIn_HandleSoundAndEnd(void); static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst); static void SetLinkOpponentMonData(u8 monId); -static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit); +static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit); static void DoSwitchOutAnimation(void); static void LinkOpponentDoMoveAnimation(void); -static void sub_8067618(u8 taskId); -static void sub_80676FC(struct Sprite *sprite); -static void sub_806782C(void); +static void Task_StartSendOutAnim(u8 taskId); +static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite); +static void EndDrawPartyStatusSummary(void); static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { @@ -123,7 +123,7 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_PRINTSTRING] = LinkOpponentHandlePrintString, [CONTROLLER_PRINTSTRINGPLAYERONLY] = LinkOpponentHandlePrintSelectionString, [CONTROLLER_CHOOSEACTION] = LinkOpponentHandleChooseAction, - [CONTROLLER_UNKNOWNYESNOBOX] = LinkOpponentHandleUnknownYesNoBox, + [CONTROLLER_YESNOBOX] = LinkOpponentHandleYesNoBox, [CONTROLLER_CHOOSEMOVE] = LinkOpponentHandleChooseMove, [CONTROLLER_OPENBAG] = LinkOpponentHandleChooseItem, [CONTROLLER_CHOOSEPOKEMON] = LinkOpponentHandleChoosePokemon, @@ -159,11 +159,11 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_BATTLEANIMATION] = LinkOpponentHandleBattleAnimation, [CONTROLLER_LINKSTANDBYMSG] = LinkOpponentHandleLinkStandbyMsg, [CONTROLLER_RESETACTIONMOVESELECTION] = LinkOpponentHandleResetActionMoveSelection, - [CONTROLLER_55] = LinkOpponentHandleCmd55, + [CONTROLLER_ENDLINKBATTLE] = LinkOpponentHandleEndLinkBattle, [CONTROLLER_TERMINATOR_NOP] = LinkOpponentCmdEnd }; -static void nullsub_28(void) +static void LinkOpponentDummy(void) { } @@ -195,7 +195,7 @@ static void CompleteOnBankSpriteCallbackDummy2(void) LinkOpponentBufferExecCompleted(); } -static void sub_8064470(void) +static void FreeTrainerSpriteAfterSlide(void) { if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { @@ -206,38 +206,38 @@ static void sub_8064470(void) } } -static void sub_80644D8(void) +static void Intro_DelayAndEnd(void) { - if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) + if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0; LinkOpponentBufferExecCompleted(); } } -static void sub_8064520(void) +static void Intro_WaitForShinyAnimAndHealthbox(void) { - bool32 r8 = FALSE; - bool32 r4 = FALSE; + bool32 healthboxAnimDone = FALSE; + bool32 twoMons = FALSE; if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) - r8 = TRUE; + healthboxAnimDone = TRUE; } else { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy) { - r8 = TRUE; + healthboxAnimDone = TRUE; } - r4 = TRUE; + twoMons = TRUE; } - if (r8) + if (healthboxAnimDone) { - if (r4 || !IsBattlerSpriteVisible(BATTLE_PARTNER(gActiveBattler))) + if (twoMons || !IsBattlerSpriteVisible(BATTLE_PARTNER(gActiveBattler))) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim) return; @@ -250,8 +250,8 @@ static void sub_8064520(void) gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE; - FreeSpriteTilesByTag(0x27F9); - FreeSpritePaletteByTag(0x27F9); + FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS); + FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS); } else { @@ -263,19 +263,19 @@ static void sub_8064520(void) if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) { - FreeSpriteTilesByTag(0x27F9); - FreeSpritePaletteByTag(0x27F9); + FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS); + FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS); } } - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; - gBattlerControllerFuncs[gActiveBattler] = sub_80644D8; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3; + gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd; } } -static void sub_8064734(void) +static void Intro_TryShinyAnimShowHealthbox(void) { - bool32 r10 = FALSE; + bool32 bgmRestored = FALSE; if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim @@ -294,27 +294,27 @@ static void sub_8064734(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL); - sub_8076918(BATTLE_PARTNER(gActiveBattler)); + StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler)); SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]); } UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); - sub_8076918(gActiveBattler); + StartHealthboxSlideIn(gActiveBattler); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE; } - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 - && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 - && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x40 + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted + && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].waitForCry && !IsCryPlayingOrClearCrySongs()) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { @@ -327,42 +327,42 @@ static void sub_8064734(void) } } - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; - r10 = TRUE; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE; + bgmRestored = TRUE; } - if (r10) + if (bgmRestored) { - if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) { - if (++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 1) + if (++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == 1) return; - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0; } if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_03005D7C[BATTLE_PARTNER(gActiveBattler)]]); + DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]); SetBattlerShadowSpriteCallback(BATTLE_PARTNER(gActiveBattler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], MON_DATA_SPECIES)); } - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); - gBattleSpritesDataPtr->animationData->field_9_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; + gBattleSpritesDataPtr->animationData->introAnimActive = FALSE; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE; - gBattlerControllerFuncs[gActiveBattler] = sub_8064520; + gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox; } } } -static void sub_8064B04(void) +static void TryShinyAnimAfterMonAnim(void) { if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0) @@ -377,8 +377,8 @@ static void sub_8064B04(void) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; - FreeSpriteTilesByTag(0x27F9); - FreeSpritePaletteByTag(0x27F9); + FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS); + FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS); LinkOpponentBufferExecCompleted(); } } @@ -401,7 +401,7 @@ static void CompleteOnHealthbarDone(void) } } -static void sub_8064C14(void) +static void HideHealthboxAfterMonFaint(void) { if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse) { @@ -410,7 +410,7 @@ static void sub_8064C14(void) } } -static void sub_8064C58(void) +static void FreeMonSpriteAfterSwitchOutAnim(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { @@ -447,18 +447,18 @@ static void DoHitAnimBlinkSpriteEffect(void) } } -static void sub_8064D60(void) +static void SwitchIn_ShowSubstitute(void) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattlerControllerFuncs[gActiveBattler] = sub_8064DD0; + gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd; } } -static void sub_8064DD0(void) +static void SwitchIn_HandleSoundAndEnd(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs()) { @@ -471,7 +471,7 @@ static void sub_8064DD0(void) } } -static void sub_8064E50(void) +static void SwitchIn_ShowHealthbox(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) @@ -479,20 +479,20 @@ static void sub_8064E50(void) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; - FreeSpriteTilesByTag(0x27F9); - FreeSpritePaletteByTag(0x27F9); + FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS); + FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); - sub_8076918(gActiveBattler); + StartHealthboxSlideIn(gActiveBattler); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); CopyBattleSpriteInvisibility(gActiveBattler); - gBattlerControllerFuncs[gActiveBattler] = sub_8064D60; + gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute; } } -static void sub_8064F40(void) +static void SwitchIn_TryShinyAnim(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim) @@ -500,12 +500,12 @@ static void sub_8064F40(void) TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); } - if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); - gBattlerControllerFuncs[gActiveBattler] = sub_8064E50; + gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox; } } @@ -1141,24 +1141,24 @@ static void LinkOpponentHandleLoadMonSprite(void) SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); - gBattlerControllerFuncs[gActiveBattler] = sub_8064B04; + gBattlerControllerFuncs[gActiveBattler] = TryShinyAnimAfterMonAnim; } static void LinkOpponentHandleSwitchInAnim(void) { gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; - sub_8066494(gActiveBattler, gBattleBufferA[gActiveBattler][2]); - gBattlerControllerFuncs[gActiveBattler] = sub_8064F40; + StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim; } -static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit) +static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) { u16 species; ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); - gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); + gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); @@ -1168,8 +1168,8 @@ static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit) GetBattlerSpriteDefault_Y(battlerId), GetBattlerSpriteSubpriority(battlerId)); - gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; - gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId; + gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; + gSprites[gBattleControllerData[battlerId]].data[2] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[2] = species; @@ -1180,7 +1180,7 @@ static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit) gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE; gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy; - gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT); + gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT); } static void LinkOpponentHandleReturnMonToBall(void) @@ -1215,12 +1215,14 @@ static void DoSwitchOutAnimation(void) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON); - gBattlerControllerFuncs[gActiveBattler] = sub_8064C58; + gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim; } break; } } +#define sSpeedX data[0] + static void LinkOpponentHandleDrawTrainerPic(void) { s16 xPos; @@ -1301,10 +1303,10 @@ static void LinkOpponentHandleDrawTrainerPic(void) GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240; - gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; + gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; } @@ -1324,15 +1326,17 @@ static void LinkOpponentHandleTrainerSlide(void) gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96; gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.x += 32; - gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle battlerId function LinkOpponentBufferExecCompleted(); } +#undef sSpeedX + static void LinkOpponentHandleTrainerSlideBack(void) { SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); @@ -1341,7 +1345,7 @@ static void LinkOpponentHandleTrainerSlideBack(void) gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy); - gBattlerControllerFuncs[gActiveBattler] = sub_8064470; + gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide; } static void LinkOpponentHandleFaintAnimation(void) @@ -1359,7 +1363,7 @@ static void LinkOpponentHandleFaintAnimation(void) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; PlaySE12WithPanning(SE_FAINT, SOUND_PAN_TARGET); gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintOpponentMon; - gBattlerControllerFuncs[gActiveBattler] = sub_8064C14; + gBattlerControllerFuncs[gActiveBattler] = HideHealthboxAfterMonFaint; } } } @@ -1386,7 +1390,7 @@ static void LinkOpponentHandlePause(void) static void LinkOpponentHandleMoveAnimation(void) { - if (!mplay_80342A4(gActiveBattler)) + if (!IsBattleSEPlaying(gActiveBattler)) { u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); @@ -1429,7 +1433,7 @@ static void LinkOpponentDoMoveAnimation(void) case 1: if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - sub_805EB9C(ST_OAM_AFFINE_OFF); + SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF); DoMoveAnim(move); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; } @@ -1438,7 +1442,7 @@ static void LinkOpponentDoMoveAnimation(void) gAnimScriptCallback(); if (!gAnimScriptActive) { - sub_805EB9C(ST_OAM_AFFINE_NORMAL); + SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL); if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); @@ -1482,7 +1486,7 @@ static void LinkOpponentHandleChooseAction(void) LinkOpponentBufferExecCompleted(); } -static void LinkOpponentHandleUnknownYesNoBox(void) +static void LinkOpponentHandleYesNoBox(void) { LinkOpponentBufferExecCompleted(); } @@ -1538,7 +1542,7 @@ static void LinkOpponentHandleExpUpdate(void) static void LinkOpponentHandleStatusIconUpdate(void) { - if (!mplay_80342A4(gActiveBattler)) + if (!IsBattleSEPlaying(gActiveBattler)) { u8 battlerId; @@ -1551,7 +1555,7 @@ static void LinkOpponentHandleStatusIconUpdate(void) static void LinkOpponentHandleStatusAnimation(void) { - if (!mplay_80342A4(gActiveBattler)) + if (!IsBattleSEPlaying(gActiveBattler)) { InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); @@ -1702,19 +1706,19 @@ static void LinkOpponentHandleIntroTrainerBallThrow(void) gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; - StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_80676FC); + StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreeOpponentSprite); - taskId = CreateTask(sub_8067618, 5); + taskId = CreateTask(Task_StartSendOutAnim, 5); gTasks[taskId].data[0] = gActiveBattler; if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; - gBattleSpritesDataPtr->animationData->field_9_x1 = 1; - gBattlerControllerFuncs[gActiveBattler] = nullsub_28; + gBattleSpritesDataPtr->animationData->introAnimActive = TRUE; + gBattlerControllerFuncs[gActiveBattler] = LinkOpponentDummy; } -static void sub_8067618(u8 taskId) +static void Task_StartSendOutAnim(u8 taskId) { u8 savedActiveBank = gActiveBattler; @@ -1722,23 +1726,23 @@ static void sub_8067618(u8 taskId) if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; - sub_8066494(gActiveBattler, FALSE); + StartSendOutAnim(gActiveBattler, FALSE); } else { gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; - sub_8066494(gActiveBattler, FALSE); + StartSendOutAnim(gActiveBattler, FALSE); gActiveBattler = BATTLE_PARTNER(gActiveBattler); gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; - sub_8066494(gActiveBattler, FALSE); + StartSendOutAnim(gActiveBattler, FALSE); gActiveBattler = BATTLE_PARTNER(gActiveBattler); } - gBattlerControllerFuncs[gActiveBattler] = sub_8064734; + gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox; gActiveBattler = savedActiveBank; DestroyTask(taskId); } -static void sub_80676FC(struct Sprite *sprite) +static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite) { FreeTrainerFrontPicPalette(sprite->oam.affineParam); FreeSpriteOamMatrix(sprite); @@ -1769,20 +1773,20 @@ static void LinkOpponentHandleDrawPartyStatusSummary(void) } gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; if (gBattleBufferA[gActiveBattler][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93; - gBattlerControllerFuncs[gActiveBattler] = sub_806782C; + gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary; } } -static void sub_806782C(void) +static void EndDrawPartyStatusSummary(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; LinkOpponentBufferExecCompleted(); } } @@ -1811,7 +1815,7 @@ static void LinkOpponentHandleSpriteInvisibility(void) static void LinkOpponentHandleBattleAnimation(void) { - if (!mplay_80342A4(gActiveBattler)) + if (!IsBattleSEPlaying(gActiveBattler)) { u8 animationId = gBattleBufferA[gActiveBattler][1]; u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); @@ -1827,7 +1831,7 @@ static void LinkOpponentHandleBattleAnimation(void) static void LinkOpponentHandleLinkStandbyMsg(void) { - sub_81851A8(&gBattleBufferA[gActiveBattler][2]); + RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][2]); LinkOpponentBufferExecCompleted(); } @@ -1836,9 +1840,9 @@ static void LinkOpponentHandleResetActionMoveSelection(void) LinkOpponentBufferExecCompleted(); } -static void LinkOpponentHandleCmd55(void) +static void LinkOpponentHandleEndLinkBattle(void) { - sub_81851A8(&gBattleBufferA[gActiveBattler][4]); + RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][4]); if (gBattleBufferA[gActiveBattler][1] == B_OUTCOME_DREW) gBattleOutcome = gBattleBufferA[gActiveBattler][1]; @@ -1849,7 +1853,7 @@ static void LinkOpponentHandleCmd55(void) FadeOutMapMusic(5); BeginFastPaletteFade(3); LinkOpponentBufferExecCompleted(); - gBattlerControllerFuncs[gActiveBattler] = sub_80587B0; + gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks; } static void LinkOpponentCmdEnd(void) |