Trap =

By Joris Dormans (November, 2022)

This is a blog about our development of Unexplored 2: The Wayfarer's Legacy. This game features state-of-the-art content generation, generative storytelling, emergent gameplay, adaptive music, and a vibrant art style.

The past few weeks I have been working on improving traps and hazards in Unexplored 2. And if you know me a little, you should know that I like to approach this type of thing from a structural perspective: I like to distill generic components and focus on the various ways in which they can be connected. A structuralist approach plays very well with the content generation we do in Unexplored 2, but hopefully it also allows you to apply these ideas to other games quite easily.

The traps and hazards we had in Unexplored 2 definitely could do with a little love. They were mostly designed in isolation and pretty early during development. Reed Lockwood's recent talk for Roguelike Celebration prompted me to have a fresh look at them again. It nudged me in the right direction, but also Brian Walker's approach with 'machine rooms' in Brogue should be mentioned as a direct inspiration, even if I researched that years ago.

Filled with generated ruins to investigate, Unexplored 2 is an excellent vehicle for sophisticated traps.

Trap = Trigger + Hazard

The first thing you have to consider is that a trap is not a single component. It actually consists of two things: a trigger and a hazard. Even when they are directly related it really helps to design and consider both components individually. It was actually the biggest mistake I made when I was first adding traps during the early development of Unexplored 2: I quickly cobbled together an invisible pressure plate that would explode when you step on it. And for some reason we never reconsidered its design until recently.

It is a lazy and poor design. It doesn't create interesting situations and it basically feels very unfair: how was the player supposed to know it was there in the first place? Lockwood called out exactly this design as flawed. To my defense, it's actually quite surprising how often you see them. Sure there might be a place for a trap like that, but simply throwing them into generated rooms at random is a very bad idea.

In this case the trigger is exactly the same thing as the hazard. They are both invisible, and once triggered, the hazard deals immediate damage. Considering the trigger and the hazard in isolation and having a closer look at their individual attributes really helps improve this design.

An early trap design in Unexplored 2, at least in this case the trigger wasn't hidden...

The first design rule should be: the trigger may be invisible or the hazard may be invisible, but they cannot be both. A simple improvement on this design is to simply make the pressure plate obvious, but leave the hazard invisible. Another would be to make the hazard visible, and here it helps to separate the trigger of the hazard: what if hazard is a clearly visible magic turret that dominates a dungeon room? At least its presence may make the player aware of the possible presence of a hidden trigger.

There are more attributes of the trigger and the hazard to consider here. How quickly does the hazard activate after triggered for example? If the turret takes time to power up before firing you at least give the player a chance to avoid the hazard after triggering it. In fact, maybe, just maybe, you can get away with an invisible trigger and an invisible hazard, but only if the hazard does not trigger instantly. The tables below list some important attributes of both triggers and corresponding hazards.

Trigger Attributes
Visibility Is the trigger visible or invisible? Is it partly hidden? Can the player perform actions to reveal hidden triggers?
Avoidability Can the player avoid the trap? Can they jump across it, or does moving slowly prevent it from triggering?
Times How many times can the trigger activate the hazard? Once? A fixed number of timers? Or can the hazard be triggered indefinitely?
Cooldown If a trigger can be activated multiple times, is there a cooldown period in which it cannot be triggered?
Delay When triggered does hazard trigger immediately or is there a delay?
Activation Time Once triggered, how long does it activate the hazard? Indefinitely or only for a specific period?
Reversibility Once triggered, can the trigger and the hazard it triggers be deactivated?
Readability Are any indications near the trigger that allow the player to predict what might be triggered?
Tinkering Does the trigger allow the player to tinker with it? Is it possible to disarm the trigger? Or to modify it in such a way that it can only be triggered by enemies?

Hazard Attributes
Visibility Is the hazard visible or invisible? Is it partly hidden? Can the player perform actions to reveal hidden hazards? When it activates is the visibility affected?
Delay Once activated, is it active immediately or does the hazard need time to 'warm up'?
Threat What is the nature of the threat? Does it cause damage? Does it blind the player or impose other negative status effects? Does it summon or alert enemies?
Period Once activated, is it constantly causing a threat or is the threat periodic somehow?
Tinkering Is it possible to tinker with the hazard? Can it be disarmed? Or changed in a way that it only affects enemies? Can this be done when it is activated or when it is not activated?
Progressive Does the threat increase or decrease every time the hazard is triggered?

When designing triggers and hazards it is important to be aware of these different attributes and the different affordances they have. In general it is best to have a wide range of triggers and hazards that each have a unique combination of characteristics. For example, the humble, hidden pressure plate might be barely visible, can be avoided by jumping, triggers every time it is stepped upon, but might be tinkered with by leaving weights on top of it. In contrast, a tripwire can only be triggered once, but might be disarmed when spotted. Or a motion sensor can be triggered multiple times, but can be avoided by moving slowly.

Obviously these are just starting points, and you can be creative in finding features that can act as triggers and hazards. For example in Unexplored 2 we have a hazard called Shard Devils, which only appear if there is enough wind. In that case any feature that allows the player to create sufficiently strong winds could act as a trigger to the trap. As the Shard Devils are initially invisible, it would be best that this trigger is not invisible.

Triggers and hazards are often found near each other. In general this is wise because it effectively communicates their cause and effect relationship. But they don't need to be. You could put the trigger at some distance, although in this case it is probably best if you encounter the dormant hazards before you have a chance of activating the trigger, and you probably still want to make sure the player understands a trigger has been activated and what effects it caused.

A hidden trigger activated a periodic hazard, creating an interesting situation instead of dealing instant damage.

Trap = Trigger + Hazard + (Distraction)

Triggers and hazards are not the only components that can be used to build traps. Traps often have a component that I call a 'distraction' which purpose is to divert the player's attention away from potential danger they find themselves in.

A distraction could be as simple as a reward item placed on or near a barely visible trigger. Or another feature that distracts the player simply by its presence. For example, in the past I have used a sign post reading 'beware of traps' close to hidden triggers. If the player needs to get close to be able to read the sign, it becomes an effective and ironic distraction.

Sometimes minor, active hazards or enemies could also act as distractions. For example a small flying creature in a room filled with hard to see pressure plates will likely make the player quite ignorant of the potential danger.

A final type of distraction are other triggers. An obvious sensor might distract a player from spotting a tripwire. The distracting trigger might even be a false trigger; it does not need to trigger anything, really. Then again, the additional trigger could trigger the same hazard, or be part of a completely different trap.

Trap = Trigger + Hazard + (Complication)

Traps get more interesting by adding complications. One of the reasons the hidden pressure plate setting of an explosion is a poor design for a game is that everything happens instantly and the whole set up is pretty singular. As far as the purpose of the trap is concerned this design is pretty effective. But as game designers we are in the business of challenging players, not of stopping them as best as we can. Adding complications is a good way to spread out the trap over space and time. This allows you to use components that are less lethal individually, but which combination can still be quite deadly. The difference is that the result will likely feel more fair and more engaging.

A simple example would be a vent that spreads blinding smoke when you enter a room. In itself this is not immediately threatening, but if the room also contains lethal spikes, or if the vent also summons creatures that are immune to its effects it becomes a completely different scenario.

Complications do not need to activate at the same time, they can be activated later in which case they can cause an interesting escalation. Traps that escalate create a much more dramatic experience. For example, a trap activates a magic turret that periodically hurls magic missiles at the player also starts filling the same room with poisonous gas 5 seconds later is more interesting than the same trap that would do all those things at the same time.

Swirling dust devils that cause blindness are more dangerous near spiked plants.

Trigger = Trigger + (Pressing Need)

Triggers can be made so that the player triggers them purposefully. This can be done to add a pressing need for the player to do this. For example a lever that activates a hazard needs to be pulled in order to open a door. Pressing needs often are ways of dealing with a barrier or another trap. The effect is that the player trades one bad thing (not satisfying the need) for another (activating the hazard).

Pressing needs offer interesting ways to create cascading effects. In Unexplored 2, some hazards can also double as triggers. Automata are one example. They are fixed, hazardous features that can deal damage periodically. The play can also hit them to deactivate them, and doing so might actually open a door. This can create the pressing need for the player to activate these hazards deliberately in order to be able to progress beyond the door the automata control.

Pressing needs can also introduce triggers that are introduced by the player themselves. For example the aforementioned shard devils could be triggered by the player casting a wind spell because they needed that spell to deal with another barrier or hazard.

A recently added trap that the player needs to navigate in order to progress.

Trap = Trap + (Tool)

Another way of making traps more interesting, and more fair, is by introducing tools for the player to deal with the trap. These tools could be rewarded for exploration in the same level, or could be brought by the player. A simple example would be an inventory item that allows the player a (better) chance to tinker with triggers or hazards. Consumable scrolls that freeze a pressure plate in place, or a magic wand that can pull levers at a safe distance, for example.

Tools could help dealing with the trigger or help mitigate the threat posed by the hazard. A potion of fire resistance will make a room engulfed in flames much less impressive. There even might be a hidden switch that prevents a hazard from triggering all together.

Tools can be placed in the same level to reward exploring players. It makes sense that in most cases these tools should be reachable before dealing with the trap, but there are exceptions. If the trap is placed in a location that the player might need to revisit, finding the right tool to deal with it after you activate the trap and before you need to deal with it again can be extra rewarding.

If tools need to be brought by the players themselves, it becomes important that the players actually know what types of triggers and hazards they could expect to encounter so they can prepare accordingly. Such preparation can be pretty satisfactory in and of itself, and acquiring the right tools to deal with a particular dangerous level can even pan out into an emergent quest goal for the player.

Trap = Trap + (Puzzle)

When combined correctly the components can create quite compelling puzzles for the player to deal with. Triggers might be triggered in a particular order to avoid setting off (too many) hazards. Particular combinations of triggers and hazards might afford interesting strategies that can be exploited by players. Solutions that they will need to find themselves. Make sure that enemies suffer the same consequences of traps as the player does, allowing the players to use the traps to their advantage as well.

Other puzzle elements can be introduced by providing hints about how to deal with dangers. If there is an audio clue that helps you find the right sequence to strike a number of gongs, for example, a good 'tool' would be to leave a note or inscription somewhere for the player to find explaining this. In general, some redundancy in the clues you provide won't do you any harm, and will make the level feel much more manageable.

An effective way of creating puzzles that still require some wit while you solve them is to use a type of hint I refer to as a 'code book'. Instead of spelling out what the player needs to do, a code book describes a number of possible signals and links those to a particular solution. For example, a code book may read something like: "If the room before the door has a red carpet, the lever on the north wall deactivates the turrets and opens the doors. If the carpet is green, it is the lever on the south wall."

You could even have a code book that involves signals that are not revealed until the trap is set off: "If the incantation summons skeletons, then..."

For me this type of code book hint has the huge advantage that they work really well in generated environments, the code can easily be reshuffled as needed. In addition, even if the player has seen the type of puzzle before they cannot know the exact answer until they start interacting with it.

Trap = Trap + (Trap)

Expanding the components that make up your traps beyond triggers and hazards, and spreading them out through time and space can quickly spiral into large complex structures. Especially when you realize you can keep connecting traps and components in many different ways: traps can include or trigger other traps. There is nothing stopping you from applying these rules recursively so in theory the possibility space is infinite.

It is still something of a personal holy grail, but I think when done right all this can create levels that need to be diffused like a time bomb. Either by design or because they were generated. Interconnected triggers, hazards, and tools can create a network that allow many different ways of dealing with the hazards, especially when superimposed by varying affordances of character builds and inventories.

In any case, this deliberation inspired me to overhaul the way Unexplored 2 generates traps and hazards. A process that is still in progress, but which already yielded interesting results in the last two updates. If you like to discuss these ideas further you are welcome to message me on twitter: @DormansJoris

Links:

 

Contact: info@ludomotion.com