diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2021-03-16 13:51:03 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2021-03-16 13:51:03 -0400 |
commit | 7794570c71a82fca440bc13e18da45f49642eb6c (patch) | |
tree | 3dfc75e9aa256218df29cb9a58e33e060dfd6b69 /src | |
parent | 6fc2bdf84011a7d68ed76762b50cc84fbf9ff5a7 (diff) |
Document pokedude battle controller, 1
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_controller_pokedude.c | 1284 | ||||
-rw-r--r-- | src/battle_util2.c | 4 |
2 files changed, 683 insertions, 605 deletions
diff --git a/src/battle_controller_pokedude.c b/src/battle_controller_pokedude.c index c3b62c871..07d3f8d31 100644 --- a/src/battle_controller_pokedude.c +++ b/src/battle_controller_pokedude.c @@ -15,18 +15,19 @@ #include "battle_controllers.h" #include "battle_interface.h" #include "battle_message.h" +#include "battle_string_ids.h" #include "reshow_battle_screen.h" #include "teachy_tv.h" #include "constants/songs.h" #include "constants/moves.h" #include "constants/pokemon.h" -struct Unk_84790E8 +struct PokedudeTextScriptHeader { - u8 unk_0; - u8 unk_1; - u16 unk_2; - void (*unk_4)(void); + u8 btlcmd; + u8 side; + u16 stringid; + void (*callback)(void); }; struct PokedudeBattlePartyInfo @@ -97,471 +98,105 @@ static void PokedudeHandleResetActionMoveSelection(void); static void PokedudeHandleCmd55(void); static void PokedudeCmdEnd(void); -static void sub_8159BA8(void); -static void sub_8159D04(void); +static void PokedudeAction_PrintVoiceoverMessage(void); +static void PokedudeAction_PrintMessageWithHealthboxPals(void); static void PokedudeBufferExecCompleted(void); -static void sub_8159824(void); +static void PokedudeSimulateInputChooseAction(void); static void PokedudeBufferRunCommand(void); -static bool8 sub_8159AB8(void); -static void sub_8159998(void); +static bool8 HandlePokedudeVoiceoverEtc(void); +static void PokedudeSimulateInputChooseMove(void); static void WaitForMonSelection(void); static void CompleteWhenChoseItem(void); -static void sub_81567B0(void); +static void Intro_WaitForShinyAnimAndHealthbox(void); static void Task_LaunchLvlUpAnim(u8 taskId); static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId); static void CompleteOnInactiveTextPrinter2(void); static void Task_PrepareToGiveExpWithExpBar(u8 taskId); -static void sub_8156B24(u8 taskId); +static void Task_GiveExpWithExpBar(u8 taskId); static void Task_UpdateLvlInHealthbox(u8 taskId); static u32 CopyPokedudeMonData(u8 monId, u8 *dst); static void SetPokedudeMonData(u8 monId); -static void sub_8159478(u8 battlerId); +static void StartSendOutAnim(u8 battlerId); static void PokedudeDoMoveAnimation(void); -static void sub_81595EC(u8 taskId); +static void Task_StartSendOutAnim(u8 taskId); static const u8 *GetPokedudeText(void); -u8 *gUnknown_3005EE0[MAX_BATTLERS_COUNT]; - static void (*const sPokedudeBufferCommands[CONTROLLER_CMDS_COUNT])(void) = -{ - PokedudeHandleGetMonData, - PokedudeHandleGetRawMonData, - PokedudeHandleSetMonData, - PokedudeHandleSetRawMonData, - PokedudeHandleLoadMonSprite, - PokedudeHandleSwitchInAnim, - PokedudeHandleReturnMonToBall, - PokedudeHandleDrawTrainerPic, - PokedudeHandleTrainerSlide, - PokedudeHandleTrainerSlideBack, - PokedudeHandleFaintAnimation, - PokedudeHandlePaletteFade, - PokedudeHandleSuccessBallThrowAnim, - PokedudeHandleBallThrowAnim, - PokedudeHandlePause, - PokedudeHandleMoveAnimation, - PokedudeHandlePrintString, - PokedudeHandlePrintSelectionString, - PokedudeHandleChooseAction, - PokedudeHandleUnknownYesNoBox, - PokedudeHandleChooseMove, - PokedudeHandleChooseItem, - PokedudeHandleChoosePokemon, - PokedudeHandleCmd23, - PokedudeHandleHealthBarUpdate, - PokedudeHandleExpUpdate, - PokedudeHandleStatusIconUpdate, - PokedudeHandleStatusAnimation, - PokedudeHandleStatusXor, - PokedudeHandleDataTransfer, - PokedudeHandleDMA3Transfer, - PokedudeHandlePlayBGM, - PokedudeHandleCmd32, - PokedudeHandleTwoReturnValues, - PokedudeHandleChosenMonReturnValue, - PokedudeHandleOneReturnValue, - PokedudeHandleOneReturnValue_Duplicate, - PokedudeHandleCmd37, - PokedudeHandleCmd38, - PokedudeHandleCmd39, - PokedudeHandleCmd40, - PokedudeHandleHitAnimation, - PokedudeHandleCmd42, - PokedudeHandlePlaySE, - PokedudeHandlePlayFanfare, - PokedudeHandleFaintingCry, - PokedudeHandleIntroSlide, - PokedudeHandleIntroTrainerBallThrow, - PokedudeHandleDrawPartyStatusSummary, - PokedudeHandleHidePartyStatusSummary, - PokedudeHandleEndBounceEffect, - PokedudeHandleSpriteInvisibility, - PokedudeHandleBattleAnimation, - PokedudeHandleLinkStandbyMsg, - PokedudeHandleResetActionMoveSelection, - PokedudeHandleCmd55, - PokedudeCmdEnd, -}; + { + PokedudeHandleGetMonData, + PokedudeHandleGetRawMonData, + PokedudeHandleSetMonData, + PokedudeHandleSetRawMonData, + PokedudeHandleLoadMonSprite, + PokedudeHandleSwitchInAnim, + PokedudeHandleReturnMonToBall, + PokedudeHandleDrawTrainerPic, + PokedudeHandleTrainerSlide, + PokedudeHandleTrainerSlideBack, + PokedudeHandleFaintAnimation, + PokedudeHandlePaletteFade, + PokedudeHandleSuccessBallThrowAnim, + PokedudeHandleBallThrowAnim, + PokedudeHandlePause, + PokedudeHandleMoveAnimation, + PokedudeHandlePrintString, + PokedudeHandlePrintSelectionString, + PokedudeHandleChooseAction, + PokedudeHandleUnknownYesNoBox, + PokedudeHandleChooseMove, + PokedudeHandleChooseItem, + PokedudeHandleChoosePokemon, + PokedudeHandleCmd23, + PokedudeHandleHealthBarUpdate, + PokedudeHandleExpUpdate, + PokedudeHandleStatusIconUpdate, + PokedudeHandleStatusAnimation, + PokedudeHandleStatusXor, + PokedudeHandleDataTransfer, + PokedudeHandleDMA3Transfer, + PokedudeHandlePlayBGM, + PokedudeHandleCmd32, + PokedudeHandleTwoReturnValues, + PokedudeHandleChosenMonReturnValue, + PokedudeHandleOneReturnValue, + PokedudeHandleOneReturnValue_Duplicate, + PokedudeHandleCmd37, + PokedudeHandleCmd38, + PokedudeHandleCmd39, + PokedudeHandleCmd40, + PokedudeHandleHitAnimation, + PokedudeHandleCmd42, + PokedudeHandlePlaySE, + PokedudeHandlePlayFanfare, + PokedudeHandleFaintingCry, + PokedudeHandleIntroSlide, + PokedudeHandleIntroTrainerBallThrow, + PokedudeHandleDrawPartyStatusSummary, + PokedudeHandleHidePartyStatusSummary, + PokedudeHandleEndBounceEffect, + PokedudeHandleSpriteInvisibility, + PokedudeHandleBattleAnimation, + PokedudeHandleLinkStandbyMsg, + PokedudeHandleResetActionMoveSelection, + PokedudeHandleCmd55, + PokedudeCmdEnd, + }; // not used static const u8 gUnknown_8479000[] = { 0x48, 0x48, 0x20, 0x5a, 0x50, 0x50, 0x50, 0x58 }; -static const u8 gUnknown_8479008[][8] = -{ - { 0, 0, 0, 0, 64, 0, 0, 0 }, - { 4, 4, 0, 0, 0, 0, 0, 0 }, -}; - -static const u8 gUnknown_8479018[][8] = -{ - { 0, 0, 0, 0, 64, 0, 0, 0 }, - { 1, 0, 0, 0, 64, 0, 0, 0 }, - { 0, 0, 0, 0, 64, 0, 0, 0 }, -}; - -static const u8 gUnknown_8479030[][8] = -{ - { 0, 0, 0, 0, 64, 0, 0, 0 }, - { 2, 0, 0, 0, 64, 0, 0, 0 }, - { 0, 0, 0, 0, 64, 0, 0, 0 }, -}; - -static const u8 gUnknown_8479048[][8] = -{ - { 0, 0, 0, 0, 64, 0, 0, 0 }, - { 0, 0, 0, 0, 64, 0, 0, 0 }, - { 1, 0, 0, 0, 64, 0, 0, 0 }, -}; - -static const u8 (*const gUnknown_8479060[])[8] = -{ - [TTVSCR_BATTLE] = gUnknown_8479008, - [TTVSCR_STATUS] = gUnknown_8479018, - [TTVSCR_MATCHUPS] = gUnknown_8479030, - [TTVSCR_CATCHING] = gUnknown_8479048, -}; - -static const u8 gUnknown_8479070[][8] = -{ - { 2, 2, 0, 0, 64, 0, 0, 0 }, - { 255, 255, 0, 0, 0, 0, 0, 0 }, -}; - -static const u8 gUnknown_8479080[][8] = -{ - { 2, 2, 0, 0, 64, 0, 0, 0 }, - { 2, 0, 0, 0, 64, 0, 0, 0 }, - { 2, 0, 0, 0, 64, 0, 0, 0 }, - { 255, 255, 0, 0, 0, 0, 0, 0 }, -}; - -static const u8 gUnknown_84790A0[][8] = -{ - { 2, 0, 0, 0, 64, 0, 0, 0 }, - { 0, 0, 0, 0, 64, 0, 0, 0 }, - { 0, 0, 0, 0, 64, 0, 0, 0 }, - { 255, 255, 0, 0, 0, 0, 0, 0 }, -}; - -static const u8 gUnknown_84790C0[][8] = -{ - { 0, 2, 0, 0, 64, 0, 0, 0 }, - { 2, 2, 0, 0, 64, 0, 0, 0 }, - { 255, 255, 0, 0, 0, 0, 0, 0 }, -}; - -static const u8 (*const gUnknown_84790D8[])[8] = -{ - [TTVSCR_BATTLE] = gUnknown_8479070, - [TTVSCR_STATUS] = gUnknown_8479080, - [TTVSCR_MATCHUPS] = gUnknown_84790A0, - [TTVSCR_CATCHING] = gUnknown_84790C0, -}; - -static const struct Unk_84790E8 gUnknown_84790E8[] = -{ - { - .unk_0 = 18, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 16, - .unk_1 = 1, - .unk_2 = 4, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 18, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 16, - .unk_1 = 0, - .unk_2 = 13, - .unk_4 = sub_8159BA8, - }, -}; - -static const struct Unk_84790E8 gUnknown_8479108[] = -{ - { - .unk_0 = 18, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = NULL, - }, - { - .unk_0 = 18, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159D04, - }, - { - .unk_0 = 21, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 16, - .unk_1 = 1, - .unk_2 = 4, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 16, - .unk_1 = 0, - .unk_2 = 13, - .unk_4 = sub_8159BA8, - }, -}; - -static const struct Unk_84790E8 gUnknown_8479130[] = -{ - { - .unk_0 = 16, - .unk_1 = 1, - .unk_2 = 4, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 18, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 22, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 16, - .unk_1 = 1, - .unk_2 = 4, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 18, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 20, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 16, - .unk_1 = 0, - .unk_2 = 13, - .unk_4 = sub_8159BA8, - }, -}; - -static const struct Unk_84790E8 gUnknown_8479168[] = -{ - { - .unk_0 = 18, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 18, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = NULL, - }, - { - .unk_0 = 18, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 16, - .unk_1 = 1, - .unk_2 = 107, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 21, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, - { - .unk_0 = 55, - .unk_1 = 0, - .unk_2 = 0, - .unk_4 = sub_8159BA8, - }, -}; - -static const struct Unk_84790E8 *const gUnknown_8479198[] = -{ - [TTVSCR_BATTLE] = gUnknown_84790E8, - [TTVSCR_STATUS] = gUnknown_8479108, - [TTVSCR_MATCHUPS] = gUnknown_8479130, - [TTVSCR_CATCHING] = gUnknown_8479168, -}; - -static const u8 *const sPokedudeTexts_Battle[] = -{ - Pokedude_Text_SpeedierBattlerGoesFirst, - Pokedude_Text_MyRattataFasterThanPidgey, - Pokedude_Text_BattlersTakeTurnsAttacking, - Pokedude_Text_MyRattataWonGetsEXP, -}; - -static const u8 *const sPokedudeTexts_Status[] = -{ - Pokedude_Text_UhOhRattataPoisoned, - Pokedude_Text_UhOhRattataPoisoned, - Pokedude_Text_HealStatusRightAway, - Pokedude_Text_UsingItemTakesTurn, - Pokedude_Text_YayWeManagedToWin, -}; - -static const u8 *const sPokedudeTexts_TypeMatchup[] = -{ - Pokedude_Text_WaterNotVeryEffectiveAgainstGrass, - Pokedude_Text_GrassEffectiveAgainstWater, - Pokedude_Text_LetsTryShiftingMons, - Pokedude_Text_ShiftingUsesTurn, - Pokedude_Text_ButterfreeDoubleResistsGrass, - Pokedude_Text_ButterfreeGoodAgainstOddish, - Pokedude_Text_YeahWeWon, -}; - -static const u8 *const sPokedudeTexts_Catching[] = -{ - Pokedude_Text_WeakenMonBeforeCatching, - Pokedude_Text_WeakenMonBeforeCatching, - Pokedude_Text_BestIfTargetStatused, - Pokedude_Text_CantDoubleUpOnStatus, - Pokedude_Text_LetMeThrowBall, - Pokedude_Text_PickBestKindOfBall, -}; - -static const struct PokedudeBattlePartyInfo sParties_Battle[] = -{ - { - .side = B_SIDE_PLAYER, - .level = 15, - .species = SPECIES_RATTATA, - .moves = { MOVE_TACKLE, MOVE_TAIL_WHIP, MOVE_HYPER_FANG, MOVE_QUICK_ATTACK }, - .nature = NATURE_LONELY, - .gender = MALE, - }, - { - .side = B_SIDE_OPPONENT, - .level = 18, - .species = SPECIES_PIDGEY, - .moves = { MOVE_TACKLE, MOVE_SAND_ATTACK, MOVE_GUST, MOVE_QUICK_ATTACK }, - .nature = NATURE_NAUGHTY, - .gender = MALE, - }, - {0xFF} -}; - -static const struct PokedudeBattlePartyInfo sParties_Status[] = -{ - { - .side = B_SIDE_PLAYER, - .level = 15, - .species = SPECIES_RATTATA, - .moves = { MOVE_TACKLE, MOVE_TAIL_WHIP, MOVE_HYPER_FANG, MOVE_QUICK_ATTACK }, - .nature = NATURE_LONELY, - .gender = MALE, - }, - { - .side = B_SIDE_OPPONENT, - .level = 14, - .species = SPECIES_ODDISH, - .moves = { MOVE_ABSORB, MOVE_SWEET_SCENT, MOVE_POISON_POWDER }, - .nature = NATURE_RASH, - .gender = MALE, - }, - {0xFF} -}; - -static const struct PokedudeBattlePartyInfo sParties_Matchups[] = -{ - { - .side = B_SIDE_PLAYER, - .level = 15, - .species = SPECIES_POLIWAG, - .moves = { MOVE_WATER_GUN, MOVE_HYPNOSIS, MOVE_BUBBLE }, - .nature = NATURE_RASH, - .gender = MALE, - }, - { - .side = B_SIDE_PLAYER, - .level = 15, - .species = SPECIES_BUTTERFREE, - .moves = { MOVE_CONFUSION, MOVE_POISON_POWDER, MOVE_STUN_SPORE, MOVE_SLEEP_POWDER }, - .nature = NATURE_RASH, - .gender = MALE, - }, - { - .side = B_SIDE_OPPONENT, - .level = 14, - .species = SPECIES_ODDISH, - .moves = { MOVE_ABSORB, MOVE_SWEET_SCENT, MOVE_POISON_POWDER }, - .nature = NATURE_RASH, - .gender = MALE, - }, - {0xFF} -}; - -static const struct PokedudeBattlePartyInfo sParties_Catching[] = -{ - { - .side = B_SIDE_PLAYER, - .level = 15, - .species = SPECIES_BUTTERFREE, - .moves = { MOVE_CONFUSION, MOVE_POISON_POWDER, MOVE_SLEEP_POWDER, MOVE_STUN_SPORE }, - .nature = NATURE_RASH, - .gender = MALE, - }, - { - .side = B_SIDE_OPPONENT, - .level = 11, - .species = SPECIES_JIGGLYPUFF, - .moves = { MOVE_SING, MOVE_DEFENSE_CURL, MOVE_POUND }, - .nature = NATURE_CAREFUL, - .gender = MALE, - }, - {0xFF} -}; - - -static const struct PokedudeBattlePartyInfo *const sPokedudeBattlePartyPointers[] = -{ - [TTVSCR_BATTLE] = sParties_Battle, - [TTVSCR_STATUS] = sParties_Status, - [TTVSCR_MATCHUPS] = sParties_Matchups, - [TTVSCR_CATCHING] = sParties_Catching, -}; - static void nullsub_99(void) { } +#define pdScriptNum simulatedInputState[2] +#define pdMessageNo simulatedInputState[3] + void SetControllerToPokedude(void) { gBattlerControllerFuncs[gActiveBattler] = PokedudeBufferRunCommand; - *(&gBattleStruct->simulatedInputState[2]) = gSpecialVar_0x8004; - gBattleStruct->simulatedInputState[3] = 0; + *(&gBattleStruct->pdScriptNum) = gSpecialVar_0x8004; + gBattleStruct->pdMessageNo = 0; } static void PokedudeBufferRunCommand(void) @@ -570,7 +205,7 @@ static void PokedudeBufferRunCommand(void) { if (gBattleBufferA[gActiveBattler][0] < NELEMS(sPokedudeBufferCommands)) { - if (!sub_8159AB8()) + if (!HandlePokedudeVoiceoverEtc()) sPokedudeBufferCommands[gBattleBufferA[gActiveBattler][0]](); } else @@ -580,9 +215,9 @@ static void PokedudeBufferRunCommand(void) } } -static void sub_8156140(void) +static void HandleInputChooseAction(void) { - sub_8159824(); + PokedudeSimulateInputChooseAction(); } static void CompleteOnBattlerSpriteCallbackDummy(void) @@ -591,10 +226,10 @@ static void CompleteOnBattlerSpriteCallbackDummy(void) PokedudeBufferExecCompleted(); } -static void sub_8156184(void) +static void CompleteOnBattlerSpritePosX_0(void) { if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded == TRUE - && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0) + && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim) { @@ -617,7 +252,7 @@ static void CompleteOnInactiveTextPrinter(void) PokedudeBufferExecCompleted(); } -static void sub_8156254(void) +static void Pokedude_SetBattleEndCallbacks(void) { if (!gPaletteFade.active) { @@ -627,7 +262,7 @@ static void sub_8156254(void) } } -static void sub_8156294(void) +static void SwitchIn_HandleSoundAndEnd(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { @@ -637,10 +272,10 @@ static void sub_8156294(void) } } -static void sub_81562F0(void) +static void SwitchIn_CleanShinyAnimShowSubstitute(void) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy - && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim) + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = 0; @@ -648,17 +283,17 @@ static void sub_81562F0(void) FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS); if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattlerControllerFuncs[gActiveBattler] = sub_8156294; + gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd; } } -static void sub_81563A8(void) +static void SwitchIn_TryShinyAnimShowHealthbox(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy - && !(gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)) + && !(gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)) { DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], @@ -667,7 +302,7 @@ static void sub_81563A8(void) StartHealthboxSlideIn(gActiveBattler); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); CopyBattleSpriteInvisibility(gActiveBattler); - gBattlerControllerFuncs[gActiveBattler] = sub_81562F0; + gBattlerControllerFuncs[gActiveBattler] = SwitchIn_CleanShinyAnimShowSubstitute; } } @@ -677,7 +312,7 @@ static void CompleteOnSpecialAnimDone(void) PokedudeBufferExecCompleted(); } -static void sub_815649C(void) +static void Intro_DelayAndEnd(void) { if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == 255) { @@ -686,9 +321,9 @@ static void sub_815649C(void) } } -static void sub_81564E4(void) +static void PokedudeHandleInputChooseMove(void) { - sub_8159998(); + PokedudeSimulateInputChooseMove(); } static void OpenPartyMenuToChooseMon(void) @@ -746,13 +381,13 @@ static void CompleteWhenChoseItem(void) } } -static void sub_8156624(void) +static void Intro_TryShinyAnimShowHealthbox(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) TryShinyAnimation(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]); if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) { @@ -772,19 +407,19 @@ static void sub_8156624(void) StartHealthboxSlideIn(gActiveBattler); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); gBattleSpritesDataPtr->animationData->healthboxSlideInStarted = 0; - gBattlerControllerFuncs[gActiveBattler] = sub_81567B0; + gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox; } } -static void sub_81567B0(void) +static void Intro_WaitForShinyAnimAndHealthbox(void) { bool32 r4 = FALSE; if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) r4 = TRUE; if (r4 - && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim - && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim) + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = 0; @@ -794,7 +429,7 @@ static void sub_81567B0(void) FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS); CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - gBattlerControllerFuncs[gActiveBattler] = sub_815649C; + gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd; } } @@ -829,7 +464,7 @@ static void Task_GiveExpToMon(u8 taskId) BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELED_UP, gainedExp); gActiveBattler = savedActiveBattler; if (IsDoubleBattle() == TRUE - && ((u16)monId == gBattlerPartyIndexes[battlerId] || (u16)monId == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])) + && ((u16)monId == gBattlerPartyIndexes[battlerId] || (u16)monId == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])) gTasks[taskId].func = Task_LaunchLvlUpAnim; else gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter; @@ -864,10 +499,10 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId) expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp; SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp); PlaySE(SE_EXP); - gTasks[taskId].func = sub_8156B24; + gTasks[taskId].func = Task_GiveExpWithExpBar; } -static void sub_8156B24(u8 taskId) +static void Task_GiveExpWithExpBar(u8 taskId) { if (gTasks[taskId].tExpTask_frames < 13) { @@ -937,7 +572,7 @@ static void Task_UpdateLvlInHealthbox(u8 taskId) { u8 monIndex = gTasks[taskId].tExpTask_monId; - GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value. + GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value. if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[battlerId ^ BIT_FLANK]) UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL); else @@ -957,7 +592,7 @@ static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId) DestroyTask(taskId); } -static void sub_8156DCC(void) +static void FreeMonSpriteAfterFaintAnim(void) { if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { @@ -1020,7 +655,7 @@ static void DoHitAnimBlinkSpriteEffect(void) } } -static void sub_8156F7C(void) +static void DoSwitchOutAnimation(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { @@ -1448,42 +1083,42 @@ static void SetPokedudeMonData(u8 monId) switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: - { - u8 iv; + { + u8 iv; - SetMonData(mon, MON_DATA_SPECIES, &battlePokemon->species); - SetMonData(mon, MON_DATA_HELD_ITEM, &battlePokemon->item); - for (i = 0; i < MAX_MON_MOVES; ++i) - { - SetMonData(mon, MON_DATA_MOVE1 + i, &battlePokemon->moves[i]); - SetMonData(mon, MON_DATA_PP1 + i, &battlePokemon->pp[i]); - } - SetMonData(mon, MON_DATA_PP_BONUSES, &battlePokemon->ppBonuses); - SetMonData(mon, MON_DATA_FRIENDSHIP, &battlePokemon->friendship); - SetMonData(mon, MON_DATA_EXP, &battlePokemon->experience); - iv = battlePokemon->hpIV; - SetMonData(mon, MON_DATA_HP_IV, &iv); - iv = battlePokemon->attackIV; - SetMonData(mon, MON_DATA_ATK_IV, &iv); - iv = battlePokemon->defenseIV; - SetMonData(mon, MON_DATA_DEF_IV, &iv); - iv = battlePokemon->speedIV; - SetMonData(mon, MON_DATA_SPEED_IV, &iv); - iv = battlePokemon->spAttackIV; - SetMonData(mon, MON_DATA_SPATK_IV, &iv); - iv = battlePokemon->spDefenseIV; - SetMonData(mon, MON_DATA_SPDEF_IV, &iv); - SetMonData(mon, MON_DATA_PERSONALITY, &battlePokemon->personality); - SetMonData(mon, MON_DATA_STATUS, &battlePokemon->status1); - SetMonData(mon, MON_DATA_LEVEL, &battlePokemon->level); - SetMonData(mon, MON_DATA_HP, &battlePokemon->hp); - SetMonData(mon, MON_DATA_MAX_HP, &battlePokemon->maxHP); - SetMonData(mon, MON_DATA_ATK, &battlePokemon->attack); - SetMonData(mon, MON_DATA_DEF, &battlePokemon->defense); - SetMonData(mon, MON_DATA_SPEED, &battlePokemon->speed); - SetMonData(mon, MON_DATA_SPATK, &battlePokemon->spAttack); - SetMonData(mon, MON_DATA_SPDEF, &battlePokemon->spDefense); + SetMonData(mon, MON_DATA_SPECIES, &battlePokemon->species); + SetMonData(mon, MON_DATA_HELD_ITEM, &battlePokemon->item); + for (i = 0; i < MAX_MON_MOVES; ++i) + { + SetMonData(mon, MON_DATA_MOVE1 + i, &battlePokemon->moves[i]); + SetMonData(mon, MON_DATA_PP1 + i, &battlePokemon->pp[i]); } + SetMonData(mon, MON_DATA_PP_BONUSES, &battlePokemon->ppBonuses); + SetMonData(mon, MON_DATA_FRIENDSHIP, &battlePokemon->friendship); + SetMonData(mon, MON_DATA_EXP, &battlePokemon->experience); + iv = battlePokemon->hpIV; + SetMonData(mon, MON_DATA_HP_IV, &iv); + iv = battlePokemon->attackIV; + SetMonData(mon, MON_DATA_ATK_IV, &iv); + iv = battlePokemon->defenseIV; + SetMonData(mon, MON_DATA_DEF_IV, &iv); + iv = battlePokemon->speedIV; + SetMonData(mon, MON_DATA_SPEED_IV, &iv); + iv = battlePokemon->spAttackIV; + SetMonData(mon, MON_DATA_SPATK_IV, &iv); + iv = battlePokemon->spDefenseIV; + SetMonData(mon, MON_DATA_SPDEF_IV, &iv); + SetMonData(mon, MON_DATA_PERSONALITY, &battlePokemon->personality); + SetMonData(mon, MON_DATA_STATUS, &battlePokemon->status1); + SetMonData(mon, MON_DATA_LEVEL, &battlePokemon->level); + SetMonData(mon, MON_DATA_HP, &battlePokemon->hp); + SetMonData(mon, MON_DATA_MAX_HP, &battlePokemon->maxHP); + SetMonData(mon, MON_DATA_ATK, &battlePokemon->attack); + SetMonData(mon, MON_DATA_DEF, &battlePokemon->defense); + SetMonData(mon, MON_DATA_SPEED, &battlePokemon->speed); + SetMonData(mon, MON_DATA_SPATK, &battlePokemon->spAttack); + SetMonData(mon, MON_DATA_SPDEF, &battlePokemon->spDefense); + } break; case REQUEST_SPECIES_BATTLE: SetMonData(mon, MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); @@ -1679,7 +1314,7 @@ static void PokedudeHandleLoadMonSprite(void) gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); - gBattlerControllerFuncs[gActiveBattler] = sub_8156184; + gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpritePosX_0; PokedudeBufferExecCompleted(); } @@ -1690,8 +1325,8 @@ static void PokedudeHandleSwitchInAnim(void) BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); gActionSelectionCursor[gActiveBattler] = 0; gMoveSelectionCursor[gActiveBattler] = 0; - sub_8159478(gActiveBattler); - gBattlerControllerFuncs[gActiveBattler] = sub_81563A8; + StartSendOutAnim(gActiveBattler); + gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnimShowHealthbox; } static void PokedudeHandleReturnMonToBall(void) @@ -1699,7 +1334,7 @@ static void PokedudeHandleReturnMonToBall(void) if (gBattleBufferA[gActiveBattler][1] == 0) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); - gBattlerControllerFuncs[gActiveBattler] = sub_8156F7C; + gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { @@ -1717,9 +1352,9 @@ static void PokedudeHandleDrawTrainerPic(void) DecompressTrainerBackPalette(BACK_PIC_POKEDUDE, gActiveBattler); SetMultiuseSpriteTemplateToTrainerBack(BACK_PIC_POKEDUDE, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, - 80, - (8 - gTrainerBackPicCoords[BACK_PIC_POKEDUDE].size) * 4 + 80, - 30); + 80, + (8 - gTrainerBackPicCoords[BACK_PIC_POKEDUDE].size) * 4 + 80, + 30); gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; @@ -1749,8 +1384,8 @@ static void PokedudeHandleTrainerSlide(void) { DecompressTrainerBackPalette(BACK_PIC_POKEDUDE, gActiveBattler); SetMultiuseSpriteTemplateToTrainerBack(BACK_PIC_POKEDUDE, GetBattlerPosition(gActiveBattler)); - gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, - 80, + gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, + 80, (8 - gTrainerBackPicCoords[BACK_PIC_POKEDUDE].size) * 4 + 80, 30); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; @@ -1791,7 +1426,7 @@ static void PokedudeHandleFaintAnimation(void) PlaySE12WithPanning(SE_FAINT, SOUND_PAN_TARGET); gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintOpponentMon; } - gBattlerControllerFuncs[gActiveBattler] = sub_8156DCC; + gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim; } } } @@ -1910,13 +1545,13 @@ static void PokedudeHandlePrintSelectionString(void) PokedudeBufferExecCompleted(); } -static void sub_8158B20(void) +static void HandleChooseActionAfterDma3(void) { if (!IsDma3ManagerBusyWithBgCopy()) { gBattle_BG0_X = 0; gBattle_BG0_Y = 160; - gBattlerControllerFuncs[gActiveBattler] = sub_8156140; + gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseAction; } } @@ -1926,7 +1561,7 @@ static void PokedudeHandleChooseAction(void) if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { - gBattlerControllerFuncs[gActiveBattler] = sub_8158B20; + gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; BattlePutTextOnWindow(gText_EmptyString3, 0); BattlePutTextOnWindow(gText_BattleMenu, 2); for (i = 0; i < MAX_MON_MOVES; ++i) @@ -1937,7 +1572,7 @@ static void PokedudeHandleChooseAction(void) } else { - gBattlerControllerFuncs[gActiveBattler] = sub_8156140; + gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseAction; } } @@ -1946,13 +1581,13 @@ static void PokedudeHandleUnknownYesNoBox(void) PokedudeBufferExecCompleted(); } -static void sub_8158C04(void) +static void PokedudeHandleChooseMoveAfterDma3(void) { if (!IsDma3ManagerBusyWithBgCopy()) { gBattle_BG0_X = 0; gBattle_BG0_Y = 320; - gBattlerControllerFuncs[gActiveBattler] = sub_81564E4; + gBattlerControllerFuncs[gActiveBattler] = PokedudeHandleInputChooseMove; } } @@ -1961,11 +1596,11 @@ static void PokedudeHandleChooseMove(void) if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { InitMoveSelectionsVarsAndStrings(); - gBattlerControllerFuncs[gActiveBattler] = sub_8158C04; + gBattlerControllerFuncs[gActiveBattler] = PokedudeHandleChooseMoveAfterDma3; } else { - gBattlerControllerFuncs[gActiveBattler] = sub_81564E4; + gBattlerControllerFuncs[gActiveBattler] = PokedudeHandleInputChooseMove; } } @@ -2016,13 +1651,13 @@ static void PokedudeHandleHealthBarUpdate(void) { u32 maxHP = GetMonData(mon, MON_DATA_MAX_HP); u32 curHP = GetMonData(mon, MON_DATA_HP); - + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal); } else { u32 maxHP = GetMonData(mon, MON_DATA_MAX_HP); - + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], 0, HP_CURRENT); } @@ -2224,7 +1859,7 @@ static void PokedudeHandleIntroTrainerBallThrow(void) paletteNum = AllocSpritePalette(0xD6F8); LoadCompressedPalette(gTrainerBackPicPaletteTable[BACK_PIC_POKEDUDE].data, 0x100 + paletteNum * 16, 32); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; - taskId = CreateTask(sub_81595EC, 5); + taskId = CreateTask(Task_StartSendOutAnim, 5); gTasks[taskId].data[0] = gActiveBattler; if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; @@ -2232,7 +1867,7 @@ static void PokedudeHandleIntroTrainerBallThrow(void) gBattlerControllerFuncs[gActiveBattler] = nullsub_99; } -static void sub_8159478(u8 battlerId) +static void StartSendOutAnim(u8 battlerId) { u16 species; @@ -2255,7 +1890,7 @@ static void sub_8159478(u8 battlerId) gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); } -static void sub_81595EC(u8 taskId) +static void Task_StartSendOutAnim(u8 taskId) { if (gTasks[taskId].data[1] < 31) { @@ -2267,8 +1902,8 @@ static void sub_81595EC(u8 taskId) gActiveBattler = gTasks[taskId].data[0]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; - sub_8159478(gActiveBattler); - gBattlerControllerFuncs[gActiveBattler] = sub_8156624; + StartSendOutAnim(gActiveBattler); + gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox; gActiveBattler = savedActiveBattler; DestroyTask(taskId); } @@ -2277,7 +1912,7 @@ static void sub_81595EC(u8 taskId) static void PokedudeHandleDrawPartyStatusSummary(void) { if (gBattleBufferA[gActiveBattler][1] != 0 - && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { PokedudeBufferExecCompleted(); } @@ -2347,28 +1982,471 @@ static void PokedudeHandleCmd55(void) BeginFastPaletteFade(3); PokedudeBufferExecCompleted(); if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER) && gBattleTypeFlags & BATTLE_TYPE_LINK) - gBattlerControllerFuncs[gActiveBattler] = sub_8156254; + gBattlerControllerFuncs[gActiveBattler] = Pokedude_SetBattleEndCallbacks; } static void PokedudeCmdEnd(void) { } -static void sub_8159824(void) +// Script handlers + +struct PokedudeInputScript +{ + // 0-3 for selection, 4 to repeat, 255 to end + u8 cursorPos[MAX_BATTLERS_COUNT]; + u8 delay[MAX_BATTLERS_COUNT]; +}; + +static const struct PokedudeInputScript sInputScripts_ChooseAction_Battle[] = +{ + { + .cursorPos = {0, 0}, + .delay = {64, 0} + }, + { + .cursorPos = {4, 4}, + .delay = {0, 0} + }, +}; + +static const struct PokedudeInputScript sInputScripts_ChooseAction_Status[] = +{ + { + .cursorPos = {0, 0}, + .delay = {64, 0} + }, + { + .cursorPos = {1, 0}, + .delay = {64, 0} + }, + { + .cursorPos = {0, 0}, + .delay = {64, 0} + }, +}; + +static const struct PokedudeInputScript sInputScripts_ChooseAction_Matchups[] = { - const u8 (*r7)[8] = gUnknown_8479060[gBattleStruct->simulatedInputState[2]]; - + { + .cursorPos = {0, 0}, + .delay = {64, 0} + }, + { + .cursorPos = {2, 0}, + .delay = {64, 0} + }, + { + .cursorPos = {0, 0}, + .delay = {64, 0} + }, +}; + +static const struct PokedudeInputScript sInputScripts_ChooseAction_Catching[] = +{ + { + .cursorPos = {0, 0}, + .delay = {64, 0} + }, + { + .cursorPos = {0, 0}, + .delay = {64, 0} + }, + { + .cursorPos = {1, 0}, + .delay = {64, 0} + }, +}; + +static const struct PokedudeInputScript *const sInputScripts_ChooseAction[] = +{ + [TTVSCR_BATTLE] = sInputScripts_ChooseAction_Battle, + [TTVSCR_STATUS] = sInputScripts_ChooseAction_Status, + [TTVSCR_MATCHUPS] = sInputScripts_ChooseAction_Matchups, + [TTVSCR_CATCHING] = sInputScripts_ChooseAction_Catching, +}; + +static const struct PokedudeInputScript sInputScripts_ChooseMove_Battle[] = +{ + { + .cursorPos = { 2, 2}, + .delay = { 64, 0} + }, + { + .cursorPos = {255, 255}, + .delay = { 0, 0} + }, +}; + +static const struct PokedudeInputScript sInputScripts_ChooseMove_Status[] = +{ + { + .cursorPos = { 2, 2}, + .delay = { 64, 0} + }, + { + .cursorPos = { 2, 0}, + .delay = { 64, 0} + }, + { + .cursorPos = { 2, 0}, + .delay = { 64, 0} + }, + { + .cursorPos = {255, 255}, + .delay = { 0, 0} + }, +}; + +static const struct PokedudeInputScript sInputScripts_ChooseMove_Matchups[] = +{ + { + .cursorPos = { 2, 0}, + .delay = { 64, 0} + }, + { + .cursorPos = { 0, 0}, + .delay = { 64, 0} + }, + { + .cursorPos = { 0, 0}, + .delay = { 64, 0} + }, + { + .cursorPos = {255, 255}, + .delay = { 0, 0} + }, +}; + +static const struct PokedudeInputScript sInputScripts_ChooseMove_Catching[] = +{ + { + .cursorPos = { 0, 2}, + .delay = { 64, 0} + }, + { + .cursorPos = { 2, 2}, + .delay = { 64, 0} + }, + { + .cursorPos = {255, 255}, + .delay = { 0, 0} + }, +}; + +static const struct PokedudeInputScript *const sInputScripts_ChooseMove[] = +{ + [TTVSCR_BATTLE] = sInputScripts_ChooseMove_Battle, + [TTVSCR_STATUS] = sInputScripts_ChooseMove_Status, + [TTVSCR_MATCHUPS] = sInputScripts_ChooseMove_Matchups, + [TTVSCR_CATCHING] = sInputScripts_ChooseMove_Catching, +}; + +static const struct PokedudeTextScriptHeader sPokedudeTextScripts_Battle[] = +{ + { + .btlcmd = CONTROLLER_CHOOSEACTION, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_PRINTSTRING, + .side = B_SIDE_OPPONENT, + .stringid = STRINGID_USEDMOVE, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_CHOOSEACTION, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_PRINTSTRING, + .side = B_SIDE_PLAYER, + .stringid = STRINGID_PKMNGAINEDEXP, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, +}; + +static const struct PokedudeTextScriptHeader sPokedudeTextScripts_Status[] = +{ + { + .btlcmd = CONTROLLER_CHOOSEACTION, + .side = B_SIDE_PLAYER, + .callback = NULL, + }, + { + .btlcmd = CONTROLLER_CHOOSEACTION, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintMessageWithHealthboxPals, + }, + { + .btlcmd = CONTROLLER_OPENBAG, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_PRINTSTRING, + .side = B_SIDE_OPPONENT, + .stringid = STRINGID_USEDMOVE, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_PRINTSTRING, + .side = B_SIDE_PLAYER, + .stringid = STRINGID_PKMNGAINEDEXP, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, +}; + +static const struct PokedudeTextScriptHeader sPokedudeTextScripts_Matchups[] = +{ + { + .btlcmd = CONTROLLER_PRINTSTRING, + .side = B_SIDE_OPPONENT, + .stringid = STRINGID_USEDMOVE, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_CHOOSEACTION, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_CHOOSEPOKEMON, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_PRINTSTRING, + .side = B_SIDE_OPPONENT, + .stringid = STRINGID_USEDMOVE, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_CHOOSEACTION, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_CHOOSEMOVE, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_PRINTSTRING, + .side = B_SIDE_PLAYER, + .stringid = STRINGID_PKMNGAINEDEXP, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, +}; + +static const struct PokedudeTextScriptHeader sPokedudeTextScripts_Catching[] = +{ + { + .btlcmd = CONTROLLER_CHOOSEACTION, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_CHOOSEACTION, + .side = B_SIDE_PLAYER, + .callback = NULL, + }, + { + .btlcmd = CONTROLLER_CHOOSEACTION, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_PRINTSTRING, + .side = B_SIDE_OPPONENT, + .stringid = STRINGID_PKMNFASTASLEEP, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_OPENBAG, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, + { + .btlcmd = CONTROLLER_55, + .side = B_SIDE_PLAYER, + .callback = PokedudeAction_PrintVoiceoverMessage, + }, +}; + +static const struct PokedudeTextScriptHeader *const sPokedudeTextScripts[] = +{ + [TTVSCR_BATTLE] = sPokedudeTextScripts_Battle, + [TTVSCR_STATUS] = sPokedudeTextScripts_Status, + [TTVSCR_MATCHUPS] = sPokedudeTextScripts_Matchups, + [TTVSCR_CATCHING] = sPokedudeTextScripts_Catching, +}; + +static const u8 *const sPokedudeTexts_Battle[] = +{ + Pokedude_Text_SpeedierBattlerGoesFirst, + Pokedude_Text_MyRattataFasterThanPidgey, + Pokedude_Text_BattlersTakeTurnsAttacking, + Pokedude_Text_MyRattataWonGetsEXP, +}; + +static const u8 *const sPokedudeTexts_Status[] = +{ + Pokedude_Text_UhOhRattataPoisoned, + Pokedude_Text_UhOhRattataPoisoned, + Pokedude_Text_HealStatusRightAway, + Pokedude_Text_UsingItemTakesTurn, + Pokedude_Text_YayWeManagedToWin, +}; + +static const u8 *const sPokedudeTexts_TypeMatchup[] = +{ + Pokedude_Text_WaterNotVeryEffectiveAgainstGrass, + Pokedude_Text_GrassEffectiveAgainstWater, + Pokedude_Text_LetsTryShiftingMons, + Pokedude_Text_ShiftingUsesTurn, + Pokedude_Text_ButterfreeDoubleResistsGrass, + Pokedude_Text_ButterfreeGoodAgainstOddish, + Pokedude_Text_YeahWeWon, +}; + +static const u8 *const sPokedudeTexts_Catching[] = +{ + Pokedude_Text_WeakenMonBeforeCatching, + Pokedude_Text_WeakenMonBeforeCatching, + Pokedude_Text_BestIfTargetStatused, + Pokedude_Text_CantDoubleUpOnStatus, + Pokedude_Text_LetMeThrowBall, + Pokedude_Text_PickBestKindOfBall, +}; + +static const struct PokedudeBattlePartyInfo sParties_Battle[] = +{ + { + .side = B_SIDE_PLAYER, + .level = 15, + .species = SPECIES_RATTATA, + .moves = { MOVE_TACKLE, MOVE_TAIL_WHIP, MOVE_HYPER_FANG, MOVE_QUICK_ATTACK }, + .nature = NATURE_LONELY, + .gender = MALE, + }, + { + .side = B_SIDE_OPPONENT, + .level = 18, + .species = SPECIES_PIDGEY, + .moves = { MOVE_TACKLE, MOVE_SAND_ATTACK, MOVE_GUST, MOVE_QUICK_ATTACK }, + .nature = NATURE_NAUGHTY, + .gender = MALE, + }, + {0xFF} +}; + +static const struct PokedudeBattlePartyInfo sParties_Status[] = +{ + { + .side = B_SIDE_PLAYER, + .level = 15, + .species = SPECIES_RATTATA, + .moves = { MOVE_TACKLE, MOVE_TAIL_WHIP, MOVE_HYPER_FANG, MOVE_QUICK_ATTACK }, + .nature = NATURE_LONELY, + .gender = MALE, + }, + { + .side = B_SIDE_OPPONENT, + .level = 14, + .species = SPECIES_ODDISH, + .moves = { MOVE_ABSORB, MOVE_SWEET_SCENT, MOVE_POISON_POWDER }, + .nature = NATURE_RASH, + .gender = MALE, + }, + {0xFF} +}; + +static const struct PokedudeBattlePartyInfo sParties_Matchups[] = +{ + { + .side = B_SIDE_PLAYER, + .level = 15, + .species = SPECIES_POLIWAG, + .moves = { MOVE_WATER_GUN, MOVE_HYPNOSIS, MOVE_BUBBLE }, + .nature = NATURE_RASH, + .gender = MALE, + }, + { + .side = B_SIDE_PLAYER, + .level = 15, + .species = SPECIES_BUTTERFREE, + .moves = { MOVE_CONFUSION, MOVE_POISON_POWDER, MOVE_STUN_SPORE, MOVE_SLEEP_POWDER }, + .nature = NATURE_RASH, + .gender = MALE, + }, + { + .side = B_SIDE_OPPONENT, + .level = 14, + .species = SPECIES_ODDISH, + .moves = { MOVE_ABSORB, MOVE_SWEET_SCENT, MOVE_POISON_POWDER }, + .nature = NATURE_RASH, + .gender = MALE, + }, + {0xFF} +}; + +static const struct PokedudeBattlePartyInfo sParties_Catching[] = +{ + { + .side = B_SIDE_PLAYER, + .level = 15, + .species = SPECIES_BUTTERFREE, + .moves = { MOVE_CONFUSION, MOVE_POISON_POWDER, MOVE_SLEEP_POWDER, MOVE_STUN_SPORE }, + .nature = NATURE_RASH, + .gender = MALE, + }, + { + .side = B_SIDE_OPPONENT, + .level = 11, + .species = SPECIES_JIGGLYPUFF, + .moves = { MOVE_SING, MOVE_DEFENSE_CURL, MOVE_POUND }, + .nature = NATURE_CAREFUL, + .gender = MALE, + }, + {0xFF} +}; + + +static const struct PokedudeBattlePartyInfo *const sPokedudeBattlePartyPointers[] = +{ + [TTVSCR_BATTLE] = sParties_Battle, + [TTVSCR_STATUS] = sParties_Status, + [TTVSCR_MATCHUPS] = sParties_Matchups, + [TTVSCR_CATCHING] = sParties_Catching, +}; + +struct PokedudeBattlerState *gPokedudeBattlerStates[MAX_BATTLERS_COUNT]; + +#define PD_BTL_STATE(battler, idx) gPokedudeBattlerStates[battler]->idx] +#define PD_BTL_ACTION(battler) PD_BTL_STATE((battler), 0) +#define PD_BTL_MOVE(battler) PD_BTL_STATE((battler), 1) +#define PD_BTL_DELAY(battler) PD_BTL_STATE((battler), 2) +#define PD_BTL_MSG(battler) PD_BTL_STATE((battler), 3) +#define PD_BTL_BG0Y(battler) PD_BTL_STATE((battler), 4) + +static void PokedudeSimulateInputChooseAction(void) +{ + const struct PokedudeInputScript *script_p = sInputScripts_ChooseAction[gBattleStruct->pdScriptNum]; + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { DoBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX, 7, 1); DoBounceEffect(gActiveBattler, BOUNCE_MON, 7, 1); } - if (*(r7[gUnknown_3005EE0[gActiveBattler][0]] + gActiveBattler + 4) == gUnknown_3005EE0[gActiveBattler][2]) + if (script_p[gPokedudeBattlerStates[gActiveBattler]->action_idx].delay[gActiveBattler] == gPokedudeBattlerStates[gActiveBattler]->timer) { if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) PlaySE(SE_SELECT); - gUnknown_3005EE0[gActiveBattler][2] = 0; - switch (r7[gUnknown_3005EE0[gActiveBattler][0]][gActiveBattler]) + gPokedudeBattlerStates[gActiveBattler]->timer = 0; + switch (script_p[gPokedudeBattlerStates[gActiveBattler]->action_idx].cursorPos[gActiveBattler]) { case 0: BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0); @@ -2384,145 +2462,145 @@ static void sub_8159824(void) break; } PokedudeBufferExecCompleted(); - ++gUnknown_3005EE0[gActiveBattler][0]; - if (r7[gUnknown_3005EE0[gActiveBattler][0]][gActiveBattler] == 4) - gUnknown_3005EE0[gActiveBattler][0] = 0; + ++gPokedudeBattlerStates[gActiveBattler]->action_idx; + if (script_p[gPokedudeBattlerStates[gActiveBattler]->action_idx].cursorPos[gActiveBattler] == 4) + gPokedudeBattlerStates[gActiveBattler]->action_idx = 0; } else { - if (gActionSelectionCursor[gActiveBattler] != r7[gUnknown_3005EE0[gActiveBattler][0]][gActiveBattler] - && r7[gUnknown_3005EE0[gActiveBattler][0]][gActiveBattler + 4] / 2 == gUnknown_3005EE0[gActiveBattler][2]) + if (gActionSelectionCursor[gActiveBattler] != script_p[gPokedudeBattlerStates[gActiveBattler]->action_idx].cursorPos[gActiveBattler] + && script_p[gPokedudeBattlerStates[gActiveBattler]->action_idx].delay[gActiveBattler] / 2 == gPokedudeBattlerStates[gActiveBattler]->timer) { PlaySE(SE_SELECT); ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); - gActionSelectionCursor[gActiveBattler] = r7[gUnknown_3005EE0[gActiveBattler][0]][gActiveBattler]; + gActionSelectionCursor[gActiveBattler] = script_p[gPokedudeBattlerStates[gActiveBattler]->action_idx].cursorPos[gActiveBattler]; ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } } -static void sub_8159998(void) +static void PokedudeSimulateInputChooseMove(void) { - const u8 (*r7)[8] = gUnknown_84790D8[gBattleStruct->simulatedInputState[2]]; + const struct PokedudeInputScript *script_p = sInputScripts_ChooseMove[gBattleStruct->pdScriptNum]; - if (*(r7[gUnknown_3005EE0[gActiveBattler][1]] + gActiveBattler + 4) == gUnknown_3005EE0[gActiveBattler][2]) + if (script_p[gPokedudeBattlerStates[gActiveBattler]->move_idx].delay[gActiveBattler] == gPokedudeBattlerStates[gActiveBattler]->timer) { if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) PlaySE(SE_SELECT); - gUnknown_3005EE0[gActiveBattler][2] = 0; + gPokedudeBattlerStates[gActiveBattler]->timer = 0; BtlController_EmitTwoReturnValues(1, B_ACTION_EXEC_SCRIPT, - r7[gUnknown_3005EE0[gActiveBattler][1]][gActiveBattler] | ((gActiveBattler ^ BIT_SIDE) << 8)); + script_p[gPokedudeBattlerStates[gActiveBattler]->move_idx].cursorPos[gActiveBattler] | ((gActiveBattler ^ BIT_SIDE) << 8)); PokedudeBufferExecCompleted(); - ++gUnknown_3005EE0[gActiveBattler][1]; - if (r7[gUnknown_3005EE0[gActiveBattler][1]][gActiveBattler] == 255) - gUnknown_3005EE0[gActiveBattler][1] = 0; + ++gPokedudeBattlerStates[gActiveBattler]->move_idx; + if (script_p[gPokedudeBattlerStates[gActiveBattler]->move_idx].cursorPos[gActiveBattler] == 255) + gPokedudeBattlerStates[gActiveBattler]->move_idx = 0; } else { - if (r7[gUnknown_3005EE0[gActiveBattler][1]][gActiveBattler] != gMoveSelectionCursor[gActiveBattler] - && r7[gUnknown_3005EE0[gActiveBattler][1]][gActiveBattler + 4] / 2 == gUnknown_3005EE0[gActiveBattler][2]) + if (script_p[gPokedudeBattlerStates[gActiveBattler]->move_idx].cursorPos[gActiveBattler] != gMoveSelectionCursor[gActiveBattler] + && script_p[gPokedudeBattlerStates[gActiveBattler]->move_idx].delay[gActiveBattler] / 2 == gPokedudeBattlerStates[gActiveBattler]->timer) { PlaySE(SE_SELECT); MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); - gMoveSelectionCursor[gActiveBattler] = r7[gUnknown_3005EE0[gActiveBattler][1]][gActiveBattler]; + gMoveSelectionCursor[gActiveBattler] = script_p[gPokedudeBattlerStates[gActiveBattler]->move_idx].cursorPos[gActiveBattler]; MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); } - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } } -static bool8 sub_8159AB8(void) +static bool8 HandlePokedudeVoiceoverEtc(void) { - const struct Unk_84790E8 *r6 = gUnknown_8479198[gBattleStruct->simulatedInputState[2]]; - const u16 * r12 = (const u16 *)&gBattleBufferA[gActiveBattler][2]; + const struct PokedudeTextScriptHeader *header_p = sPokedudeTextScripts[gBattleStruct->pdScriptNum]; + const u16 * bstringid_p = (const u16 *)&gBattleBufferA[gActiveBattler][2]; - if (gBattleBufferA[gActiveBattler][0] != r6[gBattleStruct->simulatedInputState[3]].unk_0) + if (gBattleBufferA[gActiveBattler][0] != header_p[gBattleStruct->pdMessageNo].btlcmd) return FALSE; - if (gActiveBattler != r6[gBattleStruct->simulatedInputState[3]].unk_1) + if (gActiveBattler != header_p[gBattleStruct->pdMessageNo].side) return FALSE; - if (gBattleBufferA[gActiveBattler][0] == 16 && r6[gBattleStruct->simulatedInputState[3]].unk_2 != *r12) + if (gBattleBufferA[gActiveBattler][0] == CONTROLLER_PRINTSTRING && header_p[gBattleStruct->pdMessageNo].stringid != *bstringid_p) return FALSE; - if (r6[gBattleStruct->simulatedInputState[3]].unk_4 == NULL) + if (header_p[gBattleStruct->pdMessageNo].callback == NULL) { - gBattleStruct->simulatedInputState[3]++; + gBattleStruct->pdMessageNo++; return FALSE; } - gBattlerControllerFuncs[gActiveBattler] = r6[gBattleStruct->simulatedInputState[3]].unk_4; - gUnknown_3005EE0[gActiveBattler][2] = 0; - gUnknown_3005EE0[gActiveBattler][3] = r6[gBattleStruct->simulatedInputState[3]].unk_2; - gBattleStruct->simulatedInputState[3]++; + gBattlerControllerFuncs[gActiveBattler] = header_p[gBattleStruct->pdMessageNo].callback; + gPokedudeBattlerStates[gActiveBattler]->timer = 0; + gPokedudeBattlerStates[gActiveBattler]->msg_idx = header_p[gBattleStruct->pdMessageNo].stringid; + gBattleStruct->pdMessageNo++; return TRUE; } -static void sub_8159B78(void) +static void ReturnFromPokedudeAction(void) { - gUnknown_3005EE0[gActiveBattler][2] = 0; + gPokedudeBattlerStates[gActiveBattler]->timer = 0; gBattlerControllerFuncs[gActiveBattler] = PokedudeBufferRunCommand; } -static void sub_8159BA8(void) +static void PokedudeAction_PrintVoiceoverMessage(void) { - switch (gUnknown_3005EE0[gActiveBattler][2]) + switch (gPokedudeBattlerStates[gActiveBattler]->timer) { case 0: if (!gPaletteFade.active) { BeginNormalPaletteFade(0xFFFFFF7F, 4, 0, 8, RGB_BLACK); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } break; case 1: if (!gPaletteFade.active) { - gUnknown_3005EE0[gActiveBattler][4] = gBattle_BG0_Y; + gPokedudeBattlerStates[gActiveBattler]->saved_bg0y = gBattle_BG0_Y; BtlCtrl_DrawVoiceoverMessageFrame(); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } break; case 2: gBattle_BG0_Y = 0; BattleStringExpandPlaceholdersToDisplayedString(GetPokedudeText()); BattlePutTextOnWindow(gDisplayedStringBattle, 24); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; break; case 3: if (!IsTextPrinterActive(24) && JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFF7F, 4, 8, 0, RGB_BLACK); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } break; case 4: if (!gPaletteFade.active) { - if (gUnknown_3005EE0[gActiveBattler][3] == 13) + if (gPokedudeBattlerStates[gActiveBattler]->msg_idx == STRINGID_PKMNGAINEDEXP) { BattleStopLowHpSound(); PlayBGM(MUS_VICTORY_WILD); } - gBattle_BG0_Y = gUnknown_3005EE0[gActiveBattler][4]; + gBattle_BG0_Y = gPokedudeBattlerStates[gActiveBattler]->saved_bg0y; BtlCtrl_RemoveVoiceoverMessageFrame(); - sub_8159B78(); + ReturnFromPokedudeAction(); } break; } } -static void sub_8159D04(void) +static void PokedudeAction_PrintMessageWithHealthboxPals(void) { - switch (gUnknown_3005EE0[gActiveBattler][2]) + switch (gPokedudeBattlerStates[gActiveBattler]->timer) { case 0: if (!gPaletteFade.active) { DoLoadHealthboxPalsForLevelUp(&gBattleStruct->simulatedInputState[1], - &gBattleStruct->simulatedInputState[0], - GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)); + &gBattleStruct->simulatedInputState[0], + GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)); BeginNormalPaletteFade(0xFFFFFF7F, 4, 0, 8, RGB_BLACK); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } break; case 1: @@ -2531,22 +2609,22 @@ static void sub_8159D04(void) u32 mask = (gBitTable[gBattleStruct->simulatedInputState[1]] | gBitTable[gBattleStruct->simulatedInputState[0]]) << 16; ++mask; // It's possible that this is influenced by other functions, as - --mask; // this also striked in battle_controller_oak_old_man.c but was naturally fixed. + --mask; // this also striked in battle_controller_oak_old_man.c but was naturally fixed. BeginNormalPaletteFade(mask, 4, 8, 0, RGB_BLACK); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } break; case 2: if (!gPaletteFade.active) { BtlCtrl_DrawVoiceoverMessageFrame(); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } break; case 3: BattleStringExpandPlaceholdersToDisplayedString(GetPokedudeText()); BattlePutTextOnWindow(gDisplayedStringBattle, 24); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; break; case 4: if (!IsTextPrinterActive(24) && JOY_NEW(A_BUTTON)) @@ -2558,27 +2636,27 @@ static void sub_8159D04(void) ++mask; --mask; BeginNormalPaletteFade(mask, 4, 0, 8, RGB_BLACK); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } break; case 5: if (!gPaletteFade.active) { BeginNormalPaletteFade(0xFFFFFF7F, 4, 8, 0, RGB_BLACK); - ++gUnknown_3005EE0[gActiveBattler][2]; + ++gPokedudeBattlerStates[gActiveBattler]->timer; } break; case 6: if (!gPaletteFade.active) { - if (gUnknown_3005EE0[gActiveBattler][3] == 13) + if (gPokedudeBattlerStates[gActiveBattler]->msg_idx == STRINGID_PKMNGAINEDEXP) { BattleStopLowHpSound(); PlayBGM(MUS_VICTORY_WILD); } DoFreeHealthboxPalsForLevelUp(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)); BtlCtrl_RemoveVoiceoverMessageFrame(); - sub_8159B78(); + ReturnFromPokedudeAction(); } break; } @@ -2586,17 +2664,17 @@ static void sub_8159D04(void) static const u8 *GetPokedudeText(void) { - switch (gBattleStruct->simulatedInputState[2]) + switch (gBattleStruct->pdScriptNum) { case TTVSCR_BATTLE: default: - return sPokedudeTexts_Battle[gBattleStruct->simulatedInputState[3] - 1]; + return sPokedudeTexts_Battle[gBattleStruct->pdMessageNo - 1]; case TTVSCR_STATUS: - return sPokedudeTexts_Status[gBattleStruct->simulatedInputState[3] - 1]; + return sPokedudeTexts_Status[gBattleStruct->pdMessageNo - 1]; case TTVSCR_MATCHUPS: - return sPokedudeTexts_TypeMatchup[gBattleStruct->simulatedInputState[3] - 1]; + return sPokedudeTexts_TypeMatchup[gBattleStruct->pdMessageNo - 1]; case TTVSCR_CATCHING: - return sPokedudeTexts_Catching[gBattleStruct->simulatedInputState[3] - 1]; + return sPokedudeTexts_Catching[gBattleStruct->pdMessageNo - 1]; } } diff --git a/src/battle_util2.c b/src/battle_util2.c index 6de4941cb..7b3a36d4e 100644 --- a/src/battle_util2.c +++ b/src/battle_util2.c @@ -15,7 +15,7 @@ void AllocateBattleResources(void) s32 i; for (i = 0; i < 4; ++i) - gUnknown_3005EE0[i] = AllocZeroed(8); + gPokedudeBattlerStates[i] = AllocZeroed(sizeof(struct PokedudeBattlerState)); } gBattleStruct = AllocZeroed(sizeof(*gBattleStruct)); gBattleResources = AllocZeroed(sizeof(*gBattleResources)); @@ -45,7 +45,7 @@ void FreeBattleResources(void) for (i = 0; i < 4; ++i) { - FREE_AND_SET_NULL(gUnknown_3005EE0[i]); + FREE_AND_SET_NULL(gPokedudeBattlerStates[i]); } } if (gBattleResources != NULL) |