diff options
Diffstat (limited to 'battle/effect_commands.asm')
-rw-r--r-- | battle/effect_commands.asm | 329 |
1 files changed, 111 insertions, 218 deletions
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 94b54c0bd..87196653a 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -9328,72 +9328,102 @@ BattleCommand50: ; 37492 ld a, [hBattleTurn] and a - jr nz, .asm_374ce ; 37495 $37 - call .asm_37501 + jr nz, .enemy + +; The player needs to be able to steal an item. + + call .playeritem ld a, [hl] and a ret nz - call .asm_3750c + +; The enemy needs to have an item to steal. + + call .enemyitem ld a, [hl] and a ret z + +; Can't steal mail. + ld [$d265], a ld d, a - ld a, $2e - ld hl, $5e76 - rst FarCall + callba ItemIsMail ret c + ld a, [EffectFailed] and a ret nz + ld a, [InLinkBattle] and a - jr z, .asm_374be ; 374b7 $5 + jr z, .stealenemyitem + ld a, [IsInBattle] dec a ret z -.asm_374be - call .asm_3750c + +.stealenemyitem + call .enemyitem xor a ld [hl], a ld [de], a - call .asm_37501 + + call .playeritem ld a, [$d265] ld [hl], a ld [de], a - jr .asm_374f8 ; 374cc $2a -.asm_374ce - call .asm_3750c + jr .stole + + +.enemy + +; The enemy can't already have an item. + + call .enemyitem ld a, [hl] and a ret nz - call .asm_37501 + +; The player must have an item to steal. + + call .playeritem ld a, [hl] and a ret z + +; Can't steal mail! + ld [$d265], a ld d, a - ld a, $2e - ld hl, $5e76 - rst FarCall + callba ItemIsMail ret c + ld a, [EffectFailed] and a ret nz - call .asm_37501 + +; If the enemy steals your item, +; it's gone for good if you don't get it back. + + call .playeritem xor a ld [hl], a ld [de], a - call .asm_3750c + + call .enemyitem ld a, [$d265] ld [hl], a ld [de], a -.asm_374f8 + + +.stole call GetItemName ld hl, StoleText jp StdBattleTextBox -.asm_37501 + +.playeritem ld a, 1 call BattlePartyAttr ld d, h @@ -9401,9 +9431,9 @@ BattleCommand50: ; 37492 ld hl, BattleMonItem ret -.asm_3750c +.enemyitem ld a, 1 - call $396d ; GetOTStat_Battle + call OTPartyAttr ld d, h ld e, l ld hl, EnemyMonItem @@ -9413,17 +9443,27 @@ BattleCommand50: ; 37492 BattleCommand51: ; 37517 ; arenatrap + +; Doesn't work on an absent opponent. + call CheckHiddenOpponent - jr nz, .asm_37530 ; 3751a $14 + jr nz, .failed + +; Don't trap if the opponent is already trapped. + ld a, BATTLE_VARS_SUBSTATUS5 call GetBattleVarPair - bit 7, [hl] - jr nz, .asm_37530 ; 37523 $b - set 7, [hl] + bit SUBSTATUS_CANT_RUN, [hl] + jr nz, .failed + +; Otherwise trap the opponent. + + set SUBSTATUS_CANT_RUN, [hl] call Function0x37e01 ld hl, CantEscapeNowText jp StdBattleTextBox -.asm_37530 + +.failed call Function0x37e77 jp PrintButItFailed ; 37536 @@ -9432,23 +9472,38 @@ BattleCommand51: ; 37517 BattleCommand52: ; 37536 ; nightmare +; Can't hit an absent opponent. + call CheckHiddenOpponent - jr nz, .asm_3755d ; 37539 $22 + jr nz, .failed + +; Can't hit a substitute. + call CheckSubstituteOpp - jr nz, .asm_3755d ; 3753e $1d + jr nz, .failed + +; Only works on a sleeping opponent. + ld a, BATTLE_VARS_STATUS_OPP call GetBattleVarPair - and $7 - jr z, .asm_3755d ; 37547 $14 + and SLP + jr z, .failed + +; Bail if the opponent is already having a nightmare. + ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVarPair - bit 0, [hl] - jr nz, .asm_3755d ; 37550 $b - set 0, [hl] + bit SUBSTATUS_NIGHTMARE, [hl] + jr nz, .failed + +; Otherwise give the opponent a nightmare. + + set SUBSTATUS_NIGHTMARE, [hl] call Function0x37e01 ld hl, StartedNightmareText jp StdBattleTextBox -.asm_3755d + +.failed call Function0x37e77 jp PrintButItFailed ; 37563 @@ -9457,205 +9512,43 @@ BattleCommand52: ; 37536 BattleCommand53: ; 37563 ; defrost +; Thaw the user. + ld a, BATTLE_VARS_STATUS call GetBattleVarPair - bit 5, [hl] + bit FRZ, [hl] ret z - res 5, [hl] - ld a, [hBattleTurn] - and a - jr z, .asm_37578 ; 37570 $6 - ld a, [IsInBattle] - dec a - jr z, .asm_3757f ; 37576 $7 -.asm_37578 - ld a, $20 - call UserPartyAttr - res 5, [hl] -.asm_3757f - call RefreshBattleHuds - ld hl, WasDefrostedText - jp StdBattleTextBox -; 37588 + res FRZ, [hl] +; Don't update the enemy's party struct in a wild battle. -BattleCommand54: ; 37588 -; curse - - ld de, BattleMonType1 - ld bc, PlayerStatLevels ld a, [hBattleTurn] and a - jr z, .asm_37599 ; 37591 $6 - ld de, EnemyMonType1 - ld bc, EnemyStatLevels -.asm_37599 - ld a, [de] - cp $8 - jr z, .asm_375d7 ; 3759c $39 - inc de - ld a, [de] - cp $8 - jr z, .asm_375d7 ; 375a2 $33 - ld a, [bc] - cp $d - jr c, .asm_375af ; 375a7 $6 - inc bc - ld a, [bc] - cp $d - jr nc, .asm_3760a ; 375ad $5b -.asm_375af - ld a, $1 - ld [$c689], a - call Function0x37e01 - ld a, $2 - call Function0x36532 - call SwitchTurn - call BattleCommand8d - call ResetMiss - call SwitchTurn - call BattleCommand70 - call BattleCommand8c - call ResetMiss - call BattleCommand71 - jp BattleCommand8c -.asm_375d7 - call CheckHiddenOpponent - jr nz, .asm_37604 ; 375da $28 - call CheckSubstituteOpp - jr nz, .asm_37604 ; 375df $23 - ld a, BATTLE_VARS_SUBSTATUS1_OPP - call GetBattleVarPair - bit 1, [hl] - jr nz, .asm_37604 ; 375e8 $1a - set 1, [hl] - call Function0x37e01 - ld hl, $4c9f - call CallBankF - ld hl, $4c3f - call CallBankF - call UpdateUserInParty - ld hl, PutACurseText - jp StdBattleTextBox -.asm_37604 - call Function0x37e77 - jp PrintButItFailed -.asm_3760a - ld b, $8 - call GetStatName - call Function0x37e77 - ld hl, WontRiseAnymoreText - jp StdBattleTextBox -; 37618 - - -BattleCommand55: ; 37618 -; protect - - call Function0x3762c - ret c - ld a, BATTLE_VARS_SUBSTATUS1 - call GetBattleVarPair - set 2, [hl] - call Function0x37e01 - ld hl, ProtectedItselfText - jp StdBattleTextBox -; 3762c - - -Function0x3762c: ; 3762c - ld de, $c679 - ld a, [hBattleTurn] - and a - jr z, .asm_37637 - ld de, $c681 - -.asm_37637 - call Function0x36abf - jr nz, .asm_37665 - - ld a, $3 - call CleanGetBattleVarPair - bit 4, a - jr nz, .asm_37665 - - ld b, $ff - ld a, [de] - ld c, a -.asm_37649 - ld a, c - and a - jr z, .asm_37656 - - dec c - srl b - ld a, b - and a - jr nz, .asm_37649 - - jr .asm_37665 - -.asm_37656 - call BattleRandom - and a - jr z, .asm_37656 + jr z, .party + ld a, [IsInBattle] dec a - cp b - jr nc, .asm_37665 - - ld a, [de] - inc a - ld [de], a - and a - ret - -.asm_37665 - xor a - ld [de], a - call Function0x37e77 - call PrintButItFailed - scf - ret -; 3766f - - -BattleCommand5a: ; 3766f -; endure + jr z, .done - call Function0x3762c - ret c +.party + ld a, PartyMon1Status - PartyMon1 + call UserPartyAttr + res FRZ, [hl] - ld a, BATTLE_VARS_SUBSTATUS1 - call GetBattleVarPair - set SUBSTATUS_ENDURE, [hl] - call Function0x37e01 - ld hl, BracedItselfText +.done + call RefreshBattleHuds + ld hl, WasDefrostedText jp StdBattleTextBox -; 37683 +; 37588 -BattleCommand56: ; 37683 -; spikes +INCLUDE "battle/effects/curse.asm" - ld hl, EnemyScreens - ld a, [hBattleTurn] - and a - jr z, .asm_3768e - ld hl, PlayerScreens +INCLUDE "battle/effects/protect.asm" -.asm_3768e - bit 0, [hl] - jr nz, .failed +INCLUDE "battle/effects/endure.asm" - set 0, [hl] - call Function0x37e01 - ld hl, SpikesText - jp StdBattleTextBox - -.failed - jp Function0x37354 -; 376a0 +INCLUDE "battle/effects/spikes.asm" BattleCommand57: ; 376a0 |