pokeemerald/src/battle_controller_recorded_player.c

1813 lines
71 KiB
C
Raw Normal View History

2017-10-23 11:24:58 +02:00
#include "global.h"
#include "battle.h"
2018-11-14 01:01:50 +01:00
#include "battle_ai_script_commands.h"
#include "battle_anim.h"
2017-10-23 11:24:58 +02:00
#include "battle_controllers.h"
#include "battle_message.h"
#include "battle_interface.h"
2018-11-14 01:01:50 +01:00
#include "bg.h"
2019-04-04 23:53:06 +02:00
#include "data.h"
2018-11-14 01:01:50 +01:00
#include "item_use.h"
2017-10-23 11:24:58 +02:00
#include "link.h"
#include "main.h"
#include "m4a.h"
#include "palette.h"
2018-11-14 01:01:50 +01:00
#include "pokeball.h"
#include "pokemon.h"
#include "recorded_battle.h"
#include "reshow_battle_screen.h"
#include "sound.h"
#include "string_util.h"
2017-10-23 11:24:58 +02:00
#include "task.h"
#include "text.h"
2018-11-14 01:01:50 +01:00
#include "util.h"
#include "window.h"
#include "constants/battle_anim.h"
#include "constants/songs.h"
2017-10-23 11:24:58 +02:00
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandleGetMonData(void);
static void RecordedPlayerHandleGetRawMonData(void);
static void RecordedPlayerHandleSetMonData(void);
static void RecordedPlayerHandleSetRawMonData(void);
static void RecordedPlayerHandleLoadMonSprite(void);
static void RecordedPlayerHandleSwitchInAnim(void);
static void RecordedPlayerHandleReturnMonToBall(void);
static void RecordedPlayerHandleDrawTrainerPic(void);
static void RecordedPlayerHandleTrainerSlide(void);
static void RecordedPlayerHandleTrainerSlideBack(void);
static void RecordedPlayerHandleFaintAnimation(void);
static void RecordedPlayerHandlePaletteFade(void);
static void RecordedPlayerHandleSuccessBallThrowAnim(void);
static void RecordedPlayerHandleBallThrowAnim(void);
static void RecordedPlayerHandlePause(void);
static void RecordedPlayerHandleMoveAnimation(void);
static void RecordedPlayerHandlePrintString(void);
static void RecordedPlayerHandlePrintSelectionString(void);
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandleChooseAction(void);
static void RecordedPlayerHandleYesNoBox(void);
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandleChooseMove(void);
static void RecordedPlayerHandleChooseItem(void);
static void RecordedPlayerHandleChoosePokemon(void);
static void RecordedPlayerHandleCmd23(void);
static void RecordedPlayerHandleHealthBarUpdate(void);
static void RecordedPlayerHandleExpUpdate(void);
static void RecordedPlayerHandleStatusIconUpdate(void);
static void RecordedPlayerHandleStatusAnimation(void);
static void RecordedPlayerHandleStatusXor(void);
static void RecordedPlayerHandleDataTransfer(void);
static void RecordedPlayerHandleDMA3Transfer(void);
static void RecordedPlayerHandlePlayBGM(void);
static void RecordedPlayerHandleCmd32(void);
static void RecordedPlayerHandleTwoReturnValues(void);
static void RecordedPlayerHandleChosenMonReturnValue(void);
static void RecordedPlayerHandleOneReturnValue(void);
static void RecordedPlayerHandleOneReturnValue_Duplicate(void);
2020-12-29 22:51:44 +01:00
static void RecordedPlayerHandleClearUnkVar(void);
static void RecordedPlayerHandleSetUnkVar(void);
static void RecordedPlayerHandleClearUnkFlag(void);
static void RecordedPlayerHandleToggleUnkFlag(void);
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandleHitAnimation(void);
2021-04-03 18:38:07 +02:00
static void RecordedPlayerHandleCantSwitch(void);
static void RecordedPlayerHandlePlaySE(void);
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandlePlayFanfareOrBGM(void);
static void RecordedPlayerHandleFaintingCry(void);
static void RecordedPlayerHandleIntroSlide(void);
static void RecordedPlayerHandleIntroTrainerBallThrow(void);
static void RecordedPlayerHandleDrawPartyStatusSummary(void);
2018-06-28 21:06:32 +02:00
static void RecordedPlayerHandleHidePartyStatusSummary(void);
2018-06-20 23:07:51 +02:00
static void RecordedPlayerHandleEndBounceEffect(void);
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandleSpriteInvisibility(void);
static void RecordedPlayerHandleBattleAnimation(void);
static void RecordedPlayerHandleLinkStandbyMsg(void);
static void RecordedPlayerHandleResetActionMoveSelection(void);
static void RecordedPlayerHandleEndLinkBattle(void);
static void RecordedPlayerCmdEnd(void);
2017-10-23 13:32:11 +02:00
static void RecordedPlayerBufferRunCommand(void);
static void RecordedPlayerBufferExecCompleted(void);
static void SwitchIn_WaitAndEnd(void);
2017-10-23 13:32:11 +02:00
static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst);
static void SetRecordedPlayerMonData(u8 monId);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
2017-10-23 13:32:11 +02:00
static void DoSwitchOutAnimation(void);
static void RecordedPlayerDoMoveAnimation(void);
static void Task_StartSendOutAnim(u8 taskId);
2021-01-23 02:03:21 +01:00
static void EndDrawPartyStatusSummary(void);
2017-10-23 13:32:11 +02:00
2017-10-31 18:04:08 +01:00
static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
2017-10-23 11:24:58 +02:00
{
2020-12-29 22:51:44 +01:00
[CONTROLLER_GETMONDATA] = RecordedPlayerHandleGetMonData,
[CONTROLLER_GETRAWMONDATA] = RecordedPlayerHandleGetRawMonData,
[CONTROLLER_SETMONDATA] = RecordedPlayerHandleSetMonData,
[CONTROLLER_SETRAWMONDATA] = RecordedPlayerHandleSetRawMonData,
[CONTROLLER_LOADMONSPRITE] = RecordedPlayerHandleLoadMonSprite,
[CONTROLLER_SWITCHINANIM] = RecordedPlayerHandleSwitchInAnim,
[CONTROLLER_RETURNMONTOBALL] = RecordedPlayerHandleReturnMonToBall,
[CONTROLLER_DRAWTRAINERPIC] = RecordedPlayerHandleDrawTrainerPic,
[CONTROLLER_TRAINERSLIDE] = RecordedPlayerHandleTrainerSlide,
[CONTROLLER_TRAINERSLIDEBACK] = RecordedPlayerHandleTrainerSlideBack,
[CONTROLLER_FAINTANIMATION] = RecordedPlayerHandleFaintAnimation,
[CONTROLLER_PALETTEFADE] = RecordedPlayerHandlePaletteFade,
[CONTROLLER_SUCCESSBALLTHROWANIM] = RecordedPlayerHandleSuccessBallThrowAnim,
[CONTROLLER_BALLTHROWANIM] = RecordedPlayerHandleBallThrowAnim,
[CONTROLLER_PAUSE] = RecordedPlayerHandlePause,
[CONTROLLER_MOVEANIMATION] = RecordedPlayerHandleMoveAnimation,
[CONTROLLER_PRINTSTRING] = RecordedPlayerHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = RecordedPlayerHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = RecordedPlayerHandleChooseAction,
[CONTROLLER_YESNOBOX] = RecordedPlayerHandleYesNoBox,
2020-12-29 22:51:44 +01:00
[CONTROLLER_CHOOSEMOVE] = RecordedPlayerHandleChooseMove,
[CONTROLLER_OPENBAG] = RecordedPlayerHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = RecordedPlayerHandleChoosePokemon,
[CONTROLLER_23] = RecordedPlayerHandleCmd23,
[CONTROLLER_HEALTHBARUPDATE] = RecordedPlayerHandleHealthBarUpdate,
[CONTROLLER_EXPUPDATE] = RecordedPlayerHandleExpUpdate,
[CONTROLLER_STATUSICONUPDATE] = RecordedPlayerHandleStatusIconUpdate,
[CONTROLLER_STATUSANIMATION] = RecordedPlayerHandleStatusAnimation,
[CONTROLLER_STATUSXOR] = RecordedPlayerHandleStatusXor,
[CONTROLLER_DATATRANSFER] = RecordedPlayerHandleDataTransfer,
[CONTROLLER_DMA3TRANSFER] = RecordedPlayerHandleDMA3Transfer,
[CONTROLLER_PLAYBGM] = RecordedPlayerHandlePlayBGM,
[CONTROLLER_32] = RecordedPlayerHandleCmd32,
[CONTROLLER_TWORETURNVALUES] = RecordedPlayerHandleTwoReturnValues,
[CONTROLLER_CHOSENMONRETURNVALUE] = RecordedPlayerHandleChosenMonReturnValue,
[CONTROLLER_ONERETURNVALUE] = RecordedPlayerHandleOneReturnValue,
[CONTROLLER_ONERETURNVALUE_DUPLICATE] = RecordedPlayerHandleOneReturnValue_Duplicate,
[CONTROLLER_CLEARUNKVAR] = RecordedPlayerHandleClearUnkVar,
[CONTROLLER_SETUNKVAR] = RecordedPlayerHandleSetUnkVar,
[CONTROLLER_CLEARUNKFLAG] = RecordedPlayerHandleClearUnkFlag,
[CONTROLLER_TOGGLEUNKFLAG] = RecordedPlayerHandleToggleUnkFlag,
[CONTROLLER_HITANIMATION] = RecordedPlayerHandleHitAnimation,
2021-04-03 18:38:07 +02:00
[CONTROLLER_CANTSWITCH] = RecordedPlayerHandleCantSwitch,
2020-12-29 22:51:44 +01:00
[CONTROLLER_PLAYSE] = RecordedPlayerHandlePlaySE,
[CONTROLLER_PLAYFANFAREORBGM] = RecordedPlayerHandlePlayFanfareOrBGM,
[CONTROLLER_FAINTINGCRY] = RecordedPlayerHandleFaintingCry,
[CONTROLLER_INTROSLIDE] = RecordedPlayerHandleIntroSlide,
[CONTROLLER_INTROTRAINERBALLTHROW] = RecordedPlayerHandleIntroTrainerBallThrow,
[CONTROLLER_DRAWPARTYSTATUSSUMMARY] = RecordedPlayerHandleDrawPartyStatusSummary,
[CONTROLLER_HIDEPARTYSTATUSSUMMARY] = RecordedPlayerHandleHidePartyStatusSummary,
[CONTROLLER_ENDBOUNCE] = RecordedPlayerHandleEndBounceEffect,
[CONTROLLER_SPRITEINVISIBILITY] = RecordedPlayerHandleSpriteInvisibility,
[CONTROLLER_BATTLEANIMATION] = RecordedPlayerHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = RecordedPlayerHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = RecordedPlayerHandleResetActionMoveSelection,
[CONTROLLER_ENDLINKBATTLE] = RecordedPlayerHandleEndLinkBattle,
2020-12-29 22:51:44 +01:00
[CONTROLLER_TERMINATOR_NOP] = RecordedPlayerCmdEnd
2017-10-23 11:24:58 +02:00
};
static void RecordedPlayerDummy(void)
2017-10-23 11:24:58 +02:00
{
}
2017-10-26 23:12:48 +02:00
void SetControllerToRecordedPlayer(void)
2017-10-23 11:24:58 +02:00
{
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand;
2017-10-23 11:24:58 +02:00
}
2017-10-23 13:32:11 +02:00
static void RecordedPlayerBufferRunCommand(void)
2017-10-23 11:24:58 +02:00
{
2018-02-06 20:48:02 +01:00
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
2017-10-23 11:24:58 +02:00
{
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands))
sRecordedPlayerBufferCommands[gBattleBufferA[gActiveBattler][0]]();
2017-10-23 11:24:58 +02:00
else
RecordedPlayerBufferExecCompleted();
}
}
2017-10-23 13:32:11 +02:00
static void CompleteOnBattlerSpriteCallbackDummy(void)
2017-10-23 13:32:11 +02:00
{
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void FreeTrainerSpriteAfterSlide(void)
2017-10-23 13:32:11 +02:00
{
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-23 13:32:11 +02:00
{
2021-01-23 02:03:21 +01:00
BattleGfxSfxDummy3(MALE);
2018-02-06 20:48:02 +01:00
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
}
static void Intro_DelayAndEnd(void)
2017-10-23 13:32:11 +02:00
{
2021-01-23 02:03:21 +01:00
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
2017-10-23 13:32:11 +02:00
{
2021-01-23 02:03:21 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
}
static void Intro_WaitForShinyAnimAndHealthbox(void)
2017-10-23 13:32:11 +02:00
{
bool32 healthboxAnimDone = FALSE;
2017-10-23 13:32:11 +02:00
2018-02-06 02:46:59 +01:00
if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT)
2017-10-23 13:32:11 +02:00
{
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
2018-02-06 20:48:02 +01:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
healthboxAnimDone = TRUE;
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
2017-10-23 13:32:11 +02:00
{
healthboxAnimDone = TRUE;
2017-10-23 13:32:11 +02:00
}
}
if (healthboxAnimDone && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
2020-08-30 21:11:44 +02:00
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim)
2017-10-23 13:32:11 +02:00
{
2020-08-30 21:11:44 +02:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
2017-10-23 13:32:11 +02:00
2020-08-30 21:11:44 +02:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
2017-10-23 13:32:11 +02:00
2018-02-06 20:48:02 +01:00
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
2017-10-23 13:32:11 +02:00
if (IsDoubleBattle())
2018-02-06 20:48:02 +01:00
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK);
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
2017-10-23 13:32:11 +02:00
}
}
else
{
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
2018-02-06 20:48:02 +01:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
healthboxAnimDone = TRUE;
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
2017-10-23 13:32:11 +02:00
{
healthboxAnimDone = TRUE;
2017-10-23 13:32:11 +02:00
}
}
if (IsCryPlayingOrClearCrySongs())
healthboxAnimDone = FALSE;
2017-10-23 13:32:11 +02:00
if (healthboxAnimDone)
2017-10-23 13:32:11 +02:00
{
2021-01-23 02:03:21 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
2017-10-23 13:32:11 +02:00
}
}
}
static void Intro_TryShinyAnimShowHealthbox(void)
2017-10-23 13:32:11 +02:00
{
bool32 bgmRestored = FALSE;
2017-10-23 13:32:11 +02:00
2018-02-06 02:46:59 +01:00
if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT)
2017-10-23 13:32:11 +02:00
{
2020-08-30 21:11:44 +02:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
2018-02-06 02:46:59 +01:00
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
2020-08-30 21:11:44 +02:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim
2018-02-06 02:46:59 +01:00
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
TryShinyAnimation(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]);
2017-10-23 13:32:11 +02:00
}
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
2017-10-23 13:32:11 +02:00
{
2021-01-23 02:03:21 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
2017-10-23 13:32:11 +02:00
{
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
2018-02-06 20:48:02 +01:00
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
2021-01-23 02:03:21 +01:00
StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
2018-02-06 20:48:02 +01:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
2017-10-23 13:32:11 +02:00
}
2018-02-06 20:48:02 +01:00
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
2021-01-23 02:03:21 +01:00
StartHealthboxSlideIn(gActiveBattler);
2018-02-06 20:48:02 +01:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-23 13:32:11 +02:00
}
2021-01-23 02:03:21 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
2017-10-23 13:32:11 +02:00
}
2021-01-23 02:03:21 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].waitForCry
2017-10-23 13:32:11 +02:00
&& !IsCryPlayingOrClearCrySongs())
{
2021-01-23 02:03:21 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
2017-10-23 13:32:11 +02:00
{
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
2018-02-06 02:46:59 +01:00
if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT)
m4aMPlayContinue(&gMPlayInfo_BGM);
2017-10-23 13:32:11 +02:00
}
else
{
2021-10-09 17:33:37 +02:00
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
2017-10-23 13:32:11 +02:00
}
}
2021-01-23 02:03:21 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
2017-10-23 13:32:11 +02:00
}
if (bgmRestored && gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
2018-02-06 20:48:02 +01:00
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-23 13:32:11 +02:00
{
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
2021-01-23 02:03:21 +01:00
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
2017-10-23 13:32:11 +02:00
}
}
static void WaitForMonAnimAfterLoad(void)
2017-10-23 13:32:11 +02:00
{
2021-07-07 15:11:52 +02:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void CompleteOnHealthbarDone(void)
{
2018-06-19 00:43:15 +02:00
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
2017-10-23 13:32:11 +02:00
2018-02-06 20:48:02 +01:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-23 13:32:11 +02:00
if (hpValue != -1)
{
2018-02-06 20:48:02 +01:00
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
}
2021-01-23 02:03:21 +01:00
static void FreeMonSpriteAfterFaintAnim(void)
2017-10-23 13:32:11 +02:00
{
2021-07-07 15:11:52 +02:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].y + gSprites[gBattlerSpriteIds[gActiveBattler]].y2 > DISPLAY_HEIGHT)
2017-10-23 13:32:11 +02:00
{
2018-02-06 20:48:02 +01:00
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
BattleGfxSfxDummy2(species);
2018-02-06 20:48:02 +01:00
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
}
static void FreeMonSpriteAfterSwitchOutAnim(void)
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-23 13:32:11 +02:00
{
2018-02-06 20:48:02 +01:00
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
}
static void CompleteOnInactiveTextPrinter(void)
{
2021-10-08 22:50:52 +02:00
if (!IsTextPrinterActive(B_WIN_MSG))
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void DoHitAnimBlinkSpriteEffect(void)
{
2018-02-06 20:48:02 +01:00
u8 spriteId = gBattlerSpriteIds[gActiveBattler];
2017-10-23 13:32:11 +02:00
2017-12-02 21:44:50 +01:00
if (gSprites[spriteId].data[1] == 32)
2017-10-23 13:32:11 +02:00
{
2017-12-02 21:44:50 +01:00
gSprites[spriteId].data[1] = 0;
gSprites[spriteId].invisible = FALSE;
2017-10-23 13:32:11 +02:00
gDoingBattleAnim = FALSE;
RecordedPlayerBufferExecCompleted();
}
else
{
2017-12-02 21:44:50 +01:00
if ((gSprites[spriteId].data[1] % 4) == 0)
2017-10-23 13:32:11 +02:00
gSprites[spriteId].invisible ^= 1;
2017-12-02 21:44:50 +01:00
gSprites[spriteId].data[1]++;
2017-10-23 13:32:11 +02:00
}
}
static void SwitchIn_ShowSubstitute(void)
2017-10-23 13:32:11 +02:00
{
2018-02-06 20:48:02 +01:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
CopyBattleSpriteInvisibility(gActiveBattler);
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
2017-10-23 13:32:11 +02:00
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_WaitAndEnd;
2017-10-23 13:32:11 +02:00
}
}
static void SwitchIn_WaitAndEnd(void)
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
2018-02-06 20:48:02 +01:00
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-23 13:32:11 +02:00
{
RecordedPlayerBufferExecCompleted();
}
}
static void SwitchIn_ShowHealthbox(void)
2017-10-23 13:32:11 +02:00
{
2020-08-30 21:11:44 +02:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
2017-10-23 13:32:11 +02:00
{
2020-08-30 21:11:44 +02:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
2018-02-06 20:48:02 +01:00
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
2021-01-23 02:03:21 +01:00
StartHealthboxSlideIn(gActiveBattler);
2018-02-06 20:48:02 +01:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-23 13:32:11 +02:00
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
2017-10-23 13:32:11 +02:00
}
}
static void SwitchIn_TryShinyAnim(void)
2017-10-23 13:32:11 +02:00
{
2020-08-30 21:11:44 +02:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
2017-10-23 13:32:11 +02:00
{
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
2017-10-23 13:32:11 +02:00
}
2021-01-23 02:03:21 +01:00
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
2018-02-06 02:46:59 +01:00
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
2017-10-23 13:32:11 +02:00
{
2021-01-23 02:03:21 +01:00
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
2017-10-23 13:32:11 +02:00
}
}
static void RecordedPlayerBufferExecCompleted(void)
{
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand;
2017-10-23 13:32:11 +02:00
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
2018-02-06 02:46:59 +01:00
gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
2017-10-23 13:32:11 +02:00
}
}
static void CompleteOnFinishedStatusAnimation(void)
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive)
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void CompleteOnFinishedBattleAnimation(void)
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive)
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleGetMonData(void)
{
u8 monData[sizeof(struct Pokemon) * 2 + 56]; // this allows to get full data of two pokemon, trying to get more will result in overwriting data
u32 size = 0;
2017-10-31 18:04:08 +01:00
u8 monToCheck;
2017-10-23 13:32:11 +02:00
s32 i;
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][2] == 0)
2017-10-23 13:32:11 +02:00
{
2018-02-06 20:48:02 +01:00
size += CopyRecordedPlayerMonData(gBattlerPartyIndexes[gActiveBattler], monData);
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 02:46:59 +01:00
monToCheck = gBattleBufferA[gActiveBattler][2];
2018-11-18 20:00:36 +01:00
for (i = 0; i < PARTY_SIZE; i++)
2017-10-23 13:32:11 +02:00
{
2017-10-31 18:04:08 +01:00
if (monToCheck & 1)
2017-10-23 13:32:11 +02:00
size += CopyRecordedPlayerMonData(i, monData + size);
2017-10-31 18:04:08 +01:00
monToCheck >>= 1;
2017-10-23 13:32:11 +02:00
}
}
BtlController_EmitDataTransfer(BUFFER_B, size, monData);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst)
{
struct BattlePokemon battleMon;
struct MovePpInfo moveData;
u8 nickname[20];
u8 *src;
s16 data16;
u32 data32;
s32 size = 0;
2018-02-06 02:46:59 +01:00
switch (gBattleBufferA[gActiveBattler][1])
2017-10-23 13:32:11 +02:00
{
case REQUEST_ALL_BATTLE:
battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES);
battleMon.item = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM);
for (size = 0; size < MAX_MON_MOVES; size++)
2017-10-23 13:32:11 +02:00
{
battleMon.moves[size] = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + size);
battleMon.pp[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size);
}
battleMon.ppBonuses = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES);
battleMon.friendship = GetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP);
battleMon.experience = GetMonData(&gPlayerParty[monId], MON_DATA_EXP);
battleMon.hpIV = GetMonData(&gPlayerParty[monId], MON_DATA_HP_IV);
battleMon.attackIV = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV);
battleMon.defenseIV = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV);
2017-10-24 15:35:36 +02:00
battleMon.speedIV = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV);
2017-10-23 13:32:11 +02:00
battleMon.spAttackIV = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV);
battleMon.spDefenseIV = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV);
battleMon.personality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY);
battleMon.status1 = GetMonData(&gPlayerParty[monId], MON_DATA_STATUS);
battleMon.level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
battleMon.hp = GetMonData(&gPlayerParty[monId], MON_DATA_HP);
battleMon.maxHP = GetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP);
battleMon.attack = GetMonData(&gPlayerParty[monId], MON_DATA_ATK);
battleMon.defense = GetMonData(&gPlayerParty[monId], MON_DATA_DEF);
2017-10-24 15:35:36 +02:00
battleMon.speed = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED);
2017-10-23 13:32:11 +02:00
battleMon.spAttack = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK);
battleMon.spDefense = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF);
battleMon.isEgg = GetMonData(&gPlayerParty[monId], MON_DATA_IS_EGG);
2019-05-14 15:22:16 +02:00
battleMon.abilityNum = GetMonData(&gPlayerParty[monId], MON_DATA_ABILITY_NUM);
2017-10-23 13:32:11 +02:00
battleMon.otId = GetMonData(&gPlayerParty[monId], MON_DATA_OT_ID);
GetMonData(&gPlayerParty[monId], MON_DATA_NICKNAME, nickname);
StringCopy_Nickname(battleMon.nickname, nickname);
2017-10-23 13:32:11 +02:00
GetMonData(&gPlayerParty[monId], MON_DATA_OT_NAME, battleMon.otName);
src = (u8 *)&battleMon;
for (size = 0; size < sizeof(battleMon); size++)
dst[size] = src[size];
break;
case REQUEST_SPECIES_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_HELDITEM_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_MOVES_PP_BATTLE:
for (size = 0; size < MAX_MON_MOVES; size++)
2017-10-23 13:32:11 +02:00
{
moveData.moves[size] = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + size);
moveData.pp[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size);
}
moveData.ppBonuses = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES);
src = (u8*)(&moveData);
for (size = 0; size < sizeof(moveData); size++)
dst[size] = src[size];
break;
case REQUEST_MOVE1_BATTLE:
case REQUEST_MOVE2_BATTLE:
case REQUEST_MOVE3_BATTLE:
case REQUEST_MOVE4_BATTLE:
2018-02-06 02:46:59 +01:00
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE);
2017-10-23 13:32:11 +02:00
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_PP_DATA_BATTLE:
for (size = 0; size < MAX_MON_MOVES; size++)
2017-10-23 13:32:11 +02:00
dst[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size);
dst[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES);
size++;
break;
case REQUEST_PPMOVE1_BATTLE:
case REQUEST_PPMOVE2_BATTLE:
case REQUEST_PPMOVE3_BATTLE:
case REQUEST_PPMOVE4_BATTLE:
2018-02-06 02:46:59 +01:00
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE);
2017-10-23 13:32:11 +02:00
size = 1;
break;
case REQUEST_OTID_BATTLE:
data32 = GetMonData(&gPlayerParty[monId], MON_DATA_OT_ID);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
size = 3;
break;
case REQUEST_EXP_BATTLE:
data32 = GetMonData(&gPlayerParty[monId], MON_DATA_EXP);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
size = 3;
break;
case REQUEST_HP_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_HP_EV);
size = 1;
break;
case REQUEST_ATK_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV);
size = 1;
break;
case REQUEST_DEF_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV);
size = 1;
break;
case REQUEST_SPEED_EV_BATTLE:
2017-10-24 15:35:36 +02:00
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV);
2017-10-23 13:32:11 +02:00
size = 1;
break;
case REQUEST_SPATK_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV);
size = 1;
break;
case REQUEST_SPDEF_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV);
size = 1;
break;
case REQUEST_FRIENDSHIP_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP);
size = 1;
break;
case REQUEST_POKERUS_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_POKERUS);
size = 1;
break;
case REQUEST_MET_LOCATION_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION);
size = 1;
break;
case REQUEST_MET_LEVEL_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL);
size = 1;
break;
case REQUEST_MET_GAME_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME);
size = 1;
break;
case REQUEST_POKEBALL_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL);
size = 1;
break;
case REQUEST_ALL_IVS_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_HP_IV);
dst[1] = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV);
dst[2] = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV);
2017-10-24 15:35:36 +02:00
dst[3] = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV);
2017-10-23 13:32:11 +02:00
dst[4] = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV);
dst[5] = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV);
size = 6;
break;
case REQUEST_HP_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_HP_IV);
size = 1;
break;
case REQUEST_ATK_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV);
size = 1;
break;
case REQUEST_DEF_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV);
size = 1;
break;
case REQUEST_SPEED_IV_BATTLE:
2017-10-24 15:35:36 +02:00
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV);
2017-10-23 13:32:11 +02:00
size = 1;
break;
case REQUEST_SPATK_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV);
size = 1;
break;
case REQUEST_SPDEF_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV);
size = 1;
break;
case REQUEST_PERSONALITY_BATTLE:
data32 = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
dst[3] = (data32 & 0xFF000000) >> 24;
size = 4;
break;
case REQUEST_CHECKSUM_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_STATUS_BATTLE:
data32 = GetMonData(&gPlayerParty[monId], MON_DATA_STATUS);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
dst[3] = (data32 & 0xFF000000) >> 24;
size = 4;
break;
case REQUEST_LEVEL_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
size = 1;
break;
case REQUEST_HP_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_HP);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_MAX_HP_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_ATK_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_ATK);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_DEF_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_DEF);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_SPEED_BATTLE:
2017-10-24 15:35:36 +02:00
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED);
2017-10-23 13:32:11 +02:00
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_SPATK_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_SPDEF_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_COOL_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_COOL);
size = 1;
break;
case REQUEST_BEAUTY_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY);
size = 1;
break;
case REQUEST_CUTE_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_CUTE);
size = 1;
break;
case REQUEST_SMART_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SMART);
size = 1;
break;
case REQUEST_TOUGH_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_TOUGH);
size = 1;
break;
case REQUEST_SHEEN_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SHEEN);
size = 1;
break;
case REQUEST_COOL_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON);
size = 1;
break;
case REQUEST_BEAUTY_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON);
size = 1;
break;
case REQUEST_CUTE_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON);
size = 1;
break;
case REQUEST_SMART_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON);
size = 1;
break;
case REQUEST_TOUGH_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON);
size = 1;
break;
}
return size;
}
static void RecordedPlayerHandleGetRawMonData(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleSetMonData(void)
{
2017-10-31 18:04:08 +01:00
u8 monToCheck;
2017-10-23 13:32:11 +02:00
u8 i;
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][2] == 0)
2017-10-23 13:32:11 +02:00
{
2018-02-06 20:48:02 +01:00
SetRecordedPlayerMonData(gBattlerPartyIndexes[gActiveBattler]);
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 02:46:59 +01:00
monToCheck = gBattleBufferA[gActiveBattler][2];
2018-11-18 20:00:36 +01:00
for (i = 0; i < PARTY_SIZE; i++)
2017-10-23 13:32:11 +02:00
{
2017-10-31 18:04:08 +01:00
if (monToCheck & 1)
2017-10-23 13:32:11 +02:00
SetRecordedPlayerMonData(i);
2017-10-31 18:04:08 +01:00
monToCheck >>= 1;
2017-10-23 13:32:11 +02:00
}
}
RecordedPlayerBufferExecCompleted();
}
static void SetRecordedPlayerMonData(u8 monId)
{
2018-02-06 02:46:59 +01:00
struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3];
struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3];
2017-10-23 13:32:11 +02:00
s32 i;
2018-02-06 02:46:59 +01:00
switch (gBattleBufferA[gActiveBattler][1])
2017-10-23 13:32:11 +02:00
{
case REQUEST_ALL_BATTLE:
{
u8 iv;
SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &battlePokemon->species);
SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &battlePokemon->item);
for (i = 0; i < MAX_MON_MOVES; i++)
2017-10-23 13:32:11 +02:00
{
SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + i, &battlePokemon->moves[i]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + i, &battlePokemon->pp[i]);
}
SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &battlePokemon->ppBonuses);
SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &battlePokemon->friendship);
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &battlePokemon->experience);
iv = battlePokemon->hpIV;
SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &iv);
iv = battlePokemon->attackIV;
SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &iv);
iv = battlePokemon->defenseIV;
SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &iv);
iv = battlePokemon->speedIV;
2017-10-24 15:35:36 +02:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &iv);
2017-10-23 13:32:11 +02:00
iv = battlePokemon->spAttackIV;
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &iv);
iv = battlePokemon->spDefenseIV;
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &iv);
SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &battlePokemon->personality);
SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &battlePokemon->status1);
SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &battlePokemon->level);
SetMonData(&gPlayerParty[monId], MON_DATA_HP, &battlePokemon->hp);
SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &battlePokemon->maxHP);
SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &battlePokemon->attack);
SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &battlePokemon->defense);
2017-10-24 15:35:36 +02:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &battlePokemon->speed);
2017-10-23 13:32:11 +02:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &battlePokemon->spAttack);
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &battlePokemon->spDefense);
}
break;
case REQUEST_SPECIES_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_HELDITEM_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_MOVES_PP_BATTLE:
for (i = 0; i < MAX_MON_MOVES; i++)
2017-10-23 13:32:11 +02:00
{
SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + i, &moveData->moves[i]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + i, &moveData->pp[i]);
}
SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &moveData->ppBonuses);
break;
case REQUEST_MOVE1_BATTLE:
case REQUEST_MOVE2_BATTLE:
case REQUEST_MOVE3_BATTLE:
case REQUEST_MOVE4_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_PP_DATA_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_PPMOVE1_BATTLE:
case REQUEST_PPMOVE2_BATTLE:
case REQUEST_PPMOVE3_BATTLE:
case REQUEST_PPMOVE4_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_OTID_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_EXP_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_HP_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_ATK_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_DEF_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SPEED_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SPATK_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SPDEF_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_FRIENDSHIP_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_POKERUS_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_MET_LOCATION_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_MET_LEVEL_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_MET_GAME_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_POKEBALL_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_ALL_IVS_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]);
SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]);
SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]);
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]);
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]);
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_HP_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_ATK_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_DEF_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SPEED_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SPATK_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SPDEF_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_PERSONALITY_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_CHECKSUM_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_STATUS_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_LEVEL_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_HP_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_MAX_HP_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_ATK_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_DEF_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SPEED_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SPATK_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SPDEF_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_COOL_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_BEAUTY_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_CUTE_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SMART_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_TOUGH_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SHEEN_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_COOL_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_BEAUTY_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_CUTE_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_SMART_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
case REQUEST_TOUGH_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-23 13:32:11 +02:00
break;
}
2018-02-06 20:48:02 +01:00
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
2017-10-23 13:32:11 +02:00
}
static void RecordedPlayerHandleSetRawMonData(void)
{
2018-02-06 20:48:02 +01:00
u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
2017-10-23 13:32:11 +02:00
u8 i;
2018-02-06 02:46:59 +01:00
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
dst[i] = gBattleBufferA[gActiveBattler][3 + i];
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleLoadMonSprite(void)
{
u16 species;
2018-02-06 20:48:02 +01:00
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler));
2017-10-23 13:32:11 +02:00
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate,
2021-11-08 19:18:58 +01:00
GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2),
2018-02-06 20:48:02 +01:00
GetBattlerSpriteDefault_Y(gActiveBattler),
2018-12-18 05:08:08 +01:00
GetBattlerSpriteSubpriority(gActiveBattler));
2021-07-07 15:11:52 +02:00
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -DISPLAY_WIDTH;
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = WaitForMonAnimAfterLoad;
2017-10-23 13:32:11 +02:00
}
static void RecordedPlayerHandleSwitchInAnim(void)
{
2018-02-06 02:46:59 +01:00
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
2018-02-06 20:48:02 +01:00
gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
2017-10-23 13:32:11 +02:00
}
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
2017-10-23 13:32:11 +02:00
{
u16 species;
2018-03-01 00:59:52 +01:00
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
2021-01-23 02:03:21 +01:00
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
2017-10-23 13:32:11 +02:00
2018-03-01 00:59:52 +01:00
gBattlerSpriteIds[battlerId] = CreateSprite(
&gMultiuseSpriteTemplate,
2021-11-08 19:18:58 +01:00
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2),
2018-03-01 00:59:52 +01:00
GetBattlerSpriteDefault_Y(battlerId),
2018-12-18 05:08:08 +01:00
GetBattlerSpriteSubpriority(battlerId));
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
2017-10-23 13:32:11 +02:00
2018-03-01 00:59:52 +01:00
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
2017-10-23 13:32:11 +02:00
2018-03-01 00:59:52 +01:00
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
2017-10-23 13:32:11 +02:00
2018-03-01 00:59:52 +01:00
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
2017-10-23 13:32:11 +02:00
}
static void RecordedPlayerHandleReturnMonToBall(void)
{
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][1] == 0)
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation;
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
}
static void DoSwitchOutAnimation(void)
{
2018-02-06 02:46:59 +01:00
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
2017-10-23 13:32:11 +02:00
{
case 0:
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
2017-10-23 13:32:11 +02:00
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
2017-10-23 13:32:11 +02:00
break;
case 1:
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
2017-10-23 13:32:11 +02:00
}
break;
}
}
2021-01-23 02:03:21 +01:00
#define sSpeedX data[0]
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandleDrawTrainerPic(void)
{
s16 xPos, yPos;
u32 trainerPicId;
2021-01-13 21:17:32 +01:00
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK)
2017-10-23 13:32:11 +02:00
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
2018-02-08 11:17:41 +01:00
trainerPicId = GetActiveBattlerLinkPlayerGender();
2017-10-23 13:32:11 +02:00
else
2021-01-13 21:17:32 +01:00
trainerPicId = gLinkPlayers[gRecordedBattleMultiplayerId].gender;
2017-10-23 13:32:11 +02:00
}
else
{
trainerPicId = gLinkPlayers[0].gender;
}
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
2018-02-06 02:46:59 +01:00
if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon
2017-10-23 13:32:11 +02:00
xPos = 90;
else // first mon
xPos = 32;
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
{
xPos = 90;
yPos = (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 80;
2017-10-23 13:32:11 +02:00
}
else
{
yPos = (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80;
2017-10-23 13:32:11 +02:00
}
}
else
{
xPos = 80;
yPos = (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80;
2017-10-23 13:32:11 +02:00
}
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
{
trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender);
2018-02-06 02:46:59 +01:00
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler));
2018-12-18 05:08:08 +01:00
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
2021-07-07 15:11:52 +02:00
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].y2 = 48;
2021-01-23 02:03:21 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 02:46:59 +01:00
DecompressTrainerBackPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
2018-12-18 05:08:08 +01:00
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
2018-02-06 02:46:59 +01:00
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
2021-07-07 15:11:52 +02:00
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
2021-01-23 02:03:21 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
2017-10-23 13:32:11 +02:00
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
2017-10-23 13:32:11 +02:00
}
2021-01-23 02:03:21 +01:00
#undef sSpeedX
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandleTrainerSlide(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleTrainerSlideBack(void)
{
2019-02-06 20:17:09 +01:00
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
2021-07-07 15:11:52 +02:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
2018-11-26 00:00:18 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
2018-02-06 20:48:02 +01:00
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
2017-10-23 13:32:11 +02:00
}
2021-01-23 02:03:21 +01:00
#define sSpeedX data[1]
#define sSpeedY data[2]
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandleFaintAnimation(void)
{
2018-02-06 02:46:59 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
2017-10-23 13:32:11 +02:00
{
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
2018-02-06 20:48:02 +01:00
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
2020-08-21 00:02:00 +02:00
PlaySE12WithPanning(SE_FAINT, -64);
2021-01-23 02:03:21 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedY = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim;
2017-10-23 13:32:11 +02:00
}
}
}
2021-01-23 02:03:21 +01:00
#undef sSpeedX
#undef sSpeedY
2017-10-23 13:32:11 +02:00
static void RecordedPlayerHandlePaletteFade(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleSuccessBallThrowAnim(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleBallThrowAnim(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandlePause(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleMoveAnimation(void)
{
2021-01-23 02:03:21 +01:00
if (!IsBattleSEPlaying(gActiveBattler))
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
gAnimMoveTurn = gBattleBufferA[gActiveBattler][3];
gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8);
gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24);
gAnimFriendship = gBattleBufferA[gActiveBattler][10];
gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
2017-10-23 13:32:11 +02:00
if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE
{
RecordedPlayerBufferExecCompleted();
}
else
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerDoMoveAnimation;
2017-10-23 13:32:11 +02:00
}
}
}
static void RecordedPlayerDoMoveAnimation(void)
{
2018-02-06 02:46:59 +01:00
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
u8 multihit = gBattleBufferA[gActiveBattler][11];
2017-10-23 13:32:11 +02:00
2018-02-06 02:46:59 +01:00
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
2017-10-23 13:32:11 +02:00
{
case 0:
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
2017-10-23 13:32:11 +02:00
{
2018-02-06 23:09:39 +01:00
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
2017-10-23 13:32:11 +02:00
}
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
2017-10-23 13:32:11 +02:00
break;
case 1:
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-23 13:32:11 +02:00
{
2021-01-23 02:03:21 +01:00
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
2017-10-23 13:32:11 +02:00
DoMoveAnim(move);
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
2017-10-23 13:32:11 +02:00
}
break;
case 2:
gAnimScriptCallback();
if (!gAnimScriptActive)
{
2021-01-23 02:03:21 +01:00
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
2018-02-06 23:09:39 +01:00
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
2017-10-23 13:32:11 +02:00
}
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
2017-10-23 13:32:11 +02:00
}
break;
case 3:
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-23 13:32:11 +02:00
{
2017-11-04 16:11:13 +01:00
CopyAllBattleSpritesInvisibilities();
2018-02-06 02:46:59 +01:00
TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
break;
}
}
static void RecordedPlayerHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
2018-02-06 02:46:59 +01:00
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
2017-10-23 13:32:11 +02:00
BufferStringBattle(*stringId);
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
2017-10-23 13:32:11 +02:00
}
static void RecordedPlayerHandlePrintSelectionString(void)
2017-10-23 13:32:11 +02:00
{
RecordedPlayerBufferExecCompleted();
}
static void ChooseActionInBattlePalace(void)
{
2018-02-06 02:46:59 +01:00
if (gBattleCommunication[4] >= gBattlersCount / 2)
2017-10-23 13:32:11 +02:00
{
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(gActiveBattler), 0);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
}
static void RecordedPlayerHandleChooseAction(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = ChooseActionInBattlePalace;
2017-10-23 13:32:11 +02:00
}
else
{
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(gActiveBattler), 0);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
}
static void RecordedPlayerHandleYesNoBox(void)
2017-10-23 13:32:11 +02:00
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleChooseMove(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 23:09:39 +01:00
u8 moveId = RecordedBattle_GetBattlerAction(gActiveBattler);
u8 target = RecordedBattle_GetBattlerAction(gActiveBattler);
BtlController_EmitTwoReturnValues(BUFFER_B, 10, moveId | (target << 8));
2017-10-23 13:32:11 +02:00
}
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleChooseItem(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleChoosePokemon(void)
{
2018-02-06 23:09:39 +01:00
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(gActiveBattler);
BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleCmd23(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleHealthBarUpdate(void)
{
s16 hpVal;
LoadBattleBarGfx(0);
2018-02-06 02:46:59 +01:00
hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
2017-10-23 13:32:11 +02:00
if (hpVal != INSTANT_HP_BAR_DROP)
{
2018-02-06 20:48:02 +01:00
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
2017-10-23 13:32:11 +02:00
2018-02-06 20:48:02 +01:00
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
2017-10-23 13:32:11 +02:00
2018-02-06 20:48:02 +01:00
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], 0, HP_CURRENT);
2017-10-23 13:32:11 +02:00
}
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
2017-10-23 13:32:11 +02:00
}
static void RecordedPlayerHandleExpUpdate(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleStatusIconUpdate(void)
{
2021-01-23 02:03:21 +01:00
if (!IsBattleSEPlaying(gActiveBattler))
2017-10-23 13:32:11 +02:00
{
2018-03-01 00:59:52 +01:00
u8 battlerId;
2017-10-23 13:32:11 +02:00
2018-02-06 20:48:02 +01:00
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
2018-03-01 00:59:52 +01:00
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
2017-10-23 13:32:11 +02:00
}
}
static void RecordedPlayerHandleStatusAnimation(void)
{
2021-01-23 02:03:21 +01:00
if (!IsBattleSEPlaying(gActiveBattler))
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
2017-10-23 13:32:11 +02:00
}
}
static void RecordedPlayerHandleStatusXor(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleDataTransfer(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleDMA3Transfer(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandlePlayBGM(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleCmd32(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleTwoReturnValues(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleChosenMonReturnValue(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleOneReturnValue(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleOneReturnValue_Duplicate(void)
{
RecordedPlayerBufferExecCompleted();
}
2020-12-29 22:51:44 +01:00
static void RecordedPlayerHandleClearUnkVar(void)
2017-10-23 13:32:11 +02:00
{
2020-12-29 22:51:44 +01:00
gUnusedControllerStruct.unk = 0;
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
2020-12-29 22:51:44 +01:00
static void RecordedPlayerHandleSetUnkVar(void)
2017-10-23 13:32:11 +02:00
{
2020-12-29 22:51:44 +01:00
gUnusedControllerStruct.unk = gBattleBufferA[gActiveBattler][1];
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
2020-12-29 22:51:44 +01:00
static void RecordedPlayerHandleClearUnkFlag(void)
2017-10-23 13:32:11 +02:00
{
2020-12-29 22:51:44 +01:00
gUnusedControllerStruct.flag = 0;
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
2020-12-29 22:51:44 +01:00
static void RecordedPlayerHandleToggleUnkFlag(void)
2017-10-23 13:32:11 +02:00
{
2020-12-29 22:51:44 +01:00
gUnusedControllerStruct.flag ^= 1;
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleHitAnimation(void)
{
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
2017-10-23 13:32:11 +02:00
{
RecordedPlayerBufferExecCompleted();
}
else
{
gDoingBattleAnim = TRUE;
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
2018-02-06 02:46:59 +01:00
DoHitAnimHealthboxEffect(gActiveBattler);
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
2017-10-23 13:32:11 +02:00
}
}
2021-04-03 18:38:07 +02:00
static void RecordedPlayerHandleCantSwitch(void)
2017-10-23 13:32:11 +02:00
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandlePlaySE(void)
2017-10-23 13:32:11 +02:00
{
s8 pan;
2018-02-06 02:46:59 +01:00
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
pan = SOUND_PAN_ATTACKER;
2017-10-23 13:32:11 +02:00
else
pan = SOUND_PAN_TARGET;
2017-10-23 13:32:11 +02:00
2018-02-06 02:46:59 +01:00
PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandlePlayFanfareOrBGM(void)
{
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][3])
2017-10-23 13:32:11 +02:00
{
2017-11-04 16:11:13 +01:00
BattleStopLowHpSound();
2018-02-06 02:46:59 +01:00
PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8));
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 02:46:59 +01:00
PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8));
2017-10-23 13:32:11 +02:00
}
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleFaintingCry(void)
{
2018-02-06 20:48:02 +01:00
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
2017-10-23 13:32:11 +02:00
2021-11-07 19:54:44 +01:00
PlayCry_ByMode(species, -25, CRY_MODE_FAINT);
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleIntroSlide(void)
{
2018-02-06 02:46:59 +01:00
HandleIntroSlide(gBattleBufferA[gActiveBattler][1]);
2018-02-08 11:17:41 +01:00
gIntroSlideFlags |= 1;
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleIntroTrainerBallThrow(void)
{
u8 paletteNum;
u8 taskId;
u32 trainerPicId;
2019-02-06 20:17:09 +01:00
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
2017-10-23 13:32:11 +02:00
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
2021-07-07 15:11:52 +02:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
2018-11-26 00:00:18 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
2018-02-06 20:48:02 +01:00
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
2017-10-23 13:32:11 +02:00
paletteNum = AllocSpritePalette(0xD6F9);
2021-01-13 21:17:32 +01:00
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK)
2018-02-06 20:48:02 +01:00
trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender;
2017-10-23 13:32:11 +02:00
else
trainerPicId = gSaveBlock2Ptr->playerGender;
LoadCompressedPalette(gTrainerBackPicPaletteTable[trainerPicId].data, 0x100 + paletteNum * 16, 32);
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
2017-10-23 13:32:11 +02:00
taskId = CreateTask(Task_StartSendOutAnim, 5);
2018-02-06 02:46:59 +01:00
gTasks[taskId].data[0] = gActiveBattler;
2017-10-23 13:32:11 +02:00
2018-06-28 21:06:32 +02:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerDummy;
2017-10-23 13:32:11 +02:00
}
static void Task_StartSendOutAnim(u8 taskId)
2017-10-23 13:32:11 +02:00
{
if (gTasks[taskId].data[1] < 24)
{
gTasks[taskId].data[1]++;
}
else
{
2018-02-06 02:46:59 +01:00
u8 savedActiveBank = gActiveBattler;
2017-10-23 13:32:11 +02:00
2018-02-06 02:46:59 +01:00
gActiveBattler = gTasks[taskId].data[0];
2017-10-23 13:32:11 +02:00
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
2018-02-06 20:48:02 +01:00
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE);
2017-10-23 13:32:11 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE);
2018-02-06 02:46:59 +01:00
gActiveBattler ^= BIT_FLANK;
2018-02-06 20:48:02 +01:00
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSendOutAnim(gActiveBattler, FALSE);
2018-02-06 02:46:59 +01:00
gActiveBattler ^= BIT_FLANK;
2017-10-23 13:32:11 +02:00
}
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
2018-02-06 02:46:59 +01:00
gActiveBattler = savedActiveBank;
2017-10-23 13:32:11 +02:00
DestroyTask(taskId);
}
}
static void RecordedPlayerHandleDrawPartyStatusSummary(void)
{
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
2017-10-23 13:32:11 +02:00
{
RecordedPlayerBufferExecCompleted();
}
else
{
2018-06-28 21:06:32 +02:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
2018-02-08 11:17:41 +01:00
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]);
2021-01-23 02:03:21 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
2017-10-23 13:32:11 +02:00
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][2] != 0)
2021-01-23 02:03:21 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93;
2017-10-23 13:32:11 +02:00
2021-01-23 02:03:21 +01:00
gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary;
2017-10-23 13:32:11 +02:00
}
}
2021-01-23 02:03:21 +01:00
static void EndDrawPartyStatusSummary(void)
2017-10-23 13:32:11 +02:00
{
2021-01-23 02:03:21 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
2017-10-23 13:32:11 +02:00
{
2021-01-23 02:03:21 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
}
2018-06-28 21:06:32 +02:00
static void RecordedPlayerHandleHidePartyStatusSummary(void)
2017-10-23 13:32:11 +02:00
{
2018-06-28 21:06:32 +02:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
}
2018-06-20 23:07:51 +02:00
static void RecordedPlayerHandleEndBounceEffect(void)
2017-10-23 13:32:11 +02:00
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleSpriteInvisibility(void)
{
2018-02-06 20:48:02 +01:00
if (IsBattlerSpritePresent(gActiveBattler))
2017-10-23 13:32:11 +02:00
{
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1];
2018-02-06 02:46:59 +01:00
CopyBattleSpriteInvisibility(gActiveBattler);
2017-10-23 13:32:11 +02:00
}
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleBattleAnimation(void)
{
2021-01-23 02:03:21 +01:00
if (!IsBattleSEPlaying(gActiveBattler))
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
2017-10-23 13:32:11 +02:00
2018-02-06 02:46:59 +01:00
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
2017-10-23 13:32:11 +02:00
RecordedPlayerBufferExecCompleted();
else
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
2017-10-23 13:32:11 +02:00
}
}
static void RecordedPlayerHandleLinkStandbyMsg(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleResetActionMoveSelection(void)
{
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleEndLinkBattle(void)
2017-10-23 13:32:11 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
2017-10-23 13:32:11 +02:00
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
RecordedPlayerBufferExecCompleted();
2021-01-23 02:03:21 +01:00
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
2017-10-23 13:32:11 +02:00
}
static void RecordedPlayerCmdEnd(void)
2017-10-23 13:32:11 +02:00
{
}