pokered/engine/battle/moveEffects/one_hit_ko_effect.asm

39 lines
760 B
NASM
Raw Normal View History

2014-05-22 22:13:20 +00:00
OneHitKOEffect_: ; 33f57 (c:7f57)
2015-06-11 22:41:33 +00:00
ld hl, W_DAMAGE
2014-05-22 22:13:20 +00:00
xor a
ld [hli], a
ld [hl], a ; set the damage output to zero
dec a
2014-08-09 05:39:13 +00:00
ld [wCriticalHitOrOHKO], a
ld hl, wBattleMonSpeed + 1
ld de, wEnemyMonSpeed + 1
2015-06-11 22:41:33 +00:00
ld a, [H_WHOSETURN]
2014-05-22 22:13:20 +00:00
and a
jr z, .compareSpeed
ld hl, wEnemyMonSpeed + 1
ld de, wBattleMonSpeed + 1
.compareSpeed
; set damage to 65535 and OHKO flag is the user's current speed is higher than the target's
2014-05-22 22:13:20 +00:00
ld a, [de]
dec de
ld b, a
ld a, [hld]
sub b
ld a, [de]
ld b, a
ld a, [hl]
sbc b
jr c, .userIsSlower
2015-06-11 22:41:33 +00:00
ld hl, W_DAMAGE
2014-05-22 22:13:20 +00:00
ld a, $ff
ld [hli], a
ld [hl], a
ld a, $2
2014-08-09 05:39:13 +00:00
ld [wCriticalHitOrOHKO], a
2014-05-22 22:13:20 +00:00
ret
.userIsSlower
; keep damage at 0 and set move missed flag if target's current speed is higher instead
2014-05-22 22:13:20 +00:00
ld a, $1
2015-06-11 22:41:33 +00:00
ld [W_MOVEMISSED], a
2014-05-22 22:13:20 +00:00
ret