pokecrystal-board/engine/battle/move_effects/mirror_coat.asm
vulcandth ef9b9bb437
Clean up bugs commented in the source code (#912)
Co-authored-by: Rangi <remy.oukaour+rangi42@gmail.com>
2022-07-09 16:12:02 -05:00

59 lines
845 B
NASM

BattleCommand_MirrorCoat:
ld a, 1
ld [wAttackMissed], a
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
call GetBattleVar
and a
ret z
ld b, a
callfar GetMoveEffect
ld a, b
cp EFFECT_MIRROR_COAT
ret z
call BattleCommand_ResetTypeMatchup
ld a, [wTypeMatchup]
and a
ret z
call CheckOpponentWentFirst
ret z
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
call GetBattleVar
dec a
ld de, wStringBuffer1
call GetMoveData
ld a, [wStringBuffer1 + MOVE_POWER]
and a
ret z
ld a, [wStringBuffer1 + MOVE_TYPE]
cp SPECIAL
ret c
; BUG: Counter and Mirror Coat still work if the opponent uses an item (see docs/bugs_and_glitches.md)
ld hl, wCurDamage
ld a, [hli]
or [hl]
ret z
ld a, [hl]
add a
ld [hld], a
ld a, [hl]
adc a
ld [hl], a
jr nc, .capped
ld a, $ff
ld [hli], a
ld [hl], a
.capped
xor a
ld [wAttackMissed], a
ret