pokeemerald/src/battle_controller_opponent.c

2005 lines
74 KiB
C
Raw Normal View History

#include "global.h"
#include "battle.h"
2018-11-14 01:01:50 +01:00
#include "battle_ai_script_commands.h"
#include "battle_anim.h"
#include "battle_arena.h"
#include "battle_controllers.h"
#include "battle_message.h"
#include "battle_interface.h"
2018-11-14 01:01:50 +01:00
#include "battle_setup.h"
#include "battle_tower.h"
2018-02-27 20:40:09 +01:00
#include "battle_tv.h"
2018-11-14 01:01:50 +01:00
#include "bg.h"
2019-04-04 23:53:06 +02:00
#include "data.h"
2018-11-14 01:01:50 +01:00
#include "frontier_util.h"
#include "item.h"
#include "link.h"
2017-10-25 21:57:28 +02:00
#include "main.h"
#include "m4a.h"
#include "palette.h"
2018-11-14 01:01:50 +01:00
#include "pokeball.h"
#include "pokemon.h"
#include "random.h"
#include "reshow_battle_screen.h"
#include "sound.h"
#include "string_util.h"
2017-10-25 21:57:28 +02:00
#include "task.h"
#include "text.h"
2018-11-14 01:01:50 +01:00
#include "util.h"
#include "window.h"
#include "constants/battle_anim.h"
#include "constants/items.h"
#include "constants/moves.h"
#include "constants/songs.h"
#include "constants/trainers.h"
2019-03-02 04:32:50 +01:00
#include "trainer_hill.h"
2018-02-08 00:00:25 +01:00
extern struct MusicPlayerInfo gMPlayInfo_BGM;
2017-10-25 21:57:28 +02:00
// this file's functions
2017-10-26 23:12:48 +02:00
static void OpponentHandleGetMonData(void);
static void OpponentHandleGetRawMonData(void);
static void OpponentHandleSetMonData(void);
static void OpponentHandleSetRawMonData(void);
static void OpponentHandleLoadMonSprite(void);
static void OpponentHandleSwitchInAnim(void);
static void OpponentHandleReturnMonToBall(void);
static void OpponentHandleDrawTrainerPic(void);
static void OpponentHandleTrainerSlide(void);
static void OpponentHandleTrainerSlideBack(void);
static void OpponentHandleFaintAnimation(void);
static void OpponentHandlePaletteFade(void);
static void OpponentHandleSuccessBallThrowAnim(void);
static void OpponentHandleBallThrow(void);
static void OpponentHandlePause(void);
static void OpponentHandleMoveAnimation(void);
static void OpponentHandlePrintString(void);
static void OpponentHandlePrintSelectionString(void);
2017-10-26 23:12:48 +02:00
static void OpponentHandleChooseAction(void);
static void OpponentHandleUnknownYesNoBox(void);
static void OpponentHandleChooseMove(void);
static void OpponentHandleChooseItem(void);
static void OpponentHandleChoosePokemon(void);
static void OpponentHandleCmd23(void);
static void OpponentHandleHealthBarUpdate(void);
static void OpponentHandleExpUpdate(void);
static void OpponentHandleStatusIconUpdate(void);
static void OpponentHandleStatusAnimation(void);
static void OpponentHandleStatusXor(void);
static void OpponentHandleDataTransfer(void);
static void OpponentHandleDMA3Transfer(void);
static void OpponentHandlePlayBGM(void);
static void OpponentHandleCmd32(void);
static void OpponentHandleTwoReturnValues(void);
static void OpponentHandleChosenMonReturnValue(void);
static void OpponentHandleOneReturnValue(void);
static void OpponentHandleOneReturnValue_Duplicate(void);
static void OpponentHandleCmd37(void);
static void OpponentHandleCmd38(void);
static void OpponentHandleCmd39(void);
static void OpponentHandleCmd40(void);
static void OpponentHandleHitAnimation(void);
static void OpponentHandleCmd42(void);
static void OpponentHandlePlaySE(void);
2017-10-26 23:12:48 +02:00
static void OpponentHandlePlayFanfareOrBGM(void);
static void OpponentHandleFaintingCry(void);
static void OpponentHandleIntroSlide(void);
static void OpponentHandleIntroTrainerBallThrow(void);
static void OpponentHandleDrawPartyStatusSummary(void);
2018-06-28 21:06:32 +02:00
static void OpponentHandleHidePartyStatusSummary(void);
2018-06-20 23:07:51 +02:00
static void OpponentHandleEndBounceEffect(void);
2017-10-26 23:12:48 +02:00
static void OpponentHandleSpriteInvisibility(void);
static void OpponentHandleBattleAnimation(void);
static void OpponentHandleLinkStandbyMsg(void);
static void OpponentHandleResetActionMoveSelection(void);
static void OpponentHandleCmd55(void);
static void OpponentCmdEnd(void);
2017-10-26 23:12:48 +02:00
static void OpponentBufferRunCommand(void);
static void OpponentBufferExecCompleted(void);
static void sub_805FC80(void);
static u32 GetOpponentMonData(u8 monId, u8 *dst);
static void SetOpponentMonData(u8 monId);
2018-03-01 00:59:52 +01:00
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit);
2017-10-26 23:12:48 +02:00
static void DoSwitchOutAnimation(void);
static void OpponentDoMoveAnimation(void);
static void sub_806280C(struct Sprite *sprite);
static void sub_8062828(u8 taskId);
static void sub_8062A2C(void);
2017-10-31 18:04:08 +01:00
static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
OpponentHandleGetMonData,
OpponentHandleGetRawMonData,
OpponentHandleSetMonData,
OpponentHandleSetRawMonData,
OpponentHandleLoadMonSprite,
OpponentHandleSwitchInAnim,
OpponentHandleReturnMonToBall,
OpponentHandleDrawTrainerPic,
OpponentHandleTrainerSlide,
OpponentHandleTrainerSlideBack,
OpponentHandleFaintAnimation,
2017-10-25 21:57:28 +02:00
OpponentHandlePaletteFade,
OpponentHandleSuccessBallThrowAnim,
OpponentHandleBallThrow,
OpponentHandlePause,
OpponentHandleMoveAnimation,
OpponentHandlePrintString,
OpponentHandlePrintSelectionString,
OpponentHandleChooseAction,
2017-10-25 21:57:28 +02:00
OpponentHandleUnknownYesNoBox,
OpponentHandleChooseMove,
2017-10-26 23:12:48 +02:00
OpponentHandleChooseItem,
OpponentHandleChoosePokemon,
OpponentHandleCmd23,
OpponentHandleHealthBarUpdate,
OpponentHandleExpUpdate,
OpponentHandleStatusIconUpdate,
OpponentHandleStatusAnimation,
OpponentHandleStatusXor,
OpponentHandleDataTransfer,
OpponentHandleDMA3Transfer,
OpponentHandlePlayBGM,
OpponentHandleCmd32,
2017-10-26 23:12:48 +02:00
OpponentHandleTwoReturnValues,
OpponentHandleChosenMonReturnValue,
OpponentHandleOneReturnValue,
OpponentHandleOneReturnValue_Duplicate,
OpponentHandleCmd37,
OpponentHandleCmd38,
OpponentHandleCmd39,
OpponentHandleCmd40,
OpponentHandleHitAnimation,
OpponentHandleCmd42,
OpponentHandlePlaySE,
OpponentHandlePlayFanfareOrBGM,
OpponentHandleFaintingCry,
OpponentHandleIntroSlide,
OpponentHandleIntroTrainerBallThrow,
OpponentHandleDrawPartyStatusSummary,
2018-06-28 21:06:32 +02:00
OpponentHandleHidePartyStatusSummary,
2018-06-20 23:07:51 +02:00
OpponentHandleEndBounceEffect,
OpponentHandleSpriteInvisibility,
OpponentHandleBattleAnimation,
OpponentHandleLinkStandbyMsg,
OpponentHandleResetActionMoveSelection,
OpponentHandleCmd55,
OpponentCmdEnd
};
// unknown unused data
2017-10-25 21:57:28 +02:00
static const u8 sUnknown_0831C7AC[] = {0xB0, 0xB0, 0xC8, 0x98, 0x28, 0x28, 0x28, 0x20};
2017-10-26 23:12:48 +02:00
static void nullsub_26(void)
{
}
2017-10-26 23:12:48 +02:00
void SetControllerToOpponent(void)
{
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = OpponentBufferRunCommand;
}
2017-10-25 21:57:28 +02:00
2017-10-26 23:12:48 +02:00
static void OpponentBufferRunCommand(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sOpponentBufferCommands))
sOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]]();
2017-10-25 21:57:28 +02:00
else
OpponentBufferExecCompleted();
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void CompleteOnBankSpriteCallbackDummy2(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void sub_805F240(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
}
2017-10-26 23:12:48 +02:00
static void sub_805F2A8(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
}
2017-10-26 23:12:48 +02:00
static void sub_805F2F0(void)
2017-10-25 21:57:28 +02:00
{
bool8 var = FALSE;
bool8 var2;
if (!IsDoubleBattle() || ((IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) || (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)))
{
2018-02-06 20:48:02 +01:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-25 21:57:28 +02:00
var = TRUE;
var2 = FALSE;
}
else
{
2018-02-06 20:48:02 +01:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
2017-10-25 21:57:28 +02:00
var = TRUE;
var2 = TRUE;
}
2018-02-06 02:46:59 +01:00
gUnknown_020244D8 = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler];
gUnknown_020244DC = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK];
2017-10-25 21:57:28 +02:00
if (var)
{
if (var2 == TRUE)
{
2018-02-06 02:46:59 +01:00
if (var2 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 = 0;
2017-10-25 21:57:28 +02:00
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
}
else
return;
}
2018-02-06 02:46:59 +01:00
else if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (GetBattlerPosition(gActiveBattler) == 3)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 == 0 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 == 0)
2017-10-25 21:57:28 +02:00
{
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
}
else
return;
}
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0;
2017-10-25 21:57:28 +02:00
}
else
return;
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_805F2A8;
2017-10-25 21:57:28 +02:00
}
}
2017-10-26 23:12:48 +02:00
static void sub_805F560(void)
2017-10-25 21:57:28 +02:00
{
bool32 sp = FALSE;
bool32 r10 = FALSE;
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
2018-02-06 20:48:02 +01:00
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
2018-02-06 02:46:59 +01:00
if (!(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI) && IsDoubleBattle() && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1)
2018-02-06 20:48:02 +01:00
sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]);
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80)
2017-10-25 21:57:28 +02:00
{
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
2018-02-06 20:48:02 +01:00
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
2018-02-06 02:46:59 +01:00
sub_8076918(gActiveBattler ^ BIT_FLANK);
2018-02-06 20:48:02 +01:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
2017-10-25 21:57:28 +02:00
}
2018-02-06 20:48:02 +01:00
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
2018-02-06 02:46:59 +01:00
sub_8076918(gActiveBattler);
2018-02-06 20:48:02 +01:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-25 21:57:28 +02:00
}
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
2017-10-25 21:57:28 +02:00
}
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40
2017-10-25 21:57:28 +02:00
&& !IsCryPlayingOrClearCrySongs())
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20)
2017-10-25 21:57:28 +02:00
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
{
2018-02-06 02:46:59 +01:00
if (GetBattlerPosition(gActiveBattler) == 1)
m4aMPlayContinue(&gMPlayInfo_BGM);
2017-10-25 21:57:28 +02:00
}
else
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
2017-10-25 21:57:28 +02:00
}
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1;
2017-10-25 21:57:28 +02:00
sp = TRUE;
}
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
2018-02-06 02:46:59 +01:00
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
2018-02-06 20:48:02 +01:00
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-25 21:57:28 +02:00
{
r10 = TRUE;
}
}
else
{
2018-02-06 02:46:59 +01:00
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
2018-02-06 20:48:02 +01:00
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
2018-02-06 02:46:59 +01:00
&& gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
2018-02-06 20:48:02 +01:00
&& gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
2017-10-25 21:57:28 +02:00
{
r10 = TRUE;
}
}
if (sp && r10)
{
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
2018-02-06 02:46:59 +01:00
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
2018-02-06 20:48:02 +01:00
SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES));
2017-10-25 21:57:28 +02:00
}
2018-02-06 02:46:59 +01:00
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
2018-02-06 20:48:02 +01:00
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
2017-10-25 21:57:28 +02:00
gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
2017-10-25 21:57:28 +02:00
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_805F2F0;
2017-10-25 21:57:28 +02:00
}
}
2017-10-26 23:12:48 +02:00
static void sub_805F994(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
2017-10-25 21:57:28 +02:00
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0;
2017-10-25 21:57:28 +02:00
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
OpponentBufferExecCompleted();
}
}
2017-10-26 23:12:48 +02:00
static void CompleteOnHealthbarDone(void)
2017-10-25 21:57:28 +02:00
{
2018-06-19 00:43:15 +02:00
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
2018-02-06 20:48:02 +01:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-25 21:57:28 +02:00
if (hpValue != -1)
{
2018-02-06 20:48:02 +01:00
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
2017-10-25 21:57:28 +02:00
}
else
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void sub_805FAC4(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
}
2017-10-26 23:12:48 +02:00
static void sub_805FB08(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
HideBattlerShadowSprite(gActiveBattler);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
}
2017-10-26 23:12:48 +02:00
static void CompleteOnInactiveTextPrinter(void)
2017-10-25 21:57:28 +02:00
{
if (!IsTextPrinterActive(0))
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void DoHitAnimBlinkSpriteEffect(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
u8 spriteId = gBattlerSpriteIds[gActiveBattler];
2017-10-25 21:57:28 +02:00
2017-12-02 21:44:50 +01:00
if (gSprites[spriteId].data[1] == 32)
2017-10-25 21:57:28 +02:00
{
2017-12-02 21:44:50 +01:00
gSprites[spriteId].data[1] = 0;
gSprites[spriteId].invisible = FALSE;
2017-10-25 21:57:28 +02:00
gDoingBattleAnim = FALSE;
OpponentBufferExecCompleted();
}
else
{
2017-12-02 21:44:50 +01:00
if ((gSprites[spriteId].data[1] % 4) == 0)
2017-10-25 21:57:28 +02:00
gSprites[spriteId].invisible ^= 1;
2017-12-02 21:44:50 +01:00
gSprites[spriteId].data[1]++;
2017-10-25 21:57:28 +02:00
}
}
2017-10-26 23:12:48 +02:00
static void sub_805FC10(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-25 21:57:28 +02:00
{
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_805FC80;
2017-10-25 21:57:28 +02:00
}
}
2017-10-26 23:12:48 +02:00
static void sub_805FC80(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy || gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
2017-10-25 21:57:28 +02:00
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
}
}
2017-10-26 23:12:48 +02:00
static void sub_805FD00(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0;
2017-10-25 21:57:28 +02:00
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
2018-02-06 20:48:02 +01:00
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
2018-02-06 02:46:59 +01:00
sub_8076918(gActiveBattler);
2018-02-06 20:48:02 +01:00
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
2018-02-06 02:46:59 +01:00
CopyBattleSpriteInvisibility(gActiveBattler);
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_805FC10;
2017-10-25 21:57:28 +02:00
}
}
2017-10-26 23:12:48 +02:00
static void sub_805FDF0(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
2018-02-06 20:48:02 +01:00
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
2017-10-25 21:57:28 +02:00
2018-02-06 02:46:59 +01:00
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
2018-02-06 20:48:02 +01:00
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_805FD00;
2017-10-25 21:57:28 +02:00
}
}
2017-10-26 23:12:48 +02:00
static void CompleteOnFinishedStatusAnimation(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive)
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void CompleteOnFinishedBattleAnimation(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive)
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentBufferExecCompleted(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = OpponentBufferRunCommand;
2017-10-25 21:57:28 +02:00
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
2018-02-06 02:46:59 +01:00
gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
2017-10-25 21:57:28 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
2017-10-25 21:57:28 +02:00
}
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleGetMonData(void)
2017-10-25 21:57:28 +02:00
{
u8 monData[sizeof(struct Pokemon) * 2 + 56]; // this allows to get full data of two pokemon, trying to get more will result in overwriting data
u32 size = 0;
2017-10-31 18:04:08 +01:00
u8 monToCheck;
2017-10-25 21:57:28 +02:00
s32 i;
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][2] == 0)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
size += GetOpponentMonData(gBattlerPartyIndexes[gActiveBattler], monData);
2017-10-25 21:57:28 +02:00
}
else
{
2018-02-06 02:46:59 +01:00
monToCheck = gBattleBufferA[gActiveBattler][2];
2018-11-18 20:00:36 +01:00
for (i = 0; i < PARTY_SIZE; i++)
2017-10-25 21:57:28 +02:00
{
2017-10-31 18:04:08 +01:00
if (monToCheck & 1)
2017-10-26 23:12:48 +02:00
size += GetOpponentMonData(i, monData + size);
2017-10-31 18:04:08 +01:00
monToCheck >>= 1;
2017-10-25 21:57:28 +02:00
}
}
2018-02-06 20:48:02 +01:00
BtlController_EmitDataTransfer(1, size, monData);
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static u32 GetOpponentMonData(u8 monId, u8 *dst)
2017-10-25 21:57:28 +02:00
{
struct BattlePokemon battleMon;
struct MovePpInfo moveData;
u8 nickname[20];
u8 *src;
s16 data16;
u32 data32;
s32 size = 0;
2018-02-06 02:46:59 +01:00
switch (gBattleBufferA[gActiveBattler][1])
2017-10-25 21:57:28 +02:00
{
case REQUEST_ALL_BATTLE:
battleMon.species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES);
battleMon.item = GetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM);
for (size = 0; size < MAX_MON_MOVES; size++)
2017-10-25 21:57:28 +02:00
{
battleMon.moves[size] = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + size);
battleMon.pp[size] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + size);
}
battleMon.ppBonuses = GetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES);
battleMon.friendship = GetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP);
battleMon.experience = GetMonData(&gEnemyParty[monId], MON_DATA_EXP);
battleMon.hpIV = GetMonData(&gEnemyParty[monId], MON_DATA_HP_IV);
battleMon.attackIV = GetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV);
battleMon.defenseIV = GetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV);
battleMon.speedIV = GetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV);
battleMon.spAttackIV = GetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV);
battleMon.spDefenseIV = GetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV);
battleMon.personality = GetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY);
battleMon.status1 = GetMonData(&gEnemyParty[monId], MON_DATA_STATUS);
battleMon.level = GetMonData(&gEnemyParty[monId], MON_DATA_LEVEL);
battleMon.hp = GetMonData(&gEnemyParty[monId], MON_DATA_HP);
battleMon.maxHP = GetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP);
battleMon.attack = GetMonData(&gEnemyParty[monId], MON_DATA_ATK);
battleMon.defense = GetMonData(&gEnemyParty[monId], MON_DATA_DEF);
battleMon.speed = GetMonData(&gEnemyParty[monId], MON_DATA_SPEED);
battleMon.spAttack = GetMonData(&gEnemyParty[monId], MON_DATA_SPATK);
battleMon.spDefense = GetMonData(&gEnemyParty[monId], MON_DATA_SPDEF);
battleMon.isEgg = GetMonData(&gEnemyParty[monId], MON_DATA_IS_EGG);
2019-05-14 15:22:16 +02:00
battleMon.abilityNum = GetMonData(&gEnemyParty[monId], MON_DATA_ABILITY_NUM);
2017-10-25 21:57:28 +02:00
battleMon.otId = GetMonData(&gEnemyParty[monId], MON_DATA_OT_ID);
GetMonData(&gEnemyParty[monId], MON_DATA_NICKNAME, nickname);
StringCopy10(battleMon.nickname, nickname);
GetMonData(&gEnemyParty[monId], MON_DATA_OT_NAME, battleMon.otName);
src = (u8 *)&battleMon;
for (size = 0; size < sizeof(battleMon); size++)
dst[size] = src[size];
break;
case REQUEST_SPECIES_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_HELDITEM_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_MOVES_PP_BATTLE:
for (size = 0; size < MAX_MON_MOVES; size++)
2017-10-25 21:57:28 +02:00
{
moveData.moves[size] = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + size);
moveData.pp[size] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + size);
}
moveData.ppBonuses = GetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES);
src = (u8*)(&moveData);
for (size = 0; size < sizeof(moveData); size++)
dst[size] = src[size];
break;
case REQUEST_MOVE1_BATTLE:
case REQUEST_MOVE2_BATTLE:
case REQUEST_MOVE3_BATTLE:
case REQUEST_MOVE4_BATTLE:
2018-02-06 02:46:59 +01:00
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE);
2017-10-25 21:57:28 +02:00
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_PP_DATA_BATTLE:
for (size = 0; size < MAX_MON_MOVES; size++)
2017-10-25 21:57:28 +02:00
dst[size] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + size);
dst[size] = GetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES);
size++;
break;
case REQUEST_PPMOVE1_BATTLE:
case REQUEST_PPMOVE2_BATTLE:
case REQUEST_PPMOVE3_BATTLE:
case REQUEST_PPMOVE4_BATTLE:
2018-02-06 02:46:59 +01:00
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE);
2017-10-25 21:57:28 +02:00
size = 1;
break;
case REQUEST_OTID_BATTLE:
data32 = GetMonData(&gEnemyParty[monId], MON_DATA_OT_ID);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
size = 3;
break;
case REQUEST_EXP_BATTLE:
data32 = GetMonData(&gEnemyParty[monId], MON_DATA_EXP);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
size = 3;
break;
case REQUEST_HP_EV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_HP_EV);
size = 1;
break;
case REQUEST_ATK_EV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV);
size = 1;
break;
case REQUEST_DEF_EV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV);
size = 1;
break;
case REQUEST_SPEED_EV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV);
size = 1;
break;
case REQUEST_SPATK_EV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV);
size = 1;
break;
case REQUEST_SPDEF_EV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV);
size = 1;
break;
case REQUEST_FRIENDSHIP_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP);
size = 1;
break;
case REQUEST_POKERUS_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_POKERUS);
size = 1;
break;
case REQUEST_MET_LOCATION_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION);
size = 1;
break;
case REQUEST_MET_LEVEL_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL);
size = 1;
break;
case REQUEST_MET_GAME_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME);
size = 1;
break;
case REQUEST_POKEBALL_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL);
size = 1;
break;
case REQUEST_ALL_IVS_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_HP_IV);
dst[1] = GetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV);
dst[2] = GetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV);
dst[3] = GetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV);
dst[4] = GetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV);
dst[5] = GetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV);
size = 6;
break;
case REQUEST_HP_IV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_HP_IV);
size = 1;
break;
case REQUEST_ATK_IV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV);
size = 1;
break;
case REQUEST_DEF_IV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV);
size = 1;
break;
case REQUEST_SPEED_IV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV);
size = 1;
break;
case REQUEST_SPATK_IV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV);
size = 1;
break;
case REQUEST_SPDEF_IV_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV);
size = 1;
break;
case REQUEST_PERSONALITY_BATTLE:
data32 = GetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
dst[3] = (data32 & 0xFF000000) >> 24;
size = 4;
break;
case REQUEST_CHECKSUM_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_STATUS_BATTLE:
data32 = GetMonData(&gEnemyParty[monId], MON_DATA_STATUS);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
dst[3] = (data32 & 0xFF000000) >> 24;
size = 4;
break;
case REQUEST_LEVEL_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_LEVEL);
size = 1;
break;
case REQUEST_HP_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_HP);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_MAX_HP_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_ATK_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_ATK);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_DEF_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_DEF);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_SPEED_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_SPEED);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_SPATK_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_SPATK);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_SPDEF_BATTLE:
data16 = GetMonData(&gEnemyParty[monId], MON_DATA_SPDEF);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_COOL_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_COOL);
size = 1;
break;
case REQUEST_BEAUTY_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY);
size = 1;
break;
case REQUEST_CUTE_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_CUTE);
size = 1;
break;
case REQUEST_SMART_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_SMART);
size = 1;
break;
case REQUEST_TOUGH_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_TOUGH);
size = 1;
break;
case REQUEST_SHEEN_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_SHEEN);
size = 1;
break;
case REQUEST_COOL_RIBBON_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON);
size = 1;
break;
case REQUEST_BEAUTY_RIBBON_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON);
size = 1;
break;
case REQUEST_CUTE_RIBBON_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON);
size = 1;
break;
case REQUEST_SMART_RIBBON_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON);
size = 1;
break;
case REQUEST_TOUGH_RIBBON_BATTLE:
dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON);
size = 1;
break;
}
return size;
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleGetRawMonData(void)
2017-10-25 21:57:28 +02:00
{
struct BattlePokemon battleMon;
2018-02-06 20:48:02 +01:00
u8 *src = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
2018-02-06 02:46:59 +01:00
u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBattler][1];
2017-10-25 21:57:28 +02:00
u8 i;
2018-02-06 02:46:59 +01:00
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
2017-10-25 21:57:28 +02:00
dst[i] = src[i];
2018-02-06 20:48:02 +01:00
BtlController_EmitDataTransfer(1, gBattleBufferA[gActiveBattler][2], dst);
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleSetMonData(void)
2017-10-25 21:57:28 +02:00
{
2017-10-31 18:04:08 +01:00
u8 monToCheck;
2017-10-25 21:57:28 +02:00
u8 i;
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][2] == 0)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
SetOpponentMonData(gBattlerPartyIndexes[gActiveBattler]);
2017-10-25 21:57:28 +02:00
}
else
{
2018-02-06 02:46:59 +01:00
monToCheck = gBattleBufferA[gActiveBattler][2];
2018-11-18 20:00:36 +01:00
for (i = 0; i < PARTY_SIZE; i++)
2017-10-25 21:57:28 +02:00
{
2017-10-31 18:04:08 +01:00
if (monToCheck & 1)
2017-10-26 23:12:48 +02:00
SetOpponentMonData(i);
2017-10-31 18:04:08 +01:00
monToCheck >>= 1;
2017-10-25 21:57:28 +02:00
}
}
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void SetOpponentMonData(u8 monId)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3];
struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3];
2017-10-25 21:57:28 +02:00
s32 i;
2018-02-06 02:46:59 +01:00
switch (gBattleBufferA[gActiveBattler][1])
2017-10-25 21:57:28 +02:00
{
case REQUEST_ALL_BATTLE:
{
u8 iv;
SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &battlePokemon->species);
SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &battlePokemon->item);
for (i = 0; i < MAX_MON_MOVES; i++)
2017-10-25 21:57:28 +02:00
{
SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + i, &battlePokemon->moves[i]);
SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + i, &battlePokemon->pp[i]);
}
SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &battlePokemon->ppBonuses);
SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &battlePokemon->friendship);
SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &battlePokemon->experience);
iv = battlePokemon->hpIV;
SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &iv);
iv = battlePokemon->attackIV;
SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &iv);
iv = battlePokemon->defenseIV;
SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &iv);
iv = battlePokemon->speedIV;
SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &iv);
iv = battlePokemon->spAttackIV;
SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &iv);
iv = battlePokemon->spDefenseIV;
SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &iv);
SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &battlePokemon->personality);
SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &battlePokemon->status1);
SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &battlePokemon->level);
SetMonData(&gEnemyParty[monId], MON_DATA_HP, &battlePokemon->hp);
SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &battlePokemon->maxHP);
SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &battlePokemon->attack);
SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &battlePokemon->defense);
SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &battlePokemon->speed);
SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &battlePokemon->spAttack);
SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &battlePokemon->spDefense);
}
break;
case REQUEST_SPECIES_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_HELDITEM_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_MOVES_PP_BATTLE:
for (i = 0; i < MAX_MON_MOVES; i++)
2017-10-25 21:57:28 +02:00
{
SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + i, &moveData->moves[i]);
SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + i, &moveData->pp[i]);
}
SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &moveData->ppBonuses);
break;
case REQUEST_MOVE1_BATTLE:
case REQUEST_MOVE2_BATTLE:
case REQUEST_MOVE3_BATTLE:
case REQUEST_MOVE4_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_PP_DATA_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]);
SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]);
SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]);
SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]);
SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_PPMOVE1_BATTLE:
case REQUEST_PPMOVE2_BATTLE:
case REQUEST_PPMOVE3_BATTLE:
case REQUEST_PPMOVE4_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_OTID_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_EXP_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_HP_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_ATK_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_DEF_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SPEED_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SPATK_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SPDEF_EV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_FRIENDSHIP_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_POKERUS_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_MET_LOCATION_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_MET_LEVEL_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_MET_GAME_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_POKEBALL_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_ALL_IVS_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]);
SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]);
SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]);
SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]);
SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]);
SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_HP_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_ATK_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_DEF_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SPEED_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SPATK_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SPDEF_IV_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_PERSONALITY_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_CHECKSUM_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_STATUS_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_LEVEL_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_HP_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_MAX_HP_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_ATK_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_DEF_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SPEED_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SPATK_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SPDEF_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_COOL_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_BEAUTY_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_CUTE_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SMART_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_TOUGH_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SHEEN_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_COOL_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_BEAUTY_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_CUTE_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_SMART_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
case REQUEST_TOUGH_RIBBON_BATTLE:
2018-02-06 02:46:59 +01:00
SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]);
2017-10-25 21:57:28 +02:00
break;
}
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleSetRawMonData(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
2017-10-25 21:57:28 +02:00
u8 i;
2018-02-06 02:46:59 +01:00
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
dst[i] = gBattleBufferA[gActiveBattler][3 + i];
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleLoadMonSprite(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 20:48:02 +01:00
u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
2017-10-25 21:57:28 +02:00
2018-02-06 20:48:02 +01:00
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler));
2017-10-25 21:57:28 +02:00
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate,
2018-02-06 20:48:02 +01:00
GetBattlerSpriteCoord(gActiveBattler, 2),
GetBattlerSpriteDefault_Y(gActiveBattler),
2018-12-18 05:08:08 +01:00
GetBattlerSpriteSubpriority(gActiveBattler));
2017-10-25 21:57:28 +02:00
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = species;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
2017-10-25 21:57:28 +02:00
2018-02-06 20:48:02 +01:00
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
2017-10-25 21:57:28 +02:00
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_805F994;
2017-10-25 21:57:28 +02:00
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleSwitchInAnim(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6;
2018-02-06 20:48:02 +01:00
gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
2018-02-06 02:46:59 +01:00
sub_80613DC(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_805FDF0;
2017-10-25 21:57:28 +02:00
}
2018-03-01 00:59:52 +01:00
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
2017-10-25 21:57:28 +02:00
{
u16 species;
2018-03-01 00:59:52 +01:00
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
2017-10-25 21:57:28 +02:00
gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate,
2018-03-01 00:59:52 +01:00
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
2018-12-18 05:08:08 +01:00
GetBattlerSpriteSubpriority(battlerId));
2017-10-25 21:57:28 +02:00
2018-03-01 00:59:52 +01:00
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
2017-10-25 21:57:28 +02:00
2018-03-01 00:59:52 +01:00
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
2017-10-25 21:57:28 +02:00
2018-03-01 00:59:52 +01:00
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
2017-10-25 21:57:28 +02:00
2018-03-01 00:59:52 +01:00
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
2017-10-25 21:57:28 +02:00
2018-03-01 00:59:52 +01:00
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
2017-10-25 21:57:28 +02:00
2018-03-01 00:59:52 +01:00
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
2017-10-25 21:57:28 +02:00
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleReturnMonToBall(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][1] == 0)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation;
2017-10-25 21:57:28 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
HideBattlerShadowSprite(gActiveBattler);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
}
2017-10-26 23:12:48 +02:00
static void DoSwitchOutAnimation(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
2017-10-25 21:57:28 +02:00
{
case 0:
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
2017-10-25 21:57:28 +02:00
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
2017-10-25 21:57:28 +02:00
break;
case 1:
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON);
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_805FB08;
2017-10-25 21:57:28 +02:00
}
break;
}
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleDrawTrainerPic(void)
2017-10-25 21:57:28 +02:00
{
u32 trainerPicId;
s16 xPos;
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
{
trainerPicId = GetSecretBaseTrainerPicIndex();
}
else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
2017-10-25 21:57:28 +02:00
{
2018-07-01 11:15:42 +02:00
trainerPicId = GetFrontierBrainTrainerPicIndex();
2017-10-25 21:57:28 +02:00
}
2018-09-20 22:00:00 +02:00
else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL)
2017-10-25 21:57:28 +02:00
{
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
2018-02-06 02:46:59 +01:00
if (gActiveBattler == 1)
2018-09-20 22:00:00 +02:00
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_A);
2017-10-25 21:57:28 +02:00
else
2018-09-20 22:00:00 +02:00
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_B);
2017-10-25 21:57:28 +02:00
}
else
{
2018-09-20 22:00:00 +02:00
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_A);
2017-10-25 21:57:28 +02:00
}
}
else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
{
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{
2018-02-06 02:46:59 +01:00
if (gActiveBattler == 1)
2017-10-25 21:57:28 +02:00
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
else
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B);
}
else
{
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
}
}
else if (gBattleTypeFlags & BATTLE_TYPE_EREADER_TRAINER)
{
trainerPicId = GetEreaderTrainerFrontSpriteId();
}
else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
2018-02-06 02:46:59 +01:00
if (gActiveBattler != 1)
2017-10-25 21:57:28 +02:00
trainerPicId = gTrainers[gTrainerBattleOpponent_B].trainerPic;
else
trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic;
}
else
{
trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic;
}
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS))
{
2018-02-06 02:46:59 +01:00
if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon
2017-10-25 21:57:28 +02:00
xPos = 152;
else // first mon
xPos = 200;
}
else
{
xPos = 176;
}
2018-02-06 02:46:59 +01:00
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate,
2017-10-25 21:57:28 +02:00
xPos,
(8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40,
2018-12-18 05:08:08 +01:00
GetBattlerSpriteSubpriority(gActiveBattler));
2017-10-25 21:57:28 +02:00
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
2017-10-25 21:57:28 +02:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
2017-10-25 21:57:28 +02:00
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleTrainerSlide(void)
2017-10-25 21:57:28 +02:00
{
u32 trainerPicId;
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
{
trainerPicId = GetSecretBaseTrainerPicIndex();
}
else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
2017-10-25 21:57:28 +02:00
{
2018-07-01 11:15:42 +02:00
trainerPicId = GetFrontierBrainTrainerPicIndex();
2017-10-25 21:57:28 +02:00
}
2018-09-20 22:00:00 +02:00
else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL)
2017-10-25 21:57:28 +02:00
{
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
2018-02-06 02:46:59 +01:00
if (gActiveBattler == 1)
2018-09-20 22:00:00 +02:00
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_A);
2017-10-25 21:57:28 +02:00
else
2018-09-20 22:00:00 +02:00
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_B);
2017-10-25 21:57:28 +02:00
}
else
{
2018-09-20 22:00:00 +02:00
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_A);
2017-10-25 21:57:28 +02:00
}
}
else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
{
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{
2018-02-06 02:46:59 +01:00
if (gActiveBattler == 1)
2017-10-25 21:57:28 +02:00
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
else
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B);
}
else
{
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
}
}
else if (gBattleTypeFlags & BATTLE_TYPE_EREADER_TRAINER)
{
trainerPicId = GetEreaderTrainerFrontSpriteId();
}
else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
2018-02-06 02:46:59 +01:00
if (gActiveBattler != 1)
2017-10-25 21:57:28 +02:00
trainerPicId = gTrainers[gTrainerBattleOpponent_B].trainerPic;
else
trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic;
}
else
{
trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic;
}
2018-02-06 02:46:59 +01:00
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 176, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, 0x1E);
2017-10-25 21:57:28 +02:00
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.x += 32;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
2017-10-25 21:57:28 +02:00
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
2017-10-25 21:57:28 +02:00
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleTrainerSlideBack(void)
2017-10-25 21:57:28 +02:00
{
2019-02-06 20:17:09 +01:00
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
2018-11-26 00:00:18 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
2018-02-06 20:48:02 +01:00
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = sub_805F240;
2017-10-25 21:57:28 +02:00
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleFaintAnimation(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
2017-10-25 21:57:28 +02:00
{
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
2017-10-25 21:57:28 +02:00
}
else
{
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
PlaySE12WithPanning(SE_POKE_DEAD, SOUND_PAN_TARGET);
2018-06-20 23:07:51 +02:00
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintOpponentMon;
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_805FAC4;
2017-10-25 21:57:28 +02:00
}
}
}
2017-10-26 23:12:48 +02:00
static void OpponentHandlePaletteFade(void)
2017-10-25 21:57:28 +02:00
{
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleSuccessBallThrowAnim(void)
2017-10-25 21:57:28 +02:00
{
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleBallThrow(void)
2017-10-25 21:57:28 +02:00
{
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentHandlePause(void)
2017-10-25 21:57:28 +02:00
{
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleMoveAnimation(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
if (!mplay_80342A4(gActiveBattler))
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
2017-10-25 21:57:28 +02:00
2018-02-06 02:46:59 +01:00
gAnimMoveTurn = gBattleBufferA[gActiveBattler][3];
gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8);
gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24);
gAnimFriendship = gBattleBufferA[gActiveBattler][10];
gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
2017-10-25 21:57:28 +02:00
if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE
{
OpponentBufferExecCompleted();
}
else
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = OpponentDoMoveAnimation;
2017-10-25 21:57:28 +02:00
}
}
}
2017-10-26 23:12:48 +02:00
static void OpponentDoMoveAnimation(void)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
u8 multihit = gBattleBufferA[gActiveBattler][11];
2017-10-25 21:57:28 +02:00
2018-02-06 02:46:59 +01:00
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
2017-10-25 21:57:28 +02:00
{
case 0:
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
2017-10-25 21:57:28 +02:00
{
2018-02-06 23:09:39 +01:00
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
2017-10-25 21:57:28 +02:00
}
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
2017-10-25 21:57:28 +02:00
break;
case 1:
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-25 21:57:28 +02:00
{
sub_805EB9C(ST_OAM_AFFINE_OFF);
2017-10-25 21:57:28 +02:00
DoMoveAnim(move);
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
2017-10-25 21:57:28 +02:00
}
break;
case 2:
gAnimScriptCallback();
if (!gAnimScriptActive)
{
sub_805EB9C(ST_OAM_AFFINE_NORMAL);
2018-02-06 23:09:39 +01:00
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
2017-10-25 21:57:28 +02:00
{
2018-02-06 02:46:59 +01:00
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
2018-02-06 23:09:39 +01:00
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
2017-10-25 21:57:28 +02:00
}
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
2017-10-25 21:57:28 +02:00
}
break;
case 3:
2018-02-06 02:46:59 +01:00
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
2017-10-25 21:57:28 +02:00
{
2017-11-04 16:11:13 +01:00
CopyAllBattleSpritesInvisibilities();
2018-02-06 02:46:59 +01:00
TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
break;
}
}
2017-10-26 23:12:48 +02:00
static void OpponentHandlePrintString(void)
2017-10-25 21:57:28 +02:00
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
2018-02-06 02:46:59 +01:00
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
2017-10-25 21:57:28 +02:00
BufferStringBattle(*stringId);
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gDisplayedStringBattle, 0);
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
2018-11-11 18:33:16 +01:00
BattleArena_DeductMindPoints(gActiveBattler, *stringId);
2017-10-25 21:57:28 +02:00
}
static void OpponentHandlePrintSelectionString(void)
2017-10-25 21:57:28 +02:00
{
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleChooseAction(void)
2017-10-25 21:57:28 +02:00
{
AI_TrySwitchOrUseItem();
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleUnknownYesNoBox(void)
2017-10-25 21:57:28 +02:00
{
OpponentBufferExecCompleted();
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleChooseMove(void)
2017-10-25 21:57:28 +02:00
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
2018-02-06 20:48:02 +01:00
BtlController_EmitTwoReturnValues(1, 10, ChooseMoveAndTargetInBattlePalace());
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
else
{
u8 chosenMoveId;
2018-02-06 02:46:59 +01:00
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]);
2017-10-25 21:57:28 +02:00
if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER))
{
BattleAI_SetupAIData(0xF);
chosenMoveId = BattleAI_ChooseMoveOrAction();
switch (chosenMoveId)
{
case AI_CHOICE_WATCH:
2018-02-06 23:09:39 +01:00
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_WATCH_CAREFULLY, 0);
2017-10-25 21:57:28 +02:00
break;
case AI_CHOICE_FLEE:
2018-02-06 23:09:39 +01:00
BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0);
2017-10-25 21:57:28 +02:00
break;
case 6:
2018-02-06 23:09:39 +01:00
BtlController_EmitTwoReturnValues(1, 15, gBattlerTarget);
2017-10-25 21:57:28 +02:00
break;
default:
2018-02-26 13:24:46 +01:00
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
2018-02-06 23:09:39 +01:00
gBattlerTarget = gActiveBattler;
2017-10-25 21:57:28 +02:00
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
{
2018-02-06 23:09:39 +01:00
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
2017-10-25 21:57:28 +02:00
}
2018-02-06 23:09:39 +01:00
BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBattlerTarget << 8));
2017-10-25 21:57:28 +02:00
break;
}
OpponentBufferExecCompleted();
}
else
{
u16 move;
do
{
chosenMoveId = Random() & 3;
move = moveInfo->moves[chosenMoveId];
} while (move == MOVE_NONE);
2018-02-26 13:24:46 +01:00
if (gBattleMoves[move].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
2018-02-06 20:48:02 +01:00
BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gActiveBattler << 8));
2017-10-25 21:57:28 +02:00
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
2018-02-06 20:48:02 +01:00
BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8));
2017-10-25 21:57:28 +02:00
else
2018-02-06 20:48:02 +01:00
BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));
2017-10-25 21:57:28 +02:00
OpponentBufferExecCompleted();
}
}
}
2017-10-26 23:12:48 +02:00
static void OpponentHandleChooseItem(void)
{
2018-02-06 20:48:02 +01:00
BtlController_EmitOneReturnValue(1, *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2));
2017-10-26 23:12:48 +02:00
OpponentBufferExecCompleted();
}
static void OpponentHandleChoosePokemon(void)
{
s32 chosenMonId;
2018-08-25 21:04:12 +02:00
if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == PARTY_SIZE)
2017-10-26 23:12:48 +02:00
{
chosenMonId = GetMostSuitableMonToSwitchInto();
2018-08-25 21:04:12 +02:00
if (chosenMonId == PARTY_SIZE)
2017-10-26 23:12:48 +02:00
{
2018-08-25 21:04:12 +02:00
s32 battler1, battler2, firstId, lastId;
2017-10-26 23:12:48 +02:00
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
{
2018-08-25 21:04:12 +02:00
battler2 = battler1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
2017-10-26 23:12:48 +02:00
}
else
{
2018-08-25 21:04:12 +02:00
battler1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
battler2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
2017-10-26 23:12:48 +02:00
}
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{
2018-02-06 02:46:59 +01:00
if (gActiveBattler == 1)
2017-10-26 23:12:48 +02:00
firstId = 0, lastId = 3;
else
firstId = 3, lastId = 6;
}
else
{
firstId = 0, lastId = 6;
}
for (chosenMonId = firstId; chosenMonId < lastId; chosenMonId++)
{
if (GetMonData(&gEnemyParty[chosenMonId], MON_DATA_HP) != 0
2018-08-25 21:04:12 +02:00
&& chosenMonId != gBattlerPartyIndexes[battler1]
&& chosenMonId != gBattlerPartyIndexes[battler2])
2017-10-26 23:12:48 +02:00
{
break;
}
}
}
}
else
{
2018-02-06 02:46:59 +01:00
chosenMonId = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler);
2018-08-25 21:04:12 +02:00
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
2017-10-26 23:12:48 +02:00
}
2018-02-06 02:46:59 +01:00
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId;
2018-02-06 20:48:02 +01:00
BtlController_EmitChosenMonReturnValue(1, chosenMonId, NULL);
2017-10-26 23:12:48 +02:00
OpponentBufferExecCompleted();
}
static void OpponentHandleCmd23(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleHealthBarUpdate(void)
{
s16 hpVal;
LoadBattleBarGfx(0);
2018-02-06 02:46:59 +01:00
hpVal = (gBattleBufferA[gActiveBattler][3] << 8) | gBattleBufferA[gActiveBattler][2];
2017-10-26 23:12:48 +02:00
if (hpVal != INSTANT_HP_BAR_DROP)
{
2018-02-06 20:48:02 +01:00
u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
2017-10-26 23:12:48 +02:00
2018-02-06 20:48:02 +01:00
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
2017-10-26 23:12:48 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
2017-10-26 23:12:48 +02:00
2018-02-06 20:48:02 +01:00
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
2017-10-26 23:12:48 +02:00
}
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
2017-10-26 23:12:48 +02:00
}
static void OpponentHandleExpUpdate(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleStatusIconUpdate(void)
{
2018-02-06 02:46:59 +01:00
if (!mplay_80342A4(gActiveBattler))
2017-10-26 23:12:48 +02:00
{
2018-03-01 00:59:52 +01:00
u8 battlerId;
2017-10-26 23:12:48 +02:00
2018-02-06 20:48:02 +01:00
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
2018-03-01 00:59:52 +01:00
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
2017-10-26 23:12:48 +02:00
}
}
static void OpponentHandleStatusAnimation(void)
{
2018-02-06 02:46:59 +01:00
if (!mplay_80342A4(gActiveBattler))
2017-10-26 23:12:48 +02:00
{
2018-02-06 02:46:59 +01:00
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
2017-10-26 23:12:48 +02:00
}
}
static void OpponentHandleStatusXor(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleDataTransfer(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleDMA3Transfer(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandlePlayBGM(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleCmd32(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleTwoReturnValues(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleChosenMonReturnValue(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleOneReturnValue(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleOneReturnValue_Duplicate(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleCmd37(void)
{
gUnknown_02022D0C.field_0 = 0;
OpponentBufferExecCompleted();
}
static void OpponentHandleCmd38(void)
{
2018-02-06 02:46:59 +01:00
gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1];
2017-10-26 23:12:48 +02:00
OpponentBufferExecCompleted();
}
static void OpponentHandleCmd39(void)
{
gUnknown_02022D0C.flag_x80 = 0;
OpponentBufferExecCompleted();
}
static void OpponentHandleCmd40(void)
{
gUnknown_02022D0C.flag_x80 ^= 1;
OpponentBufferExecCompleted();
}
static void OpponentHandleHitAnimation(void)
{
2018-02-06 20:48:02 +01:00
if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
2017-10-26 23:12:48 +02:00
{
OpponentBufferExecCompleted();
}
else
{
gDoingBattleAnim = TRUE;
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
2018-02-06 02:46:59 +01:00
DoHitAnimHealthboxEffect(gActiveBattler);
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
2017-10-26 23:12:48 +02:00
}
}
static void OpponentHandleCmd42(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandlePlaySE(void)
2017-10-26 23:12:48 +02:00
{
s8 pan;
2018-02-06 02:46:59 +01:00
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
pan = SOUND_PAN_ATTACKER;
2017-10-26 23:12:48 +02:00
else
pan = SOUND_PAN_TARGET;
2017-10-26 23:12:48 +02:00
2018-02-06 02:46:59 +01:00
PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan);
2017-10-26 23:12:48 +02:00
OpponentBufferExecCompleted();
}
static void OpponentHandlePlayFanfareOrBGM(void)
{
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][3])
2017-10-26 23:12:48 +02:00
{
2017-11-04 16:11:13 +01:00
BattleStopLowHpSound();
2018-02-06 02:46:59 +01:00
PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8));
2017-10-26 23:12:48 +02:00
}
else
{
2018-02-06 02:46:59 +01:00
PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8));
2017-10-26 23:12:48 +02:00
}
OpponentBufferExecCompleted();
}
static void OpponentHandleFaintingCry(void)
{
2018-02-06 20:48:02 +01:00
u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
2017-10-26 23:12:48 +02:00
PlayCry3(species, 25, 5);
OpponentBufferExecCompleted();
}
static void OpponentHandleIntroSlide(void)
{
2018-02-06 02:46:59 +01:00
HandleIntroSlide(gBattleBufferA[gActiveBattler][1]);
2018-02-08 11:17:41 +01:00
gIntroSlideFlags |= 1;
2017-10-26 23:12:48 +02:00
OpponentBufferExecCompleted();
}
static void OpponentHandleIntroTrainerBallThrow(void)
{
u8 paletteNum;
u8 taskId;
2019-02-06 20:17:09 +01:00
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
2017-10-26 23:12:48 +02:00
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
2018-11-26 00:00:18 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
2017-10-26 23:12:48 +02:00
2018-02-06 20:48:02 +01:00
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_806280C);
2017-10-26 23:12:48 +02:00
taskId = CreateTask(sub_8062828, 5);
2018-02-06 02:46:59 +01:00
gTasks[taskId].data[0] = gActiveBattler;
2017-10-26 23:12:48 +02:00
2018-06-28 21:06:32 +02:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
2017-10-26 23:12:48 +02:00
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = nullsub_26;
2017-10-26 23:12:48 +02:00
}
static void sub_806280C(struct Sprite *sprite)
{
FreeTrainerFrontPicPalette(sprite->oam.affineParam);
FreeSpriteOamMatrix(sprite);
DestroySprite(sprite);
}
static void sub_8062828(u8 taskId)
{
2018-02-06 02:46:59 +01:00
u8 savedActiveBank = gActiveBattler;
2017-10-26 23:12:48 +02:00
2018-02-06 02:46:59 +01:00
gActiveBattler = gTasks[taskId].data[0];
2017-10-26 23:12:48 +02:00
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
2018-02-06 20:48:02 +01:00
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
2018-02-06 02:46:59 +01:00
sub_80613DC(gActiveBattler, FALSE);
2017-10-26 23:12:48 +02:00
}
else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))
{
2018-02-06 20:48:02 +01:00
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
2018-02-06 02:46:59 +01:00
sub_80613DC(gActiveBattler, FALSE);
2017-10-26 23:12:48 +02:00
}
else
{
2018-02-06 20:48:02 +01:00
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
2018-02-06 02:46:59 +01:00
sub_80613DC(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
2018-02-06 20:48:02 +01:00
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
2018-02-06 02:46:59 +01:00
sub_80613DC(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
2017-10-26 23:12:48 +02:00
}
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_805F560;
2018-02-06 02:46:59 +01:00
gActiveBattler = savedActiveBank;
2017-10-26 23:12:48 +02:00
DestroyTask(taskId);
}
static void OpponentHandleDrawPartyStatusSummary(void)
{
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
2017-10-26 23:12:48 +02:00
{
OpponentBufferExecCompleted();
}
else
{
2018-06-28 21:06:32 +02:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
2017-10-26 23:12:48 +02:00
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][2] != 0)
2017-10-26 23:12:48 +02:00
{
2018-02-06 02:46:59 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E < 2)
2017-10-26 23:12:48 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E++;
2017-10-26 23:12:48 +02:00
return;
}
else
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E = 0;
2017-10-26 23:12:48 +02:00
}
}
2018-02-08 11:17:41 +01:00
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]);
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0;
2017-10-26 23:12:48 +02:00
2018-02-06 02:46:59 +01:00
if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D;
2017-10-26 23:12:48 +02:00
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = sub_8062A2C;
2017-10-26 23:12:48 +02:00
}
}
static void sub_8062A2C(void)
{
2018-02-06 02:46:59 +01:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C)
2017-10-26 23:12:48 +02:00
{
2018-02-06 02:46:59 +01:00
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0;
2017-10-26 23:12:48 +02:00
OpponentBufferExecCompleted();
}
}
2018-06-28 21:06:32 +02:00
static void OpponentHandleHidePartyStatusSummary(void)
2017-10-26 23:12:48 +02:00
{
2018-06-28 21:06:32 +02:00
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
2017-10-26 23:12:48 +02:00
OpponentBufferExecCompleted();
}
2018-06-20 23:07:51 +02:00
static void OpponentHandleEndBounceEffect(void)
2017-10-26 23:12:48 +02:00
{
OpponentBufferExecCompleted();
}
static void OpponentHandleSpriteInvisibility(void)
{
2018-02-06 20:48:02 +01:00
if (IsBattlerSpritePresent(gActiveBattler))
2017-10-26 23:12:48 +02:00
{
2018-02-06 20:48:02 +01:00
gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1];
2018-02-06 02:46:59 +01:00
CopyBattleSpriteInvisibility(gActiveBattler);
2017-10-26 23:12:48 +02:00
}
OpponentBufferExecCompleted();
}
static void OpponentHandleBattleAnimation(void)
{
2018-02-06 02:46:59 +01:00
if (!mplay_80342A4(gActiveBattler))
2017-10-26 23:12:48 +02:00
{
2018-02-06 02:46:59 +01:00
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
2017-10-26 23:12:48 +02:00
2018-02-06 02:46:59 +01:00
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
2017-10-26 23:12:48 +02:00
OpponentBufferExecCompleted();
else
2018-02-06 20:48:02 +01:00
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
2017-10-26 23:12:48 +02:00
}
}
static void OpponentHandleLinkStandbyMsg(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleResetActionMoveSelection(void)
{
OpponentBufferExecCompleted();
}
static void OpponentHandleCmd55(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_LINK && !(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
2017-10-26 23:12:48 +02:00
{
gMain.inBattle = 0;
gMain.callback1 = gPreBattleCallback1;
SetMainCallback2(gMain.savedCallback);
}
OpponentBufferExecCompleted();
}
static void OpponentCmdEnd(void)
2017-10-26 23:12:48 +02:00
{
}