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"
|
2019-04-04 17:05:46 -04:00
|
|
|
#include "constants/rgb.h"
|
2017-10-22 20:38:23 +02:00
|
|
|
|
|
|
|
static void SafariHandleDrawTrainerPic(void);
|
|
|
|
static void SafariHandleSuccessBallThrowAnim(void);
|
|
|
|
static void SafariHandleBallThrowAnim(void);
|
|
|
|
static void SafariHandlePrintString(void);
|
2017-11-25 18:42:31 +01:00
|
|
|
static void SafariHandlePrintSelectionString(void);
|
2017-10-22 20:38:23 +02:00
|
|
|
static void SafariHandleChooseAction(void);
|
|
|
|
static void SafariHandleChooseItem(void);
|
|
|
|
static void SafariHandleStatusIconUpdate(void);
|
|
|
|
static void SafariHandleFaintingCry(void);
|
|
|
|
static void SafariHandleIntroSlide(void);
|
|
|
|
static void SafariHandleIntroTrainerBallThrow(void);
|
|
|
|
static void SafariHandleBattleAnimation(void);
|
2021-01-22 02:48:22 -05:00
|
|
|
static void SafariHandleEndLinkBattle(void);
|
2018-09-18 21:51:10 +02:00
|
|
|
static void SafariHandleBattleDebug(void);
|
2017-10-22 20:38:23 +02:00
|
|
|
|
|
|
|
static void SafariBufferRunCommand(void);
|
|
|
|
static void SafariBufferExecCompleted(void);
|
|
|
|
static void CompleteWhenChosePokeblock(void);
|
|
|
|
|
2017-10-31 18:04:08 +01:00
|
|
|
static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
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,
|
|
|
|
[CONTROLLER_INTROSLIDE] = SafariHandleIntroSlide,
|
|
|
|
[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
|
|
|
};
|
|
|
|
|
2017-10-26 23:12:48 +02:00
|
|
|
void SetControllerToSafari(void)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2023-08-04 17:29:29 +02:00
|
|
|
gBattlerControllerEndFuncs[gActiveBattler] = SafariBufferExecCompleted;
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariBufferRunCommand(void)
|
|
|
|
{
|
2018-02-06 13:48:02 -06:00
|
|
|
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2019-01-05 16:00:57 +01:00
|
|
|
if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sSafariBufferCommands))
|
|
|
|
sSafariBufferCommands[gBattleResources->bufferA[gActiveBattler][0]]();
|
2017-10-22 20:38:23 +02:00
|
|
|
else
|
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HandleInputChooseAction(void)
|
|
|
|
{
|
2020-09-04 21:11:55 -04:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
|
2018-02-05 19:46:59 -06:00
|
|
|
switch (gActionSelectionCursor[gActiveBattler])
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2021-10-12 19:50:32 -04:00
|
|
|
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_BALL, 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-10-12 19:50:32 -04:00
|
|
|
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_POKEBLOCK, 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-10-12 19:50:32 -04:00
|
|
|
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_GO_NEAR, 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-10-12 19:50:32 -04:00
|
|
|
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_RUN, 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
2020-09-04 21:11:55 -04:00
|
|
|
else if (JOY_NEW(DPAD_LEFT))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2018-02-05 19:46:59 -06:00
|
|
|
if (gActionSelectionCursor[gActiveBattler] & 1)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-02-05 19:46:59 -06:00
|
|
|
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
|
|
|
gActionSelectionCursor[gActiveBattler] ^= 1;
|
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 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
|
|
|
{
|
2018-02-05 19:46:59 -06:00
|
|
|
if (!(gActionSelectionCursor[gActiveBattler] & 1))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-02-05 19:46:59 -06:00
|
|
|
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
|
|
|
gActionSelectionCursor[gActiveBattler] ^= 1;
|
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 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
|
|
|
{
|
2018-02-05 19:46:59 -06:00
|
|
|
if (gActionSelectionCursor[gActiveBattler] & 2)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-02-05 19:46:59 -06:00
|
|
|
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
|
|
|
gActionSelectionCursor[gActiveBattler] ^= 2;
|
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 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
|
|
|
{
|
2018-02-05 19:46:59 -06:00
|
|
|
if (!(gActionSelectionCursor[gActiveBattler] & 2))
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-02-05 19:46:59 -06:00
|
|
|
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
|
|
|
gActionSelectionCursor[gActiveBattler] ^= 2;
|
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-01 15:28:57 +02:00
|
|
|
static void CompleteOnBattlerSpriteCallbackDummy(void)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2018-02-06 13:48:02 -06:00
|
|
|
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CompleteOnInactiveTextPrinter(void)
|
|
|
|
{
|
2021-10-08 16:50:52 -04:00
|
|
|
if (!IsTextPrinterActive(B_WIN_MSG))
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CompleteOnHealthboxSpriteCallbackDummy(void)
|
|
|
|
{
|
2018-02-06 13:48:02 -06:00
|
|
|
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
|
2021-01-22 20:13:34 -05:00
|
|
|
static void SafariSetBattleEndCallbacks(void)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
gMain.inBattle = FALSE;
|
|
|
|
gMain.callback1 = gPreBattleCallback1;
|
|
|
|
SetMainCallback2(gMain.savedCallback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-16 00:08:23 +01:00
|
|
|
static void SafariOpenPokeblockCase(void)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CompleteWhenChosePokeblock(void)
|
|
|
|
{
|
|
|
|
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
|
|
|
{
|
2021-10-12 19:50:32 -04:00
|
|
|
BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId);
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CompleteOnFinishedBattleAnimation(void)
|
|
|
|
{
|
2018-02-05 19:46:59 -06:00
|
|
|
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive)
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariBufferExecCompleted(void)
|
|
|
|
{
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
|
2017-10-22 20:38:23 +02:00
|
|
|
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
|
|
|
{
|
|
|
|
u8 playerId = GetMultiplayerId();
|
|
|
|
|
|
|
|
PrepareBufferDataTransferLink(2, 4, &playerId);
|
2019-01-05 16:00:57 +01:00
|
|
|
gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CompleteOnFinishedStatusAnimation(void)
|
|
|
|
{
|
2018-02-05 19:46:59 -06:00
|
|
|
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive)
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
|
2021-01-22 20:03:21 -05:00
|
|
|
#define sSpeedX data[0]
|
|
|
|
|
2017-10-22 20:38:23 +02:00
|
|
|
static void SafariHandleDrawTrainerPic(void)
|
|
|
|
{
|
2018-02-05 19:46:59 -06:00
|
|
|
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler);
|
2018-07-01 15:28:57 +02:00
|
|
|
SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, GetBattlerPosition(gActiveBattler));
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattlerSpriteIds[gActiveBattler] = CreateSprite(
|
2018-07-01 15:28:57 +02:00
|
|
|
&gMultiuseSpriteTemplate,
|
2017-10-22 20:38:23 +02:00
|
|
|
80,
|
2019-01-04 18:17:55 +01:00
|
|
|
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].size) * 4 + 80,
|
2017-10-22 20:38:23 +02:00
|
|
|
30);
|
2018-02-06 13:48:02 -06:00
|
|
|
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
|
2021-07-07 09:11:52 -04:00
|
|
|
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
|
2021-01-22 20:03:21 -05:00
|
|
|
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
|
|
|
|
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
|
2018-07-01 15:28:57 +02:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2021-01-22 20:03:21 -05:00
|
|
|
#undef sSpeedX
|
|
|
|
|
2017-10-22 20:38:23 +02:00
|
|
|
static void SafariHandleSuccessBallThrowAnim(void)
|
|
|
|
{
|
2023-08-05 11:05:37 +02:00
|
|
|
BtlController_HandleSuccessBallThrowAnim(gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariHandleBallThrowAnim(void)
|
|
|
|
{
|
2023-08-05 11:05:37 +02:00
|
|
|
BtlController_HandleBallThrowAnim(gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariHandlePrintString(void)
|
|
|
|
{
|
|
|
|
u16 *stringId;
|
|
|
|
|
|
|
|
gBattle_BG0_X = 0;
|
|
|
|
gBattle_BG0_Y = 0;
|
2022-08-22 20:30:45 -04:00
|
|
|
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
|
2017-10-22 20:38:23 +02:00
|
|
|
BufferStringBattle(*stringId);
|
2021-10-08 16:50:52 -04:00
|
|
|
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2017-11-25 18:42:31 +01:00
|
|
|
static void SafariHandlePrintSelectionString(void)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2018-02-05 19:46:59 -06:00
|
|
|
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariHandlePrintString();
|
|
|
|
else
|
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HandleChooseActionAfterDma3(void)
|
|
|
|
{
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
|
|
|
gBattle_BG0_X = 0;
|
2021-04-15 02:04:01 -04:00
|
|
|
gBattle_BG0_Y = DISPLAY_HEIGHT;
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseAction;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariHandleChooseAction(void)
|
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = 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);
|
|
|
|
|
2018-02-05 19:46:59 -06:00
|
|
|
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 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
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariHandleChooseItem(void)
|
|
|
|
{
|
2021-02-24 11:01:02 -05:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = SafariOpenPokeblockCase;
|
2018-02-07 22:53:40 +01:00
|
|
|
gBattlerInMenuId = gActiveBattler;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariHandleStatusIconUpdate(void)
|
|
|
|
{
|
2018-02-06 13:48:02 -06:00
|
|
|
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_BALLS_TEXT);
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
|
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.
|
2017-10-22 20:38:23 +02:00
|
|
|
static void SafariHandleFaintingCry(void)
|
|
|
|
{
|
2018-02-06 13:48:02 -06:00
|
|
|
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
|
2017-10-22 20:38:23 +02:00
|
|
|
|
2021-11-07 13:54:44 -05:00
|
|
|
PlayCry_Normal(species, 25);
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariHandleIntroSlide(void)
|
|
|
|
{
|
2019-01-05 16:00:57 +01:00
|
|
|
HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]);
|
2018-02-08 11:17:41 +01:00
|
|
|
gIntroSlideFlags |= 1;
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariHandleIntroTrainerBallThrow(void)
|
|
|
|
{
|
2018-02-06 13:48:02 -06:00
|
|
|
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT);
|
2021-01-22 20:03:21 -05:00
|
|
|
StartHealthboxSlideIn(gActiveBattler);
|
2018-02-06 13:48:02 -06:00
|
|
|
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
|
|
|
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthboxSpriteCallbackDummy;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SafariHandleBattleAnimation(void)
|
|
|
|
{
|
2019-01-05 16:00:57 +01:00
|
|
|
u8 animationId = gBattleResources->bufferA[gActiveBattler][1];
|
|
|
|
u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
|
2017-10-22 20:38:23 +02:00
|
|
|
|
2018-02-05 19:46:59 -06:00
|
|
|
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
|
2017-10-22 20:38:23 +02:00
|
|
|
SafariBufferExecCompleted();
|
|
|
|
else
|
2018-02-06 13:48:02 -06:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2021-01-22 02:48:22 -05:00
|
|
|
static void SafariHandleEndLinkBattle(void)
|
2017-10-22 20:38:23 +02:00
|
|
|
{
|
2019-01-05 16:00:57 +01:00
|
|
|
gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1];
|
2017-10-22 20:38:23 +02:00
|
|
|
FadeOutMapMusic(5);
|
|
|
|
BeginFastPaletteFade(3);
|
|
|
|
SafariBufferExecCompleted();
|
2018-09-20 11:55:35 +02:00
|
|
|
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
|
2021-01-22 20:13:34 -05:00
|
|
|
gBattlerControllerFuncs[gActiveBattler] = SafariSetBattleEndCallbacks;
|
2017-10-22 20:38:23 +02:00
|
|
|
}
|
|
|
|
|
2018-09-18 21:51:10 +02:00
|
|
|
static void SafariHandleBattleDebug(void)
|
|
|
|
{
|
|
|
|
SafariBufferExecCompleted();
|
|
|
|
}
|