ground x2 vs flying if inverse battle

This commit is contained in:
sneed 2022-06-10 22:31:53 +03:00
parent 15fe85902f
commit 407047ace7

View File

@ -7770,33 +7770,35 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move)
return FALSE; return FALSE;
} }
// Only called directly when calculating damage type effectiveness
bool32 IsBattlerGrounded(u8 battlerId) static bool32 IsBattlerGrounded2(u8 battlerId, bool32 considerInverse)
{ {
if (GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_IRON_BALL) if (GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_IRON_BALL)
return TRUE; return TRUE;
else if (gFieldStatuses & STATUS_FIELD_GRAVITY) if (gFieldStatuses & STATUS_FIELD_GRAVITY)
return TRUE; return TRUE;
#if B_ROOTED_GROUNDING >= GEN_4 #if B_ROOTED_GROUNDING >= GEN_4
else if (gStatuses3[battlerId] & STATUS3_ROOTED) if (gStatuses3[battlerId] & STATUS3_ROOTED)
return TRUE; return TRUE;
#endif #endif
else if (gStatuses3[battlerId] & STATUS3_SMACKED_DOWN) if (gStatuses3[battlerId] & STATUS3_SMACKED_DOWN)
return TRUE; return TRUE;
if (gStatuses3[battlerId] & STATUS3_TELEKINESIS)
return FALSE;
if (gStatuses3[battlerId] & STATUS3_MAGNET_RISE)
return FALSE;
if (GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_AIR_BALLOON)
return FALSE;
if (GetBattlerAbility(battlerId) == ABILITY_LEVITATE)
return FALSE;
if (IS_BATTLER_OF_TYPE(battlerId, TYPE_FLYING) && (!considerInverse || !FlagGet(B_FLAG_INVERSE_BATTLE)))
return FALSE;
return TRUE;
}
else if (gStatuses3[battlerId] & STATUS3_TELEKINESIS) bool32 IsBattlerGrounded(u8 battlerId)
return FALSE; {
else if (gStatuses3[battlerId] & STATUS3_MAGNET_RISE) IsBattlerGrounded2(battlerId, FALSE);
return FALSE;
else if (GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_AIR_BALLOON)
return FALSE;
else if (GetBattlerAbility(battlerId) == ABILITY_LEVITATE)
return FALSE;
else if (IS_BATTLER_OF_TYPE(battlerId, TYPE_FLYING))
return FALSE;
else
return TRUE;
} }
bool32 IsBattlerAlive(u8 battlerId) bool32 IsBattlerAlive(u8 battlerId)
@ -9172,7 +9174,7 @@ static u16 CalcTypeEffectivenessMultiplierInternal(u16 move, u8 moveType, u8 bat
&& gBattleMons[battlerDef].type3 != gBattleMons[battlerDef].type1) && gBattleMons[battlerDef].type3 != gBattleMons[battlerDef].type1)
MulByTypeEffectiveness(&modifier, move, moveType, battlerDef, gBattleMons[battlerDef].type3, battlerAtk, recordAbilities); MulByTypeEffectiveness(&modifier, move, moveType, battlerDef, gBattleMons[battlerDef].type3, battlerAtk, recordAbilities);
if (moveType == TYPE_GROUND && !IsBattlerGrounded(battlerDef) && !(gBattleMoves[move].flags & FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING)) if (moveType == TYPE_GROUND && !IsBattlerGrounded2(battlerDef, TRUE) && !(gBattleMoves[move].flags & FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING))
{ {
modifier = UQ_4_12(0.0); modifier = UQ_4_12(0.0);
if (recordAbilities && defAbility == ABILITY_LEVITATE) if (recordAbilities && defAbility == ABILITY_LEVITATE)