summaryrefslogtreecommitdiff
path: root/How-To-Add-a-Pocket-PC.md
blob: 66fdf92f8a0ebf47c1beb8f777542d55dd5fb418 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
This tutorial is for how to add a Pocket PC that you can use at any time to access the PC without having to go to the Pokémon Center.


## Contents

1. [Add the Pocket PC as a Key Item](#1-add-the-pocket-pc-as-a-key-item)
2. [Add the new function to handle using the PC](#2-add-the-function-to-handle-using-the-PC)
3. [Get the Pocket PC from Elm's Aide](#3-Get-the-Pocket-PC-from-Elms-Aide)


## 1. Add the Pocket PC as a Key Item

This section is similar to adding any normal item and can be carried out the same way until you get to the attributes:

To start with, we'll implement the Pocket PC's essential data. Firt edit [constants/item_constants.asm](../blob/master/constants/item_constants.asm):

```diff
 	const WATER_STONE  ; 18
-	const ITEM_19      ; 19
+	const POCKET_PC    ; 19
 	const HP_UP        ; 1a
```

Edit [data/items/names.asm](../blob/master/data/items/names.asm):

```diff
 	li "WATER STONE"
-	li "TERU-SAMA"
+	li "POCKET PC"
 	li "HP UP"
```

Edit [data/items/descriptions.asm](../blob/master/data/items/descriptions.asm):

```diff
 	dw WaterStoneDesc
-	dw TeruSama2Desc
+	dw PocketPCDesc
 	dw HPUpDesc

 	...

-TeruSama2Desc:
-	db   "?@"
+PocketPCDesc:
+	db   "Access the PC"
+	next "right here!@"
```

Edit [data/items/attributes.asm](../blob/master/data/items/attributes.asm):

```diff
-; ITEM_19
-	item_attribute $9999, HELD_NONE, 0, NO_LIMITS, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
+; POCKET_PC
+	item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE
```

Edit [engine/items/item_effects.asm](../blob/master/engine/items/item_effects.asm):

Replace the old slot:
```diff
 	dw EvoStoneEffect      ; WATER_STONE
-	dw NoEffect            ; ITEM_19
+	dw PocketPCEffect      ; POCKET_PC
 	dw VitaminEffect       ; HP_UP
```

Add the new effect:

```diff
        ItemfinderEffect:
	farcall ItemFinder
	ret

+	PocketPCEffect:
+	farcall PocketPCFunction
+	ret
```

And last, edit [data/items/catch_rate_items.asm](../blob/master/data/items/catch_rate_items.asm) (you won't need two Pocket PCs!):

```diff
 TimeCapsule_CatchRateItems:
-	db ITEM_19, LEFTOVERS
 	...
```

## 2. Add the new function to handle using the PC

Now we need to create the `PocketPCFunction` that we added to the [engine/items/item_effects.asm](../blob/master/engine/items/item_effects.asm). This will be done in the [engine/events/overworld.asm](../blob/master/engine/events/overworld.asm) file.

Here we have the base of the function, it is handled similarly to the `BikeFunction` as we want different scripts to trigger based on whether we are using it from the Bag or as a registered item:

```diff
 RodNothingText:
	text_far _RodNothingText
	text_end

 UnusedNothingHereText: ; unused
	text_far _UnusedNothingHereText
	text_end

+PocketPCFunction:
+	call .LoadPocketPC
+	and $7f
+	ld [wFieldMoveSucceeded], a
+	ret
+	
+.LoadPocketPC:
+	ld a, [wPlayerState]
+	ld hl, Script_LoadPocketPC
+	ld de, Script_LoadPocketPC_Register
+	call .CheckIfRegistered
+	call QueueScript
+	ld a, TRUE
+	ret
+	
+.CheckIfRegistered:
+	ld a, [wUsingItemWithSelect]
+	and a
+	ret z
+	ld h, d
+	ld l, e
+	ret
```

Next we need to add the two scripts that will run depending on the scenario:

```diff
+Script_LoadPocketPC:
+	reloadmappart
+	special UpdateTimePals
+	special PokemonCenterPC
+	reloadmappart
+	end
+
+Script_LoadPocketPC_Register:
+	special PokemonCenterPC
+	reloadmappart
+	end
	
 Script_GetOnBike:
	reloadmappart
	special UpdateTimePals
	loadvar VAR_MOVEMENT, PLAYER_BIKE
```

The difference between them is when using from the Bag we need to move to the overworld, done with `reloadmappart`.

In both cases we use the `PokemonCenterPC` function which has its own special pointer. This will then just act like you were standing in front of the PC in the Pokémon Center. Then after you have done everything in the PC and exit we have `reloadmappart` to properly load the map once more.


## 3. Get the Pocket PC from Elm's Aide

Now we need to actually get the item into your inventory, one place that makes sense is right after you get your starter.

Getting the Pocket PC before you get any Pokémon causes it to crash when accessing the PC; this is solved by just getting it after you get a Pokémon.
 
So we just need to edit the script for when you get your first Potion to also give the Pocket PC to the player. This is done in [maps/ElmsLab.asm](../blob/master/maps/ElmsLab.asm):

First we add the new call to both events:

```diff
 ElmJumpRightScript:
	applymovement ELMSLAB_ELM, ElmJumpRightMovement
	opentext
	end

 AideScript_WalkPotion1:
	applymovement ELMSLAB_ELMS_AIDE, AideWalksRight1
	turnobject PLAYER, DOWN
	scall AideScript_GivePotion
+	scall AideScript_GivePocketPC
	applymovement ELMSLAB_ELMS_AIDE, AideWalksLeft1
	end

AideScript_WalkPotion2:
	applymovement ELMSLAB_ELMS_AIDE, AideWalksRight2
	turnobject PLAYER, DOWN
	scall AideScript_GivePotion
+	scall AideScript_GivePocketPC
	applymovement ELMSLAB_ELMS_AIDE, AideWalksLeft2
	end
```

Then we add the script and move the end scene to our new script:
```diff
AideScript_GivePotion:
	opentext
	writetext AideText_GiveYouPotion
	promptbutton
	verbosegiveitem POTION
	writetext AideText_AlwaysBusy
	waitbutton
	closetext
-	setscene SCENE_ELMSLAB_NOTHING
	end

+AideScript_GivePocketPC:
+	opentext
+	writetext AideText_GetPocketPCText
+	promptbutton
+	giveitem POCKET_PC
+	writetext AideText_PocketPCInfoText
+	waitbutton
+	closetext
+	setscene SCENE_ELMSLAB_NOTHING
+	end
```

Add last we add the new text used when giving the PocketPC:
```diff
ElmsLabPCText:
	text "OBSERVATIONS ON"
	line "#MON EVOLUTION"

	para "…It says on the"
	line "screen…"
	done
	
+AideText_GetPocketPCText:
+	text "Oh, I have this"
+	line "for you too."
+
+	para "It's a Pocket PC!"
+	done
+	
+AideText_PocketPCInfoText:
+	text "Use this to manage"
+	line "your party."
+	done
```

Now you have a whole script added to get your Pocket PC! This can be added anywhere else you would like instead of here, just make sure it is after you get your starter and make the proper adjustments depending on your chosen map.