summaryrefslogtreecommitdiff
path: root/items
diff options
context:
space:
mode:
authorpikalaxalt <PikalaxALT@gmail.com>2016-03-27 12:47:28 -0400
committerpikalaxalt <PikalaxALT@gmail.com>2016-03-27 12:47:28 -0400
commit93e12d200300c7320640922fe6bcebe64f942eda (patch)
tree21868005ec792f7c60b70c4482bde8adc0dea636 /items
parent2650bcffad179be1a874bfaadccb0bb554d28096 (diff)
Split up banks 1-3 of main.asm
Diffstat (limited to 'items')
-rw-r--r--items/item_effects.asm4
-rwxr-xr-xitems/pokeball_wobble.asm88
2 files changed, 92 insertions, 0 deletions
diff --git a/items/item_effects.asm b/items/item_effects.asm
index aa6c8f795..fb8e030bc 100644
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -338,11 +338,13 @@ endr
; catch rate than BRN/PSN/PAR, which in turn provide a higher catch rate than
; no status effect at all. But instead, it makes BRN/PSN/PAR provide no
; benefit.
+; Uncomment the line below to fix this.
ld b, a
ld a, [EnemyMonStatus]
and 1 << FRZ | SLP
ld c, 10
jr nz, .addstatus
+ ; ld a, [EnemyMonStatus]
and a
ld c, 5
jr nz, .addstatus
@@ -3315,3 +3317,5 @@ GetMthMoveOfCurrentMon: ; f969
add hl, bc
ret
; f971
+
+INCLUDE "items/pokeball_wobble.asm"
diff --git a/items/pokeball_wobble.asm b/items/pokeball_wobble.asm
new file mode 100755
index 000000000..7fb4d3e38
--- /dev/null
+++ b/items/pokeball_wobble.asm
@@ -0,0 +1,88 @@
+GetPokeBallWobble: ; f971 (3:7971)
+; Returns whether a Poke Ball will wobble in the catch animation.
+; Whether a Pokemon is caught is determined beforehand.
+
+ push de
+
+ ld a, [rSVBK]
+ ld d, a
+ push de
+
+ ld a, 1 ; BANK(Buffer2)
+ ld [rSVBK], a
+
+ ld a, [Buffer2]
+ inc a
+ ld [Buffer2], a
+
+; Wobble up to 3 times.
+ cp 3 + 1
+ jr z, .finished
+
+ ld a, [wWildMon]
+ and a
+ ld c, 0 ; next
+ jr nz, .done
+
+ ld hl, .WobbleProbabilities
+ ld a, [Buffer1]
+ 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
+ jr c, .done
+ ld c, 2 ; escaped
+ jr .done
+
+.finished
+ ld a, [wWildMon]
+ and a
+ ld c, 1 ; caught
+ jr nz, .done
+ ld c, 2 ; escaped
+
+.done
+ pop de
+ ld e, a
+ ld a, d
+ ld [rSVBK], a
+ ld a, e
+ pop de
+ ret
+
+.WobbleProbabilities: ; f9ba
+; catch rate, chance of wobbling / 255
+; nLeft/255 = (nRight/255) ** 4
+ db 1, 63
+ db 2, 75
+ db 3, 84
+ db 4, 90
+ db 5, 95
+ db 7, 103
+ db 10, 113
+ db 15, 126
+ db 20, 134
+ db 30, 149
+ db 40, 160
+ db 50, 169
+ db 60, 177
+ db 80, 191
+ db 100, 201
+ db 120, 211
+ db 140, 220
+ db 160, 227
+ db 180, 234
+ db 200, 240
+ db 220, 246
+ db 240, 251
+ db 254, 253
+ db 255, 255