Spike Trap Issue

So I have my spike trap set up and most of it works, but it won't damage my party when I step on it. Why is this?
1710105832799.png

1710105858713.png

1710105893649.png
your scriptcall is wrong as there is no ruby as "@event_id" as MV uses Javascript.

as it needs to be this._eventId and $gamePlayer.x but I dont see your entire
scriptcall conditions to make it correct.

but I made a simple function to make that easier without using region ID.
so when you step on it or stand still, the player can damaged.

I just need to find the thread where I place it for you to use.
there is also another scriptcall there that does the trick too.
give me a second to grab that one for you.

[Here] is the link which can make things easier when it's correct, if you want to
hurt the player on the region ID, it needs a different approach though.
there is also another scriptcall there that does the trick too.
give me a second to grab that one for you.
It's probably this one that checks if there's any event with player touch or event touch trigger on the player's tile
$gamePlayer.checkEventTriggerHere([1,2])
your scriptcall is wrong as there is no ruby as "@event_id" as MV uses Javascript.

as it needs to be this._eventId and $gamePlayer.x but I dont see your entire
scriptcall conditions to make it correct.

but I made a simple function to make that easier without using region ID.
so when you step on it or stand still, the player can damaged.

I just need to find the thread where I place it for you to use.
there is also another scriptcall there that does the trick too.
give me a second to grab that one for you.

[Here] is the link which can make things easier when it's correct, if you want to
hurt the player on the region ID, it needs a different approach though.
So I would place that in the plugin manager, correct? How would it work exactly?
if you copy and saved in as JS, and placed in the plugin and activate it,
than you dont have to worry on anything else, just the flip the spikes ON and OFF
and do dmg, whatever it needs to do.

and set the trap as event/player touch, and create 1 parallel event to toggle
the switch on and off, thats all.

otherwise, use the scriptcall AquaEcho mentions as conditional if using
parallel process.
if you copy and saved in as JS, and placed in the plugin and activate it,
than you dont have to worry on anything else, just the flip the spikes ON and OFF
and do dmg, whatever it needs to do.

and set the trap as event/player touch, and create 1 parallel event to toggle
the switch on and off, thats all.

otherwise, use the scriptcall AquaEcho mentions as conditional if using
parallel process.
1710107435608.png

So it should look like this, right? The spikes are still not causing damage.
you can do page 1 empty if nothing, page 2 with damage part.
or like that, but I don't think you need the region part though as
I don't see the reason for that though.

conditional seems fine, but if you use the code in the link, you don't
need that conditional brance.

but usefull if you have loads of them. if you see my played my game jam on XMas,
(Bring Back Christmas) I use that trick on my stairs which is seen a lot.
so you can see the power the plugin code I used.
View attachment 297911
So it should look like this, right? The spikes are still not causing damage.
The spikes have to be player touch or event touch for that script to work. You would put the parallel check in a common event.
The spikes have to be player touch or event touch for that script to work. You would put the parallel check in a common event.
So that worked, but I much prefer the region id part, because my character wasn't able to move once I stepped on the spikes:
1710108142905.png

1710108161215.png
So that worked, but I much prefer the region id part, because my character wasn't able to move once I stepped on the spikes:
Your common event never runs because it's not set to parallel and is just a block of code that never gets called. Only the code in your spike trap is running. You should put everything but the movement routes in the common event and set it to parallel
Your common event never runs because it's not set to parallel and is just a block of code that never gets called. Only the code in your spike trap is running. You should put everything but the movement routes in the common event and set it to parallel
1710108490886.png
I have a parallel event on all maps that runs the player coord. part.
spikes require 2 pages, and is easy, as I can make a sample how to do it though.
and it's far easier.

for page 1:
nothing here

for page 2, dmgs player and step back

both pages on event touch.

on a parallel event on the map.

page 1
wait 300
moveRoute event X
down, left, right, up
Swtch x is ON

on page 2,
wait 300
and do it vice versa (also in parallel)

use this event as a controller for all spikes and it does work and is effective.

I DM tomorrow a sample from my game jam project, which require the snippet I made.
spikes require 2 pages, and is easy, as I can make a sample how to do it though.
and it's far easier.

for page 1:
nothing here

for page 2, dmgs player and step back

both pages on event touch.

on a parallel event on the map.

page 1
wait 300
moveRoute event X
down, left, right, up
Swtch x is ON

on page 2,
wait 300
and do it vice versa (also in parallel)

use this event as a controller for all spikes and it does work and is effective.

I DM tomorrow a sample from my game jam project, which require the snippet I made.
Ok, but if I wanted to do the region id part that I was originally doing, how would I fix the code?
$game_player.x == $game_map.events[@event_id].x && $game_player.y == $game_map.events[@event_id].y
What would the correct code look like for mv?
It would be something like

If:Script: $gameMap.regionId($gamePlayer.x,$gamePlayer.y) ==1

This is completely off memory as I can't look it up right now
It would be something like

If:Script: $gameMap.regionId($gamePlayer.x,$gamePlayer.y) ==1

This is completely off memory as I can't look it up right now
So, it worked, but now it is damaging my player even if they are not right on the spikes. I have some regions around the spikes for testing atm. So how do I fix this?
1710110504847.png
So, it worked, but now it is damaging my player even if they are not right on the spikes. I have some regions around the spikes for testing atm. So how do I fix this?
View attachment 297921
You need to do this the way ShadowDragon said. You have spike events that toggle between retracted and protracted so you need two event pages: one which damages the player and the other does nothing, with one page having a switch trigger. You would have either a parallel common event or map event that toggles that switch every 20 frames.
Sad part is that I had a spike trap event that worked just fine in my old game, but I no longer have it and can't remember what I did to make it work. I know I had it setup the same way as in the vx ace video I watched but the script call was slightly different.
There are other ways to do it, like making every trap a parallel event which you were doing at first, it would just be horribly inefficient and taxing on your PC's processor the more traps you had on the map.
There are other ways to do it, like making every trap a parallel event which you were doing at first, it would just be horribly inefficient and taxing on your PC's processor the more traps you had on the map.
That is understandable. How would the event look in game though for the way @ShadowDragon was showing it? Text doesn't always help me understand how it would look when set up. More of a visual learner.
All of the script call is the incorrect syntax - there's a pinned thread with MV script calls that has the correct syntax you can copy.

But I don't understand why you're resorting to script if you're not familiar with it, all of that can be done with event commands.

I also don't understand why you're doing it through a parallel event and checking regions instead of just making the spikes damage on touch like @AquaEcho suggested, but...definitely no need to use code.

Original thread: https://forums.rpgmakerweb.com/threads/spike-trap-issue.166674/