2018-06-24 14:09:41 +00:00
|
|
|
_GiveOddEgg:
|
2017-12-11 18:47:58 +00:00
|
|
|
; Figure out which egg to give.
|
|
|
|
|
2022-07-21 23:59:10 +00:00
|
|
|
; Compare a random word to probabilities out of $ffff.
|
2017-12-11 18:47:58 +00:00
|
|
|
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
|
|
|
|
|
2020-06-21 22:33:31 +00:00
|
|
|
; Break when the random word <= the next probability in de.
|
2020-04-16 13:30:50 +00:00
|
|
|
ldh a, [hRandomSub]
|
2017-12-11 18:47:58 +00:00
|
|
|
cp d
|
|
|
|
jr c, .done
|
|
|
|
jr z, .ok
|
|
|
|
jr .next
|
|
|
|
.ok
|
2020-04-16 13:30:50 +00:00
|
|
|
ldh a, [hRandomAdd]
|
2017-12-11 18:47:58 +00:00
|
|
|
cp e
|
|
|
|
jr c, .done
|
|
|
|
jr z, .done
|
|
|
|
.next
|
|
|
|
inc bc
|
|
|
|
jr .loop
|
|
|
|
.done
|
|
|
|
|
|
|
|
ld hl, OddEggs
|
2019-01-03 00:04:50 +00:00
|
|
|
ld a, NICKNAMED_MON_STRUCT_LENGTH
|
2017-12-11 18:47:58 +00:00
|
|
|
call AddNTimes
|
|
|
|
|
2021-03-17 20:16:02 +00:00
|
|
|
; Writes to wOddEgg, wOddEggName, and wOddEggOT,
|
|
|
|
; even though OddEggs does not have data for wOddEggOT
|
2019-01-03 00:04:50 +00:00
|
|
|
ld de, wOddEgg
|
2019-01-03 12:30:44 +00:00
|
|
|
ld bc, NICKNAMED_MON_STRUCT_LENGTH + 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
|
2020-12-23 21:29:30 +00:00
|
|
|
ld [wItemQuantityChange], a
|
2017-12-11 18:47:58 +00:00
|
|
|
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
|
|
|
|
|
2020-12-23 21:29:30 +00:00
|
|
|
; load species in wMobileMonSpecies
|
2017-12-11 18:47:58 +00:00
|
|
|
ld a, EGG
|
2022-09-15 00:49:58 +00:00
|
|
|
ld [wMobileMonMiscSpecies], a
|
2017-12-11 18:47:58 +00:00
|
|
|
|
2020-12-23 21:29:30 +00:00
|
|
|
; load pointer to (wMobileMonSpecies - 1) in wMobileMonSpeciesPointer
|
2022-09-15 00:49:58 +00:00
|
|
|
ld a, LOW(wMobileMonMiscSpecies - 1)
|
2020-12-23 21:29:30 +00:00
|
|
|
ld [wMobileMonSpeciesPointer], a
|
2022-09-15 00:49:58 +00:00
|
|
|
ld a, HIGH(wMobileMonMiscSpecies - 1)
|
2020-12-23 21:29:30 +00:00
|
|
|
ld [wMobileMonSpeciesPointer + 1], a
|
|
|
|
; load pointer to wOddEgg in wMobileMonStructPointer
|
2019-01-03 00:04:50 +00:00
|
|
|
ld a, LOW(wOddEgg)
|
2020-12-23 21:29:30 +00:00
|
|
|
ld [wMobileMonStructPointer], a
|
2019-01-03 00:04:50 +00:00
|
|
|
ld a, HIGH(wOddEgg)
|
2020-12-23 21:29:30 +00:00
|
|
|
ld [wMobileMonStructPointer + 1], a
|
2017-12-11 18:47:58 +00:00
|
|
|
|
|
|
|
; 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
|
|
|
|
|
2021-03-17 20:16:02 +00:00
|
|
|
; load pointer to wTempOddEggNickname in wMobileMonOTPointer
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, LOW(wTempOddEggNickname)
|
2021-03-17 20:16:02 +00:00
|
|
|
ld [wMobileMonOTPointer], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, HIGH(wTempOddEggNickname)
|
2021-03-17 20:16:02 +00:00
|
|
|
ld [wMobileMonOTPointer + 1], a
|
2020-12-23 21:29:30 +00:00
|
|
|
; load pointer to wOddEggName in wMobileMonNicknamePointer
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, LOW(wOddEggName)
|
2020-12-23 21:29:30 +00:00
|
|
|
ld [wMobileMonNicknamePointer], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, HIGH(wOddEggName)
|
2020-12-23 21:29:30 +00:00
|
|
|
ld [wMobileMonNicknamePointer + 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"
|