Making Characters do Floor Damage

Hello, all!

I tried to look this up so I wouldn't have to ask but everything I find on floor damage is just people asking how to change the percentage of floor damage done by the tiles. Nothing similar to what I need.

i am using a tileset that has characters for dungeon traps. Holes in the ground that allow either spikes or fire to come up. I need those traps to actually hurt the player when they hit him/her. Now, my game is a traditional turn-based JRPG, but I want the player to use a decent chunk of HP on each character when hit.

The spikes are on a sprite sheet with 4 of them and you just "turn" to go between them. So I have them set to a custom route on autonomous movement with:

Turn Up
Wait 60 frames
Turn Left
Wait 60 frames

Repeated indefinitely. And I want the player to be damaged on the Turn Left part where the spikes come up.

Here is a video showing them. I avoid the spikes as if they would hurt me when they come up, but they don't. I simple walk over them, lol.

Try THIS tutorial
Thank you so much for the response, but I don't think this helps with my issue (please correct me if I'm wrong)

The thing is, both examples in the link you provided tie the spikes or fire to switches. So if the switch is on, the player attempts to walk over the spikes and is hurt and pushes back. If it's off, the player can just walk safely over.

My spikes are not tied to switches. The player simply has to run over them at the correct time.

The thing about the link you sent is since it's tied to a switch, you simply make the character lose the HP automatically is the switch is on. With mine, since there is no switch, the game has to know WHEN you went over the spikes (if they were up or down) to know whether or not to take the damage from the player, whereas the links you provided simply auto takes away the HP if the switch is on.
Yeah I mean if you use a moveroute that's just not a good idea. Just make it 2 pages with a self switch if you're not even using the motions inbetween.

1741978085571.png

Then on page 2:
1741978106067.png

The script condition here being:

$gamePlayer.x === $gameMap.event(this._eventId).x && $gamePlayer.y === $gameMap.event(this._eventId).y;

This makes sure the player is on the same tile as the spike(since it's a parallel process, not a touch trigger), then dealing damage, then putting the spike back down. This is certainly not the best way to make many spikes on the same map, as they all run parallel and can lag your game as well as some other jankies that can occurs, especially when exiting a battle scene on the same map and they only trigger their damage for 1 frame when they pop up (which was fine for my game since my spikes go back down immediately.)

If you don't immediately put the spike back down, or make the player jump off the spikes, the damage would trigger every frame.

Maybe this helps.
Dude, the switch is what makes the spikes go up and down "at the right time" you can modify what and how the switch is called or use self switches. The first page being touch means the player would have to touch it to receive damage.
So, forgive me guys, this is all new to me.

@Slaughty Am I mistaken? Because my understanding is: in the example you sent me, you walk into the room simply unable to onto the tile as it automatically makes the spikes shoot up, hit the player, and cause damage.

So, the only solution is to hit the physical switch on the screen, which makes it so that the player can then walk on the spike tiles as much and as long as he wants because they are off now, due to physically hitting that switch. So they can now walk over them without fear of being hurt. Heck, they can stop on them and just sit there for a minute without anything happen.

That physical switch creates an ON and OFF situation based on if it's hit.

I don't want EITHER of those things to be the case. There is no on or off. My spikes simply come up, go down, come up, go down, constantly, in one second intervals. The player has to run over the tile(s) while the spikes are down, timing it to not be on the tile when the spikes come up and hit them.

-----

@SGHarlekin I haven't tried your coding yet because you suggested it was not the ideal way of doing it. It's just the way i could think of doing it that would work, but I am more than open to suggestions. can you suggest the best way that would work for this?

I mean, this is a super, super common situation in these games so I'd have to imagine many people are familiar with so pretty effective options.
can you suggest the best way that would work for this?
If I could, I probably would've given you that instead.

The most common way of handling it would probably be a fairly straight forward common event on parallel which controls the movement of the spikes as well as checking the position of the player. If it aligns with the position of any of the spikes, deal damage. This should work for you since it seems you want the spikes to just all pop at the same time. In my case it's not what I wanted.

I'd also suggest you trying things people show you instead of just disregarding it when whatever you're doing doesn't work whatsoever. Worst case scenario you learn how the engine works even if the solution provided is not ideal.
So here's one way you can do this, I'm sure there's others.

First, here's my map setup:
Spoiler: Map Setup
I have regions 1 & 2 marked over the spike traps. The event in the top left corner is our controlling event.
SpikeTrap_Map.JPG

Spoiler: Spike1 Event
This is marked with region 1 on our map. Spike1 will damage the player always because it's page two has the priority below character. So if they touch the event while the spike is up, they will get damaged.
SpikeTrap_Spike1_Page1.JPG

SpikeTrap_Spike1_Page2.JPG

SpikeTrap_Spike1_Page3.JPG

Spoiler: Spike2 Event
This is marked as Region 2. Spike2 is an example of not being able to pass through or get damaged by the spike while it is up because its priority is the same as character. It will only hurt the player if they are standing on the spike when it goes up. I didn't know what you wanted so I did it both ways.
SpikeTrap_Spike2_Page1.JPG

SpikeTrap_Spike2_Page2.JPG

SpikeTrap_Spike2_Page3.JPG
Spoiler: Spike3 Event
Spike3 is just a copy and paste of Spike1 so it is also marked with region 1

Spoiler: Controlling Event
This is the "brains" of the operation. First page just sets us up, it can be totally ignored honestly because for this it's unnecessary, it's just a personal habit of mine. If you're going to be doing these traps a lot, I would just move the second page to a parallel common event.
SpikeTrap_Controller_1.JPG

"Brains" starts here:
SpikeTrap_Controller_2.JPG

SpikeTrap_Controller_3.JPG

SpikeTrap_Controller_4.JPG
Basically 10 times a second we are checking to see if the player is standing on a spike region. If it is, it checks to see if the Spike is up, by checking to see if the timer is between the values we put in our spike's page conditionals. If all of that is true, then damage player and move them off the spike or they'll just keep receiving damage.
"I'd also suggest you trying things people show you instead of just disregarding it when whatever you're doing doesn't work whatsoever. Worst case scenario you learn how the engine works even if the solution provided is not ideal."

Your post came off as "You're not doing this a very good way, but if that's how you want to do it, then here, try this"

So no, I wasn't "disregarding" it. I was saying "I'm new to this, and don't really know what I'm doing, so if you know a better way then I'm willing to try it as I'm not stuck on the way I'm doing it"
"The most common way of handling it would probably be a fairly straight forward common event on parallel which controls the movement of the spikes as well as checking the position of the player. If it aligns with the position of any of the spikes, deal damage. This should work for you since it seems you want the spikes to just all pop at the same time. In my case it's not what I wanted.

See, this is the information I was looking for. So it sounds like the common event is the best way to go about it, because the link I posted only has all the spikes going at the same time because it is the very first time the player encounters it, so I was keeping it simple for them.

It gets harder from there with the spikes going at different times and speeds.
@Slaughty Thank you for this response. I am reading this now and it also sounds like it may work along with the suggestion from the other poster so I'm going to try both. I'm just trying to process exactly what everything is.
Yes, your final paragraph makes it sound like this is exactly what I need so thank you. I'm going to play around with both of these options and see if they both work equally well for what I need or if there are any unforeseen issues. Thank you both.
@Slaughty

Just got home and ready to try to put the code together. I'll let you know how it works out for me.
This is similar to a couple other puzzles I've put together so I think I can handle it (I did some puzzles where you had to direct 3 fireballs moving around the room to 3 torches and it used the same type of controller up in the corner, which I'm sure you're familiar with)

When you say you aren't sure whether or not I want the spikes to hurt the player or stop them if they walk into the side of them while they are already up, that's a good question. And it's funny you ask that because the very first suggestion I was given was just eventing:

If: Trap is facing Left
Flash screen
Change HP - 10
Wait 1 frame

And that's it. And it actually worked, however it ONLY worked if you walked into the spikes while they were up. It didn't work if you were already standing on the tile WHEN the spikes came up. So, wouldn't been a nice, simple solution but it had that problem that you mentioned 🙂

Okay, here I go, wish me luck, lol...
Double-post notice: @JasonHebert1

Original thread: https://forums.rpgmakerweb.com/threads/making-characters-do-floor-damage.176239/