2018-06-24 14:09:41 +00:00
|
|
|
_GiveOddEgg:
|
2017-12-11 18:47:58 +00:00
|
|
|
; Figure out which egg to give.
|
|
|
|
|
|
|
|
; Compare a random word to
|
|
|
|
; probabilities out of 0xffff.
|
|
|
|
call Random
|
|
|
|
ld hl, OddEggProbabilities
|
|
|
|
ld c, 0
|
|
|
|
ld b, c
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
|
|
|
|
; Break on $ffff.
|
|
|
|
ld a, d
|
2017-12-25 18:40:10 +00:00
|
|
|
cp HIGH($ffff)
|
2017-12-11 18:47:58 +00:00
|
|
|
jr nz, .not_done
|
|
|
|
ld a, e
|
2017-12-25 18:40:10 +00:00
|
|
|
cp LOW($ffff)
|
2017-12-11 18:47:58 +00:00
|
|
|
jr z, .done
|
|
|
|
.not_done
|
|
|
|
|
|
|
|
; Break when [hRandom] <= de.
|
|
|
|
ld a, [hRandom + 1]
|
|
|
|
cp d
|
|
|
|
jr c, .done
|
|
|
|
jr z, .ok
|
|
|
|
jr .next
|
|
|
|
.ok
|
|
|
|
ld a, [hRandom + 0]
|
|
|
|
cp e
|
|
|
|
jr c, .done
|
|
|
|
jr z, .done
|
|
|
|
.next
|
|
|
|
inc bc
|
|
|
|
jr .loop
|
|
|
|
.done
|
|
|
|
|
|
|
|
ld hl, OddEggs
|
2018-07-16 19:58:07 +00:00
|
|
|
ld a, OddEgg1End - OddEgg1
|
2017-12-11 18:47:58 +00:00
|
|
|
call AddNTimes
|
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wOddEggSpecies
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH + 2 * MON_NAME_LENGTH
|
2017-12-11 18:47:58 +00:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
ld a, EGG_TICKET
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wCurItem], a
|
2017-12-11 18:47:58 +00:00
|
|
|
ld a, 1
|
|
|
|
ld [wItemQuantityChangeBuffer], a
|
|
|
|
ld a, -1
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wCurItemQuantity], a
|
|
|
|
ld hl, wNumItems
|
2017-12-11 18:47:58 +00:00
|
|
|
call TossItem
|
|
|
|
|
|
|
|
; load species in wcd2a
|
|
|
|
ld a, EGG
|
|
|
|
ld [wMobileMonSpeciesBuffer], a
|
|
|
|
|
|
|
|
; load pointer to (wMobileMonSpeciesBuffer - 1) in wMobileMonSpeciesPointerBuffer
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, LOW(wMobileMonSpeciesBuffer - 1)
|
2017-12-11 18:47:58 +00:00
|
|
|
ld [wMobileMonSpeciesPointerBuffer], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, HIGH(wMobileMonSpeciesBuffer - 1)
|
2017-12-11 18:47:58 +00:00
|
|
|
ld [wMobileMonSpeciesPointerBuffer + 1], a
|
2018-01-23 22:39:09 +00:00
|
|
|
; load pointer to wOddEggSpecies in wMobileMonStructurePointerBuffer
|
|
|
|
ld a, LOW(wOddEggSpecies)
|
2017-12-11 18:47:58 +00:00
|
|
|
ld [wMobileMonStructurePointerBuffer], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, HIGH(wOddEggSpecies)
|
2017-12-11 18:47:58 +00:00
|
|
|
ld [wMobileMonStructurePointerBuffer + 1], a
|
|
|
|
|
|
|
|
; load Odd Egg Name in wTempOddEggNickname
|
|
|
|
ld hl, .Odd
|
|
|
|
ld de, wTempOddEggNickname
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2017-12-11 18:47:58 +00:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
; load pointer to wTempOddEggNickname in wMobileMonOTNamePointerBuffer
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, LOW(wTempOddEggNickname)
|
2017-12-11 18:47:58 +00:00
|
|
|
ld [wMobileMonOTNamePointerBuffer], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, HIGH(wTempOddEggNickname)
|
2017-12-11 18:47:58 +00:00
|
|
|
ld [wMobileMonOTNamePointerBuffer + 1], a
|
|
|
|
; load pointer to wOddEggName in wMobileMonNicknamePointerBuffer
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, LOW(wOddEggName)
|
2017-12-11 18:47:58 +00:00
|
|
|
ld [wMobileMonNicknamePointerBuffer], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, HIGH(wOddEggName)
|
2017-12-11 18:47:58 +00:00
|
|
|
ld [wMobileMonNicknamePointerBuffer + 1], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall AddMobileMonToParty
|
2017-12-11 18:47:58 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
.Odd:
|
|
|
|
db "ODD@@@@@@@@@"
|
|
|
|
|
2018-01-26 03:19:24 +00:00
|
|
|
INCLUDE "data/events/odd_eggs.asm"
|