pokecrystal-board/engine/events/dratini.asm
Rangi 32ed487a47 Merge branch 'master' of https://github.com/pret/pokecrystal
# 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
2018-02-03 19:42:56 -05:00

113 lines
1.8 KiB
NASM

GiveDratini: ; 0x8b170
; if wScriptVar is 0 or 1, change the moveset of the last Dratini in the party.
; 0: give it a special moveset with Extremespeed.
; 1: give it the normal moveset of a level 15 Dratini.
ld a, [wScriptVar]
cp $2
ret nc
ld bc, wPartyCount
ld a, [bc]
ld hl, MON_SPECIES
call .GetNthPartyMon
ld a, [bc]
ld c, a
ld de, PARTYMON_STRUCT_LENGTH
.CheckForDratini:
; start at the end of the party and search backwards for a Dratini
ld a, [hl]
cp DRATINI
jr z, .GiveMoveset
ld a, l
sub e
ld l, a
ld a, h
sbc d
ld h, a
dec c
jr nz, .CheckForDratini
ret
.GiveMoveset:
push hl
ld a, [wScriptVar]
ld hl, .Movesets
ld bc, .Moveset1 - .Moveset0
call AddNTimes
; get address of mon's first move
pop de
inc de
inc de
.GiveMoves:
ld a, [hl]
and a ; is the move 00?
ret z ; if so, we're done here
push hl
push de
ld [de], a ; give the Pokémon the new move
; get the PP of the new move
dec a
ld hl, Moves + MOVE_PP
ld bc, MOVE_LENGTH
call AddNTimes
ld a, BANK(Moves)
call GetFarByte
; get the address of the move's PP and update the PP
ld hl, MON_PP - MON_MOVES
add hl, de
ld [hl], a
pop de
pop hl
inc de
inc hl
jr .GiveMoves
.Movesets:
.Moveset0:
; Dratini does not normally learn Extremespeed. This is a special gift.
db WRAP
db THUNDER_WAVE
db TWISTER
db EXTREMESPEED
db 0
.Moveset1:
; This is the normal moveset of a level 15 Dratini
db WRAP
db LEER
db THUNDER_WAVE
db TWISTER
db 0
.GetNthPartyMon: ; 0x8b1ce
; inputs:
; hl must be set to 0 before calling this function.
; a must be set to the number of Pokémon in the party.
; outputs:
; returns the address of the last Pokémon in the party in hl.
; sets carry if a is 0.
ld de, wPartyMon1
add hl, de
and a
jr z, .EmptyParty
dec a
ret z
ld de, PARTYMON_STRUCT_LENGTH
.loop
add hl, de
dec a
jr nz, .loop
ret
.EmptyParty:
scf
ret
; 8b1e1