BattleCommand_Counter:
; counter
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_COUNTER
call BattleCommand_ResetTypeMatchup
ld a, [wTypeMatchup]
call CheckOpponentWentFirst
dec a
ld de, wStringBuffer1
call GetMoveData
ld a, [wStringBuffer1 + MOVE_POWER]
ld a, [wStringBuffer1 + MOVE_TYPE]
cp SPECIAL
ret nc
ld hl, wCurDamage
ld a, [hli]
or [hl]
ld a, [hl]
add a
ld [hld], a
adc a
ld [hl], a
jr nc, .capped
ld a, $ff
ld [hli], a
.capped
xor a
ret