2014-05-22 22:13:20 +00:00
|
|
|
OneHitKOEffect_: ; 33f57 (c:7f57)
|
2015-02-03 19:51:53 +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
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wBattleMonSpeed + 1
|
|
|
|
ld de, wEnemyMonSpeed + 1
|
2015-04-08 10:15:08 +00:00
|
|
|
ld a, [H_WHOSETURN]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-04-08 10:15:08 +00:00
|
|
|
jr z, .compareSpeed
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wEnemyMonSpeed + 1
|
|
|
|
ld de, wBattleMonSpeed + 1
|
2015-04-08 10:15:08 +00:00
|
|
|
.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
|
2015-04-08 10:15:08 +00:00
|
|
|
jr c, .userIsSlower
|
2015-02-03 19:51:53 +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
|
2015-04-08 10:15:08 +00:00
|
|
|
.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-02-03 19:51:53 +00:00
|
|
|
ld [W_MOVEMISSED], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|