A stone in the water plugin

I am making a puzzle game where in some of the puzzles you will need to push a random stone block in a water tile/damage floor to be able to safely step on it. I can event a single or even double case of it but since some of the puzzles are massive I cannot really have a separate event waiting for each possible variation of a stone pushed in the water or "poison" floor. Or even if it was technically possible it would not be a viable option since it would be super prone to human error.

What I need for example is a plugin to allow these block events to be pushed over damage floor and in water although it is same priority and when they first get in the water or damage floor they should not be moveable and they should become a static block you can step on and that negates floor damage. Maybe a script that will make it so that specially tagged events (stones) will be able to freely go to any tile marked with a region and then when they are in that region they will be forced to their self switch A stated. Does it make sense?

Sorry for the strange name for a topic but I could not find anything more descriptive.
edit : the code that I posted before doesn't work at all.
Here is the improved version

Basically the event that you are pushing will turn on (the true value in the script) the self switch "A" of the event it passes over. From there you can make the event the boulder passes over become passable. Then if you placed a certain region id over the event that the boulder passed over using the conditional branch that check the value variable you can change the boulder graphics.
Spoiler
Code:
id = this.eventId();
mapid = $gameMap.mapId();
sswitch = "A";
ss = true;
x = $gameMap.event(id)._x
y = $gameMap.event(id)._y
value = $gameMap.regionId(x, y)
events = $gameMap.eventsXy(x, y);
events.forEach(function(ev){
if(ev.eventId() !== id){
var key = [mapid, ev.eventId(), sswitch];
$gameSelfSwitches.setValue(key, ss);
}
})
You are an actual genius, mah man!

Of course by solving my one question it...became four questions! Touché!

1) First and foremost, I am dumb, forget the first one!
2) When I am pushing the stone and relying on the Set Movement Route I set to my hero I am not taking terrain damage. How can I change that?
3) I am taking terrain damage even if I stand on the newly spawned (by the stone push) event. How can I disable that?
4) The stone still cannot go in the water tiles and I will either need to make it go through somehow. However, if I just set it the through condition when being pushed I risk letting the player become Sisyphus and push the stone over some hill. Do you have any particular idea for this? I am thinking of making the stone through and using somekind of plugin to make a certain region disable the passage even of through events for the places I do not want the stone to go. However it may become tedious especially when I am using smart jump which relies on regions to work. It may be better to use a region that will allow passage of all events that are not the actor. The actor will be alone anyway so it would not become a mess due to some NPC going for a swim.

upload_2018-7-10_3-14-40.png
You should probably share you puzzle setup so it's a bit clearer.
I will be using parallax mapping and my maps are currently a bunch of placeholders. It will be hard to explain it with a normal puzzle for now. I will show you what I mean with a small map I created for that purpose. In the picture you have two types of terrain - water one which is unpassable and poison one which is passable but deals damage. What I want to do is to be able to push the stone in each of them and the stone should become a platform. You should be able to step on the platform and should not take terrain damage while on it.

For now I have:
A stone that you can push in the poison floor. It becomes invisible and the event below becomes a platform for you to step on. I found a proper way to reset each puzzle on demand so what I need to figure out is how to make you not prone to floor damage while on the newly created platform and how to be able to push the stone in the water as well.

upload_2018-7-10_14-5-29.png
Okay, I found a solution to the passability problem with yet one more Yanfly plugin. This time it was the Region Block one.
Now I only need to find out how to dissable the terrain damage when this certain platform is over the poison tiles.
If you add this script command (you'll need to separate it into 2 scripts) after the boulder moves but before you move the character it will change the region Id to 0. However I'm not sure if it let's you reset the puzzle too easily.
Spoiler
Code:
id = this.eventId();
mapid = $gameMap.mapId();
sswitch = "A";
ss = true;
x = $gameMap.event(id)._x;
y = $gameMap.event(id)._y;
tilesetId = $gameMap.tilesetId();
width = $dataMap.width;
height = $dataMap.height;
value = $gameMap.regionId(x, y);
events = $gameMap.eventsXy(x, y);
events.forEach(function(ev){
if(ev.eventId() !== id){
var key = [mapid, ev.eventId(), sswitch];
$gameSelfSwitches.setValue(key, ss);
tileId = $gameMap.tileId(ev._x, ev._y, 0);
$dataTilesets[tilesetId].flags[tileId]=0;
$dataMap.data[(5 * height + ev._y) * width + ev._x] = 0;
}
});
There is a tad bit more work to this than I thought so I'll leave it at this for now, using exclusively script tags probably isn't the way.
Thanks Ruiran! You certainly saved my project from an early demise and earned your credits spot for sure!
I will keep the thread open while I am experimenting with your latest bit of code and Yanfly's two plugins I mentioned earlier and see if I can come up with a solution that works for me.

Quick Edit:
Okay, I found something out. I used Region 11 to mark the location that the stone can turn into...a stone in a water tile. Region 11 is marked to allow all events in by Yanfly's RegionRestrictions. This make it so that the stone can go even in water. I set an event in each tile that is a possible spot for the stone to be pushed. Its first page is blank and has Through marked so that it does allow the stone in as well. The second page looks like this:
upload_2018-7-11_3-3-55.png


This picture I used is from the tileset and because it is with Below characters priority there it allows my players to step on it for some reason. This allows the player to go in the water if the stone was pushed in it first.
And to turn that Self-Switch to on I use your code here. Its second page is just Self-Switch A == ON and is blank.
upload_2018-7-11_3-7-9.png


With this solved I am done with thinking about how to improvise pushing a stone in the water. Thanks once again Ruiran!

Now I need to find out how to make my character take damage even when pushing the stone through the damage floor and how to make him not take damage if a stone was pushed in there. I have two possible solutions:
1) I can check the terrain tag of the terrain below the event before the push animation and after the push animation I can use it to determine whether or not the player should take damage based on it. The terrain tags are used in Yanfly's FloorDamage plugin. If I can find the right commands that should work.
2) The next one is to make the second page of the blank events in Region 11 for the ones waiting in the poison floor but not those in the water contain a random tile of the Tileset which was marked with a Terrain tag that will deal -1 damage so that it negates the effect of the tile below it. The damage dealt should be 1-1=0. I am not sure what will work first though but if they do not do that in exactly the same time I will be screwed because either I will enter with max health and because of that still receive 1 damage or I will enter with 1 health and die because I received the damage before I healed. Terrain damage can kill me, right? It better can since my game would not work otherwise. 😀

I will experiment a little more and determine whether my new questions belong to this case (and thus belong to this thread) or if I need to make a new one.
One last from me and I will be closing the thread tomorrow since I got frustrated by how blind I was.

This whole time I could have done that! Instead of having a separate event waiting in each possible spot where the stone can go in the water and have a long script to switch the Self-Switch of the event...I could have just done that with the stone event. I used your code Ruiran to check the region below the event and if it is the proper one the event transforms. As simple as that.

Dang it! It was not just two days lost though. I learned a lot. Thank you once again!

upload_2018-7-11_3-50-55.png


upload_2018-7-11_3-52-56.png
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/a-stone-in-the-water-plugin.97472/