I need some help with a puzzle I’m making regarding damage tiles.
To put it short, I wanted to make a puzzle of sorts where you must push a boulder unto a poison tile, to whcih it turns into a bridge tile, and then you can cross over it without taking damage. But no matter how I do it, my characters still take damage when they cross it.
I tried looking for tutorials on how to circumvent this, but most I could find don’t really align with what I’m trying to do. Anyone here could lend me some help?
rpg_objects.js, line 5987. This is the code we need to figure out how to modify
Game_Map.prototype.isDamageFloor = function(x, y) {
return this.isValid(x, y) && this.checkLayeredTilesFlags(x, y, 0x100);
};
You could save the above as a .js file and install it as a plugin, it will override the normal functionality with whatever you wrote in your plugin
So now the trick is to figure out how you want to tell the game that this poison tile is no longer a poison tile. Adding a check if there’s a below-layer event on it will be incompatible with any cutscene events that you happen to locate on top of a poison tile. Of course, you could also avoid having any events on a poison tile to avoid that oversight from happening.
So if you wanted your game to say if any event is on a poison tile, it is no longer a poison tile, this is the code you want to save as a .js and install as a plugin. Be aware this has potential to lag your game on maps with a large number of events!
_aliasIsDamageFloor = Game_Map.prototype.isDamageFloor;
Game_Map.prototype.isDamageFloor = function(x, y) {
return _aliasIsDamageFloor.call(this, x, y) && this.eventsXy(x, y).length == 0;
};
1 Like
I think I kind of end up faking the damage tiles with events. With VXAce and onwards you can have one event checking if you’re over a specific region, and if you are apply damage. Then for the place where you want to drop a bridge, make that part of the logic of the bridge. If the bridge is set and you fall there, don’t do damage, else apply damage.
I’m sure you can work it out better through code, but yeah when I need a quick and dirty solution I just do that.
Give the bridge-boulder-whatever event a custom move route, on the event page it uses when the boulder is set in place. Set the Frequency set to highest.
Copy and Paste this script call in the route:
$dataMap.data[(0 * $dataMap.height + this.y) * $dataMap.width + this.x] = this._tileId
It changes the map tile of the event’s location to something else. In this example, the event’s tile Id is a bridge tile (80) but it can be any tile id that doesn’t have a damage flag. Fyi, if the event graphic is set to something other then a tile graphic, then “this._tileId” will be “0”, which probably doesn’t allow passage. I’m assuming the damage tile is on the bottom - that’s the tile we’re changing.
Changing the tiles of $dataMap is only temporary. If you update or refresh the scene, like opening the menu or transferring the player, the tiles will revert back to the way they were. For this reason the event’s move route will change it continuously. With the Frequency set to highest, there should only be a 1-2 frame delay before the event’s movement replaces the tile id again.
I think this is a little misleading. It’s true, technically speaking, but the scene isn’t refreshed all that often – as far as I know, only if you go to a different scene and return (eg a battle, opening the menu, etc).
What this means in practice is that if you need the bridge to change back into a damage tile later, it won’t work properly. If you only need a one-way conversion though, this approach should be fine.
There’s no accounting for plugins or parallel processes that might also refresh the map. The main thing is if the player saves, exits, and reloads the game, the move route ensure the damage tile that the event is on is overwritten when they come back.
If you wanted to push the tile away and restore the $dataMap to its initial state the easiest way is an transfer command (moving nowhere with no fade). That will refresh the map tiles too. Although, if there are party followers they will collapse on the Player’s location, so there is some jank to it.