How To Set Up A Spike Trap

I have searched the forums and the net, and was unable to find a direct answer. Now that I have figured it out I though I would share. There may be a better way to do this, and if so, please share and I will update and credit.

On with the show...

For this event you will want to set up 2 tabs, each set to 'Priority' Below Characters and 'Trigger' Parallel Process.

Tab 1:

  • Set your 'Graphic' to the spikes down image (located in the !Other1 graphics).
  • Set a 'Conditional Branch' based on this 'Script' (Uncheck 'Set handling when conditions do not apply'):

    $game_player.x == $game_map.events[@event_id].x && $game_player.y == $game_map.events[@event_id].y
  • Inside the branch use a 'Flash Screen' command set to 10 frames.
  • Next we want to 'Play SE' for the damage. I used 'Damage1', 80, 100
  • Reduce the parties HP by your desired value (I used -10 HP) with the 'Change HP: Entire Party'.
  • Lastly, set 'Control Self Switch' A to On


Spoiler
r05x6r.jpg

Tab 2:

  • Set your 'Graphic' to the spikes up image (located in the !Other1 graphics).
  • Set the 'Self Switch' on the left to check if  'A is On'.
  • Set a 'Conditional Branch' based on this 'Script'(This time leave 'Set handling when conditions do not apply' checked):

    $game_player.x == $game_map.events[@event_id].x && $game_player.y == $game_map.events[@event_id].y
  • Leave the first condition blank
  • In the 'Else' condition, set 'Control Self Switch' A to Off.


Spoiler
iljfyo.jpg

You can turn it off/on through the use of a lever or switch by making a third tab:
Tab 3:

Leave the 3rd tab blank, but place a check in the upper left 'Conditions' with your switch enabled (1st image) and set your graphic to the spike down position. For my example it is 'Condition 085: Spike T1 Deactivated'. If you do this you will want to set up a lever, button, switch, etc. with two tabs as follows:

  • Tab 1​​For this tab, set your graphic of your choosing to what you consider to be the 'On' setting.
  • Set the 'Priority' to 'Same as Characters.
  • If using a lever, set 'Trigger' to 'Action Button'. If using a button that you step on, set 'Trigger' to 'Player Touch'.
  • Set your 'Control Switch' to the On position. For this example mine is: Switch 085: Spike T1 Deactivated.
  • Set your 'Control  Self Switch' to A = On.
[*]​Tab 2
  • ​For this tab, set your graphic of your choosing to what you consider to be the 'Off' setting.
  • On the left, check the box for 'Self Switch' A to On.
  • Set the 'Priority' to 'Same as Characters.
  • If using a lever, set 'Trigger' to 'Action Button'. If using a button that you step on, set 'Trigger' to 'Player Touch'.
  • Set your 'Control Switch' to the Off position. For this example mine is: Switch 085: Spike T1 Deactivated.
  • Set your 'Control  Self Switch' to A = Off.




Spoiler
2z707ky.jpg


Lever/Switch/Etc.

Tab 1

sx2hwi.jpg


Tab 2

5tisx.jpg
How does this work?

The first page of the event begins running as a parallel process with the graphic of the spikes down and checks to see if the condition applies. The condition has the script inside it that checks to see if the players X, Y position is the same as this event. Once the player steps on the event the condition activates which causes the screen to flash, a sound effect to play, the parties HP to reduce and then causes the event to go to the 2nd page. 

The 2nd page has the graphic of the spikes up and is set to see if the player is still standing in that location. As long as the player stands there the page is active. Once the player moves from that location the page is turned off and reverts back to the first page, showing the spikes in the down position.

What does the 3rd tab and lever/switch/etc. do?

This sets it so that when you activate the lever/switch/etc. it will deactivate the traps by turning on appropriate switch on the 3rd tab of the spikes. When that tab is active all that will happen is will display the trap in the down position. You can then re-engage the lever/switch/etc. to turn the trap back on.

References:

I used this thread to get started with this. It is thanks to the tips, notes and questions by Mahoken, Shaz and Orathan that I was able to get this set up.
Wouldn't you want it to move your player off of it though? Otherwise they can just take a bit of damage and bypass whatever the spikes were meant to block.
Not in this case. This case is essentially setting them up as a normal damage tile.
What I did with mine was to have it call a common event.  That event checked which way the player was facing and then sent them back 2 tiles in the appropriate direction, using 'Jump' in the Set Move Route command.  Using Jump makes it look as if they have been knocked back.  It also took the HP off.
I have an addition I plan to add to it soon, I will add the ideas/suggestions from the 2 of you as well, I am sure others will appreciate it as well.   😎  
 
Updated to include disabling the trap through use of a lever/switch/etc.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-set-up-a-spike-trap.38658/