Writing an outdoors script

Just like with town scripts, we need to tell the Editor which script to use for this outdoors section. Click on Outdoors > Outdoor Details...

[IMAGE]

... then set the section script to be o00cavern. The convention for outdoors script names is "o(X coordinate)(Y coordinate)name". Since we just have one outdoors section, both coordinates are zero. Set the section name to be "Cavern" while we're at it; this is the name that will be displayed to the player.

[IMAGE]

We're going to have a group of goblins wait for the player on the bridge, so let's create a special encounter rectangle just before it. Just like we did in the merchant's tunnel, click the "Create Special Encounter" button and create a rectangle with state 10.

[IMAGE]

Now we just need to write the script. Create a new file in the scenario directory called o00cavern.txt, and copy the following:

beginoutdoorscript;

body;

beginstate INIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
  if (get_flag(100, 0) == 0) {
    set_flag(100, 0, 1);
    message_dialog("There is a group of jeering goblins guarding the bridge. Maybe one of them has the necklace?", "");
  }
break;

Again, this works just the way our town script did. State 10 displays a message only once thanks to the SDF. Normally, the first number of a SDF is the town number; we'll have our outdoors SDFs be at 100. Don't forget to update your notes file!

100: Cavern
  0: Seeing the bridge goblins (state 10)
    0: Haven't seen
    1: Have seen

Now let's work on those goblins.