Add a new scene script - pret/pokecrystal GitHub Wiki

This tutorial is for adding a scene event to a map. We'll be Using Azalea Gym as an example.

Contents

  1. Define SceneID in WRAM
  2. Define scene_var
  3. Add the Scene to Azalea Gym

1. Define SceneID in WRAM

Azalea Town Doesn't have a SceneID yet, so we need to define it. Edit ram/wram.asm:

INCLUDE "constants.asm"

INCLUDE "macros/wram.asm"
...
wMobileTradeRoomSceneID::                         db ; d9bf
wMobileBattleRoomSceneID::                        db ; d9c0
+wAzaleaGymSceneID::                              db ; d9c1

-	ds 49
+       ds 48

If you add more Scene Ids in the future you'll have to decrement the number after ds accordingly. This allows the game to keep track of which scene the map has.

The ds is the unused space in this section. Each scene id takes one.

2. Define scene_var

Edit data/maps/scenes.asm:

scene_var: MACRO
; map, variable
...
	scene_var MOBILE_BATTLE_ROOM,                          wMobileBattleRoomSceneID
+	scene_var AZALEA_GYM,                                  wAzaleaGymSceneID
	db -1 ; end

This associates the scene ID with the map. You first list the map constant then the scene ID.

3. Add the Scene to Azalea Gym

Edit maps/AzaleaGym.asm:

	object_const_def ; object_event constants
	const AZALEAGYM_BUGSY
...
AzaleaGym_MapScripts:
	def_scene_scripts
+	scene_script AzaleaGymSlowpokeScene, SCENE_AZALEAGYM_SLOWPOKE
+	scene_script AzaleaGymNoop1, SCENE_AZALEAGYM_NOOP

	def_callbacks

+AzaleaGymSlowpokeScene:
+       end
+AzaleaGymNoop1:
+       end

You define the scenes at the top of a map by specifying the script and then the ID you want to assign to that scene. The first scene in the list is the default one. Anything in the script will activate by default on the map load. Most commonly you will use scenes for coord_events instead. Look at various maps within pokecrystal that have scenes already in order to see some examples of how they can be used.

That's it! Now you can use these scenes for a Coord event.