Allowing events that use tiles for their event graphic to inherit the tile's terrain tag?

Hey there. I've done some testing and while events that use graphics from the map's tileset will inherit the tile's passability information (at least as long as the event is "Below Characters") it seems like it doesn't inherit the tile's terrain tag; that is, if you try to get the terrain tag information for a location on the map (through a script call or through Get Location Info) and there's a tileset event there with a non-zero terrain tag, RPG Maker ignores the event when getting the terrain tag information.

If this actually isn't the case and I messed something up you can let me know and lock this thread (sorry for wasting your time in that case!), but otherwise this is an issue and I'm hoping that a plugin could change this behavior relatively easily.
Try this ...

Code:
Game_Map.prototype.terrainTag = function(x, y) {
    if (this.isValid(x, y)) {
        var flags = this.tilesetFlags();
        var tiles = this.allTiles(x, y);
        for (var i = 0; i < tiles.length; i++) {
            var tag = flags[tiles[i]] >> 12;
            if (tag > 0) {
                return tag;
            }
        }
    }
    return 0;
};
Try this ...

Code:
Game_Map.prototype.terrainTag = function(x, y) {
    if (this.isValid(x, y)) {
        var flags = this.tilesetFlags();
        var tiles = this.allTiles(x, y);
        for (var i = 0; i < tiles.length; i++) {
            var tag = flags[tiles[i]] >> 12;
            if (tag > 0) {
                return tag;
            }
        }
    }
    return 0;
};

I'll give this a try when I get home, thanks. I'm guessing from reading through this that it isn't meant to be a standalone plugin or a script call, so should I be looking for an existing function of the same name to replace this with in the js files that come with MV?
You could just save it to a file with a .js extension and add it to your game like any plugin.

However, if you want a plugin description, I'll wrap it up for you:

Code:
//=======================================================
// EventTerrain.js
//=======================================================

/*:
 * @plugindesc Allow TerrainTag to get terrain from events using map tiles
 * @author Shaz
 *
 * @help This plugin does not provide plugin commands.
*/

(function() {
  Game_Map.prototype.terrainTag = function(x, y) {
     if (this.isValid(x, y)) {
         var flags = this.tilesetFlags();
         var tiles = this.allTiles(x, y);
         for (var i = 0; i < tiles.length; i++) {
             var tag = flags[tiles[i]] >> 12;
             if (tag > 0) {
                 return tag;
             }
         }
     }
     return 0;
  };

})();


Save that into a file called EventTerrain.js in your plugins folder.
Hey, it's working beautifully! Thank you so much.

Original thread: https://forums.rpgmakerweb.com/threads/allowing-events-that-use-tiles-for-their-event-graphic-to-inherit-the-tiles-terrain-tag.83414/