Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted most battle preproc ifs to regular ifs #3392

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
#define ABILITYEFFECT_TRACE2 10
#define ABILITYEFFECT_MOVE_END_OTHER 11
#define ABILITYEFFECT_NEUTRALIZINGGAS 12
#define ABILITYEFFECT_FIELD_SPORT 13 // Only used if B_SPORT_TURNS < GEN_6
#define ABILITYEFFECT_FIELD_SPORT 13 // Only used if B_SPORT_TURNS >= GEN_6
#define ABILITYEFFECT_ON_WEATHER 14
#define ABILITYEFFECT_ON_TERRAIN 15
#define ABILITYEFFECT_SWITCH_IN_TERRAIN 16
#define ABILITYEFFECT_SWITCH_IN_WEATHER 17
// Special cases
#define ABILITYEFFECT_MUD_SPORT 252 // Only used if B_SPORT_TURNS < GEN_6
#define ABILITYEFFECT_WATER_SPORT 253 // Only used if B_SPORT_TURNS < GEN_6
#define ABILITYEFFECT_MUD_SPORT 252 // Only used if B_SPORT_TURNS >= GEN_6
#define ABILITYEFFECT_WATER_SPORT 253 // Only used if B_SPORT_TURNS >= GEN_6

// For the first argument of ItemBattleEffects, to deteremine which block of item effects to try
#define ITEMEFFECT_ON_SWITCH_IN 0
Expand Down
6 changes: 3 additions & 3 deletions include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define B_RECALCULATE_STATS GEN_LATEST // In Gen5+, the stats of the Pokémon who participate in battle are recalculated at the end of each battle.

// Damage settings
#define B_BURN_DAMAGE GEN_LATEST // In Gen7+, burn damage is 1/16th of max HP instead of 1/8th.
#define B_BURN_DAMAGE GEN_LATEST // In Gen7+, burn damage is 1/16th of max HP instead of 1/8th. Also applies to Frostbite.
#define B_BURN_FACADE_DMG GEN_LATEST // In Gen6+, burn's effect of lowering the Attack stat no longer applies to Facade.
#define B_BINDING_DAMAGE GEN_LATEST // In Gen6+, binding damage is 1/8 of max HP instead of 1/16. (With Binding Band, 1/6 and 1/8 respectively.)
#define B_PSYWAVE_DMG GEN_LATEST // Psywave's damage formula. See Cmd_psywavedamageeffect.
Expand Down Expand Up @@ -128,14 +128,14 @@
#define B_SNOW_WARNING GEN_LATEST // In Gen9+, Snow Warning will summon snow instead of hail.

// Item settings
#define B_HP_BERRIES GEN_LATEST // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn.
#define B_HP_BERRIES GEN_LATEST // In Gen4+, berries which restore HP activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn.
#define B_BERRIES_INSTANT GEN_LATEST // In Gen4+, most berries activate on battle start/switch-in if applicable. In Gen3, they only activate either at the move end or turn end.
#define B_CONFUSE_BERRIES_HEAL GEN_LATEST // Before Gen7, Figy and similar berries restore 1/8th of HP and trigger at half HP. In Gen7 they restore half HP, triggering at 25% HP. In Gen8 they heal 1/3rd of HP.
#define B_X_ITEMS_BUFF GEN_LATEST // In Gen7+, the X Items raise a stat by 2 stages instead of 1.
#define B_MENTAL_HERB GEN_LATEST // In Gen5+, the Mental Herb cures Taunt, Encore, Torment, Heal Block, and Disable in addition to Infatuation from before.
#define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items.
#define B_RESTORE_HELD_BATTLE_ITEMS TRUE // In Gen9 all non berry items are restored after battle.
#define B_SOUL_DEW_BOOST GEN_LATEST // In Gens3-6, Soul Dew boosts Lati@s' Sp. Atk and Sp. Def. In Gen7+ it boosts the power of their Psychic and Dragon type moves instead.
#define B_SOUL_DEW_BOOST GEN_LATEST // In Gens3-6, Soul Dew boosts Latis' Sp. Atk and Sp. Def. In Gen7+ it boosts the power of their Psychic and Dragon type moves instead.
#define B_NET_BALL_MODIFIER GEN_LATEST // In Gen7+, Net Ball's catch multiplier is x5 instead of x3.
#define B_DIVE_BALL_MODIFIER GEN_LATEST // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing.
#define B_NEST_BALL_MODIFIER GEN_LATEST // Nest Ball's formula varies depending on the Gen. See Cmd_handleballthrow.
Expand Down
48 changes: 14 additions & 34 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,11 +938,10 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
} // ignore def ability check

// gen7+ dark type mons immune to priority->elevated moves from prankster
#if B_PRANKSTER_DARK_TYPES >= GEN_7
if (aiData->abilities[battlerAtk] == ABILITY_PRANKSTER && IS_BATTLER_OF_TYPE(battlerDef, TYPE_DARK) && IS_MOVE_STATUS(move)
if (B_PRANKSTER_DARK_TYPES >= GEN_7 && IS_BATTLER_OF_TYPE(battlerDef, TYPE_DARK)
&& aiData->abilities[battlerAtk] == ABILITY_PRANKSTER && IS_MOVE_STATUS(move)
&& !(moveTarget & (MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_USER)))
RETURN_SCORE_MINUS(10);
#endif

// terrain & effect checks
if (AI_IsTerrainAffected(battlerDef, STATUS_FIELD_ELECTRIC_TERRAIN))
Expand Down Expand Up @@ -1126,10 +1125,9 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
ADJUST_SCORE(-20);
else if (!HasMoveWithType(battlerAtk, TYPE_ELECTRIC))
ADJUST_SCORE(-10);
#if B_CHARGE_SPDEF_RAISE >= GEN_5
else if (!BattlerStatCanRise(battlerAtk, aiData->abilities[battlerAtk], STAT_SPDEF))
else if (B_CHARGE_SPDEF_RAISE >= GEN_5
&& !BattlerStatCanRise(battlerAtk, aiData->abilities[battlerAtk], STAT_SPDEF))
ADJUST_SCORE(-5);
#endif
break;
case EFFECT_QUIVER_DANCE:
case EFFECT_GEOMANCY:
Expand Down Expand Up @@ -1416,10 +1414,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
ADJUST_SCORE(-10);
break;
case EFFECT_OHKO:
#if B_SHEER_COLD_IMMUNITY >= GEN_7
if (move == MOVE_SHEER_COLD && IS_BATTLER_OF_TYPE(battlerDef, TYPE_ICE))
if (B_SHEER_COLD_IMMUNITY >= GEN_7 && move == MOVE_SHEER_COLD && IS_BATTLER_OF_TYPE(battlerDef, TYPE_ICE))
return 0;
#endif
if (!ShouldTryOHKO(battlerAtk, battlerDef, aiData->abilities[battlerAtk], aiData->abilities[battlerDef], move))
ADJUST_SCORE(-10);
break;
Expand Down Expand Up @@ -1447,10 +1443,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
ADJUST_SCORE(-8);
else if (aiData->hpPercents[battlerAtk] <= 25)
ADJUST_SCORE(-10);
#if B_SOUND_SUBSTITUTE >= GEN_6
else if (HasSoundMove(battlerDef))
else if (B_SOUND_SUBSTITUTE >= GEN_6 && HasSoundMove(battlerDef))
ADJUST_SCORE(-8);
#endif
break;
case EFFECT_LEECH_SEED:
if (gStatuses3[battlerDef] & STATUS3_LEECHSEED
Expand All @@ -1462,9 +1456,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
break;
case EFFECT_DISABLE:
if (gDisableStructs[battlerDef].disableTimer == 0
#if B_MENTAL_HERB >= GEN_5
&& aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB
#endif
&& (B_MENTAL_HERB < GEN_5 || aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB)
&& !PartnerHasSameMoveEffectWithoutTarget(BATTLE_PARTNER(battlerAtk), move, aiData->partnerMove))
{
if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER) // Attacker should go first
Expand All @@ -1484,9 +1476,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
break;
case EFFECT_ENCORE:
if (gDisableStructs[battlerDef].encoreTimer == 0
#if B_MENTAL_HERB >= GEN_5
&& aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB
#endif
&& (B_MENTAL_HERB < GEN_5 || aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB)
&& !DoesPartnerHaveSameMoveEffect(BATTLE_PARTNER(battlerAtk), battlerDef, move, aiData->partnerMove))
{
if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER) // Attacker should go first
Expand Down Expand Up @@ -1715,10 +1705,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
ADJUST_SCORE(-10);
break;
}
#if B_MENTAL_HERB >= GEN_5
if (aiData->holdEffects[battlerDef] == HOLD_EFFECT_MENTAL_HERB)
if (B_MENTAL_HERB >= GEN_5 && aiData->holdEffects[battlerDef] == HOLD_EFFECT_MENTAL_HERB)
ADJUST_SCORE(-6);
#endif
break;
case EFFECT_WILL_O_WISP:
if (!AI_CanBurn(battlerAtk, battlerDef, aiData->abilities[battlerDef], BATTLE_PARTNER(battlerAtk), move, aiData->partnerMove))
Expand Down Expand Up @@ -3829,10 +3817,7 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
break;
case EFFECT_DISABLE:
if (gDisableStructs[battlerDef].disableTimer == 0
#if B_MENTAL_HERB >= GEN_5
&& aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB // mental herb
#endif
)
&& (B_MENTAL_HERB < GEN_5 || aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB))
{
if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER) // AI goes first
{
Expand All @@ -3853,10 +3838,7 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
break;
case EFFECT_ENCORE:
if (gDisableStructs[battlerDef].encoreTimer == 0
#if B_MENTAL_HERB >= GEN_5
&& aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB // mental herb
#endif
)
&& (B_MENTAL_HERB < GEN_5 || aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB))
{
if (IsEncoreEncouragedEffect(gBattleMoves[gLastMoves[battlerDef]].effect))
ADJUST_SCORE(3);
Expand Down Expand Up @@ -3905,9 +3887,8 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
{
bool32 canSteal = FALSE;

#if B_TRAINERS_KNOCK_OFF_ITEMS == TRUE
if (B_TRAINERS_KNOCK_OFF_ITEMS == TRUE)
canSteal = TRUE;
#endif
if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER || GetBattlerSide(battlerAtk) == B_SIDE_PLAYER)
canSteal = TRUE;

Expand Down Expand Up @@ -4363,9 +4344,8 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
case EFFECT_CHARGE:
if (HasDamagingMoveOfType(battlerAtk, TYPE_ELECTRIC))
ADJUST_SCORE(2);
#if B_CHARGE_SPDEF_RAISE >= GEN_5
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPDEF, &score);
#endif
if (B_CHARGE_SPDEF_RAISE >= GEN_5)
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPDEF, &score);
break;
case EFFECT_TAUNT:
if (IS_MOVE_STATUS(predictedMove))
Expand Down
51 changes: 14 additions & 37 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,8 @@ bool32 IsBattlerTrapped(u32 battler, bool32 checkSwitch)
{
u32 holdEffect = AI_DATA->holdEffects[battler];

#if B_GHOSTS_ESCAPE >= GEN_6
if (IS_BATTLER_OF_TYPE(battler, TYPE_GHOST))
if (B_GHOSTS_ESCAPE >= GEN_6 && IS_BATTLER_OF_TYPE(battler, TYPE_GHOST))
return FALSE;
#endif
if (checkSwitch && holdEffect == HOLD_EFFECT_SHED_SHELL)
return FALSE;
else if (!checkSwitch && GetBattlerAbility(battler) == ABILITY_RUN_AWAY)
Expand Down Expand Up @@ -702,9 +700,7 @@ bool32 IsTruantMonVulnerable(u32 battlerAI, u32 opposingBattler)
bool32 IsAffectedByPowder(u32 battler, u32 ability, u32 holdEffect)
{
if (ability == ABILITY_OVERCOAT
#if B_POWDER_GRASS >= GEN_6
|| IS_BATTLER_OF_TYPE(battler, TYPE_GRASS)
#endif
|| (B_POWDER_GRASS >= GEN_6 && IS_BATTLER_OF_TYPE(battler, TYPE_GRASS))
|| holdEffect == HOLD_EFFECT_SAFETY_GOGGLES)
return FALSE;
return TRUE;
Expand Down Expand Up @@ -846,8 +842,8 @@ s32 AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u8 *typeEffectivenes
case EFFECT_FINAL_GAMBIT:
dmg = gBattleMons[battlerAtk].hp;
break;
#if B_BEAT_UP >= GEN_5
case EFFECT_BEAT_UP:
if (B_BEAT_UP >= GEN_5)
{
u32 partyCount = CalculatePartyCount(GetBattlerParty(battlerAtk));
u32 i;
Expand All @@ -859,7 +855,6 @@ s32 AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u8 *typeEffectivenes
gBattleStruct->beatUpSlot = 0;
}
break;
#endif
}

// Handle other multi-strike moves
Expand Down Expand Up @@ -1672,10 +1667,8 @@ bool32 IsMoveEncouragedToHit(u32 battlerAtk, u32 battlerDef, u32 move)
if (AI_DATA->abilities[battlerDef] == ABILITY_NO_GUARD || AI_DATA->abilities[battlerAtk] == ABILITY_NO_GUARD)
return TRUE;

#if B_TOXIC_NEVER_MISS >= GEN_6
if (gBattleMoves[move].effect == EFFECT_TOXIC && IS_BATTLER_OF_TYPE(battlerAtk, TYPE_POISON))
if (B_TOXIC_NEVER_MISS >= GEN_6 && gBattleMoves[move].effect == EFFECT_TOXIC && IS_BATTLER_OF_TYPE(battlerAtk, TYPE_POISON))
return TRUE;
#endif

// discouraged from hitting
weather = AI_GetWeather(AI_DATA);
Expand All @@ -1687,9 +1680,7 @@ bool32 IsMoveEncouragedToHit(u32 battlerAtk, u32 battlerDef, u32 move)
if ((((weather & B_WEATHER_RAIN) && (gBattleMoves[move].effect == EFFECT_THUNDER || gBattleMoves[move].effect == EFFECT_HURRICANE))
|| (((weather & (B_WEATHER_HAIL | B_WEATHER_SNOW)) && move == MOVE_BLIZZARD)))
|| (gBattleMoves[move].effect == EFFECT_VITAL_THROW)
#if B_MINIMIZE_DMG_ACC >= GEN_6
|| ((gStatuses3[battlerDef] & STATUS3_MINIMIZED) && gBattleMoves[move].minimizeDoubleDamage)
#endif
|| (B_MINIMIZE_DMG_ACC >= GEN_6 && (gStatuses3[battlerDef] & STATUS3_MINIMIZED) && gBattleMoves[move].minimizeDoubleDamage)
|| (gBattleMoves[move].accuracy == 0))
{
return TRUE;
Expand Down Expand Up @@ -1722,10 +1713,8 @@ bool32 ShouldTryOHKO(u32 battlerAtk, u32 battlerDef, u32 atkAbility, u32 defAbil
else // test the odds
{
u32 odds = accuracy + (gBattleMons[battlerAtk].level - gBattleMons[battlerDef].level);
#if B_SHEER_COLD_ACC >= GEN_7
if (move == MOVE_SHEER_COLD && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE))
if (B_SHEER_COLD_ACC >= GEN_7 && move == MOVE_SHEER_COLD && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE))
odds -= 10;
#endif
if (Random() % 100 + 1 < odds && gBattleMons[battlerAtk].level >= gBattleMons[battlerDef].level)
return TRUE;
}
Expand Down Expand Up @@ -2340,9 +2329,6 @@ bool32 IsStatRaisingEffect(u32 effect)
case EFFECT_EVASION_UP_2:
case EFFECT_MINIMIZE:
case EFFECT_DEFENSE_CURL:
#if B_CHARGE_SPDEF_RAISE >= GEN_5
case EFFECT_CHARGE:
#endif
case EFFECT_CALM_MIND:
case EFFECT_COSMIC_POWER:
case EFFECT_DRAGON_DANCE:
Expand All @@ -2359,6 +2345,8 @@ bool32 IsStatRaisingEffect(u32 effect)
case EFFECT_STOCKPILE:
case EFFECT_VICTORY_DANCE:
return TRUE;
case EFFECT_CHARGE:
return B_CHARGE_SPDEF_RAISE >= GEN_5;
default:
return FALSE;
}
Expand Down Expand Up @@ -2520,15 +2508,10 @@ static u32 GetTrapDamage(u32 battlerId)
if (gBattleMons[battlerId].status2 & STATUS2_WRAPPED)
{
if (holdEffect == HOLD_EFFECT_BINDING_BAND)
#if B_BINDING_DAMAGE >= GEN_6
damage = gBattleMons[battlerId].maxHP / 6;
else
damage = gBattleMons[battlerId].maxHP / 8;
#else
damage = gBattleMons[battlerId].maxHP / 8;
damage = gBattleMons[battlerId].maxHP / (B_BINDING_DAMAGE >= GEN_6 ? 6 : 8);
else
damage = gBattleMons[battlerId].maxHP / 16;
#endif
damage = gBattleMons[battlerId].maxHP / (B_BINDING_DAMAGE >= GEN_6 ? 8 : 16);

if (damage == 0)
damage = 1;
}
Expand Down Expand Up @@ -2768,19 +2751,15 @@ bool32 ShouldPivot(u32 battlerAtk, u32 battlerDef, u32 defAbility, u32 move, u32

if (!IS_MOVE_STATUS(move) && (shouldSwitch
|| (AtMaxHp(battlerDef) && (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH
#if B_STURDY >= GEN_5
|| defAbility == ABILITY_STURDY
#endif
|| (B_STURDY >= GEN_5 && defAbility == ABILITY_STURDY)
|| defAbility == ABILITY_MULTISCALE
|| defAbility == ABILITY_SHADOW_SHIELD))))
return PIVOT; // pivot to break sash/sturdy/multiscale
}
else if (!hasStatBoost)
{
if (!IS_MOVE_STATUS(move) && (AtMaxHp(battlerDef) && (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH
#if B_STURDY >= GEN_5
|| (defAbility == ABILITY_STURDY)
#endif
|| (B_STURDY >= GEN_5 && defAbility == ABILITY_STURDY)
|| defAbility == ABILITY_MULTISCALE
|| defAbility == ABILITY_SHADOW_SHIELD)))
return PIVOT; // pivot to break sash/sturdy/multiscale
Expand Down Expand Up @@ -2921,9 +2900,7 @@ bool32 CanKnockOffItem(u32 battler, u32 item)
| BATTLE_TYPE_LINK
| BATTLE_TYPE_RECORDED_LINK
| BATTLE_TYPE_SECRET_BASE
#if B_TRAINERS_KNOCK_OFF_ITEMS == TRUE
| BATTLE_TYPE_TRAINER
#endif
| (B_TRAINERS_KNOCK_OFF_ITEMS == TRUE ? BATTLE_TYPE_TRAINER : 0)
)) && GetBattlerSide(battler) == B_SIDE_PLAYER)
return FALSE;

Expand Down
4 changes: 1 addition & 3 deletions src/battle_anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1468,10 +1468,8 @@ static void LoadDefaultBg(void)
{
if (IsContest())
LoadContestBgAfterMoveAnim();
#if B_TERRAIN_BG_CHANGE == TRUE
else if (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
else if (B_TERRAIN_BG_CHANGE == TRUE && gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
DrawTerrainTypeBattleBackground();
#endif
else
DrawMainBattleBackground();
}
Expand Down
9 changes: 4 additions & 5 deletions src/battle_bg.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,11 +856,10 @@ void LoadBattleTextboxAndBackground(void)
CopyBgTilemapBufferToVram(0);
LoadCompressedPalette(gBattleTextboxPalette, BG_PLTT_ID(0), 2 * PLTT_SIZE_4BPP);
LoadBattleMenuWindowGfx();
#if B_TERRAIN_BG_CHANGE == TRUE
DrawTerrainTypeBattleBackground();
#else
DrawMainBattleBackground();
#endif
if (B_TERRAIN_BG_CHANGE == TRUE)
DrawTerrainTypeBattleBackground();
else
DrawMainBattleBackground();
}

static void DrawLinkBattleParticipantPokeballs(u8 taskId, u8 multiplayerId, u8 bgId, u8 destX, u8 destY)
Expand Down
6 changes: 3 additions & 3 deletions src/battle_controller_opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,8 @@ static void OpponentHandleChooseMove(u32 battler)
target = GetBattlerAtPosition(Random() & 2);
} while (!CanTargetBattler(battler, target, move));

#if B_WILD_NATURAL_ENEMIES == TRUE
// Don't bother to loop through table if the move can't attack ally
if (!(gBattleMoves[move].target & MOVE_TARGET_BOTH))
if (B_WILD_NATURAL_ENEMIES == TRUE && !(gBattleMoves[move].target & MOVE_TARGET_BOTH))
{
u16 i, speciesAttacker, speciesTarget, isPartnerEnemy = FALSE;
static const u16 naturalEnemies[][2] =
Expand Down Expand Up @@ -622,8 +621,9 @@ static void OpponentHandleChooseMove(u32 battler)
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (target << 8));
}
else
#endif
{
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (target << 8));
}
}
else
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));
Expand Down
Loading
Loading