diff --git a/include/battle_ai_util.h b/include/battle_ai_util.h index fd55a99f7..5f077fe0c 100644 --- a/include/battle_ai_util.h +++ b/include/battle_ai_util.h @@ -9,6 +9,7 @@ bool32 AI_RandLessThan(u8 val); void RecordLastUsedMoveByTarget(void); +bool32 IsAiVsAiBattle(void); bool32 BattlerHasAi(u32 battlerId); bool32 IsAiBattlerAware(u32 battlerId); void ClearBattlerMoveHistory(u8 battlerId); diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index d815d3f8b..67f3e2dd8 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -1001,6 +1001,9 @@ static bool8 ShouldUseItem(void) u8 validMons = 0; bool8 shouldUse = FALSE; + if (IsAiVsAiBattle()) + return FALSE; + // If teaming up with player and Pokemon is on the right, or Pokemon is currently held by Sky Drop if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT) || gStatuses3[gActiveBattler] & STATUS3_SKY_DROPPED) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index b27501c19..6d7b74b3b 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -441,19 +441,24 @@ void RecordLastUsedMoveByTarget(void) RecordKnownMove(gBattlerTarget, gLastMoves[gBattlerTarget]); } +bool32 IsAiVsAiBattle(void) +{ + return (B_FLAG_AI_VS_AI_BATTLE && FlagGet(B_FLAG_AI_VS_AI_BATTLE)); +} + bool32 BattlerHasAi(u32 battlerId) { switch (GetBattlerPosition(battlerId)) { case B_POSITION_PLAYER_LEFT: - if (FlagGet(B_FLAG_AI_VS_AI_BATTLE)) + if (IsAiVsAiBattle()) return TRUE; default: return FALSE; case B_POSITION_OPPONENT_LEFT: return TRUE; case B_POSITION_PLAYER_RIGHT: - if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || FlagGet(B_FLAG_AI_VS_AI_BATTLE)) + if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || IsAiVsAiBattle()) return TRUE; else return FALSE; diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 996ac15a5..67e475e51 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -11,7 +11,6 @@ #include "battle_z_move.h" #include "bg.h" #include "data.h" -#include "event_data.h" #include "item_use.h" #include "link.h" #include "main.h" @@ -1317,7 +1316,7 @@ static void PlayerPartnerHandleDrawTrainerPic(void) xPos = 90; yPos = (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80; } - else if (FlagGet(B_FLAG_AI_VS_AI_BATTLE)) + else if (IsAiVsAiBattle()) { trainerPicId = gTrainers[gPartnerTrainerId].trainerPic; xPos = 60; @@ -1830,7 +1829,7 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void) u8 spriteId = gPartnerSpriteId; LoadCompressedPalette(gTrainerBackPicPaletteTable[spriteId].data, 0x100 + paletteNum * 16, 32); } - else if (FlagGet(B_FLAG_AI_VS_AI_BATTLE)) + else if (IsAiVsAiBattle()) { u8 spriteId = gTrainers[gPartnerTrainerId].trainerPic; LoadCompressedPalette(gTrainerFrontPicPaletteTable[spriteId].data, OBJ_PLTT_ID(paletteNum), PLTT_SIZE_4BPP); diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 8888249f2..397dda6d8 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -1,12 +1,12 @@ #include "global.h" #include "battle.h" #include "battle_ai_main.h" +#include "battle_ai_util.h" #include "battle_anim.h" #include "battle_controllers.h" #include "battle_message.h" #include "battle_setup.h" #include "cable_club.h" -#include "event_data.h" #include "link.h" #include "link_rfu.h" #include "party_menu.h" @@ -171,7 +171,7 @@ static void InitSinglePlayerBtlControllers(void) gBattlerControllerFuncs[0] = SetControllerToSafari; else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) gBattlerControllerFuncs[0] = SetControllerToWally; - else if (FlagGet(B_FLAG_AI_VS_AI_BATTLE)) + else if (IsAiVsAiBattle()) gBattlerControllerFuncs[0] = SetControllerToPlayerPartner; else gBattlerControllerFuncs[0] = SetControllerToPlayer; @@ -224,7 +224,7 @@ static void InitSinglePlayerBtlControllers(void) { gBattleMainFunc = BeginBattleIntro; - if (FlagGet(B_FLAG_AI_VS_AI_BATTLE)) + if (IsAiVsAiBattle()) gBattlerControllerFuncs[0] = SetControllerToPlayerPartner; else gBattlerControllerFuncs[0] = SetControllerToPlayer; @@ -233,7 +233,7 @@ static void InitSinglePlayerBtlControllers(void) gBattlerControllerFuncs[1] = SetControllerToOpponent; gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - if (FlagGet(B_FLAG_AI_VS_AI_BATTLE)) + if (IsAiVsAiBattle()) gBattlerControllerFuncs[2] = SetControllerToPlayerPartner; else gBattlerControllerFuncs[2] = SetControllerToPlayer;