From b5417fafec7dd37cb4be391f3bd3d4541a2a381e Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Tue, 26 Dec 2017 17:47:05 -0500 Subject: Split battle/ into data/ and engine/ components --- engine/battle/effect_commands/nightmare.asm | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 engine/battle/effect_commands/nightmare.asm (limited to 'engine/battle/effect_commands/nightmare.asm') diff --git a/engine/battle/effect_commands/nightmare.asm b/engine/battle/effect_commands/nightmare.asm new file mode 100644 index 000000000..788e3de41 --- /dev/null +++ b/engine/battle/effect_commands/nightmare.asm @@ -0,0 +1,38 @@ +BattleCommand_Nightmare: ; 37536 +; nightmare + +; Can't hit an absent opponent. + + call CheckHiddenOpponent + jr nz, .failed + +; Can't hit a substitute. + + call CheckSubstituteOpp + jr nz, .failed + +; Only works on a sleeping opponent. + + ld a, BATTLE_VARS_STATUS_OPP + call GetBattleVarAddr + and SLP + jr z, .failed + +; Bail if the opponent is already having a nightmare. + + ld a, BATTLE_VARS_SUBSTATUS1_OPP + call GetBattleVarAddr + bit SUBSTATUS_NIGHTMARE, [hl] + jr nz, .failed + +; Otherwise give the opponent a nightmare. + + set SUBSTATUS_NIGHTMARE, [hl] + call AnimateCurrentMove + ld hl, StartedNightmareText + jp StdBattleTextBox + +.failed + call AnimateFailedMove + jp PrintButItFailed +; 37563 -- cgit v1.2.3