Lava rolling in, damages player

Hi all, first post. Apologies if this is in the wrong place.

What I'm trying to do is have the entire left side of the map be consumed by lava and have the player flee from it; stepping on it would result in the player taking damage.

It's certainly possible to set up a multitude of event tiles with a timed lava animation (with the leftmost having the least delay, with progressively shorter delays towards the right) but I've heard that using an insane number of events will inevitably cause lag, especially on slower systems.

Am I doing this right? I've tried using a "show picture" method on the map that is correctly timed to when I want the event happen, but the image is tied to the screen and it gets difficult to coordinate the damage occurring to the player.

I'm truly stumped. Thanks for reading.

Cheers.
I think you might be able to get away with doing this via @Yanfly's new Event Hitbox Resize script. You could make a really bigass hitbox (like 17 x 50) for the giant ocean of lava (note that it wouldn't need to actually be as big as the lava, but only as big as the area where the player might be able to touch it), and have the event move left and right to represent the "tide" of the lava. Set up the damage processing on an event page with the condition Event Touch (not Player Touch). The one issue is that it would be more difficult to have the player continue to keep taking damage if he stands in the lava for a prolonged period of time, but if the lava is constantly rolling in and out, then it won't be much of a problem.

Short of doing that, you'd have to get into programming basics. You could set up a variable to track how far in or out the lava is, and make sure that the Show Picture synchs with that variable. Then you could have a Parallel Process event track the player's current x (and y if you want) positions, and if the player's position is far enough left to intersect with the lava picture at the current time, deal damage to them (then the PP event would wait X frames so it doesn't constantly trigger 60 times per second). Every tile is 48 pixels, and the leftmost tile on the map is x = 0, so if the Lava's upper-left corner is at 0 pixels, it's 200 pixels wide, and it has rolled in 220 pixels, for example, you'd want to deal damage to players standing at x = 8 or less. I believe the correct syntax for the player's position is $gamePlayer._x (it might just be $gamePlayer.x), and the correct syntax for a Variable (as defined in the editor) is $gameVariables.getValue(n) where n is the variable you want to check, so your Conditional Branch in the PP event could use the Script line: ($gamePlayer._x * 48 <= $gameVariables.getValue(78) + 200 ) and you could adjust the 200 number slightly depending on how much "intersect" you want to allow between the lava and the tile the player is standing on before dealing damage. Inside the Condition Branch is where you'd deal damage to the player, and after the Condition Branch is where you'd add the Wait.

You are correct that creating hundreds of events would cause serious lag (not to mention would look a lot worse than Show Picture), which is why that approach should be an absolute last resort.

I did something that used events as the lava tiles. When they become full "dormant tiles" all they are doing at that stage is a stepping animation so not much lag going on there. if you want to know more about this, you can message me and I can give you the breakdown of how it works. I will be up front with you, it is a lot of self switches going on to control the lava flow physics.

I guess it depends on how big you want your map to be, or could this be broken up into a few maps - like in a canyon or something?
Ohh hey guys, thanks for the detailed replies! Both seem like viable options. The map is actually of a town, so there are limited areas where the lava will reach. I've done a setup with the event approach and self-switches -- not as well-done as in the video (great job, by the way) -- but functional. I didn't notice any lag personally, but my system is pretty powerful.

I am interested in using the yanfly plugin or the show picture approach. I will give it a shot and post back here with my results, and will reach out if I need more help. Thanks again.
Alright, so here's how I solved it:

I used the TDDP_BindPicturesToMap plugin, which was obviously necessary because the lava would flow according to the map and not the player's position. I created an event that displayed a large picture of the lava exactly where I wanted it, and rather than using the "move picture" command - which would not work as the picture would indeed be bound to the map - I used "show picture" immediately followed by a "bind picture" from the plugin, and moved it by showing the same picture 48 pixels in the direction I wanted it to move. Rinse and repeat to get the full flow of lava. It worked, although the code is a bit annoying to tweak when adjusting the timing of the lava and what have you.

To make it do damage, I created a single event on each line (row or column) the lava would cross, used the yanfly plugin to expand the hitbox to the appropriate length, and set a timer according to the movement of the picture. The damage would only come in once the self-switch would change to "A" active after the timer expired.

Downsides: obviously, the jerky movement of the lava is not ideal. I could make an even more complicated code - rather than waiting a full second to move a tile, I could add in-betweens, for instance, or changes in opacity to create a nicer effect. But this results in a lot of repetitive code that would have to be tweaked just right in order to perform adequately. It really is a shame the "bind pictures to map" plugin does not accommodate a "move picture" command that allows for the picture to remain bound while not moving uniquely with the screen. A second issue is that it takes some really precise coding of the timing across the separate events, particularly if one wants to have lava come from different directions.

Anyhow, it works.

Thanks for the help, all!

Original thread: https://forums.rpgmakerweb.com/threads/lava-rolling-in-damages-player.107830/