TRAP AND TRAPFINDING SYSTEM

A relatively easy to create trap system using Random Number Generation

  • pianotm
  • 01/20/2021 11:45 PM
  • 1957 views
Trap Setting

THIS TUTORIAL ASSUMES THAT YOU UNDERSTAND BASIC EVENTING AND IF I TELL YOU SOMETHING LIKE, CREATE A MOVE ACTION, YOU WILL KNOW WHAT I'M TALKING ABOUT.

Should work with all RPG Makers. When making traps in any game setting, there are specific questions that need to be asked.

1. Where are the traps?
2. Are the traps detectable?
3. Can they be disabled?
4. Can they be avoided?
5. What happens when they're triggered?

For this tutorial, we'll assume that questions 2, 3, and 4 are all answered “yes”. Traps are extremely simple to make. Ideally, they should be placed on a path in such a way that they cannot be bypassed without finding another route. For gameplay purposes, consider making it impossible to progress without encountering the trap. There are plenty of variations on making a trap. I'm going to show you the method I am currently using.

It requires two events: the detection event, which is the point on the map in which your protagonist will either see or fail to see your trap, and the second is the trap itself.


Corridor with trap.


In this first image, I show how a standard trap setup. At the top is the transfer event for another map. If you want to get to that map, you're going to have to get by my trap, Mr. or Mrs. Protagonist! It's not as easy as it sounds! For this tutorial, I've limited you to the mercy of the Random Number Gods! Your skills mean nothing! Success or failure is entirely predicated on how the dice land! Mwahahahaha!!!
But you will need two variables and four switches, if you dare! You will also need a fifth switch if you want to use the optional enhancement item, but you'd be a fool to try, mortal!

Variables:
1. Random Number
2. Trap Damage
Switches:
1. Trap Spotted
2. Trap Found
3. Trap Not Found
4. Trap Disabled
5. (Optional) Rogue Kit

The Optional Item
For this method of adding a trap finding/disabling bonus, this has to be a found item, there should be only one example of it, and finding it should be set to activate the Rogue Kit switch. There are likely better ways of doing this, but this was just the really easy way I came up with that most directly works with the laid out trap finding and disabling method.

Spotting the Trap
Let's start with the bottom event; the Trap Detection event. This is painfully simple, it's a single switch.
1. Set the first page to Player Touch in the trigger condition.
2. The event priority should default to “below characters”, but just check to make sure it's set to that.
3. In contents, create a switch, and call it Trap Detection or whatever you like.
4. Turn Trap Detection on.
5. Create a second page that is triggered by Trap Detection, and forget about it.
This is exclusively seeing if you detect the trap or not. How that is done is going to be in the trap itself.


And the next page is blank.


Before Setting the Trap
In Age of Myth, I currently had seven traps placed before I decided to create an item that grants a bonus to trap finding and disabling. The item cannot be purchased and only exists in a single location, so I simply turned on a switch upon finding the item. This meant altering my trap detection parameters. I will include that in the tutorial so that you don't find yourself having to go back and make sure all of your traps are corrected like I did. Again, there's a few ways to do this, but I decided that my trap system is simple enough that I didn't want to tie this item to another conditional branch. I basically didn't feel like rewriting the events.

Setting the Trap
Time to work on our trap event.
1. Create a new event and set its trigger to Parallel Process.
2. Set your first page to be activated on Trap Detection. This way, the parallel process doesn't run the second you enter the map.
3. In contents, create a variable called “Random Number”. You will be able to use this for every trap, and anything else that needs a random number generator.
4. In this event, tick Set in Operation, and for Random, choose 1 through 4.

Creating your Random Number Generator.


5. After creating the Random Number variable, create a conditional branch.
6. In this conditional branch, tick “variable” and select your Random Number variable. Set it as Equal to 1. Untick the condition handling box at the bottom.

Setting your trap detection method.

7. Copy and paste this three times so that you have four conditional branches.
8. Set the other four to 2, 3, and 4 respectively.
9. In the first, create a message that you've found the trap! Then create a switch called “Trap Found” and turn it on.
10. In the next conditional branch create a switch named “Trap Not Found” and turn it on. In the two remaining conditional branches, copy paste your Trap Not Found switch.

Congratulations! Your protagonist has a 25 percent chance of spotting a trap.


11. Copy this page, and press the Paste Page function.
12. Add your trap finding item switch to the switch triggers for this page as the second switch. Add a conditional branch that successfully finds the trap.

Congratulations! Your protagonist's chance of spotting a trap has improved.


Now, your protagonist is fully capable of spotting the trap. Now, let's figure out what happens. We will start with what happens if the trap is found. Okay, this is a long procedure. If you feel you've missed a step, refer to the event code that I'll be placing below.

1. Create a new page, give your trap a sprite, set it to its untriggered appearance and make sure the priority is set to same as character.
2. Set the Condition to your “Trap Found” switch and set the Trigger to Action Button.
3. Ask your character if he or she wants to disable or find another way, and give them a choice. Obviously, they'll have to choose to disable the trap before proceeding, so put all handling in that choice, and leave the other choice blank.
4. Remember your Random Number variable? Call it and set it once again to 1 through 4.
5. As before, we'll be creating four conditional branches and setting the first one as our success handler. So let's get into that one.
6. You want something to happen once the disable attempt is made, so in your success handler, simply create a move action that sets the trap to through on and another move action to move the character up and onto the trap. You might also consider awarding them experience.
7. Create a switch called “Trap Disabled” and turn it on.
8. The remaining conditional branches are our failure handlers and they will all have identical commands.
9. Again, move the character up and onto the trap, but this time, create a move action for the trap to change to its triggered sprite, and move the player back off of the trap.
10. Since this is on the same page, paranoia has me always making a new random number variable. Name this one Trap Damage and set it to 0 through 4 (the 0 is because I also give the character a chance to dodge the trap and avoid taking damage. This is entirely up to you.).
11. Create five conditional branches looking for the Random Number variable, equal to 0 through 4.
12. In Conditional Branch 0, simply give a message saying that the character dodged.
13. In Branches 1 through 4, Change HP: Entire Party: -1 through -4.
14. Set the trap to through on and turn on your “Trap Disabled” switch.
15. Copy paste this whole process in the remaining Conditional Branches.

Your Protagonist's health depends on success or failure.


16. As previously, you can copy paste this page to create a new handler for special trap finding item.

We'd all like an improved chance at avoiding damage, wouldn't we?


Now that we've figured out what to do if you find the trap, what happens if you don't find the trap? Well, what would you see if you didn't find something? Absolutely nothing so if your random number generator doesn't find the trap, the player should have no indication that the trap is there until they've stepped on it.

1. Create another page and make the Condition your Trap Not Found switch.
2. For this, you can simply copy paste the conditions of one of your failed conditional branches from the previous page.

Of course, just not spotting the trap isn't very good for your Protagonist, either.


3. Create one last page, and set its condition to your Trap Disabled switch. Make sure its priority is “Below Characters” and that it is set to action button. Leave this page empty. The trap is set.

Alright. To make sure you've got this straight, I am placing the contents of the events below for reference. Apparently, placing this within a hide tag was not an option. I am terribly sorry about that. But, the two events are divided into quotes so they can be distinguished from each other.

Detection Event:
Page 1: Player Touch, Below Characters.
Conditions: none
@> Control Switches: [0001:Trap Spotted] = ON


Page 2: Action Button, Below Characters.
Conditions: Trap Spotted is ON.
Contents: Empty


Trap Event:
Page 1: Parallel Process, Below Characters
Conditions: Trap Spotted is ON.
@> Control Variables: [0001:Random Number] = Random No. (1...4)

@> Conditional Branch: Variable [0001:Random Number] == 1
@> Text: YOU'VE SPOTTED A TRAP!
@> Control Switches: [0002:Trap Found] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 2
@> Control Switches: [0003:Trap Not Found] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 3
@> Control Switches: [0003:Trap Not Found] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 4
@> Control Switches: [0003:Trap Not Found] = ON
@>
: Branch End


Page 2 (OPTIONAL): Parallel Process, Below Characters
Conditions: Trap Spotted is ON. Rogue Kit switch is ON.
@> Control Variables: [0001:Random Number] = Random No. (1...5)

@> Conditional Branch: Variable [0001:Random Number] == 1
@> Text: YOU'VE SPOTTED A TRAP!
@> Control Switches: [0002:Trap Found] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 2
@> Text: YOU'VE SPOTTED A TRAP!
@> Control Switches: [0002:Trap Found] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 3
@> Control Switches: [0003:Trap Not Found] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 4
@> Control Switches: [0003:Trap Not Found] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 5
@> Control Switches: [0003:Trap Not Found] = ON
@>
: Branch End


Page 3: Action Button, Same as Characters
Conditions: Trap Found is ON
@> Text: Attempt to disable or find another

: : way?
@> Show Choices: Disable, Find another way
: When [Disable]
@> Control Variables: [0001:Random Number] = Random No. (1...4)
@> Conditional Branch: Variable [0001:Random Number] == 1
@> Set Move Route: This Event, Through ON
@> Set Move Route: Player, Move Up
@> Wait for All Movement
@> Text: Success!
: : Gain 50 XP.
@> Control Variables: [0016:Leveling] += 50
@> Control Switches: [0004:Trap Disabled] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 2
@> Set Move Route: This Event, Through ON
@> Set Move Route: Player, Move Up
@> Wait for All Movement
@> Play SE: 'Slash9', 80, 100, 50
@> Set Move Route: Player, Direction Fix ON, Jump , Move Down, Move Down, Land , Direction Fix OFF
@> Wait for All Movement
@> Set Move Route: This Event, Turn Right
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up, Turn Left
@> Wait: 0.2 seconds
@> Change Faceset: 'Hero Face 3', 1, Left, No Flip
@> Text: AAAHH!!!
@> Control Variables: [0002:Trap Damage] = Random No. (0...4)
@> Conditional Branch: Variable [0002:Trap Damage] == 0
@> Text: Successfully evaded.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 1
@> Change HP: Entire Party, - 1
@> Text: You take 1 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 2
@> Change HP: Entire Party, - 2
@> Text: You take 2 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 3
@> Change HP: Entire Party, - 3
@> Text: You take 3 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 4
@> Change HP: Entire Party, - 4
@> Text: You take 4 damage.
@>
: Branch End
@> Set Move Route: This Event, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic...
@> Wait for All Movement
@> Control Switches: [0004:Trap Disabled] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 3
@> Set Move Route: This Event, Through ON
@> Set Move Route: Player, Move Up
@> Wait for All Movement
@> Play SE: 'Slash9', 80, 100, 50
@> Set Move Route: Player, Direction Fix ON, Jump , Move Down, Move Down, Land , Direction Fix OFF
@> Wait for All Movement
@> Set Move Route: This Event, Turn Right
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up, Turn Left
@> Wait: 0.2 seconds
@> Change Faceset: 'Hero Face 3', 1, Left, No Flip
@> Text: AAAHH!!!
@> Control Variables: [0002:Trap Damage] = Random No. (0...4)
@> Conditional Branch: Variable [0002:Trap Damage] == 0
@> Text: Successfully evaded.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 1
@> Change HP: Entire Party, - 1
@> Text: You take 1 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 2
@> Change HP: Entire Party, - 2
@> Text: You take 2 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 3
@> Change HP: Entire Party, - 3
@> Text: You take 3 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 4
@> Change HP: Entire Party, - 4
@> Text: You take 4 damage.
@>
: Branch End
@> Set Move Route: This Event, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic...
@> Wait for All Movement
@> Control Switches: [0004:Trap Disabled] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 4
@> Set Move Route: This Event, Through ON
@> Set Move Route: Player, Move Up
@> Wait for All Movement
@> Play SE: 'Slash9', 80, 100, 50
@> Set Move Route: Player, Direction Fix ON, Jump , Move Down, Move Down, Land , Direction Fix OFF
@> Wait for All Movement
@> Set Move Route: This Event, Turn Right
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up, Turn Left
@> Wait: 0.2 seconds
@> Change Faceset: 'Hero Face 3', 1, Left, No Flip
@> Text: AAAHH!!!
@> Control Variables: [0002:Trap Damage] = Random No. (0...4)
@> Conditional Branch: Variable [0002:Trap Damage] == 0
@> Text: Successfully evaded.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 1
@> Change HP: Entire Party, - 1
@> Text: You take 1 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 2
@> Change HP: Entire Party, - 2
@> Text: You take 2 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 3
@> Change HP: Entire Party, - 3
@> Text: You take 3 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 4
@> Change HP: Entire Party, - 4
@> Text: You take 4 damage.
@>
: Branch End
@> Set Move Route: This Event, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic...
@> Wait for All Movement
@> Control Switches: [0004:Trap Disabled] = ON
@>
: Branch End
@>
: When [Find another way]
@>
: Branch End


Page 4 (Optional): Action Button, Same as Characters
Conditions: Trap Found is ON, Rogue Kit is ON
@> Text: Attempt to disable or find another

: : way?
@> Show Choices: Disable, Find another way
: When [Disable]
@> Control Variables: [0001:Random Number] = Random No. (1...5)
@> Conditional Branch: Variable [0001:Random Number] == 1
@> Set Move Route: This Event, Through ON
@> Set Move Route: Player, Move Up
@> Wait for All Movement
@> Text: Success!
: : Gain 50 XP.
@> Control Variables: [0016:Leveling] += 50
@> Control Switches: [0004:Trap Disabled] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 5
@> Set Move Route: This Event, Through ON
@> Set Move Route: Player, Move Up
@> Wait for All Movement
@> Text: Success!
: : Gain 50 XP.
@> Control Variables: [0016:Leveling] += 50
@> Control Switches: [0004:Trap Disabled] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 2
@> Set Move Route: This Event, Through ON
@> Set Move Route: Player, Move Up
@> Wait for All Movement
@> Play SE: 'Slash9', 80, 100, 50
@> Set Move Route: Player, Direction Fix ON, Jump , Move Down, Move Down, Land , Direction Fix OFF
@> Wait for All Movement
@> Set Move Route: This Event, Turn Right
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up, Turn Left
@> Wait: 0.2 seconds
@> Change Faceset: 'Hero Face 3', 1, Left, No Flip
@> Text: AAAHH!!!
@> Control Variables: [0002:Trap Damage] = Random No. (0...4)
@> Conditional Branch: Variable [0002:Trap Damage] == 0
@> Text: Successfully evaded.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 1
@> Change HP: Entire Party, - 1
@> Text: You take 1 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 2
@> Change HP: Entire Party, - 2
@> Text: You take 2 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 3
@> Change HP: Entire Party, - 3
@> Text: You take 3 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 4
@> Change HP: Entire Party, - 4
@> Text: You take 4 damage.
@>
: Branch End
@> Set Move Route: This Event, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic...
@> Wait for All Movement
@> Control Switches: [0004:Trap Disabled] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 3
@> Set Move Route: This Event, Through ON
@> Set Move Route: Player, Move Up
@> Wait for All Movement
@> Play SE: 'Slash9', 80, 100, 50
@> Set Move Route: Player, Direction Fix ON, Jump , Move Down, Move Down, Land , Direction Fix OFF
@> Wait for All Movement
@> Set Move Route: This Event, Turn Right
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up, Turn Left
@> Wait: 0.2 seconds
@> Change Faceset: 'Hero Face 3', 1, Left, No Flip
@> Text: AAAHH!!!
@> Control Variables: [0002:Trap Damage] = Random No. (0...4)
@> Conditional Branch: Variable [0002:Trap Damage] == 0
@> Text: Successfully evaded.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 1
@> Change HP: Entire Party, - 1
@> Text: You take 1 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 2
@> Change HP: Entire Party, - 2
@> Text: You take 2 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 3
@> Change HP: Entire Party, - 3
@> Text: You take 3 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 4
@> Change HP: Entire Party, - 4
@> Text: You take 4 damage.
@>
: Branch End
@> Set Move Route: This Event, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic...
@> Wait for All Movement
@> Control Switches: [0004:Trap Disabled] = ON
@>
: Branch End
@> Conditional Branch: Variable [0001:Random Number] == 4
@> Set Move Route: This Event, Through ON
@> Set Move Route: Player, Move Up
@> Wait for All Movement
@> Play SE: 'Slash9', 80, 100, 50
@> Set Move Route: Player, Direction Fix ON, Jump , Move Down, Move Down, Land , Direction Fix OFF
@> Wait for All Movement
@> Set Move Route: This Event, Turn Right
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up, Turn Left
@> Wait: 0.2 seconds
@> Change Faceset: 'Hero Face 3', 1, Left, No Flip
@> Text: AAAHH!!!
@> Control Variables: [0002:Trap Damage] = Random No. (0...4)
@> Conditional Branch: Variable [0002:Trap Damage] == 0
@> Text: Successfully evaded.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 1
@> Change HP: Entire Party, - 1
@> Text: You take 1 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 2
@> Change HP: Entire Party, - 2
@> Text: You take 2 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 3
@> Change HP: Entire Party, - 3
@> Text: You take 3 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 4
@> Change HP: Entire Party, - 4
@> Text: You take 4 damage.
@>
: Branch End
@> Set Move Route: This Event, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic...
@> Wait for All Movement
@> Control Switches: [0004:Trap Disabled] = ON
@>
: Branch End
@>
: When [Find another way]
@>
: Branch End


Page 5: Player Touch, Below Characters
Conditions: Trap Not Found is ON
@> Set Move Route: This Event, Through ON, Turn Down, Change Graphic...

@> Wait for All Movement
@> Play SE: 'Slash9', 80, 100, 50
@> Set Move Route: Player, Direction Fix ON, Jump , Move Down, Move Down, Land , Direction Fix OFF
@> Wait for All Movement
@> Set Move Route: This Event, Turn Right
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up
@> Wait: 0.2 seconds
@> Set Move Route: This Event, Turn Up, Turn Left
@> Wait: 0.2 seconds
@> Change Faceset: 'Hero Face 3', 1, Left, No Flip
@> Text: AAAHH!!!
@> Control Variables: [0002:Trap Damage] = Random No. (0...4)
@> Conditional Branch: Variable [0002:Trap Damage] == 0
@> Text: Successfully evaded.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 1
@> Change HP: Entire Party, - 1
@> Text: You take 1 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 2
@> Change HP: Entire Party, - 2
@> Text: You take 2 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 3
@> Change HP: Entire Party, - 3
@> Text: You take 3 damage.
@>
: Branch End
@> Conditional Branch: Variable [0002:Trap Damage] == 4
@> Change HP: Entire Party, - 4
@> Text: You take 4 damage.
@>
: Branch End
@> Set Move Route: This Event, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic..., Wait, Change Graphic...
@> Wait for All Movement
@> Control Switches: [0004:Trap Disabled] = ON

Page 6: Action Button, Below Characters.
Conditions: Trap Disabled is ON.
Contents: Empty[/quote]