How To Add a Pocket PC - pret/pokecrystal GitHub Wiki

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
  2. Add the new function to handle using the PC
  3. Get the Pocket PC from Elm's 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:

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

Edit data/items/names.asm:

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

Edit data/items/descriptions.asm:

 	dw WaterStoneDesc
-	dw TeruSama2Desc
+	dw PocketPCDesc
 	dw HPUpDesc

 	...

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

Edit data/items/attributes.asm:

-; 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:

Replace the old slot:

 	dw EvoStoneEffect      ; WATER_STONE
-	dw NoEffect            ; ITEM_19
+	dw PocketPCEffect      ; POCKET_PC
 	dw VitaminEffect       ; HP_UP

Add the new effect:

        ItemfinderEffect:
	farcall ItemFinder
	ret

+	PocketPCEffect:
+	farcall PocketPCFunction
+	ret

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

 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. This will be done in the 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:

 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:

+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:

First we add the new call to both events:

 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:

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:

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.