Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/battle/move_effects/one_hit_ko.asm
1271 views
1
OneHitKOEffect_:
2
ld hl, wDamage
3
xor a
4
ld [hli], a
5
ld [hl], a ; set the damage output to zero
6
dec a
7
ld [wCriticalHitOrOHKO], a
8
ld hl, wBattleMonSpeed + 1
9
ld de, wEnemyMonSpeed + 1
10
ldh a, [hWhoseTurn]
11
and a
12
jr z, .compareSpeed
13
ld hl, wEnemyMonSpeed + 1
14
ld de, wBattleMonSpeed + 1
15
.compareSpeed
16
; set damage to 65535 and OHKO flag is the user's current speed is higher than the target's
17
ld a, [de]
18
dec de
19
ld b, a
20
ld a, [hld]
21
sub b
22
ld a, [de]
23
ld b, a
24
ld a, [hl]
25
sbc b
26
jr c, .userIsSlower
27
ld hl, wDamage
28
ld a, $ff
29
ld [hli], a
30
ld [hl], a
31
ld a, $2
32
ld [wCriticalHitOrOHKO], a
33
ret
34
.userIsSlower
35
; keep damage at 0 and set move missed flag if target's current speed is higher instead
36
ld a, $1
37
ld [wMoveMissed], a
38
ret
39
40