From 770a57bec7b86b0a32fa103fae12f9bd589fe0a4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 30 Dec 2019 13:14:20 +0100 Subject: [PATCH] Fix some moves hitting the user --- src/battle_util.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index cdc645cbe..f03d53d27 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4652,14 +4652,23 @@ void HandleAction_RunBattleScript(void) // identical to RunBattleScriptCommands u32 SetRandomTarget(u32 battlerId) { + u32 target; static const u8 targets[2][2] = { [B_SIDE_PLAYER] = {B_POSITION_OPPONENT_LEFT, B_POSITION_OPPONENT_RIGHT}, [B_SIDE_OPPONENT] = {B_POSITION_PLAYER_LEFT, B_POSITION_PLAYER_RIGHT}, }; - u32 target = GetBattlerAtPosition(targets[GetBattlerSide(battlerId)][Random() % 2]); - if (!IsBattlerAlive(target)) - target ^= BIT_FLANK; + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + target = GetBattlerAtPosition(targets[GetBattlerSide(battlerId)][Random() % 2]); + if (!IsBattlerAlive(target)) + target ^= BIT_FLANK; + } + else + { + target = GetBattlerAtPosition(targets[GetBattlerSide(battlerId)][0]); + } return target; }