From 51a6081c8ef88cd69e1e899db2109bc87c8f20c3 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 2 Nov 2025 16:31:09 -0300 Subject: [PATCH] Parametrized Ice Face's weather form change (#8115) --- src/battle_util.c | 45 +++++++-------------------- src/data/pokemon/form_change_tables.h | 1 + 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index fb23ab400d..c2542b9b3f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -67,6 +67,7 @@ static void SetRandomMultiHitCounter(); static bool32 IsNonVolatileStatusBlocked(u32 battlerDef, enum Ability abilityDef, enum Ability abilityAffected, const u8 *battleScript, enum FunctionCallOption option); static bool32 CanSleepDueToSleepClause(u32 battlerAtk, u32 battlerDef, enum FunctionCallOption option); static bool32 IsOpposingSideEmpty(u32 battler); +static bool32 CanBattlerFormChange(u32 battler, enum FormChanges method); // Submoves static u32 GetMirrorMoveMove(void); @@ -4518,17 +4519,6 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, u32 battler, enum Ability ab effect++; } break; - case ABILITY_ICE_FACE: - if (IsBattlerWeatherAffected(battler, B_WEATHER_HAIL | B_WEATHER_SNOW) - && gBattleMons[battler].species == SPECIES_EISCUE_NOICE - && !(gBattleMons[battler].volatiles.transformed)) - { - // TODO: Convert this to a proper FORM_CHANGE type. - gBattleMons[battler].species = SPECIES_EISCUE_ICE; - BattleScriptPushCursorAndCallback(BattleScript_BattlerFormChangeWithStringEnd3); - effect++; - } - break; case ABILITY_COMMANDER: partner = BATTLE_PARTNER(battler); if (!gSpecialStatuses[battler].switchInAbilityDone @@ -5518,33 +5508,22 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, u32 battler, enum Ability ab { case ABILITY_FORECAST: case ABILITY_FLOWER_GIFT: - if ((IsBattlerWeatherAffected(battler, gBattleWeather) + case ABILITY_ICE_FACE: + { + u32 battlerWeatherAffected = IsBattlerWeatherAffected(battler, gBattleWeather); + if (battlerWeatherAffected && !CanBattlerFormChange(battler, FORM_CHANGE_BATTLE_WEATHER)) + { + // If Hail/Snow activates when in Eiscue is in base, prevent reversion when Eiscue Noice gets broken + gDisableStructs[battler].weatherAbilityDone = TRUE; + } + + if (((!gDisableStructs[battler].weatherAbilityDone && battlerWeatherAffected) || gBattleWeather == B_WEATHER_NONE || !HasWeatherEffect()) // Air Lock active && TryBattleFormChange(battler, FORM_CHANGE_BATTLE_WEATHER)) { gBattleScripting.battler = battler; - BattleScriptPushCursorAndCallback(BattleScript_BattlerFormChangeWithStringEnd3); - effect++; - } - break; - case ABILITY_ICE_FACE: - { - u32 battlerWeatherAffected = IsBattlerWeatherAffected(battler, B_WEATHER_HAIL | B_WEATHER_SNOW); - if (battlerWeatherAffected && gBattleMons[battler].species == SPECIES_EISCUE) - { - // If Hail/Snow activates when in Eiscue is in base, prevent reversion when Eiscue Noice gets broken gDisableStructs[battler].weatherAbilityDone = TRUE; - } - if (!gDisableStructs[battler].weatherAbilityDone - && battlerWeatherAffected - && gBattleMons[battler].species == SPECIES_EISCUE_NOICE - && !(gBattleMons[battler].volatiles.transformed)) - { - // TODO: Convert this to a proper FORM_CHANGE type. - gBattleScripting.battler = battler; - gDisableStructs[battler].weatherAbilityDone = TRUE; - gBattleMons[battler].species = SPECIES_EISCUE_ICE; BattleScriptPushCursorAndCallback(BattleScript_BattlerFormChangeWithStringEnd3); effect++; } @@ -9048,7 +9027,7 @@ u16 GetBattleFormChangeTargetSpecies(u32 battler, enum FormChanges method) return targetSpecies; } -bool32 CanBattlerFormChange(u32 battler, enum FormChanges method) +static bool32 CanBattlerFormChange(u32 battler, enum FormChanges method) { // Can't change form if transformed. if (gBattleMons[battler].volatiles.transformed diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index fd443458c7..34ff79783f 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -1204,6 +1204,7 @@ static const struct FormChange sAlcremieFormChangeTable[] = #if P_FAMILY_EISCUE static const struct FormChange sEiscueFormChangeTable[] = { + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_EISCUE_ICE, B_WEATHER_HAIL | B_WEATHER_SNOW, ABILITY_ICE_FACE}, {FORM_CHANGE_FAINT, SPECIES_EISCUE_ICE}, {FORM_CHANGE_END_BATTLE, SPECIES_EISCUE_ICE}, {FORM_CHANGE_TERMINATOR},