From c2dfc571b2d488314f97507bde63bd620bc47aba Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 16 Jan 2021 12:21:04 -0700 Subject: [PATCH] misty terrain blocks confusion --- data/battle_scripts_1.s | 1 + include/battle_util.h | 1 + src/battle_script_commands.c | 3 +-- src/battle_util.c | 9 +++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index fd8a96f355..3eb883a3d6 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -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 diff --git a/include/battle_util.h b/include/battle_util.h index a48e037c14..c9fa1da61d 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -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 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 43acc29687..1e24b0d751 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -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++; } diff --git a/src/battle_util.c b/src/battle_util.c index 32264ced39..8a4428e510 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -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) {