2018-06-24 07:09:41 -07:00
|
|
|
GetPokeBallWobble:
|
2016-03-27 09:47:28 -07:00
|
|
|
; Returns whether a Poke Ball will wobble in the catch animation.
|
|
|
|
; Whether a Pokemon is caught is determined beforehand.
|
|
|
|
|
|
|
|
push de
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rSVBK]
|
2016-03-27 09:47:28 -07:00
|
|
|
ld d, a
|
|
|
|
push de
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, BANK(wBuffer2)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2016-03-27 09:47:28 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBuffer2]
|
2016-03-27 09:47:28 -07:00
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer2], a
|
2016-03-27 09:47:28 -07:00
|
|
|
|
|
|
|
; Wobble up to 3 times.
|
|
|
|
cp 3 + 1
|
|
|
|
jr z, .finished
|
|
|
|
|
|
|
|
ld a, [wWildMon]
|
|
|
|
and a
|
|
|
|
ld c, 0 ; next
|
|
|
|
jr nz, .done
|
|
|
|
|
2018-01-25 18:34:42 -08:00
|
|
|
ld hl, WobbleProbabilities
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBuffer1]
|
2016-03-27 09:47:28 -07:00
|
|
|
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
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2016-03-27 09:47:28 -07:00
|
|
|
ld a, e
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-01-25 18:34:42 -08:00
|
|
|
INCLUDE "data/battle/wobble_probabilities.asm"
|