misty terrain blocks confusion

This commit is contained in:
Evan 2021-01-16 12:21:04 -07:00
parent 10b1d33d13
commit c2dfc571b2
4 changed files with 12 additions and 2 deletions

View file

@ -2894,6 +2894,7 @@ BattleScript_EffectConfuse:
jumpifability BS_TARGET, ABILITY_OWN_TEMPO, BattleScript_OwnTempoPrevents
jumpifsubstituteblocks BattleScript_ButItFailed
jumpifstatus2 BS_TARGET, STATUS2_CONFUSION, BattleScript_AlreadyConfused
jumpifterrainaffected BS_TARGET, FIELD_STATUS_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsafeguard BattleScript_SafeguardProtected
attackanimation

View file

@ -135,6 +135,7 @@ bool32 CanBePoisoned(u8 battlerId);
bool32 CanBeBurned(u8 battlerId);
bool32 CanBeParalyzed(u8 battlerId);
bool32 CanBeFrozen(u8 battlerId);
bool32 CanBeConfused(u8 battlerId);
bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag);
#endif // GUARD_BATTLE_UTIL_H

View file

@ -2684,8 +2684,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
switch (gBattleScripting.moveEffect)
{
case MOVE_EFFECT_CONFUSION:
if (GetBattlerAbility(gEffectBattler) == ABILITY_OWN_TEMPO
|| gBattleMons[gEffectBattler].status2 & STATUS2_CONFUSION)
if (!CanBeConfused(gEffectBattler))
{
gBattlescriptCurrInstr++;
}

View file

@ -5143,6 +5143,15 @@ bool32 CanBeFrozen(u8 battlerId)
return TRUE;
}
bool32 CanBeConfused(u8 battlerId)
{
if (GetBattlerAbility(gEffectBattler) == ABILITY_OWN_TEMPO
|| gBattleMons[gEffectBattler].status2 & STATUS2_CONFUSION
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN))
return FALSE;
return TRUE;
}
// second argument is 1/X of current hp compared to max hp
static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId)
{