Add a new spawn point - pret/pokecrystal GitHub Wiki
This tutorial is for how to add a new spawn point for Fly, Teleport, whiting out, etc. We will continue off of the Global Terminal map we created in the map and landmark tutorial.
First, define two new constants in constants/map_data_constants.asm:
; johto
const SPAWN_NEW_BARK
...
const SPAWN_GOLDENROD
+ const SPAWN_GLOBALTERMINAL
...
; johto
DEF JOHTO_FLYPOINT EQU const_value
const FLY_NEW_BARK
...
const FLY_GOLDENROD
+ const FLY_GLOBALTERMINAL
Then, edit data/maps/spawn_points.asm:
SpawnPoints:
...
spawn GOLDENROD_CITY, 15, 28
+ spawn GLOBAL_TERMINAL_OUTSIDE, 8, 10
The first value is the map to spawn at, and the latter two values are the coordinates of the spawn point. This is similar to map objects, warps, etc.
Next, edit data/maps/flypoints.asm:
Flypoints:
...
; Johto
...
flypoint GOLDENROD, GOLDENROD_CITY
+ flypoint GLOBALTERMINAL, GLOBAL_TERMINAL
Then, modify constants/engine_flags.asm:
...
; wVisitedSpawns
const ENGINE_FLYPOINT_GOLDENROD
+ const ENGINE_FLYPOINT_GLOBALTERMINAL
Next, modify data/events/engine_flags.asm:
EngineFlags:
...
; fly
...
engine_flag wVisitedSpawns, SPAWN_GOLDENROD
+ engine_flag wVisitedSpawns, SPAWN_GLOBALTERMINAL
Finally, edit maps/GlobalTerminalOutside.asm:
...
def_callbacks
+ callback MAPCALLBACK_NEWMAP, .Flypoint
+.Flypoint:
+ setflag ENGINE_FLYPOINT_GLOBALTERMINAL
+ return
These last three changes allow the player to fly to the Global Terminal after they reach it on foot.