From 62640456e78c9944967dac20e1d3e550663a64fc Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Thu, 18 Jul 2024 12:48:23 +0200 Subject: [PATCH] Fixes residual damage order. #4945 Follow up. (#4993) --- src/battle_util.c | 100 +++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 012d7346f1fd..7bb0aba60c28 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2299,6 +2299,7 @@ u8 DoFieldEndTurnEffects(void) enum { + ENDTURN_WEATHER_DAMAGE, ENDTURN_INGRAIN, ENDTURN_AQUA_RING, ENDTURN_ABILITIES, @@ -2340,7 +2341,6 @@ enum ENDTURN_DYNAMAX, ENDTURN_GMAX_MOVE_RESIDUAL_DAMAGE, ENDTURN_SEA_OF_FIRE_DAMAGE, - ENDTURN_WEATHER_DAMAGE, ENDTURN_BATTLER_COUNT }; @@ -2381,6 +2381,55 @@ u8 DoBattlerEndTurnEffects(void) ability = GetBattlerAbility(battler); switch (gBattleStruct->turnEffectsTracker) { + case ENDTURN_WEATHER_DAMAGE: + ability = GetBattlerAbility(battler); + if (!IsBattlerAlive(battler) || !WEATHER_HAS_EFFECT || ability == ABILITY_MAGIC_GUARD) + { + gBattleStruct->turnEffectsTracker++; + break; + } + else if (gBattleWeather & B_WEATHER_SANDSTORM + && ability != ABILITY_SAND_VEIL + && ability != ABILITY_SAND_FORCE + && ability != ABILITY_SAND_RUSH + && ability != ABILITY_OVERCOAT + && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ROCK) + && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_GROUND) + && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_STEEL) + && !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_SAFETY_GOGGLES) + { + gBattleScripting.battler = battler; + gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 16; + BattleScriptExecute(BattleScript_DamagingWeather); + effect++; + } + else if (gBattleWeather & (B_WEATHER_HAIL | B_WEATHER_SNOW) + && ability == ABILITY_ICE_BODY + && !(gStatuses3[battler] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + && !BATTLER_MAX_HP(battler) + && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)) + { + gBattleScripting.battler = battler; + gBattleMoveDamage = -1 * (GetNonDynamaxMaxHP(battler) / 16); + BattleScriptExecute(BattleScript_IceBodyHeal); + effect++; + } + else if (gBattleWeather & B_WEATHER_HAIL + && !IS_BATTLER_OF_TYPE(battler, TYPE_ICE) + && ability != ABILITY_SNOW_CLOAK + && ability != ABILITY_OVERCOAT + && ability != ABILITY_ICE_BODY + && !(gStatuses3[battler] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + && GetBattlerHoldEffect(battler, TRUE) != HOLD_EFFECT_SAFETY_GOGGLES) + { + gBattleScripting.battler = battler; + gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 16; + BattleScriptExecute(BattleScript_DamagingWeather); + effect++; + } + gBattleStruct->turnEffectsTracker++; + break; case ENDTURN_INGRAIN: // ingrain if ((gStatuses3[battler] & STATUS3_ROOTED) && !BATTLER_MAX_HP(battler) @@ -2955,55 +3004,6 @@ u8 DoBattlerEndTurnEffects(void) } gBattleStruct->turnEffectsTracker++; break; - case ENDTURN_WEATHER_DAMAGE: - ability = GetBattlerAbility(battler); - if (!IsBattlerAlive(battler) || !WEATHER_HAS_EFFECT || ability == ABILITY_MAGIC_GUARD) - { - gBattleStruct->turnEffectsTracker++; - break; - } - else if (gBattleWeather & B_WEATHER_SANDSTORM - && ability != ABILITY_SAND_VEIL - && ability != ABILITY_SAND_FORCE - && ability != ABILITY_SAND_RUSH - && ability != ABILITY_OVERCOAT - && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ROCK) - && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_GROUND) - && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_STEEL) - && !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) - && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_SAFETY_GOGGLES) - { - gBattleScripting.battler = battler; - gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 16; - BattleScriptExecute(BattleScript_DamagingWeather); - effect++; - } - else if (gBattleWeather & (B_WEATHER_HAIL | B_WEATHER_SNOW) - && ability == ABILITY_ICE_BODY - && !(gStatuses3[battler] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) - && !BATTLER_MAX_HP(battler) - && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)) - { - gBattleScripting.battler = battler; - gBattleMoveDamage = -1 * (GetNonDynamaxMaxHP(battler) / 16); - BattleScriptExecute(BattleScript_IceBodyHeal); - effect++; - } - else if (gBattleWeather & B_WEATHER_HAIL - && !IS_BATTLER_OF_TYPE(battler, TYPE_ICE) - && ability != ABILITY_SNOW_CLOAK - && ability != ABILITY_OVERCOAT - && ability != ABILITY_ICE_BODY - && !(gStatuses3[battler] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) - && GetBattlerHoldEffect(battler, TRUE) != HOLD_EFFECT_SAFETY_GOGGLES) - { - gBattleScripting.battler = battler; - gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 16; - BattleScriptExecute(BattleScript_DamagingWeather); - effect++; - } - gBattleStruct->turnEffectsTracker++; - break; case ENDTURN_BATTLER_COUNT: // done gBattleStruct->turnEffectsTracker = 0; gBattleStruct->turnEffectsBattlerId++;