Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/events/give_pokemon.asm
1271 views
1
_GivePokemon::
2
; returns success in carry
3
; and whether the mon was added to the party in [wAddedToParty]
4
call EnableAutoTextBoxDrawing
5
xor a
6
ld [wAddedToParty], a
7
ld a, [wPartyCount]
8
cp PARTY_LENGTH
9
jr c, .addToParty
10
ld a, [wBoxCount]
11
cp MONS_PER_BOX
12
jr nc, .boxFull
13
; add to box
14
xor a
15
ld [wEnemyBattleStatus3], a
16
ld a, [wCurPartySpecies]
17
ld [wEnemyMonSpecies2], a
18
callfar LoadEnemyMonData
19
call SetPokedexOwnedFlag
20
callfar SendNewMonToBox
21
ld hl, wStringBuffer
22
ld a, [wCurrentBoxNum]
23
and BOX_NUM_MASK
24
cp 9
25
jr c, .singleDigitBoxNum
26
sub 9
27
ld [hl], "1"
28
inc hl
29
add "0"
30
jr .next
31
.singleDigitBoxNum
32
add "1"
33
.next
34
ld [hli], a
35
ld [hl], "@"
36
ld hl, SentToBoxText
37
call PrintText
38
scf
39
ret
40
.boxFull
41
ld hl, BoxIsFullText
42
call PrintText
43
and a
44
ret
45
.addToParty
46
call SetPokedexOwnedFlag
47
call AddPartyMon
48
ld a, 1
49
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
50
ld [wAddedToParty], a
51
scf
52
ret
53
54
SetPokedexOwnedFlag:
55
ld a, [wCurPartySpecies]
56
push af
57
ld [wPokedexNum], a
58
predef IndexToPokedex
59
ld a, [wPokedexNum]
60
dec a
61
ld c, a
62
ld hl, wPokedexOwned
63
ld b, FLAG_SET
64
predef FlagActionPredef
65
pop af
66
ld [wNamedObjectIndex], a
67
call GetMonName
68
ld hl, GotMonText
69
jp PrintText
70
71
GotMonText:
72
text_far _GotMonText
73
sound_get_item_1
74
text_end
75
76
SentToBoxText:
77
text_far _SentToBoxText
78
text_end
79
80
BoxIsFullText:
81
text_far _BoxIsFullText
82
text_end
83
84