Fix some moves hitting the user

This commit is contained in:
DizzyEggg 2019-12-30 13:14:20 +01:00
parent 77842b0376
commit 770a57bec7

View File

@ -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;
}