diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f449306a6..f02dd9a3e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2118,14 +2118,14 @@ BattleScript_TerrainPreventsEnd2:: waitmessage B_WAIT_TIME_LONG end2 -BattleScript_ElectricTerrainPrevents: +BattleScript_ElectricTerrainPrevents:: pause B_WAIT_TIME_SHORT printstring STRINGID_ELECTRICTERRAINPREVENTS waitmessage B_WAIT_TIME_LONG orhalfword gMoveResultFlags, MOVE_RESULT_FAILED goto BattleScript_MoveEnd -BattleScript_MistyTerrainPrevents: +BattleScript_MistyTerrainPrevents:: pause B_WAIT_TIME_SHORT printstring STRINGID_MISTYTERRAINPREVENTS waitmessage B_WAIT_TIME_LONG @@ -2698,7 +2698,6 @@ BattleScript_EffectRest:: jumpifability BS_ATTACKER, ABILITY_COMATOSE, BattleScript_RestIsAlreadyAsleep jumpifcantmakeasleep BattleScript_RestCantSleep trysetrest BattleScript_AlreadyAtFullHp - jumpifterrainaffected BS_ATTACKER, (STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_MISTY_TERRAIN), BattleScript_ButItFailed pause B_WAIT_TIME_SHORT printfromtable gRestUsedStringIds waitmessage B_WAIT_TIME_LONG @@ -4593,8 +4592,6 @@ BattleScript_EffectYawn:: jumpifability BS_TARGET, ABILITY_VITAL_SPIRIT, BattleScript_PrintBankAbilityMadeIneffective jumpifability BS_TARGET, ABILITY_INSOMNIA, BattleScript_PrintBankAbilityMadeIneffective jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_PrintBankAbilityMadeIneffective - jumpifterrainaffected BS_TARGET, STATUS_FIELD_ELECTRIC_TERRAIN, BattleScript_ElectricTerrainPrevents - jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents jumpifflowerveil BattleScript_FlowerVeilProtects jumpifleafguard BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 175496ca0..30066438b 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -374,5 +374,7 @@ extern const u8 BattleScript_BattlerGotOverItsInfatuation[]; extern const u8 BattleScript_Pickpocket[]; extern const u8 BattleScript_StickyBarbTransfer[]; extern const u8 BattleScript_TerrainPreventsEnd2[]; +extern const u8 BattleScript_MistyTerrainPrevents[]; +extern const u8 BattleScript_ElectricTerrainPrevents[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d57d2daae..b8a37704c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8800,6 +8800,14 @@ static void Cmd_trysetrest(void) { gBattlescriptCurrInstr = failJump; } + else if (IsBattlerTerrainAffected(gBattlerTarget, STATUS_FIELD_ELECTRIC_TERRAIN)) + { + gBattlescriptCurrInstr = BattleScript_ElectricTerrainPrevents; + } + else if (IsBattlerTerrainAffected(gBattlerTarget, STATUS_FIELD_MISTY_TERRAIN)) + { + gBattlescriptCurrInstr = BattleScript_MistyTerrainPrevents; + } else { if (gBattleMons[gBattlerTarget].status1 & ((u8)(~STATUS1_SLEEP))) @@ -11438,6 +11446,18 @@ static void Cmd_setyawn(void) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } + else if (IsBattlerTerrainAffected(gBattlerTarget, STATUS_FIELD_ELECTRIC_TERRAIN)) + { + // When Yawn is used while Electric Terrain is set and drowsiness is set from Yawn being used against target in the previous turn: + // "But it failed" will display first. + gBattlescriptCurrInstr = BattleScript_ElectricTerrainPrevents; + } + else if (IsBattlerTerrainAffected(gBattlerTarget, STATUS_FIELD_MISTY_TERRAIN)) + { + // When Yawn is used while Misty Terrain is set and drowsiness is set from Yawn being used against target in the previous turn: + // "But it failed" will display first. + gBattlescriptCurrInstr = BattleScript_MistyTerrainPrevents; + } else { gStatuses3[gBattlerTarget] |= STATUS3_YAWN_TURN(2);