Eventing Spike Traps for Dungeon Floors
hiddenone
by
hiddenone
on
August 3, 2021
August 3, 2021

Eventing Spike Traps for Dungeon Floors

Eventing Spike Traps for Dungeon Floors
by

hiddenone

on

August 3, 2021

Game dungeons are almost always full of monsters, but sometimes that’s all they have to challenge the player. Additions like puzzles and traps can turn a simple map into an exciting dungeon to explore, so let’s take a look at one type of trap we can add to our dungeon floors: spike traps.

The simplest version of a spike trap damages the player when they step on it. There are tons of ways we could make it hurt the player when they step on a spike trap, from adding a bleeding state to poisoning them or even killing characters with low HP, but for all these examples we’ll keep things basic and just remove some HP.

Trap 1 - Simple Switch-controlled Spike Trap

Our first trap will be straightforward. When the player steps on the spikes they will stab up and hurt the player. The player can stop this from happening by activating a nearby switch, making it safe to walk over the trap.

So we’ll need two events to make this work: the spike trap event and the switch event. While not necessary to make the trap work, including a treasure beyond the spike trap is a good way to make sure your players will actually try to find a way around the spike trap.

For our spike trap event, it will need two pages. The first page is where all the damage happens, so we need to set the page’s Priority to ‘Below characters’ and the Trigger to ‘Player Touch’, so that it will activate as soon as the player steps onto the event. The event will be made up of mostly move routes, to show the spikes pop out of the floor and then go back down. Because we’re using the default spikes from the !Other1 sheet, we show the spikes simply by having the event turn in place with a short wait between each turn so that it’s visible to the player. Then we just need to include a Change HP command to remove some of the party’s health, and our spikes work!

Well, they’ll mostly work. There is an issue if we leave it with just move routes for the spike trap: the player will be able to just walk over it to get past it! To stop that from happening, we need to include one more move route to have the player move 1 step backwards so that they are back to being in front of the trap.

While not needed to have the spike trap work, we can also include a sound effect and exclamation balloon over the player so that it’s obvious stepping on the trap is a bad thing.

The second page is only active when the trap switch is On, and is simply the holes in the floor with no contents so the player can safely pass by.

With the spike trap ready, we need to make the switch event next. It also needs two pages, one where the trap switch is turned On and one where it’s turned Off. A simple sound effect and move route to have the switch turn in place to change its position from up to down (or down to up) on each page makes the switch look like the player is really flipping it is the only extras the event needs.

All that’s left is to playtest and make sure it works in-game! The switch could affect multiple spike trap events in a dungeon, offering the player an easy path back to the entrance or new rooms to explore after the boss is beaten.

Trap 2 - Making Multiple Traps Move Together

Now that we know how to make a single spike trap, let’s move on to making a different type trap: multiple spike traps blocking the player’s path. When we flip the traps’ switch, all of the spike traps will lower into the floor so that the player can safely walk by.

To do that, we’ll need a few events: as many spike trap events as we need and one switch event that will control all of them.

Our spike trap events need two pages like in our first trap, the first page where they’re up and in the way and the second page where they can be walked over once the trap switch is On. Since each trap will act the same, we can copy-paste them to put them everywhere we want them (we just want to make sure to edit their names slightly so we can tell which event we’re working on in the future).

For this example our trap events don’t do anything, but we could add in some HP damage or a comment from the party about needing to find the switch to page 1 if we felt like it.

Our switch event is where all the action happens. It not only turns the trap switch On/Off, but it also makes the trap events sink into the floor by having them turn in place in move routes. To make them all move at the same time, we want to make sure that the Wait option in the move route is only checked on the last move route in the line.

The switch’s second page turns the trap switch Off and has the spike traps all pop back out of the floor.

Now, the above method works fine for controlling a couple of events at once, but what happens if we wanted to change a bunch of trap events at once?

We could still do it with move routes, but that will lead to crazy long event pages! Instead, let’s take a look at how we can use some script calls to simplify things.

Before we get to the script calls though, let’s set up our trap events. While we could keep using spikes for this, how about we mix it up and use flames from two different sprite sheets? When the switch is Off the first page will show a huge flame and when the switch is On the second page will show a tiny bit of smoke.

Once our first flame event is ready, we can copy-paste it all over. There is an important thing we need to keep in mind however! The script calls we’ll be using work best when all the events are sequential, so we need to make sure that all of our flame events are in a specific range. In my case, they make up events 9 through 24.

Now we can get to our switch event. It’ll have a similar layout to the switch event above, but instead of the move routes for the trap events we’ll be using a few script calls. The basic code we’ll be using to affect all our flame events at once is:

for (var id = min; id < max + 1; id ++){

$gameMap.event(id).whatever code we need;

}

Where min is the first event in the bunch (9) and max is the last one (24). Then we can just put id into the event script calls so that each event between 9 and 24 will run the same code. Unfortunately only one wait script call will run per script event command, so we’ll need to use multiple scripts with wait commands between them. But it still will be much shorter than using move routes.

So for our page 1’s first script, we need to first turn off direction fix and turn the flames to face left (shrinking the flames), which looks like this:

for (var id = 9 ; id < 24 + 1; id ++){

$gameMap.event(id).setDirectionFix(false);

$gameMap.event(id).setDirection(4);

}

A  5-frame wait comes next, and then the script to have the events turn right to show an even shorter flame:

for (var id = 9 ; id < 24 + 1; id ++){

$gameMap.event(id).setDirection(6);

}

Another wait, and we can have the events turn up to show a small amount of fire:

for (var id = 9 ; id < 24 + 1; id ++){

$gameMap.event(id).setDirection(8);

}

All that’s left is a final wait and then turning the trap switch On, which will change all the flame events to their second page, where the smoke shows.

Our switch’s second page will make the flames rise back up from the floor, so the script calls will be pretty similar to the first page. The notable exception is the first call, where we need to also change the events’ sprite to the flame in the !Other2 file. To do that we’ll need to use the code $gameMap.event(id).setImage("filename", index); , where filename is replaced with the sprite sheet’s name and index is a number between 0 (which is the upper-left sprite in a sheet of 8) to 7 (the lower-right sprite). We also need to turn the direction fix off, so our first script call looks like this:

for (var id = 9 ; id < 24 + 1; id ++){

$gameMap.event(id).setDirectionFix(false);

$gameMap.event(id).setDirection(8);

$gameMap.event(id).setImage("!Other2", 3);

}

Then we can just change the direction to face right, wait a moment, face left, wait again, and then turn the trap switch Off so that the flame events all go back to the first page with the tall flames.

With the script calls set up, we can playtest and see all the traps change at once! If a few flame trap events are not changing properly, make sure to check that they weren’t added later (meaning they’re not in the script call’s id range). If you do need to add more trap events later, you’ll need to also add more script calls to cover that range of events.

And now we know how to add some new traps to our dungeons. This is just the tip of floor trap possibilities, so if you’d like to see a part two covering more options make sure to let us know!

Recommended Posts

footer-map