summaryrefslogtreecommitdiff
path: root/engine/battle_anims
diff options
context:
space:
mode:
authorentrpntr <entrpntr@gmail.com>2020-05-04 16:23:03 -0400
committerentrpntr <entrpntr@gmail.com>2020-05-04 16:23:03 -0400
commit858f7a0b8a7aebe69df387654e3201051d348b9e (patch)
tree990a5c6dbd7e312b57a89298070cbff8e55293aa /engine/battle_anims
parentfd35959d94c9487e74b2376e529302b32061af83 (diff)
Finish cleanup of bank 3.
Diffstat (limited to 'engine/battle_anims')
-rw-r--r--engine/battle_anims/pokeball_wobble.asm45
1 files changed, 45 insertions, 0 deletions
diff --git a/engine/battle_anims/pokeball_wobble.asm b/engine/battle_anims/pokeball_wobble.asm
new file mode 100644
index 00000000..c430e513
--- /dev/null
+++ b/engine/battle_anims/pokeball_wobble.asm
@@ -0,0 +1,45 @@
+GetPokeBallWobble:
+; Returns whether a Poke Ball will wobble in the catch animation.
+; Whether a Pokemon is caught is determined beforehand.
+
+ ld a, [wBuffer2]
+ inc a
+ ld [wBuffer2], a
+
+; Wobble up to 3 times.
+ cp 3 + 1
+ jr z, .finished
+
+ ld a, [wWildMon]
+ and a
+ ld c, 0 ; next
+ ret nz
+
+ ld hl, WobbleProbabilities
+ ld a, [wBuffer1]
+ ld b, a
+.loop
+ ld a, [hli]
+ cp b
+ jr nc, .checkwobble
+ inc hl
+ jr .loop
+
+.checkwobble
+ ld b, [hl]
+ call Random
+ cp b
+ ld c, 0 ; next
+ ret c
+ ld c, 2 ; escaped
+ ret
+
+.finished
+ ld a, [wWildMon]
+ and a
+ ld c, 1 ; caught
+ ret nz
+ ld c, 2 ; escaped
+ ret
+
+INCLUDE "data/battle/wobble_probabilities.asm"