08 December 2010

Zelda Forest Maze Tutorial - RMXP/VX

Zelda Maze Demo RMXPEDIT (9 Dec 2011): Demo now available. Checked for viruses using Comodo Antivirus.

Continuing with the Fun With Variables theme and as an expansion to the Simple Event-Based Random Teleport tutorial, here's something a little different. It's designed for RMXP but can also be adapted work on RMVX (though not the same way on RM2K3 without some tweaking).

For those of you familiar with the "infamous" Forest Maze in The Legend of Zelda (for the NES) will know all about it. For those unfamiliar with it - shame on you for not playing this classic! - the aim is to find your way through the forest using specific directions. If you don't, you'll just be wandering aimlessly and won't find your way out. That's the foundation of this tutorial.

This is a rather long, but not overly complex, tutorial, so take the time to read it and go through step by step as necessary.

Pre-Setup

To begin, we'll need the following:

  • 4 Variables: 0001: Randomize, 0002: Map ID, 0003: Coord-X and 0004: Coord-Y.
  • 1 Common Event: Teleport
  • 2 Maps: Maze Map and Congratulations!
  • At least 5 events for the map, although I've used 9 in total (some just for effects).

Maps Setup


Map 1
Click the image for a larger view (opens in a new window)
Let's set up the two maps first. Both maps are set at their minimum sizes, 20x15. For the first, Maze, I used the "Forest" tileset and drew a 9x9 grassy square roughly in the centre of the map, then placed a stone-path cross in the centre of that. In each of the corners, I used the tree graphic overlapping onto the "blank" parts of the map. And finally, placed the "Starting Position" directly in the centre of the cross.


Map 2
Click the image for a larger view (opens in a new window)
For the second map, which is where the player will be transported after successful navigation through the maze, I used a homey farm scene, although of course it can be anything.

The only thing on this map (for this tutorial) is a single "Autostart" event. In the Event Commands, place a congratulations message and an "Erase Event", something like this:

@>Text:CONGRATULATIONS!
 :   : You've escaped the maze!
@>Erase Event


That's it for the basic map setup. Let's now go back to the first map and start creating the events.

Events Setup

On Map 1 then, create an Autostart event with 2 pages. On the first page, set the "Trigger" to "Autorun", then in the Event Commands, place the following:

  • Set the variable Dir Num to 0.
  • Set the variable Map ID to 1.
  • Set the variable Coord-X to 8.
  • Set the variable Coord-Y to 7.
  • Finally, turn Self-Switch A to ON.

On Page 2, just check the "Self-Switch" (set to A) under "Conditions", keeping the Event Commands blank.


Map 2
Click the image for a larger view (opens in a new window)
Next, we'll be creating several events, but leaving them blank for the time being. Make a note of them, as we'll be editing them one at a time. These are for the directions and decorations. There isn't really a need for the decorations, but it does add a little something to the maps, changing them imperceptibly but without needing to create a separate map and transfer to that map. It also gives the observant player an indication they he or she is on the right track, otherwise the map remains the same.

The events we need to set up are as follows:

  • Create a Teleport Common Event.
  • Place an event, Directions, with an appropriate graphic (such as a signpost or NPC), somewhere on the map.
  • Somewhere on the map, place two events, Stump L and Stump R. On the Forest tileset are two tree stumps (used in this tutorial). For the default stump graphics I used the left and right ones on the top for these two events.
  • Somewhere on the map, for another event, Mushrooms, I also used the tileset for the clump of mushrooms graphics.
  • Finally, create 4 events the ends of each path at the cardinal points, naming them North, East, South and West.

It's time to go through each event, one at a time, and set them for our one-map maze routine.

Priming The Events

We'll go through each event, one by one, according to the placement above to make things run more smoothly.

Common Event
   In the Database, create a Common Event, which we'll name Teleport for convenience, with the "Trigger" set to "None". In the Event Commands, only one line is necessary: "Transfer Player", with "Appoint With Variables" set at Map ID, Coords-X and Coords-Y for "Map ID", "Map X" and "Map Y" respectively. It might also be a good idea to set the "Fading" to "No" to allow for smoother transitioning.

Directions
   We'll start by editing the Directions event, which will contain a message giving directions, in this case our directions are: "North, South, North, North, East, West". We'll be placing the message box in a Conditional Branch, however. Thus:

@>Conditional Branch: Variable [0001: Dir Num] == 0
   @>Text: North, South, North, North, East, West.
@>: Branch End

Create another blank page, then under "Conditions" set the "Variable" to "0001: Dir Num" which is "1 or above", with a blank Graphic in place.

This will check whether Dir Num is set to zero. If it is the signpost/NPC graphic will remain visible. If it's 1 or above, the graphic will disappear. (Notice we did not use a Switch here, but instead primed the variable. This is because the graphic will disappear once the player has chosen the correct first direction, otherwise it will still appear on-screen.

Stump L
   Create two more new pages and, leaving the first page blank (with the left stump graphic intact), on Page 2 under "Conditions" set the "Variable" Dir Num to value "2". Let's change the graphic to something else, say, the mossy left stump instead.

On Page 3, do the same but set the Dir Num value to "4" and perhaps we can set the graphic to the left portion of the horizontal log (from the Forest tileset).

What this will then do is change the ordinary stump to a mossy one if the number of correct directions is 2 (we'll add 1 to Dir Num each time the player has gone in the correct direction according to the "Directions" signpost or NPC - that comes later though) and if the player has chosen 4 correct directions, it'll change to a log.

Stump R
   This is the same as with "Stump L", but with the all of the right-hand sides of the stump and log. Make sure the Dir Num values are teh same as Stump L's, otherwise you'll get some odd-looking stumps!

Mushrooms
   As with the "Stump L" and "Stump R" events, we'll need to add a value to "Variable" Dir Num, setting it to, say, 5. There's no need for additional pages here; it will automatically trigger when the correct number of directions equals 5.

This brings us conveniently onto the next set of events. The easy part is done, but now the fun really begins!

Directional Events

The idea of these directional events is to, not only check for the correct direction in sequence, but also to transfer the player to the opposite end, as though the player is walking north and emerging south, and vice versa.

In each of our "directional events" - the North, East, South and West ones we created and left blank earlier - there will be several Conditional Branches used, which can be quite confusing at times, especially if they're "nested".

Now, if we remind ourselves of the correct route through the maze - North (1), South (2), North (3), North (4), East (5), West (6) - to make things easier, we'll realise that the player must go up, down, up twice, right then west, before successfully making it out again. The numbers in the brackets are the order in which the directions must be followed (stored in Dir Num).

Each of these directional events should also have their "Trigger" points set to "Player Touch".

So, starting with the North event, let's set it up so that if the player goes North the first, third and fourth times, a "success" sound will play and the player will be transported to the opposite end (South end) accordingly.

On our map, the coordinates are (X8,Y11) for the southern exit (on top of the "South" event), which we'll be using for the variables Coords-X and Coords-Y. In the Event Commands, place these commands first, above the Conditional Branch.

Next, create a "Conditional Branch", with the "Variable" Dir Num "Equal To" zero (which, if you remember, we set up as default in the very first event we created for this map). Make sure the "Else" (i.e. "Set handling when conditions do not apply") is also checked.

Under this first branch, The first command is "Play SE" and choose an appropriate sound effect to indicate a correct direction. I chose "Right02" for this tutorial. Add 1 to the variable Dir Num. Copy this Branch Condition and paste it below the first "Else", changing the variable condition to 3. Copy again and paste again, this time below the second "Else", changing the variable condition to 4.

Finally, at the very bottom we need to insert a "Call Common Event" command, set to the "Teleport" Common Event we created earlier. And that's it for this event.

This is pretty much the same routine throughout these directional events when determining correct paths through. The only difference is they have only one Conditional Branch instead of three, primarily because to get through the maze you'll have to go North three times. The only things we'll need to change are the XY coordinates and the Dir Num values.

The second direction was South, so in the Event Commands of the South event, you should have the variables for the X and Y Coordinates set to 8 and 3 respectively, and a Conditional Branch with Dir Num set to 2. At the end is the "Call Common Event" again, set to "Teleport".

In the East event, the X and Y Coordinates are 4 and 7, and Dir Num is set to 5.

Finally, onto the West event. This is essentially the same - X and Y Coordinates and Conditional Branch - but with a few differences. Dir Num in the Conditional Branch should be set to 6, with the "Else" box also checked. Under the "Play SE" command, place a "Transfer Player" command going to the second, Congratulations map we created. And finally, under the "Else", we'll need to add the Teleport Common Event call.

Once that's done, the final test is playtesting. If you did it right, you should hear a sound when you go N, S, N, N, E and W and each time you should notice some changes on the map.

Additional Notes

This is just a simple maze tutorial in the same vein as the Forest Map in Zelda. You can make it more complex by adding more directions, following the same basic rules: For each correct direction, another Conditional Branch must be implemented with the Dir Num adjusted accordingly. For larger maps with additional teleporters, the same rules also apply.

I'll create a demo of this tutorial for both RMXP and RMVX in time as well.

0 Comments So Far:

Post a Comment

Related Posts with Thumbnails
Template Design "Perfect World" by SkinCorner