Add missing weather checks for AI sandstorm/hail damage helpers (#9155)
This commit is contained in:
parent
d88b82eab2
commit
75500c86ab
@ -3162,23 +3162,31 @@ static u32 GetPoisonDamage(u32 battlerId)
|
||||
return damage;
|
||||
}
|
||||
|
||||
static bool32 BattlerAffectedBySandstorm(u32 battlerId, enum Ability ability)
|
||||
static bool32 DoesBattlerTakeSandstormDamage(u32 battlerId, enum Ability ability)
|
||||
{
|
||||
if (!(AI_GetWeather() & B_WEATHER_SANDSTORM))
|
||||
return FALSE;
|
||||
|
||||
if (!IS_BATTLER_ANY_TYPE(battlerId, TYPE_ROCK, TYPE_GROUND, TYPE_STEEL)
|
||||
&& ability != ABILITY_SAND_VEIL
|
||||
&& ability != ABILITY_SAND_FORCE
|
||||
&& ability != ABILITY_SAND_RUSH
|
||||
&& ability != ABILITY_MAGIC_GUARD
|
||||
&& ability != ABILITY_OVERCOAT)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool32 BattlerAffectedByHail(u32 battlerId, enum Ability ability)
|
||||
static bool32 DoesBattlerTakeHailDamage(u32 battlerId, enum Ability ability)
|
||||
{
|
||||
if (!(AI_GetWeather() & B_WEATHER_HAIL))
|
||||
return FALSE;
|
||||
|
||||
if (!IS_BATTLER_OF_TYPE(battlerId, TYPE_ICE)
|
||||
&& ability != ABILITY_SNOW_CLOAK
|
||||
&& ability != ABILITY_OVERCOAT
|
||||
&& ability != ABILITY_ICE_BODY)
|
||||
&& ability != ABILITY_ICE_BODY
|
||||
&& ability != ABILITY_MAGIC_GUARD
|
||||
&& ability != ABILITY_OVERCOAT)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@ -3194,7 +3202,7 @@ static u32 GetWeatherDamage(u32 battlerId)
|
||||
|
||||
if (weather & B_WEATHER_SANDSTORM)
|
||||
{
|
||||
if (BattlerAffectedBySandstorm(battlerId, ability)
|
||||
if (DoesBattlerTakeSandstormDamage(battlerId, ability)
|
||||
&& gBattleMons[battlerId].volatiles.semiInvulnerable != STATE_UNDERGROUND
|
||||
&& gBattleMons[battlerId].volatiles.semiInvulnerable != STATE_UNDERWATER
|
||||
&& holdEffect != HOLD_EFFECT_SAFETY_GOGGLES)
|
||||
@ -3206,7 +3214,7 @@ static u32 GetWeatherDamage(u32 battlerId)
|
||||
}
|
||||
if ((weather & B_WEATHER_HAIL) && ability != ABILITY_ICE_BODY)
|
||||
{
|
||||
if (BattlerAffectedByHail(battlerId, ability)
|
||||
if (DoesBattlerTakeHailDamage(battlerId, ability)
|
||||
&& gBattleMons[battlerId].volatiles.semiInvulnerable != STATE_UNDERGROUND
|
||||
&& gBattleMons[battlerId].volatiles.semiInvulnerable != STATE_UNDERWATER
|
||||
&& holdEffect != HOLD_EFFECT_SAFETY_GOGGLES)
|
||||
@ -3238,8 +3246,11 @@ u32 GetBattlerSecondaryDamage(u32 battlerId)
|
||||
|
||||
bool32 BattlerWillFaintFromWeather(u32 battler, enum Ability ability)
|
||||
{
|
||||
if ((BattlerAffectedBySandstorm(battler, ability) || BattlerAffectedByHail(battler, ability))
|
||||
&& gBattleMons[battler].hp <= max(1, gBattleMons[battler].maxHP / 16))
|
||||
if (gAiLogicData->holdEffects[battler] == HOLD_EFFECT_SAFETY_GOGGLES)
|
||||
return FALSE;
|
||||
|
||||
if ((DoesBattlerTakeSandstormDamage(battler, ability) || DoesBattlerTakeHailDamage(battler, ability))
|
||||
&& gBattleMons[battler].hp <= max(1, GetNonDynamaxMaxHP(battler) / 16))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user