[RMMV] Toggling Floor Damage Question

Hi everyone,

I'm currently creating a lava dungeon in my game and introducing dangerous tiles that deal Floor Damage when the player walks over them. When the player walks on the Light Red tiles, no damage is taken, but when the player walks on the Dark Red tiles (typically placed closer to the lava, which players can sometimes walk around at their leisure), they lose some HP. The Tileset -> Damage Floor buttons are working as expected, but I wanted to customize part of the dungeon in such a way that the tiles of that area actually flip back and forth, between Light Red (no damage / safe-to-walk) and Dark Red (damage-dealing). I want to make this part of the dungeon more timing/strategy based, but I'm having trouble figuring out how to make a safe tile change to a dangerous tile (and then turn back again after a second or two) during the game.

I thought that maybe creating an Event for each tile I want to flip back and forth could be a solution, and I've tried a few things to no avail. I'm assuming that "Change Tileset" isn't the way to go, because that would simultaneously flip everything on my entire map, rather than an individual tile. (As an absolute last resort, I suppose I could make a smaller, separate map for this tile-flipping puzzle, but I'd much rather keep this lava dungeon as one large map, if possible, and I want different tiles to individually flip at different times anyway.)

I explored making a Below Character Priority two-page event for a single tile, the first page with Wait 120 Frames + Turn Switch On, and the second page with Wait 120 Frames + Turn Switch Off, and that was successful with creating an independent flipping *image* between Light Red and Dark Red (when the Trigger of both pages was set to Parallel), but I wasn't able to make it deal damage to me when I walk over the Dark Red image, yet be safe when I walk over the Light Red image (because the underlying *tile* below the image was never actually flipping, just the image laid on top of it). Adding in contents to an event page, like Change HP and Flash Screen - both of which normally happen when a player takes Floor Damage - automatically occur when these Parallel events switch their Light/Dark Red colors, even if I'm nowhere near the tiles. I obviously only want the screen to flash and the player to take damage when the player is actually standing/walking on the dangerous tiles, not merely when the player watches the tiles switch from safe to dangerous, from afar, but that's undermined when I put those commands in the Parallel pages running automatically (and I couldn't find a Conditional that said something like: "IF the player is standing/walking on this current Dark Red image, THEN flash the screen and change their HP", but I feel like such a thing would be a viable solution to my issue).

So while I can toggle images on top of individual tiles, they aren't toggling the actual tiles or the safe/dangerous effects, and I'm having trouble making events enforce the idea of "you need to time your movement correctly, because this tile switches from a safe space to a dangerous space after some time". Any ideas how I could set this up? (I guess it's kind of like wanting to create a rhythm similar to Crypt of the NecroDancer.) Thanks!
You're trying to make one event do too many things. The event that represents the harmful tile maintaining its own graphic via parallel process means that it can't also maintain its own damage capability because that only needs to happen when the player walks over it.

Make your events on player touch, and create a single parallel process director event which does the timer and changes the graphic of the tile events.
You're trying to make one event do too many things. The event that represents the harmful tile maintaining its own graphic via parallel process means that it can't also maintain its own damage capability because that only needs to happen when the player walks over it.

Make your events on player touch, and create a single parallel process director event which does the timer and changes the graphic of the tile events.

You're totally right that my issue was trying to have both Player Touch and Parallel commands on the same event, which apparently is impossible. Can you please elaborate a little more on how to create this separate director event that runs Parallel and influences all the other tiles that I want to toggle between safe (Light Red) and dangerous (Dark Red)? I'm not exactly sure what I would tell that Parallel "master event" to do.
You can modify the self switches of another event using a script call, because self switches are just like switches except with a more complex indexing key. For example:

$gameSelfSwitches.setValue([1, 2, 'A'], true) will turn on self switch A for event 2 on map 1.

Knowing this, you can have your tile events' "damage" page be activated by self switch A, and have your director event turn on/off self switch A on whichever events you want to flip.
there is a simpler way to do this (in my opinion, haven't tested it.

Make a two-page event, with one page using a safe floor tile (IMPORTAT: do not use a sprite, scroll down to use a tile!!!) set to "below player", and the other event page being set to "above" and having no graphic at all, allowing the player to see the the dangerous tile below it.

If these change, the tile will either be overridden by the safe tile (making it safe) or the event will be out of the way, allowing the player to be damaged by the tile's floor damage.

How you switch between them - there are several solutions. You can use your wait-variant with every event being parallel, or you can use a single other parallel process switching those tiles like described above.
However there is a third option:
decide on how many different "steps" in the sequence you want to have, so that the tiles aren't all dangerous at the same time. Probably four or five should be OK.
Then give every safe-event page one of these switches as a condition and delete the invisible page.
now have a single parallel process event on the map control those switches at different times.
example:
switch 1 ON (makes the first set of tiles safe)
wait 120
switch 2 ON (makes the secont set of tiles safe)
switch 3 OFF (makes the third set of tiles dangerous)
wait 120
switch 1 OFF (the first set now becomes dangerous)
switch 4 OFF
wait 120
Switch 2 OFF
Switch 3 ON
wait 120

etc
You can modify the self switches of another event using a script call, because self switches are just like switches except with a more complex indexing key. For example:

$gameSelfSwitches.setValue([1, 2, 'A'], true) will turn on self switch A for event 2 on map 1.

Knowing this, you can have your tile events' "damage" page be activated by self switch A, and have your director event turn on/off self switch A on whichever events you want to flip.

Those scripts are not something I'm particularly comfortable creating, as I have very little experience writing lines like that ^^;;

there is a simpler way to do this (in my opinion, haven't tested it.

Make a two-page event, with one page using a safe floor tile (IMPORTAT: do not use a sprite, scroll down to use a tile!!!) set to "below player", and the other event page being set to "above" and having no graphic at all, allowing the player to see the the dangerous tile below it.

If these change, the tile will either be overridden by the safe tile (making it safe) or the event will be out of the way, allowing the player to be damaged by the tile's floor damage.

How you switch between them - there are several solutions. You can use your wait-variant with every event being parallel, or you can use a single other parallel process switching those tiles like described above.
However there is a third option:
decide on how many different "steps" in the sequence you want to have, so that the tiles aren't all dangerous at the same time. Probably four or five should be OK.
Then give every safe-event page one of these switches as a condition and delete the invisible page.
now have a single parallel process event on the map control those switches at different times.
example:
switch 1 ON (makes the first set of tiles safe)
wait 120
switch 2 ON (makes the secont set of tiles safe)
switch 3 OFF (makes the third set of tiles dangerous)
wait 120
switch 1 OFF (the first set now becomes dangerous)
switch 4 OFF
wait 120
Switch 2 OFF
Switch 3 ON
wait 120

etc

This setup is appealing to me, and it's working pretty well! The one little annoyance I'm finding, regardless of whether the toggling tiles are Player Touch or even Event Touch, is that if I'm already standing on a safe space that's becoming dangerous, I don't take damage when the tile becomes dangerous. In other words, the only way I take damage is when I literally walk onto an already-dangerous tile. If it toggles and becomes dangerous underneath me, I don't actually take damage and the screen doesn't flash (the actual bad effects don't trigger, even though the tile will visually change from Light Red to Dark Red below me). Any ideas how to actually trigger the negative conditions when I'm already standing on the tile that's becoming dangerous? Otherwise, a player could just stand still on a toggling tile without ever actually taking damage!
only two ways for this, because the engine does not check for dynamic changes.

1) you're asking for a plugin that changes that part of the engine behaviour, and it might need to be a custom one as I don't remember hearing about one that does this.

2) the event that control the switches also has to check if the player is on one of the dangerous tiles when switching, and if yes add the damage and the screenflash manually.

the second one is possible (control variable to get player location, then get location info to check either for event or for terrain tag (would need to be implemented) or something else like that.
only two ways for this, because the engine does not check for dynamic changes.

1) you're asking for a plugin that changes that part of the engine behaviour, and it might need to be a custom one as I don't remember hearing about one that does this.

2) the event that control the switches also has to check if the player is on one of the dangerous tiles when switching, and if yes add the damage and the screenflash manually.

the second one is possible (control variable to get player location, then get location info to check either for event or for terrain tag (would need to be implemented) or something else like that.

The second option definitely sounds preferable! How would I do this, exactly? I found the Control Variable option in the Event Commands, but I'm not sure how to check for the player's location, if/how that belongs in a Conditional (IF player is on spot X, THEN flash screen + lower HP, etc.).
you'll need several variables, and the true power of "control variable" is in the game data section, the button that is hidden behind the default "map id" there.

use two control variables to get player x and y, then use that with get location info to get the info you want from that position into a third variable.
and then check that info in any way you think it works best. for example you can give different lava fields different region ID and check "if region ID =## and switch # is off, do damage"
or work with terrain tags or event IDs or whatever, that complete depends on what logic you need.
you'll need several variables, and the true power of "control variable" is in the game data section, the button that is hidden behind the default "map id" there.

use two control variables to get player x and y, then use that with get location info to get the info you want from that position into a third variable.
and then check that info in any way you think it works best. for example you can give different lava fields different region ID and check "if region ID =## and switch # is off, do damage"
or work with terrain tags or event IDs or whatever, that complete depends on what logic you need.

Sounds complicated, but I'll look into this, thank you!
I would call it intermediate level eventing. It's not simple, but far from the maximum events can do, and it is on a level that you'll need dozens of times for puzzles in a game.
I would call it intermediate level eventing. It's not simple, but far from the maximum events can do, and it is on a level that you'll need dozens of times for puzzles in a game.

Fair enough; I meant complicated *for me* haha.

"use two control variables to get player x and y, then use that with get location info to get the info you want from that position into a third variable."

So I found: Control Variables -> Game Data -> Character, Player, Map X and Map Y. These represent the X coordinate of the player on the current map and the Y coordinate of the player on the current map? I'm not exactly sure what I should set the "Variable" and "Operation" to, above the "Game Data" Operand entry in Control Variables. I'm guessing I'm creating a brand new, unused variable and then choosing Set with Map X, and then creating a second brand new, unused variable + Set + Map Y?

Assuming that part is correct, I now have two new variables being used:
1. Player X Location (Variable Name) + Set + Game Data Map X of Player
2. Player Y Location (Variable Name) + Set + Game Data Map Y of Player

I guess I have two follow-up questions at this point:

1. Will these be in the single Parallel director event that controls all the other tile switches, or will these be placed in each individual tile that is toggling between safe and dangerous? I'm guessing it's placed in the Parallel master event, every time a switch is flipped by that special event to change a tile from safe to dangerous, to actually check to see if the player is currently standing on that tile that's becoming dangerous (so that they properly become harmed)?

2. I'm not sure how to do the next part that you recommended, which was "then use that with get location info to get the info you want from that position into a third variable."
a. I found the "Get Location Info..." Event Command in the third tab, and I'm guessing that based on your explanation, the first entry, Variable, should be a third brand new variable, which I've called Player Exact Spot.
b. I'm not sure which Info Type option to select (e.g., Terrain Tag, Event ID, Region ID).
c. I assume the Location entry should be "Designation with variables", where X = my new Player X Location variable and Y = my new Player Y Location variable (otherwise, why create these two other variables at all), although I'm not exactly sure what to do with this information, nor why alternatively setting the Location to be "Direct designation" and choosing the dangerous tile doesn't address the issue.
the answer to both 1&2 is "depends"

to be exactly, it depends on how you want to check for the data, which is theoretically possible with all three variants (terrain tag, event id or region id).
which of those ways to choose is up to you, they all have different advantages and disadvantages.
event ID would be most usefull if the "trap" is rarely used and especially if it is a moving one.
terrain tag would be most usefull if the result is based on the tileset, because terrain tag is set on the tileset, not on the map. That makes it easier to use (especially over multiple maps) but much less flexible.
region id is the most flexible one but requires you to set the region ID on the map positions in addition to everything else and more work. Basically you have to set the region ID on every tile that should have the effect, and use a different ID for each different switch in the main control event.

And YOU have to choose which way to go, I can't tell you that - because it depends on your game specifically. You might have to experiment and test all options to find the best one.
the answer to both 1&2 is "depends"

to be exactly, it depends on how you want to check for the data, which is theoretically possible with all three variants (terrain tag, event id or region id).
which of those ways to choose is up to you, they all have different advantages and disadvantages.
event ID would be most usefull if the "trap" is rarely used and especially if it is a moving one.
terrain tag would be most usefull if the result is based on the tileset, because terrain tag is set on the tileset, not on the map. That makes it easier to use (especially over multiple maps) but much less flexible.
region id is the most flexible one but requires you to set the region ID on the map positions in addition to everything else and more work. Basically you have to set the region ID on every tile that should have the effect, and use a different ID for each different switch in the main control event.

And YOU have to choose which way to go, I can't tell you that - because it depends on your game specifically. You might have to experiment and test all options to find the best one.

Based on the way my game is set up, Region ID's flexibility would definitely be the way to go (and I don't mind marking all the toggling tiles with their appropriate Region #s, even if that takes a while).

It seems, so far, the Parallel event will be able to identify that the player is standing on a specific Region Tile # based on the player's X,Y position and whatever Region # I mark that tile as (e.g., "The player is currently at the coordinates (50,60), and that exact tile is marked as Region #4"), so I guess the next step is for the event to somehow say "Any time a player is on a tile marked with Region #4 at this time (when that Region #4's danger switch is turned on, making that tile turn Dark Red), the player should take damage and the screen should flash."

I'm struggling to figure out what else goes in the Event Command that connects the location info with the ability to deal damage based on that location info though. How does "the player is currently on a Region #4 tile" lead to "the player is currently on a Region #4 tile, and therefore should be taking damage at this time"?
You do a conditional branch for the variable you stored the region ID in being 4, and inside that conditional branch you do the flash and damage.
You do a conditional branch for the variable you stored the region ID in being 4, and inside that conditional branch you do the flash and damage.

I think I may understand what you're saying. Let me check:
So this 3rd variable, recording Region ID and based on the previous two variables of Player Location X and Player Location Y, is named as Player Exact Spot.
Now if I try Conditional Branch -> Variable -> If "Player Exact Spot = 4", Then deal damage / screen flash, this will translate to dealing damage / screen flashing when the player is on Region ID 4, because the " = 4 " part is specifically calling for the Region ID, because that's how the 3rd variable Info Type was chosen?

And then, assuming I'm understanding this, I would essentially repeat this type of Conditional for any Region ID #s that are being used in this whole toggling-tile puzzle, so that the same rules apply throughout the entire area?
If the damaging tiles are all doing the same amount of damage, just paint every damage tile with the same region ID, and then you only need one conditional that'll cover the whole thing.
If the damaging tiles are all doing the same amount of damage, just paint every damage tile with the same region ID, and then you only need one conditional that'll cover the whole thing.

Each tile will do the same amount of damage when becoming Dark Red, but I'll be staggering their timings so that the player has to continuously move through the toggling tiles (think of, like, 10 rows of tiles, and each row flips back and forth at slightly different rates). I think with this sort of pattern, I might need 10 different Region ID #s, since I'll probably use 10 different switches (one per row). Thoughts?
Yeah, using one region ID per switch will be the most hassle-free way to do this.
Yeah, using one region ID per switch will be the most hassle-free way to do this.

Thank you so much! I'll tinker with various Conditional / Region # setups.

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-toggling-floor-damage-question.137005/