sovereignx/src/battle_controller_player_partner.c

1261 lines
47 KiB
C
Raw Normal View History

2017-10-22 19:49:21 +01:00
#include "global.h"
#include "battle.h"
2020-12-20 21:47:20 +00:00
#include "battle_ai_main.h"
#include "battle_ai_util.h"
2018-11-14 00:01:50 +00:00
#include "battle_anim.h"
2017-10-22 19:49:21 +01:00
#include "battle_controllers.h"
#include "battle_message.h"
#include "battle_interface.h"
2018-11-14 00:01:50 +00:00
#include "battle_setup.h"
#include "battle_tower.h"
2020-12-01 18:43:15 +00:00
#include "battle_z_move.h"
2018-11-14 00:01:50 +00:00
#include "bg.h"
2019-04-04 22:53:06 +01:00
#include "data.h"
2018-11-14 00:01:50 +00:00
#include "item_use.h"
2017-10-22 19:49:21 +01:00
#include "link.h"
#include "main.h"
#include "m4a.h"
#include "palette.h"
#include "party_menu.h"
2018-11-14 00:01:50 +00:00
#include "pokeball.h"
#include "pokemon.h"
#include "reshow_battle_screen.h"
#include "sound.h"
#include "string_util.h"
2017-10-22 19:49:21 +01:00
#include "task.h"
#include "text.h"
2018-11-14 00:01:50 +00:00
#include "util.h"
#include "window.h"
#include "constants/battle_anim.h"
#include "constants/songs.h"
#include "constants/party_menu.h"
2018-11-14 00:01:50 +00:00
#include "constants/trainers.h"
2017-10-22 19:49:21 +01:00
2017-10-23 10:07:36 +01:00
static void PlayerPartnerHandleGetMonData(void);
static void PlayerPartnerHandleGetRawMonData(void);
static void PlayerPartnerHandleSetMonData(void);
static void PlayerPartnerHandleSetRawMonData(void);
static void PlayerPartnerHandleLoadMonSprite(void);
static void PlayerPartnerHandleSwitchInAnim(void);
static void PlayerPartnerHandleReturnMonToBall(void);
static void PlayerPartnerHandleDrawTrainerPic(void);
static void PlayerPartnerHandleTrainerSlide(void);
static void PlayerPartnerHandleTrainerSlideBack(void);
static void PlayerPartnerHandleFaintAnimation(void);
static void PlayerPartnerHandlePaletteFade(void);
static void PlayerPartnerHandleSuccessBallThrowAnim(void);
static void PlayerPartnerHandleBallThrowAnim(void);
static void PlayerPartnerHandlePause(void);
static void PlayerPartnerHandleMoveAnimation(void);
static void PlayerPartnerHandlePrintString(void);
static void PlayerPartnerHandlePrintSelectionString(void);
2017-10-23 10:07:36 +01:00
static void PlayerPartnerHandleChooseAction(void);
static void PlayerPartnerHandleYesNoBox(void);
2017-10-23 10:07:36 +01:00
static void PlayerPartnerHandleChooseMove(void);
static void PlayerPartnerHandleChooseItem(void);
static void PlayerPartnerHandleChoosePokemon(void);
static void PlayerPartnerHandleCmd23(void);
static void PlayerPartnerHandleHealthBarUpdate(void);
static void PlayerPartnerHandleExpUpdate(void);
static void PlayerPartnerHandleStatusIconUpdate(void);
static void PlayerPartnerHandleStatusAnimation(void);
static void PlayerPartnerHandleStatusXor(void);
static void PlayerPartnerHandleDataTransfer(void);
static void PlayerPartnerHandleDMA3Transfer(void);
static void PlayerPartnerHandlePlayBGM(void);
static void PlayerPartnerHandleCmd32(void);
static void PlayerPartnerHandleTwoReturnValues(void);
static void PlayerPartnerHandleChosenMonReturnValue(void);
static void PlayerPartnerHandleOneReturnValue(void);
static void PlayerPartnerHandleOneReturnValue_Duplicate(void);
2020-12-29 21:51:44 +00:00
static void PlayerPartnerHandleClearUnkVar(void);
static void PlayerPartnerHandleSetUnkVar(void);
static void PlayerPartnerHandleClearUnkFlag(void);
static void PlayerPartnerHandleToggleUnkFlag(void);
2017-10-23 10:07:36 +01:00
static void PlayerPartnerHandleHitAnimation(void);
2021-04-03 17:38:07 +01:00
static void PlayerPartnerHandleCantSwitch(void);
static void PlayerPartnerHandlePlaySE(void);
2017-10-23 10:07:36 +01:00
static void PlayerPartnerHandlePlayFanfareOrBGM(void);
static void PlayerPartnerHandleFaintingCry(void);
static void PlayerPartnerHandleIntroSlide(void);
static void PlayerPartnerHandleIntroTrainerBallThrow(void);
static void PlayerPartnerHandleDrawPartyStatusSummary(void);
2018-06-28 20:06:32 +01:00
static void PlayerPartnerHandleHidePartyStatusSummary(void);
2018-06-20 22:07:51 +01:00
static void PlayerPartnerHandleEndBounceEffect(void);
2017-10-23 10:07:36 +01:00
static void PlayerPartnerHandleSpriteInvisibility(void);
static void PlayerPartnerHandleBattleAnimation(void);
static void PlayerPartnerHandleLinkStandbyMsg(void);
static void PlayerPartnerHandleResetActionMoveSelection(void);
static void PlayerPartnerHandleEndLinkBattle(void);
static void PlayerPartnerHandleBattleDebug(void);
static void PlayerPartnerCmdEnd(void);
2017-10-23 10:07:36 +01:00
static void PlayerPartnerBufferRunCommand(void);
static void PlayerPartnerBufferExecCompleted(void);
static void Task_LaunchLvlUpAnim(u8 taskId);
2017-10-23 10:07:36 +01:00
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId);
static void Task_PrepareToGiveExpWithExpBar(u8 taskId);
static void Task_GiveExpWithExpBar(u8 taskId);
static void Task_UpdateLvlInHealthbox(u8 taskId);
static void SwitchIn_WaitAndEnd(void);
2017-10-23 10:07:36 +01:00
static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst);
static void SetPlayerPartnerMonData(u8 monId);
static void PlayerPartnerDoMoveAnimation(void);
static void Task_StartSendOutAnim(u8 taskId);
2021-01-23 01:03:21 +00:00
static void EndDrawPartyStatusSummary(void);
2017-10-23 10:07:36 +01:00
2017-10-31 17:04:08 +00:00
static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
2017-10-22 19:49:21 +01:00
{
2020-12-29 21:51:44 +00:00
[CONTROLLER_GETMONDATA] = PlayerPartnerHandleGetMonData,
[CONTROLLER_GETRAWMONDATA] = PlayerPartnerHandleGetRawMonData,
[CONTROLLER_SETMONDATA] = PlayerPartnerHandleSetMonData,
[CONTROLLER_SETRAWMONDATA] = PlayerPartnerHandleSetRawMonData,
[CONTROLLER_LOADMONSPRITE] = PlayerPartnerHandleLoadMonSprite,
[CONTROLLER_SWITCHINANIM] = PlayerPartnerHandleSwitchInAnim,
[CONTROLLER_RETURNMONTOBALL] = PlayerPartnerHandleReturnMonToBall,
[CONTROLLER_DRAWTRAINERPIC] = PlayerPartnerHandleDrawTrainerPic,
[CONTROLLER_TRAINERSLIDE] = PlayerPartnerHandleTrainerSlide,
[CONTROLLER_TRAINERSLIDEBACK] = PlayerPartnerHandleTrainerSlideBack,
[CONTROLLER_FAINTANIMATION] = PlayerPartnerHandleFaintAnimation,
[CONTROLLER_PALETTEFADE] = PlayerPartnerHandlePaletteFade,
[CONTROLLER_SUCCESSBALLTHROWANIM] = PlayerPartnerHandleSuccessBallThrowAnim,
[CONTROLLER_BALLTHROWANIM] = PlayerPartnerHandleBallThrowAnim,
[CONTROLLER_PAUSE] = PlayerPartnerHandlePause,
[CONTROLLER_MOVEANIMATION] = PlayerPartnerHandleMoveAnimation,
[CONTROLLER_PRINTSTRING] = PlayerPartnerHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = PlayerPartnerHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = PlayerPartnerHandleChooseAction,
[CONTROLLER_YESNOBOX] = PlayerPartnerHandleYesNoBox,
2020-12-29 21:51:44 +00:00
[CONTROLLER_CHOOSEMOVE] = PlayerPartnerHandleChooseMove,
[CONTROLLER_OPENBAG] = PlayerPartnerHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = PlayerPartnerHandleChoosePokemon,
[CONTROLLER_23] = PlayerPartnerHandleCmd23,
[CONTROLLER_HEALTHBARUPDATE] = PlayerPartnerHandleHealthBarUpdate,
[CONTROLLER_EXPUPDATE] = PlayerPartnerHandleExpUpdate,
[CONTROLLER_STATUSICONUPDATE] = PlayerPartnerHandleStatusIconUpdate,
[CONTROLLER_STATUSANIMATION] = PlayerPartnerHandleStatusAnimation,
[CONTROLLER_STATUSXOR] = PlayerPartnerHandleStatusXor,
[CONTROLLER_DATATRANSFER] = PlayerPartnerHandleDataTransfer,
[CONTROLLER_DMA3TRANSFER] = PlayerPartnerHandleDMA3Transfer,
[CONTROLLER_PLAYBGM] = PlayerPartnerHandlePlayBGM,
[CONTROLLER_32] = PlayerPartnerHandleCmd32,
[CONTROLLER_TWORETURNVALUES] = PlayerPartnerHandleTwoReturnValues,
[CONTROLLER_CHOSENMONRETURNVALUE] = PlayerPartnerHandleChosenMonReturnValue,
[CONTROLLER_ONERETURNVALUE] = PlayerPartnerHandleOneReturnValue,
[CONTROLLER_ONERETURNVALUE_DUPLICATE] = PlayerPartnerHandleOneReturnValue_Duplicate,
[CONTROLLER_CLEARUNKVAR] = PlayerPartnerHandleClearUnkVar,
[CONTROLLER_SETUNKVAR] = PlayerPartnerHandleSetUnkVar,
[CONTROLLER_CLEARUNKFLAG] = PlayerPartnerHandleClearUnkFlag,
[CONTROLLER_TOGGLEUNKFLAG] = PlayerPartnerHandleToggleUnkFlag,
[CONTROLLER_HITANIMATION] = PlayerPartnerHandleHitAnimation,
2021-04-03 17:38:07 +01:00
[CONTROLLER_CANTSWITCH] = PlayerPartnerHandleCantSwitch,
2020-12-29 21:51:44 +00:00
[CONTROLLER_PLAYSE] = PlayerPartnerHandlePlaySE,
[CONTROLLER_PLAYFANFAREORBGM] = PlayerPartnerHandlePlayFanfareOrBGM,
[CONTROLLER_FAINTINGCRY] = PlayerPartnerHandleFaintingCry,
[CONTROLLER_INTROSLIDE] = PlayerPartnerHandleIntroSlide,
[CONTROLLER_INTROTRAINERBALLTHROW] = PlayerPartnerHandleIntroTrainerBallThrow,
[CONTROLLER_DRAWPARTYSTATUSSUMMARY] = PlayerPartnerHandleDrawPartyStatusSummary,
[CONTROLLER_HIDEPARTYSTATUSSUMMARY] = PlayerPartnerHandleHidePartyStatusSummary,
[CONTROLLER_ENDBOUNCE] = PlayerPartnerHandleEndBounceEffect,
[CONTROLLER_SPRITEINVISIBILITY] = PlayerPartnerHandleSpriteInvisibility,
[CONTROLLER_BATTLEANIMATION] = PlayerPartnerHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = PlayerPartnerHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = PlayerPartnerHandleResetActionMoveSelection,
[CONTROLLER_ENDLINKBATTLE] = PlayerPartnerHandleEndLinkBattle,
[CONTROLLER_DEBUGMENU] = PlayerPartnerHandleBattleDebug,
2020-12-29 21:51:44 +00:00
[CONTROLLER_TERMINATOR_NOP] = PlayerPartnerCmdEnd
2017-10-22 19:49:21 +01:00
};
static void PlayerPartnerDummy(void)
2017-10-22 19:49:21 +01:00
{
}
2017-10-26 22:12:48 +01:00
void SetControllerToPlayerPartner(void)
2017-10-22 19:49:21 +01:00
{
2023-08-04 16:29:29 +01:00
gBattlerControllerEndFuncs[gActiveBattler] = PlayerPartnerBufferExecCompleted;
2018-02-06 19:48:02 +00:00
gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand;
2017-10-22 19:49:21 +01:00
}
2017-10-23 10:07:36 +01:00
static void PlayerPartnerBufferRunCommand(void)
2017-10-22 19:49:21 +01:00
{
2018-02-06 19:48:02 +00:00
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
2017-10-22 19:49:21 +01:00
{
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands))
sPlayerPartnerBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
2017-10-22 19:49:21 +01:00
else
PlayerPartnerBufferExecCompleted();
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
2017-10-23 10:07:36 +01:00
{
2018-02-06 19:48:02 +00:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void FreeTrainerSpriteAfterSlide(void)
2017-10-23 10:07:36 +01:00
{
2018-02-06 19:48:02 +00:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-23 10:07:36 +01:00
{
2021-01-23 01:03:21 +00:00
BattleGfxSfxDummy3(MALE);
2018-02-06 19:48:02 +00:00
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
}
static void Intro_DelayAndEnd(void)
2017-10-23 10:07:36 +01:00
{
2021-01-23 01:03:21 +00:00
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
2017-10-23 10:07:36 +01:00
{
2021-01-23 01:03:21 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
}
static void Intro_WaitForHealthbox(void)
2017-10-23 10:07:36 +01:00
{
bool32 finished = FALSE;
2017-10-23 10:07:36 +01:00
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
2018-02-06 19:48:02 +00:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
finished = TRUE;
2017-10-23 10:07:36 +01:00
}
else
{
2018-02-06 19:48:02 +00:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
2022-08-27 06:26:13 +01:00
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
2017-10-23 10:07:36 +01:00
{
finished = TRUE;
2017-10-23 10:07:36 +01:00
}
}
if (IsCryPlayingOrClearCrySongs())
finished = FALSE;
2017-10-23 10:07:36 +01:00
if (finished)
2017-10-23 10:07:36 +01:00
{
2021-01-23 01:03:21 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
2017-10-23 10:07:36 +01:00
}
}
static void Intro_ShowHealthbox(void)
2017-10-23 10:07:36 +01:00
{
2018-02-06 01:46:59 +00:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
2022-08-27 06:26:13 +01:00
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive
2021-01-23 01:03:21 +00:00
&& gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
2018-02-06 19:48:02 +00:00
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
2021-01-23 01:03:21 +00:00
&& ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay != 1)
2017-10-23 10:07:36 +01:00
{
2021-01-23 01:03:21 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
2017-10-23 10:07:36 +01:00
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
2022-08-27 06:26:13 +01:00
DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL);
StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler));
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]);
2017-10-23 10:07:36 +01:00
}
2021-01-23 01:03:21 +00:00
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
2018-02-06 19:48:02 +00:00
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
2021-01-23 01:03:21 +00:00
StartHealthboxSlideIn(gActiveBattler);
2018-02-06 19:48:02 +00:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-23 10:07:36 +01:00
2021-01-23 01:03:21 +00:00
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
2017-10-23 10:07:36 +01:00
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForHealthbox;
2017-10-23 10:07:36 +01:00
}
}
static void WaitForMonAnimAfterLoad(void)
2017-10-23 10:07:36 +01:00
{
2021-07-07 14:11:52 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void CompleteOnHealthbarDone(void)
{
2018-06-18 23:43:15 +01:00
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
2017-10-23 10:07:36 +01:00
2018-02-06 19:48:02 +00:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-23 10:07:36 +01:00
if (hpValue != -1)
{
2022-08-25 16:37:47 +01:00
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
2017-10-23 10:07:36 +01:00
}
else
{
2018-02-06 19:48:02 +00:00
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
}
static void CompleteOnInactiveTextPrinter(void)
{
2021-10-08 21:50:52 +01:00
if (!IsTextPrinterActive(B_WIN_MSG))
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
// the whole exp task is copied&pasted from player controller
#define tExpTask_monId data[0]
#define tExpTask_gainedExp data[1]
#define tExpTask_bank data[2]
#define tExpTask_frames data[10]
static void Task_GiveExpToMon(u8 taskId)
{
u32 monId = (u8)(gTasks[taskId].tExpTask_monId);
2018-02-28 23:59:52 +00:00
u8 battlerId = gTasks[taskId].tExpTask_bank;
2017-10-23 10:07:36 +01:00
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
2018-02-28 23:59:52 +00:00
if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[battlerId]) // give exp without the expbar
2017-10-23 10:07:36 +01:00
{
struct Pokemon *mon = &gPlayerParty[monId];
u16 species = GetMonData(mon, MON_DATA_SPECIES);
u8 level = GetMonData(mon, MON_DATA_LEVEL);
u32 currExp = GetMonData(mon, MON_DATA_EXP);
2022-10-24 21:01:48 +01:00
u32 nextLvlExp = gExperienceTables[gSpeciesInfo[species].growthRate][level + 1];
2017-10-23 10:07:36 +01:00
if (currExp + gainedExp >= nextLvlExp)
{
u8 savedActiveBank;
SetMonData(mon, MON_DATA_EXP, &nextLvlExp);
CalculateMonStats(mon);
gainedExp -= nextLvlExp - currExp;
2018-02-06 01:46:59 +00:00
savedActiveBank = gActiveBattler;
2018-02-28 23:59:52 +00:00
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
2018-02-06 01:46:59 +00:00
gActiveBattler = savedActiveBank;
2017-10-23 10:07:36 +01:00
if (IsDoubleBattle() == TRUE
2022-08-27 06:26:13 +01:00
&& ((u16)(monId) == gBattlerPartyIndexes[battlerId] || (u16)(monId) == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]))
gTasks[taskId].func = Task_LaunchLvlUpAnim;
2017-10-23 10:07:36 +01:00
else
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
}
else
{
currExp += gainedExp;
SetMonData(mon, MON_DATA_EXP, &currExp);
2018-02-28 23:59:52 +00:00
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
2017-10-23 10:07:36 +01:00
DestroyTask(taskId);
}
}
else
{
gTasks[taskId].func = Task_PrepareToGiveExpWithExpBar;
}
}
static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
s32 gainedExp = gTasks[taskId].tExpTask_gainedExp;
2018-02-28 23:59:52 +00:00
u8 battlerId = gTasks[taskId].tExpTask_bank;
2017-10-23 10:07:36 +01:00
struct Pokemon *mon = &gPlayerParty[monIndex];
u8 level = GetMonData(mon, MON_DATA_LEVEL);
u16 species = GetMonData(mon, MON_DATA_SPECIES);
u32 exp = GetMonData(mon, MON_DATA_EXP);
2022-10-24 21:01:48 +01:00
u32 currLvlExp = gExperienceTables[gSpeciesInfo[species].growthRate][level];
2017-10-23 10:07:36 +01:00
u32 expToNextLvl;
exp -= currLvlExp;
2022-10-24 21:01:48 +01:00
expToNextLvl = gExperienceTables[gSpeciesInfo[species].growthRate][level + 1] - currLvlExp;
2018-02-28 23:59:52 +00:00
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
2017-10-23 10:07:36 +01:00
PlaySE(SE_EXP);
gTasks[taskId].func = Task_GiveExpWithExpBar;
2017-10-23 10:07:36 +01:00
}
static void Task_GiveExpWithExpBar(u8 taskId)
2017-10-23 10:07:36 +01:00
{
if (gTasks[taskId].tExpTask_frames < 13)
{
gTasks[taskId].tExpTask_frames++;
}
else
{
u8 monId = gTasks[taskId].tExpTask_monId;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
2018-02-28 23:59:52 +00:00
u8 battlerId = gTasks[taskId].tExpTask_bank;
2017-10-23 10:07:36 +01:00
s16 r4;
2018-06-18 23:43:15 +01:00
r4 = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
2018-02-28 23:59:52 +00:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
2017-10-23 10:07:36 +01:00
if (r4 == -1)
{
u8 level;
s32 currExp;
u16 species;
s32 expOnNextLvl;
m4aSongNumStop(SE_EXP);
level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
currExp = GetMonData(&gPlayerParty[monId], MON_DATA_EXP);
species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES);
2022-10-24 21:01:48 +01:00
expOnNextLvl = gExperienceTables[gSpeciesInfo[species].growthRate][level + 1];
2017-10-23 10:07:36 +01:00
if (currExp + gainedExp >= expOnNextLvl)
{
u8 savedActiveBank;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &expOnNextLvl);
CalculateMonStats(&gPlayerParty[monId]);
gainedExp -= expOnNextLvl - currExp;
2018-02-06 01:46:59 +00:00
savedActiveBank = gActiveBattler;
2018-02-28 23:59:52 +00:00
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
2018-02-06 01:46:59 +00:00
gActiveBattler = savedActiveBank;
gTasks[taskId].func = Task_LaunchLvlUpAnim;
2017-10-23 10:07:36 +01:00
}
else
{
currExp += gainedExp;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp);
2018-02-28 23:59:52 +00:00
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
2017-10-23 10:07:36 +01:00
DestroyTask(taskId);
}
}
}
}
static void Task_LaunchLvlUpAnim(u8 taskId)
2017-10-23 10:07:36 +01:00
{
2018-02-28 23:59:52 +00:00
u8 battlerId = gTasks[taskId].tExpTask_bank;
2017-10-23 10:07:36 +01:00
u8 monIndex = gTasks[taskId].tExpTask_monId;
2022-08-27 06:26:13 +01:00
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)])
2018-02-28 23:59:52 +00:00
battlerId ^= BIT_FLANK;
2017-10-23 10:07:36 +01:00
2018-02-28 23:59:52 +00:00
InitAndLaunchSpecialAnimation(battlerId, battlerId, battlerId, B_ANIM_LVL_UP);
gTasks[taskId].func = Task_UpdateLvlInHealthbox;
2017-10-23 10:07:36 +01:00
}
static void Task_UpdateLvlInHealthbox(u8 taskId)
2017-10-23 10:07:36 +01:00
{
2018-02-28 23:59:52 +00:00
u8 battlerId = gTasks[taskId].tExpTask_bank;
2017-10-23 10:07:36 +01:00
2018-02-28 23:59:52 +00:00
if (!gBattleSpritesDataPtr->healthBoxesData[battlerId].specialAnimActive)
2017-10-23 10:07:36 +01:00
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
2022-08-27 06:26:13 +01:00
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)])
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battlerId)], &gPlayerParty[monIndex], HEALTHBOX_ALL);
2017-10-23 10:07:36 +01:00
else
2018-02-28 23:59:52 +00:00
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], &gPlayerParty[monIndex], HEALTHBOX_ALL);
2017-10-23 10:07:36 +01:00
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
}
}
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId)
{
u8 monIndex;
2018-02-28 23:59:52 +00:00
u8 battlerId;
2017-10-23 10:07:36 +01:00
monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
2018-02-28 23:59:52 +00:00
battlerId = gTasks[taskId].tExpTask_bank;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
2017-10-23 10:07:36 +01:00
DestroyTask(taskId);
}
static void CompleteOnInactiveTextPrinter2(void)
{
2021-10-08 21:50:52 +01:00
if (!IsTextPrinterActive(B_WIN_MSG))
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void DoHitAnimBlinkSpriteEffect(void)
{
2018-02-06 19:48:02 +00:00
u8 spriteId = gBattlerSpriteIds[gActiveBattler];
2017-10-23 10:07:36 +01:00
2017-12-02 20:44:50 +00:00
if (gSprites[spriteId].data[1] == 32)
2017-10-23 10:07:36 +01:00
{
2017-12-02 20:44:50 +00:00
gSprites[spriteId].data[1] = 0;
gSprites[spriteId].invisible = FALSE;
2017-10-23 10:07:36 +01:00
gDoingBattleAnim = FALSE;
PlayerPartnerBufferExecCompleted();
}
else
{
2017-12-02 20:44:50 +00:00
if ((gSprites[spriteId].data[1] % 4) == 0)
2017-10-23 10:07:36 +01:00
gSprites[spriteId].invisible ^= 1;
2017-12-02 20:44:50 +00:00
gSprites[spriteId].data[1]++;
2017-10-23 10:07:36 +01:00
}
}
static void SwitchIn_ShowSubstitute(void)
2017-10-23 10:07:36 +01:00
{
2018-02-06 19:48:02 +00:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-23 10:07:36 +01:00
{
2018-02-06 01:46:59 +00:00
CopyBattleSpriteInvisibility(gActiveBattler);
2018-02-06 22:09:39 +00:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
2018-02-06 01:46:59 +00:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
2017-10-23 10:07:36 +01:00
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_WaitAndEnd;
2017-10-23 10:07:36 +01:00
}
}
static void SwitchIn_WaitAndEnd(void)
2017-10-23 10:07:36 +01:00
{
2018-02-06 01:46:59 +00:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
2018-02-06 19:48:02 +00:00
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-23 10:07:36 +01:00
{
PlayerPartnerBufferExecCompleted();
}
}
static void SwitchIn_ShowHealthbox(void)
2017-10-23 10:07:36 +01:00
{
2020-08-30 20:11:44 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
2017-10-23 10:07:36 +01:00
{
2020-08-30 20:11:44 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
2017-10-23 10:07:36 +01:00
2021-01-23 01:03:21 +00:00
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
2017-10-23 10:07:36 +01:00
2021-01-23 01:03:21 +00:00
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
2018-02-06 19:48:02 +00:00
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
2021-01-23 01:03:21 +00:00
StartHealthboxSlideIn(gActiveBattler);
2018-02-06 19:48:02 +00:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-23 10:07:36 +01:00
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
2017-10-23 10:07:36 +01:00
}
}
static void SwitchIn_TryShinyAnim(void)
2017-10-23 10:07:36 +01:00
{
2020-08-30 20:11:44 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
2018-02-06 01:46:59 +00:00
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
2017-10-23 10:07:36 +01:00
{
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
2017-10-23 10:07:36 +01:00
}
2021-01-23 01:03:21 +00:00
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
2018-02-06 01:46:59 +00:00
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
2017-10-23 10:07:36 +01:00
{
2021-01-23 01:03:21 +00:00
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
2017-10-23 10:07:36 +01:00
}
}
static void PlayerPartnerBufferExecCompleted(void)
{
2018-02-06 19:48:02 +00:00
gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand;
2017-10-23 10:07:36 +01:00
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
2017-10-23 10:07:36 +01:00
}
else
{
2018-02-06 19:48:02 +00:00
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
2017-10-23 10:07:36 +01:00
}
}
static void CompleteOnFinishedStatusAnimation(void)
{
2018-02-06 01:46:59 +00:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive)
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void CompleteOnFinishedBattleAnimation(void)
{
2018-02-06 01:46:59 +00:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive)
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleGetMonData(void)
{
2023-08-04 16:29:29 +01:00
BtlController_HandleGetMonData(gActiveBattler, gPlayerParty);
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandleGetRawMonData(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleSetMonData(void)
{
2023-08-04 16:29:29 +01:00
BtlController_HandleSetMonData(gActiveBattler, gPlayerParty);
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandleSetRawMonData(void)
{
2023-08-04 16:29:29 +01:00
BtlController_HandleSetRawMonData(gActiveBattler, gPlayerParty);
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandleLoadMonSprite(void)
{
BtlController_HandleLoadMonSprite(gActiveBattler, gPlayerParty, WaitForMonAnimAfterLoad);
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandleSwitchInAnim(void)
{
2023-08-04 12:42:40 +01:00
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandleReturnMonToBall(void)
{
2023-08-04 16:29:29 +01:00
BtlController_HandleReturnMonToBall(gActiveBattler);
2017-10-23 10:07:36 +01:00
}
2021-01-23 01:03:21 +00:00
#define sSpeedX data[0]
2017-10-23 10:07:36 +01:00
// some explanation here
// in emerald it's possible to have a tag battle in the battle frontier facilities with AI
// which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven) that use the back pic as well as animate it
static void PlayerPartnerHandleDrawTrainerPic(void)
{
s16 xPos, yPos;
u32 trainerPicId;
if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
2017-10-23 10:07:36 +01:00
{
trainerPicId = TRAINER_BACK_PIC_STEVEN;
2017-10-23 10:07:36 +01:00
xPos = 90;
yPos = (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80;
2017-10-23 10:07:36 +01:00
}
2018-11-24 00:02:02 +00:00
else if (gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER)
{
trainerPicId = gPartnerSpriteId;
xPos = 90;
2019-01-05 09:14:20 +00:00
yPos = (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80;
2018-11-24 00:02:02 +00:00
}
2017-10-23 10:07:36 +01:00
else
{
trainerPicId = GetFrontierTrainerFrontSpriteId(gPartnerTrainerId);
xPos = 32;
yPos = (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 80;
2017-10-23 10:07:36 +01:00
}
// Use back pic only if the partner is Steven
2018-11-24 00:02:02 +00:00
if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER || gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER)
2017-10-23 10:07:36 +01:00
{
2018-02-06 01:46:59 +00:00
DecompressTrainerBackPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
2018-12-18 04:08:08 +00:00
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
2018-02-06 01:46:59 +00:00
2018-02-06 19:48:02 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
2021-07-07 14:11:52 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
2021-01-23 01:03:21 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
2017-10-23 10:07:36 +01:00
}
else // otherwise use front sprite
{
2018-02-06 01:46:59 +00:00
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler));
2018-12-18 04:08:08 +00:00
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
2018-02-06 19:48:02 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
2021-07-07 14:11:52 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].y2 = 48;
2021-01-23 01:03:21 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
2018-02-06 19:48:02 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
2017-10-23 10:07:36 +01:00
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
2017-10-23 10:07:36 +01:00
}
2021-01-23 01:03:21 +00:00
#undef sSpeedX
2017-10-23 10:07:36 +01:00
static void PlayerPartnerHandleTrainerSlide(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleTrainerSlideBack(void)
{
2019-02-06 19:17:09 +00:00
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
2018-02-06 19:48:02 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
2021-07-07 14:11:52 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
2018-11-25 23:00:18 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
2018-02-06 19:48:02 +00:00
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandleFaintAnimation(void)
{
2023-08-04 21:15:39 +01:00
BtlController_HandleFaintAnimation(gActiveBattler);
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandlePaletteFade(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleSuccessBallThrowAnim(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleBallThrowAnim(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandlePause(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleMoveAnimation(void)
{
2021-01-23 01:03:21 +00:00
if (!IsBattleSEPlaying(gActiveBattler))
2017-10-23 10:07:36 +01:00
{
u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8);
2018-02-06 01:46:59 +00:00
gAnimMoveTurn = gBattleResources->bufferA[gActiveBattler][3];
gAnimMovePower = gBattleResources->bufferA[gActiveBattler][4] | (gBattleResources->bufferA[gActiveBattler][5] << 8);
gAnimMoveDmg = gBattleResources->bufferA[gActiveBattler][6] | (gBattleResources->bufferA[gActiveBattler][7] << 8) | (gBattleResources->bufferA[gActiveBattler][8] << 16) | (gBattleResources->bufferA[gActiveBattler][9] << 24);
gAnimFriendship = gBattleResources->bufferA[gActiveBattler][10];
gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16];
2018-02-06 01:46:59 +00:00
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
gTransformedOtIds[gActiveBattler] = gAnimDisableStructPtr->transformedMonOtId;
2022-06-03 15:24:57 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerDoMoveAnimation;
2017-10-23 10:07:36 +01:00
}
}
static void PlayerPartnerDoMoveAnimation(void)
{
u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8);
u8 multihit = gBattleResources->bufferA[gActiveBattler][11];
2017-10-23 10:07:36 +01:00
2018-02-06 01:46:59 +00:00
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
2017-10-23 10:07:36 +01:00
{
case 0:
2018-02-06 22:09:39 +00:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
2017-10-23 10:07:36 +01:00
{
2018-02-06 22:09:39 +00:00
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
2018-02-06 01:46:59 +00:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
2017-10-23 10:07:36 +01:00
}
2018-02-06 01:46:59 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
2017-10-23 10:07:36 +01:00
break;
case 1:
2018-02-06 01:46:59 +00:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-23 10:07:36 +01:00
{
2021-01-23 01:03:21 +00:00
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
2017-10-23 10:07:36 +01:00
DoMoveAnim(move);
2018-02-06 01:46:59 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
2017-10-23 10:07:36 +01:00
}
break;
case 2:
gAnimScriptCallback();
if (!gAnimScriptActive)
{
2021-01-23 01:03:21 +00:00
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
2018-02-06 22:09:39 +00:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
2017-10-23 10:07:36 +01:00
{
2018-02-06 01:46:59 +00:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
2018-02-06 22:09:39 +00:00
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
2017-10-23 10:07:36 +01:00
}
2018-02-06 01:46:59 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
2017-10-23 10:07:36 +01:00
}
break;
case 3:
2018-02-06 01:46:59 +00:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-23 10:07:36 +01:00
{
2017-11-04 15:11:13 +00:00
CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8));
2018-02-06 01:46:59 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
break;
}
}
static void PlayerPartnerHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
2017-10-23 10:07:36 +01:00
BufferStringBattle(*stringId);
2021-10-08 21:50:52 +01:00
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
2018-02-06 19:48:02 +00:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2;
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandlePrintSelectionString(void)
2017-10-23 10:07:36 +01:00
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleChooseAction(void)
{
AI_TrySwitchOrUseItem();
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleYesNoBox(void)
2017-10-23 10:07:36 +01:00
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleChooseMove(void)
{
u8 chosenMoveId;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
2017-10-23 10:07:36 +01:00
chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
2021-12-17 03:57:30 +00:00
2018-02-26 12:24:46 +00:00
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED))
2018-02-06 22:09:39 +00:00
gBattlerTarget = gActiveBattler;
2017-10-23 10:07:36 +01:00
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
{
2018-02-06 22:09:39 +00:00
gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
2017-10-23 10:07:36 +01:00
}
2022-08-25 16:37:47 +01:00
if (ShouldUseZMove(gActiveBattler, gBattlerTarget, moveInfo->moves[chosenMoveId]))
2020-12-01 18:43:15 +00:00
QueueZMove(gActiveBattler, moveInfo->moves[chosenMoveId]);
2017-10-23 10:07:36 +01:00
// If partner can mega evolve, do it.
if (CanMegaEvolve(gActiveBattler))
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
else
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleChooseItem(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleChoosePokemon(void)
{
s32 chosenMonId;
// Choosing Revival Blessing target
if ((gBattleResources->bufferA[gActiveBattler][1] & 0xF) == PARTY_ACTION_CHOOSE_FAINTED_MON)
2017-10-23 10:07:36 +01:00
{
chosenMonId = gSelectedMonPartyId = GetFirstFaintedPartyIndex(gActiveBattler);
}
// Switching out
else
{
chosenMonId = GetMostSuitableMonToSwitchInto();
if (chosenMonId == PARTY_SIZE) // just switch to the next mon
2017-10-23 10:07:36 +01:00
{
u8 playerMonIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
u8 selfIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
for (chosenMonId = PARTY_SIZE / 2; chosenMonId < PARTY_SIZE; chosenMonId++)
2017-10-23 10:07:36 +01:00
{
if (GetMonData(&gPlayerParty[chosenMonId], MON_DATA_HP) != 0
&& chosenMonId != gBattlerPartyIndexes[playerMonIdentity]
&& chosenMonId != gBattlerPartyIndexes[selfIdentity])
{
break;
}
2017-10-23 10:07:36 +01:00
}
}
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId;
2017-10-23 10:07:36 +01:00
}
BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL);
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleCmd23(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleHealthBarUpdate(void)
{
s16 hpVal;
LoadBattleBarGfx(0);
hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
2017-10-23 10:07:36 +01:00
if (hpVal != INSTANT_HP_BAR_DROP)
{
2018-02-06 19:48:02 +00:00
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
2017-10-23 10:07:36 +01:00
2018-02-06 19:48:02 +00:00
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
2017-10-23 10:07:36 +01:00
}
else
{
2018-02-06 19:48:02 +00:00
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
2017-10-23 10:07:36 +01:00
2018-02-06 19:48:02 +00:00
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
2017-10-23 10:07:36 +01:00
}
2018-02-06 19:48:02 +00:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandleExpUpdate(void)
{
u8 monId = gBattleResources->bufferA[gActiveBattler][1];
2017-10-23 10:07:36 +01:00
2018-10-17 03:47:08 +01:00
if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_LEVEL)
2017-10-23 10:07:36 +01:00
{
PlayerPartnerBufferExecCompleted();
}
else
{
s16 expPointsToGive;
u8 taskId;
LoadBattleBarGfx(1);
GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); // unused return value
expPointsToGive = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
2017-10-23 10:07:36 +01:00
taskId = CreateTask(Task_GiveExpToMon, 10);
gTasks[taskId].tExpTask_monId = monId;
gTasks[taskId].tExpTask_gainedExp = expPointsToGive;
2018-02-06 01:46:59 +00:00
gTasks[taskId].tExpTask_bank = gActiveBattler;
gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy;
2017-10-23 10:07:36 +01:00
}
}
#undef tExpTask_monId
#undef tExpTask_gainedExp
#undef tExpTask_bank
#undef tExpTask_frames
static void PlayerPartnerHandleStatusIconUpdate(void)
{
2021-01-23 01:03:21 +00:00
if (!IsBattleSEPlaying(gActiveBattler))
2017-10-23 10:07:36 +01:00
{
2018-02-28 23:59:52 +00:00
u8 battlerId;
2017-10-23 10:07:36 +01:00
2018-02-06 19:48:02 +00:00
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
2018-02-28 23:59:52 +00:00
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
2018-02-06 19:48:02 +00:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
2017-10-23 10:07:36 +01:00
}
}
static void PlayerPartnerHandleStatusAnimation(void)
{
2021-01-23 01:03:21 +00:00
if (!IsBattleSEPlaying(gActiveBattler))
2017-10-23 10:07:36 +01:00
{
InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1],
gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24));
2018-02-06 19:48:02 +00:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
2017-10-23 10:07:36 +01:00
}
}
static void PlayerPartnerHandleStatusXor(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleDataTransfer(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleDMA3Transfer(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandlePlayBGM(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleCmd32(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleTwoReturnValues(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleChosenMonReturnValue(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleOneReturnValue(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleOneReturnValue_Duplicate(void)
{
PlayerPartnerBufferExecCompleted();
}
2020-12-29 21:51:44 +00:00
static void PlayerPartnerHandleClearUnkVar(void)
2017-10-23 10:07:36 +01:00
{
2020-12-29 21:51:44 +00:00
gUnusedControllerStruct.unk = 0;
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
2020-12-29 21:51:44 +00:00
static void PlayerPartnerHandleSetUnkVar(void)
2017-10-23 10:07:36 +01:00
{
gUnusedControllerStruct.unk = gBattleResources->bufferA[gActiveBattler][1];
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
2020-12-29 21:51:44 +00:00
static void PlayerPartnerHandleClearUnkFlag(void)
2017-10-23 10:07:36 +01:00
{
2020-12-29 21:51:44 +00:00
gUnusedControllerStruct.flag = 0;
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
2020-12-29 21:51:44 +00:00
static void PlayerPartnerHandleToggleUnkFlag(void)
2017-10-23 10:07:36 +01:00
{
2020-12-29 21:51:44 +00:00
gUnusedControllerStruct.flag ^= 1;
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleHitAnimation(void)
{
2018-02-06 19:48:02 +00:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
2017-10-23 10:07:36 +01:00
{
PlayerPartnerBufferExecCompleted();
}
else
{
gDoingBattleAnim = TRUE;
2018-02-06 19:48:02 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
2018-02-06 01:46:59 +00:00
DoHitAnimHealthboxEffect(gActiveBattler);
2018-02-06 19:48:02 +00:00
gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
2017-10-23 10:07:36 +01:00
}
}
2021-04-03 17:38:07 +01:00
static void PlayerPartnerHandleCantSwitch(void)
2017-10-23 10:07:36 +01:00
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandlePlaySE(void)
2017-10-23 10:07:36 +01:00
{
s8 pan;
2018-02-06 01:46:59 +00:00
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
pan = SOUND_PAN_ATTACKER;
2017-10-23 10:07:36 +01:00
else
pan = SOUND_PAN_TARGET;
2017-10-23 10:07:36 +01:00
PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan);
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandlePlayFanfareOrBGM(void)
{
if (gBattleResources->bufferA[gActiveBattler][3])
2017-10-23 10:07:36 +01:00
{
2017-11-04 15:11:13 +00:00
BattleStopLowHpSound();
PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8));
2017-10-23 10:07:36 +01:00
}
else
{
PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8));
2017-10-23 10:07:36 +01:00
}
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleFaintingCry(void)
{
2018-02-06 19:48:02 +00:00
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
2017-10-23 10:07:36 +01:00
2021-11-07 18:54:44 +00:00
PlayCry_ByMode(species, -25, CRY_MODE_FAINT);
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleIntroSlide(void)
{
HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]);
2018-02-08 10:17:41 +00:00
gIntroSlideFlags |= 1;
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleIntroTrainerBallThrow(void)
{
u8 paletteNum;
u8 taskId;
2019-02-06 19:17:09 +00:00
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
2017-10-23 10:07:36 +01:00
2018-02-06 19:48:02 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
2021-07-07 14:11:52 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
2018-11-25 23:00:18 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
2018-02-06 19:48:02 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
2017-10-23 10:07:36 +01:00
2021-01-23 01:03:21 +00:00
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
2018-02-06 19:48:02 +00:00
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
2017-10-23 10:07:36 +01:00
paletteNum = AllocSpritePalette(0xD6F9);
if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
2017-10-23 10:07:36 +01:00
{
u8 spriteId = TRAINER_BACK_PIC_STEVEN;
2022-08-19 15:29:35 +01:00
LoadCompressedPalette(gTrainerBackPicPaletteTable[spriteId].data, OBJ_PLTT_ID(paletteNum), PLTT_SIZE_4BPP);
2017-10-23 10:07:36 +01:00
}
2018-11-24 00:02:02 +00:00
else if (gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER)
{
u8 spriteId = gPartnerSpriteId;
LoadCompressedPalette(gTrainerBackPicPaletteTable[spriteId].data, 0x100 + paletteNum * 16, 32);
}
2017-10-23 10:07:36 +01:00
else
{
u8 spriteId = GetFrontierTrainerFrontSpriteId(gPartnerTrainerId);
2022-08-19 15:29:35 +01:00
LoadCompressedPalette(gTrainerFrontPicPaletteTable[spriteId].data, OBJ_PLTT_ID(paletteNum), PLTT_SIZE_4BPP);
2017-10-23 10:07:36 +01:00
}
2018-02-06 19:48:02 +00:00
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
2017-10-23 10:07:36 +01:00
taskId = CreateTask(Task_StartSendOutAnim, 5);
2018-02-06 01:46:59 +00:00
gTasks[taskId].data[0] = gActiveBattler;
2017-10-23 10:07:36 +01:00
2018-06-28 20:06:32 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
2017-10-23 10:07:36 +01:00
2021-01-23 01:03:21 +00:00
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerDummy;
2017-10-23 10:07:36 +01:00
}
static void Task_StartSendOutAnim(u8 taskId)
2017-10-23 10:07:36 +01:00
{
if (gTasks[taskId].data[1] < 24)
{
gTasks[taskId].data[1]++;
}
else
{
2018-02-06 01:46:59 +00:00
u8 savedActiveBank = gActiveBattler;
2017-10-23 10:07:36 +01:00
2018-02-06 01:46:59 +00:00
gActiveBattler = gTasks[taskId].data[0];
2017-10-23 10:07:36 +01:00
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE);
2017-10-23 10:07:36 +01:00
}
else
{
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE);
2018-02-06 01:46:59 +00:00
gActiveBattler ^= BIT_FLANK;
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSendOutAnim(gActiveBattler, FALSE);
2018-02-06 01:46:59 +00:00
gActiveBattler ^= BIT_FLANK;
2017-10-23 10:07:36 +01:00
}
gBattlerControllerFuncs[gActiveBattler] = Intro_ShowHealthbox;
2018-02-06 01:46:59 +00:00
gActiveBattler = savedActiveBank;
2017-10-23 10:07:36 +01:00
DestroyTask(taskId);
}
}
static void PlayerPartnerHandleDrawPartyStatusSummary(void)
{
if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
2017-10-23 10:07:36 +01:00
{
PlayerPartnerBufferExecCompleted();
}
else
{
2018-06-28 20:06:32 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]);
2021-01-23 01:03:21 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
2017-10-23 10:07:36 +01:00
if (gBattleResources->bufferA[gActiveBattler][2] != 0)
2021-01-23 01:03:21 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93;
2017-10-23 10:07:36 +01:00
2021-01-23 01:03:21 +00:00
gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary;
2017-10-23 10:07:36 +01:00
}
}
2021-01-23 01:03:21 +00:00
static void EndDrawPartyStatusSummary(void)
2017-10-23 10:07:36 +01:00
{
2021-01-23 01:03:21 +00:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
2017-10-23 10:07:36 +01:00
{
2021-01-23 01:03:21 +00:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
}
2018-06-28 20:06:32 +01:00
static void PlayerPartnerHandleHidePartyStatusSummary(void)
2017-10-23 10:07:36 +01:00
{
2018-06-28 20:06:32 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
}
2018-06-20 22:07:51 +01:00
static void PlayerPartnerHandleEndBounceEffect(void)
2017-10-23 10:07:36 +01:00
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleSpriteInvisibility(void)
{
2018-02-06 19:48:02 +00:00
if (IsBattlerSpritePresent(gActiveBattler))
2017-10-23 10:07:36 +01:00
{
gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleResources->bufferA[gActiveBattler][1];
2018-02-06 01:46:59 +00:00
CopyBattleSpriteInvisibility(gActiveBattler);
2017-10-23 10:07:36 +01:00
}
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleBattleAnimation(void)
{
2021-01-23 01:03:21 +00:00
if (!IsBattleSEPlaying(gActiveBattler))
2017-10-23 10:07:36 +01:00
{
u8 animationId = gBattleResources->bufferA[gActiveBattler][1];
u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
2017-10-23 10:07:36 +01:00
2018-02-06 01:46:59 +00:00
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
2017-10-23 10:07:36 +01:00
PlayerPartnerBufferExecCompleted();
else
2018-02-06 19:48:02 +00:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
2017-10-23 10:07:36 +01:00
}
}
static void PlayerPartnerHandleLinkStandbyMsg(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleResetActionMoveSelection(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleEndLinkBattle(void)
2017-10-23 10:07:36 +01:00
{
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1];
2017-10-23 10:07:36 +01:00
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
PlayerPartnerBufferExecCompleted();
2021-01-23 01:03:21 +00:00
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
2017-10-23 10:07:36 +01:00
}
static void PlayerPartnerHandleBattleDebug(void)
{
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerCmdEnd(void)
2017-10-23 10:07:36 +01:00
{
}