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

Fixes residual damage order. #4945 Follow up. #4993

Merged
merged 1 commit into from
Jul 18, 2024
Merged
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
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
Loading