2017-10-22 20:38:23 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "battle.h"
|
2018-11-14 00:01:50 +00:00
|
|
|
#include "battle_anim.h"
|
2017-10-22 20:38:23 +02:00
|
|
|
#include "battle_controllers.h"
|
|
|
|
#include "battle_interface.h"
|
2018-11-14 00:01:50 +00:00
|
|
|
#include "battle_message.h"
|
|
|
|
#include "bg.h"
|
2019-04-04 23:53:06 +02:00
|
|
|
#include "data.h"
|
2018-11-14 00:01:50 +00:00
|
|
|
#include "item_menu.h"
|
2017-10-22 20:38:23 +02:00
|
|
|
#include "link.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "m4a.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "pokeball.h"
|
2017-12-16 00:08:23 +01:00
|
|
|
#include "pokeblock.h"
|
2018-11-14 00:01:50 +00:00
|
|
|
#include "pokemon.h"
|
|
|
|
#include "reshow_battle_screen.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "constants/battle_anim.h"
|
|
|
|
#include "constants/songs.h"
|
2023-08-06 21:50:59 +02:00
|
|
|
#include "constants/trainers.h"
|
2019-04-04 17:05:46 -04:00
|
|
|
#include "constants/rgb.h"
|
2017-10-22 20:38:23 +02:00
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleDrawTrainerPic(u32 battler);
|
|
|
|
static void SafariHandleSuccessBallThrowAnim(u32 battler);
|
|
|
|
static void SafariHandleBallThrowAnim(u32 battler);
|
|
|
|
static void SafariHandlePrintString(u32 battler);
|
|
|
|
static void SafariHandlePrintSelectionString(u32 battler);
|
|
|
|
static void SafariHandleChooseAction(u32 battler);
|
|
|
|
static void SafariHandleChooseItem(u32 battler);
|
|
|
|
static void SafariHandleStatusIconUpdate(u32 battler);
|
|
|
|
static void SafariHandleFaintingCry(u32 battler);
|
|
|
|
static void SafariHandleIntroTrainerBallThrow(u32 battler);
|
|
|
|
static void SafariHandleBattleAnimation(u32 battler);
|
|
|
|
static void SafariHandleEndLinkBattle(u32 battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariBufferRunCommand(u32 battler);
|
|
|
|
static void SafariBufferExecCompleted(u32 battler);
|
|
|
|
static void CompleteWhenChosePokeblock(u32 battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-05 11:05:37 +02:00
|
|
|
[CONTROLLER_GETMONDATA] = BtlController_Empty,
|
|
|
|
[CONTROLLER_GETRAWMONDATA] = BtlController_Empty,
|
|
|
|
[CONTROLLER_SETMONDATA] = BtlController_Empty,
|
|
|
|
[CONTROLLER_SETRAWMONDATA] = BtlController_Empty,
|
|
|
|
[CONTROLLER_LOADMONSPRITE] = BtlController_Empty,
|
|
|
|
[CONTROLLER_SWITCHINANIM] = BtlController_Empty,
|
|
|
|
[CONTROLLER_RETURNMONTOBALL] = BtlController_Empty,
|
2020-12-29 16:51:44 -05:00
|
|
|
[CONTROLLER_DRAWTRAINERPIC] = SafariHandleDrawTrainerPic,
|
2023-08-05 11:05:37 +02:00
|
|
|
[CONTROLLER_TRAINERSLIDE] = BtlController_Empty,
|
|
|
|
[CONTROLLER_TRAINERSLIDEBACK] = BtlController_Empty,
|
|
|
|
[CONTROLLER_FAINTANIMATION] = BtlController_Empty,
|
|
|
|
[CONTROLLER_PALETTEFADE] = BtlController_Empty,
|
2020-12-29 16:51:44 -05:00
|
|
|
[CONTROLLER_SUCCESSBALLTHROWANIM] = SafariHandleSuccessBallThrowAnim,
|
|
|
|
[CONTROLLER_BALLTHROWANIM] = SafariHandleBallThrowAnim,
|
2023-08-05 11:05:37 +02:00
|
|
|
[CONTROLLER_PAUSE] = BtlController_Empty,
|
|
|
|
[CONTROLLER_MOVEANIMATION] = BtlController_Empty,
|
2020-12-29 16:51:44 -05:00
|
|
|
[CONTROLLER_PRINTSTRING] = SafariHandlePrintString,
|
|
|
|
[CONTROLLER_PRINTSTRINGPLAYERONLY] = SafariHandlePrintSelectionString,
|
|
|
|
[CONTROLLER_CHOOSEACTION] = SafariHandleChooseAction,
|
2023-08-05 11:05:37 +02:00
|
|
|
[CONTROLLER_YESNOBOX] = BtlController_Empty,
|
|
|
|
[CONTROLLER_CHOOSEMOVE] = BtlController_Empty,
|
2020-12-29 16:51:44 -05:00
|
|
|
[CONTROLLER_OPENBAG] = SafariHandleChooseItem,
|
2023-08-05 11:05:37 +02:00
|
|
|
[CONTROLLER_CHOOSEPOKEMON] = BtlController_Empty,
|
|
|
|
[CONTROLLER_23] = BtlController_Empty,
|
|
|
|
[CONTROLLER_HEALTHBARUPDATE] = BtlController_Empty,
|
|
|
|
[CONTROLLER_EXPUPDATE] = BtlController_Empty,
|
2020-12-29 16:51:44 -05:00
|
|
|
[CONTROLLER_STATUSICONUPDATE] = SafariHandleStatusIconUpdate,
|
2023-08-05 11:05:37 +02:00
|
|
|
[CONTROLLER_STATUSANIMATION] = BtlController_Empty,
|
|
|
|
[CONTROLLER_STATUSXOR] = BtlController_Empty,
|
|
|
|
[CONTROLLER_DATATRANSFER] = BtlController_Empty,
|
|
|
|
[CONTROLLER_DMA3TRANSFER] = BtlController_Empty,
|
|
|
|
[CONTROLLER_PLAYBGM] = BtlController_Empty,
|
|
|
|
[CONTROLLER_32] = BtlController_Empty,
|
|
|
|
[CONTROLLER_TWORETURNVALUES] = BtlController_Empty,
|
|
|
|
[CONTROLLER_CHOSENMONRETURNVALUE] = BtlController_Empty,
|
|
|
|
[CONTROLLER_ONERETURNVALUE] = BtlController_Empty,
|
|
|
|
[CONTROLLER_ONERETURNVALUE_DUPLICATE] = BtlController_Empty,
|
|
|
|
[CONTROLLER_CLEARUNKVAR] = BtlController_Empty,
|
|
|
|
[CONTROLLER_SETUNKVAR] = BtlController_Empty,
|
|
|
|
[CONTROLLER_CLEARUNKFLAG] = BtlController_Empty,
|
|
|
|
[CONTROLLER_TOGGLEUNKFLAG] = BtlController_Empty,
|
|
|
|
[CONTROLLER_HITANIMATION] = BtlController_Empty,
|
|
|
|
[CONTROLLER_CANTSWITCH] = BtlController_Empty,
|
2023-08-05 12:13:50 +02:00
|
|
|
[CONTROLLER_PLAYSE] = BtlController_HandlePlaySE,
|
|
|
|
[CONTROLLER_PLAYFANFAREORBGM] = BtlController_HandlePlayFanfareOrBGM,
|
2020-12-29 16:51:44 -05:00
|
|
|
[CONTROLLER_FAINTINGCRY] = SafariHandleFaintingCry,
|
2023-08-05 14:11:25 +02:00
|
|
|
[CONTROLLER_INTROSLIDE] = BtlController_HandleIntroSlide,
|
2020-12-29 16:51:44 -05:00
|
|
|
[CONTROLLER_INTROTRAINERBALLTHROW] = SafariHandleIntroTrainerBallThrow,
|
2023-08-05 11:05:37 +02:00
|
|
|
[CONTROLLER_DRAWPARTYSTATUSSUMMARY] = BtlController_Empty,
|
|
|
|
[CONTROLLER_HIDEPARTYSTATUSSUMMARY] = BtlController_Empty,
|
|
|
|
[CONTROLLER_ENDBOUNCE] = BtlController_Empty,
|
|
|
|
[CONTROLLER_SPRITEINVISIBILITY] = BtlController_Empty,
|
2020-12-29 16:51:44 -05:00
|
|
|
[CONTROLLER_BATTLEANIMATION] = SafariHandleBattleAnimation,
|
2023-08-05 11:05:37 +02:00
|
|
|
[CONTROLLER_LINKSTANDBYMSG] = BtlController_Empty,
|
|
|
|
[CONTROLLER_RESETACTIONMOVESELECTION] = BtlController_Empty,
|
2021-01-22 02:48:22 -05:00
|
|
|
[CONTROLLER_ENDLINKBATTLE] = SafariHandleEndLinkBattle,
|
2023-08-05 11:05:37 +02:00
|
|
|
[CONTROLLER_DEBUGMENU] = BtlController_Empty,
|
|
|
|
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
|
2017-10-22 20:38:23 +02:00
|
|
|
};
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
void SetControllerToSafari(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattlerControllerEndFuncs[battler] = SafariBufferExecCompleted;
|
|
|
|
gBattlerControllerFuncs[battler] = SafariBufferRunCommand;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariBufferRunCommand(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
if (gBattleControllerExecFlags & gBitTable[battler])
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sSafariBufferCommands))
|
|
|
|
sSafariBufferCommands[gBattleResources->bufferA[battler][0]](battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
else
|
2023-08-07 12:51:58 +02:00
|
|
|
SafariBufferExecCompleted(battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void HandleInputChooseAction(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2020-09-04 21:11:55 -04:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
switch (gActionSelectionCursor[battler])
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2023-08-29 15:21:31 +02:00
|
|
|
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_BALL, 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2023-08-29 15:21:31 +02:00
|
|
|
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_POKEBLOCK, 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2023-08-29 15:21:31 +02:00
|
|
|
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_GO_NEAR, 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2023-08-29 15:21:31 +02:00
|
|
|
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_RUN, 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
break;
|
|
|
|
}
|
2023-08-07 12:51:58 +02:00
|
|
|
SafariBufferExecCompleted(battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
2020-09-04 21:11:55 -04:00
|
|
|
else if (JOY_NEW(DPAD_LEFT))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
if (gActionSelectionCursor[battler] & 1)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2023-08-07 12:51:58 +02:00
|
|
|
ActionSelectionDestroyCursorAt(gActionSelectionCursor[battler]);
|
|
|
|
gActionSelectionCursor[battler] ^= 1;
|
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-04 21:11:55 -04:00
|
|
|
else if (JOY_NEW(DPAD_RIGHT))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
if (!(gActionSelectionCursor[battler] & 1))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2023-08-07 12:51:58 +02:00
|
|
|
ActionSelectionDestroyCursorAt(gActionSelectionCursor[battler]);
|
|
|
|
gActionSelectionCursor[battler] ^= 1;
|
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-04 21:11:55 -04:00
|
|
|
else if (JOY_NEW(DPAD_UP))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
if (gActionSelectionCursor[battler] & 2)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2023-08-07 12:51:58 +02:00
|
|
|
ActionSelectionDestroyCursorAt(gActionSelectionCursor[battler]);
|
|
|
|
gActionSelectionCursor[battler] ^= 2;
|
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-04 21:11:55 -04:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
if (!(gActionSelectionCursor[battler] & 2))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2023-08-07 12:51:58 +02:00
|
|
|
ActionSelectionDestroyCursorAt(gActionSelectionCursor[battler]);
|
|
|
|
gActionSelectionCursor[battler] ^= 2;
|
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void Controller_WaitForHealthbox(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
if (gSprites[gHealthboxSpriteIds[battler]].callback == SpriteCallbackDummy)
|
|
|
|
SafariBufferExecCompleted(battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariSetBattleEndCallbacks(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
gMain.inBattle = FALSE;
|
|
|
|
gMain.callback1 = gPreBattleCallback1;
|
|
|
|
SetMainCallback2(gMain.savedCallback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariOpenPokeblockCase(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattlerControllerFuncs[battler] = CompleteWhenChosePokeblock;
|
2017-10-22 20:38:23 +02:00
|
|
|
FreeAllWindowBuffers();
|
2017-12-16 00:08:23 +01:00
|
|
|
OpenPokeblockCaseInBattle();
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void CompleteWhenChosePokeblock(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
|
|
|
{
|
2023-08-29 15:21:31 +02:00
|
|
|
BtlController_EmitOneReturnValue(battler, BUFFER_B, gSpecialVar_ItemId);
|
2023-08-07 12:51:58 +02:00
|
|
|
SafariBufferExecCompleted(battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariBufferExecCompleted(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattlerControllerFuncs[battler] = SafariBufferRunCommand;
|
2017-10-22 20:38:23 +02:00
|
|
|
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
|
|
|
{
|
|
|
|
u8 playerId = GetMultiplayerId();
|
|
|
|
|
2023-08-29 15:21:31 +02:00
|
|
|
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattleControllerExecFlags &= ~gBitTable[battler];
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleDrawTrainerPic(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-06 21:50:59 +02:00
|
|
|
u32 trainerPicId = gSaveBlock2Ptr->playerGender + TRAINER_BACK_PIC_BRENDAN;
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
BtlController_HandleDrawTrainerPic(battler, trainerPicId, FALSE,
|
2023-08-06 21:50:59 +02:00
|
|
|
80, 80 + 4 * (8 - gTrainerBackPicCoords[trainerPicId].size),
|
|
|
|
30);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleSuccessBallThrowAnim(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
BtlController_HandleSuccessBallThrowAnim(battler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleBallThrowAnim(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
BtlController_HandleBallThrowAnim(battler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandlePrintString(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
BtlController_HandlePrintString(battler, FALSE, FALSE);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandlePrintSelectionString(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
|
|
|
SafariHandlePrintString(battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
else
|
2023-08-07 12:51:58 +02:00
|
|
|
SafariBufferExecCompleted(battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void HandleChooseActionAfterDma3(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
|
|
|
gBattle_BG0_X = 0;
|
2021-04-15 02:04:01 -04:00
|
|
|
gBattle_BG0_Y = DISPLAY_HEIGHT;
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattlerControllerFuncs[battler] = HandleInputChooseAction;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleChooseAction(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattlerControllerFuncs[battler] = HandleChooseActionAfterDma3;
|
2021-10-08 16:50:52 -04:00
|
|
|
BattlePutTextOnWindow(gText_SafariZoneMenu, B_WIN_ACTION_MENU);
|
2017-10-22 20:38:23 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
ActionSelectionDestroyCursorAt(i);
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo2);
|
2021-10-08 16:50:52 -04:00
|
|
|
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_ACTION_PROMPT);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleChooseItem(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2021-02-24 11:01:02 -05:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattlerControllerFuncs[battler] = SafariOpenPokeblockCase;
|
|
|
|
gBattlerInMenuId = battler;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleStatusIconUpdate(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_SAFARI_BALLS_TEXT);
|
|
|
|
SafariBufferExecCompleted(battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-05 12:13:50 +02:00
|
|
|
// All of the other controllers(except Wally's) use CRY_MODE_FAINT.
|
|
|
|
// Player is not a pokemon, so it can't really faint in the Safari anyway.
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleFaintingCry(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
|
2017-10-22 20:38:23 +02:00
|
|
|
|
2021-11-07 13:54:44 -05:00
|
|
|
PlayCry_Normal(species, 25);
|
2023-08-07 12:51:58 +02:00
|
|
|
SafariBufferExecCompleted(battler);
|
|
|
|
SafariBufferExecCompleted(battler);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleIntroTrainerBallThrow(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_SAFARI_ALL_TEXT);
|
|
|
|
StartHealthboxSlideIn(battler);
|
|
|
|
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
|
|
|
gBattlerControllerFuncs[battler] = Controller_WaitForHealthbox;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleBattleAnimation(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
BtlController_HandleBattleAnimation(battler, TRUE, FALSE);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:51:58 +02:00
|
|
|
static void SafariHandleEndLinkBattle(u32 battler)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattleOutcome = gBattleResources->bufferA[battler][1];
|
2017-10-22 20:38:23 +02:00
|
|
|
FadeOutMapMusic(5);
|
|
|
|
BeginFastPaletteFade(3);
|
2023-08-07 12:51:58 +02:00
|
|
|
SafariBufferExecCompleted(battler);
|
2018-09-20 11:55:35 +02:00
|
|
|
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
|
2023-08-07 12:51:58 +02:00
|
|
|
gBattlerControllerFuncs[battler] = SafariSetBattleEndCallbacks;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|