mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07:00
32ed487a47
# Conflicts: # audio/engine.asm # constants/gfx_constants.asm # constants/map_data_constants.asm # constants/pokemon_data_constants.asm # constants/sprite_constants.asm # constants/wram_constants.asm # data/maps/data.asm # engine/battle/ai/scoring.asm # engine/battle/core.asm # engine/battle/effect_commands.asm # engine/battle/misc.asm # engine/battle_anims/getpokeballwobble.asm # engine/breeding.asm # engine/buy_sell_toss.asm # engine/decorations.asm # engine/events/battle_tower/battle_tower.asm # engine/events/battle_tower/rules.asm # engine/events/buena.asm # engine/events/bug_contest/contest_2.asm # engine/events/daycare.asm # engine/events/dratini.asm # engine/events/halloffame.asm # engine/events/happiness_egg.asm # engine/events/kurt.asm # engine/events/lucky_number.asm # engine/events/magnet_train.asm # engine/events/overworld.asm # engine/events/pokerus/pokerus.asm # engine/events/print_unown.asm # engine/events/print_unown_2.asm # engine/events/unown_walls.asm # engine/item_effects.asm # engine/link.asm # engine/mon_menu.asm # engine/player_object.asm # engine/routines/playslowcry.asm # engine/scripting.asm # engine/search.asm # engine/search2.asm # engine/specials.asm # engine/start_menu.asm # engine/timeset.asm # home/battle_vars.asm # home/map.asm # maps/GoldenrodUndergroundSwitchRoomEntrances.asm # maps/IlexForest.asm # maps/KrissHouse2F.asm # maps/Route39Barn.asm # mobile/mobile_12_2.asm # mobile/mobile_40.asm # mobile/mobile_5f.asm # wram.asm
97 lines
2.0 KiB
NASM
97 lines
2.0 KiB
NASM
_GiveOddEgg: ; 1fb4b6
|
|
; 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
|
|
cp HIGH($ffff)
|
|
jr nz, .not_done
|
|
ld a, e
|
|
cp LOW($ffff)
|
|
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
|
|
ld a, OddEgg2 - OddEgg1
|
|
call AddNTimes
|
|
|
|
ld de, wOddEggSpecies
|
|
ld bc, PARTYMON_STRUCT_LENGTH + 2 * MON_NAME_LENGTH
|
|
call CopyBytes
|
|
|
|
ld a, EGG_TICKET
|
|
ld [wCurItem], a
|
|
ld a, 1
|
|
ld [wItemQuantityChangeBuffer], a
|
|
ld a, -1
|
|
ld [wCurItemQuantity], a
|
|
ld hl, wNumItems
|
|
call TossItem
|
|
|
|
; load species in wcd2a
|
|
ld a, EGG
|
|
ld [wMobileMonSpeciesBuffer], a
|
|
|
|
; load pointer to (wMobileMonSpeciesBuffer - 1) in wMobileMonSpeciesPointerBuffer
|
|
ld a, LOW(wMobileMonSpeciesBuffer - 1)
|
|
ld [wMobileMonSpeciesPointerBuffer], a
|
|
ld a, HIGH(wMobileMonSpeciesBuffer - 1)
|
|
ld [wMobileMonSpeciesPointerBuffer + 1], a
|
|
; load pointer to wOddEggSpecies in wMobileMonStructurePointerBuffer
|
|
ld a, LOW(wOddEggSpecies)
|
|
ld [wMobileMonStructurePointerBuffer], a
|
|
ld a, HIGH(wOddEggSpecies)
|
|
ld [wMobileMonStructurePointerBuffer + 1], a
|
|
|
|
; load Odd Egg Name in wTempOddEggNickname
|
|
ld hl, .Odd
|
|
ld de, wTempOddEggNickname
|
|
ld bc, MON_NAME_LENGTH
|
|
call CopyBytes
|
|
|
|
; load pointer to wTempOddEggNickname in wMobileMonOTNamePointerBuffer
|
|
ld a, LOW(wTempOddEggNickname)
|
|
ld [wMobileMonOTNamePointerBuffer], a
|
|
ld a, HIGH(wTempOddEggNickname)
|
|
ld [wMobileMonOTNamePointerBuffer + 1], a
|
|
; load pointer to wOddEggName in wMobileMonNicknamePointerBuffer
|
|
ld a, LOW(wOddEggName)
|
|
ld [wMobileMonNicknamePointerBuffer], a
|
|
ld a, HIGH(wOddEggName)
|
|
ld [wMobileMonNicknamePointerBuffer + 1], a
|
|
farcall AddMobileMonToParty
|
|
ret
|
|
; 1fb546
|
|
|
|
.Odd:
|
|
db "ODD@@@@@@@@@"
|
|
|
|
INCLUDE "data/events/odd_eggs.asm"
|