2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_MirrorCoat:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
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
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wStringBuffer1
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetMoveData
|
|
|
|
|
2018-08-06 13:17:01 -07:00
|
|
|
ld a, [wStringBuffer1 + MOVE_POWER]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2018-08-06 13:17:01 -07:00
|
|
|
ld a, [wStringBuffer1 + MOVE_TYPE]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp SPECIAL
|
|
|
|
ret c
|
|
|
|
|
2022-07-09 14:12:02 -07:00
|
|
|
; BUG: Counter and Mirror Coat still work if the opponent uses an item (see docs/bugs_and_glitches.md)
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage
|
2018-01-26 08:36:00 -08:00
|
|
|
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
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|