Skip to content

Commit

Permalink
Fixes residual damage order. #4945 Follow up. (#4993)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine authored Jul 18, 2024
1 parent b21ffa1 commit 6264045
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2299,6 +2299,7 @@ u8 DoFieldEndTurnEffects(void)

enum
{
ENDTURN_WEATHER_DAMAGE,
ENDTURN_INGRAIN,
ENDTURN_AQUA_RING,
ENDTURN_ABILITIES,
Expand Down Expand Up @@ -2340,7 +2341,6 @@ enum
ENDTURN_DYNAMAX,
ENDTURN_GMAX_MOVE_RESIDUAL_DAMAGE,
ENDTURN_SEA_OF_FIRE_DAMAGE,
ENDTURN_WEATHER_DAMAGE,
ENDTURN_BATTLER_COUNT
};

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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++;
Expand Down

0 comments on commit 6264045

Please sign in to comment.