diff --git a/include/config/battle.h b/include/config/battle.h index cffa3701b3..6a410f6ee0 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -230,7 +230,7 @@ #define B_OVERWORLD_FOG GEN_LATEST // In Gen8+, overworld Fog summons Misty Terrain in battle. In Gen4 only, overworld Fog summons the unique fog weather condition in battle. #define B_OVERWORLD_SNOW GEN_LATEST // In Gen9+, overworld Snow will summon snow instead of hail in battle. #define B_SNOW_WARNING GEN_LATEST // In Gen9+, Snow Warning will summon snow instead of hail. -#define B_PREFERRED_ICE_WEATHER B_ICE_WEATHER_BOTH // Toggles Hail move effects to Snow and vis versa. +#define B_PREFERRED_ICE_WEATHER B_ICE_WEATHER_BOTH // Toggles Hail move effects to Snow and vice versa. // Terrain settings #define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. diff --git a/src/battle_util.c b/src/battle_util.c index c2d5f61563..c1a7d99d66 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6755,16 +6755,25 @@ u32 IsAbilityOnFieldExcept(u32 battler, u32 ability) u32 IsAbilityPreventingEscape(u32 battler) { - u32 id; if (B_GHOSTS_ESCAPE >= GEN_6 && IS_BATTLER_OF_TYPE(battler, TYPE_GHOST)) return 0; - if ((id = IsAbilityOnOpposingSide(battler, ABILITY_SHADOW_TAG)) - && (B_SHADOW_TAG_ESCAPE >= GEN_4 && GetBattlerAbility(battler) != ABILITY_SHADOW_TAG)) - return id; - if ((id = IsAbilityOnOpposingSide(battler, ABILITY_ARENA_TRAP)) && IsBattlerGrounded(battler)) - return id; - if ((id = IsAbilityOnOpposingSide(battler, ABILITY_MAGNET_PULL)) && IS_BATTLER_OF_TYPE(battler, TYPE_STEEL)) - return id; + + for (u32 battlerDef = 0; battlerDef < gBattlersCount; battlerDef++) + { + if (battler == battlerDef || IsBattlerAlly(battler, battlerDef)) + continue; + + u32 ability = GetBattlerAbility(battlerDef); + + if (ability == ABILITY_SHADOW_TAG && (B_SHADOW_TAG_ESCAPE <= GEN_3 || GetBattlerAbility(battler) != ABILITY_SHADOW_TAG)) + return battlerDef + 1; + + if (ability == ABILITY_ARENA_TRAP && IsBattlerGrounded(battler)) + return battlerDef + 1; + + if (ability == ABILITY_MAGNET_PULL && IS_BATTLER_OF_TYPE(battler, TYPE_STEEL)) + return battlerDef + 1; + } return 0; }