RGSS3 Terrain Tags Refresh Glitch


Changing tilesets via the change tileset command will break all "COVER" values set on the map. Is there a way to fix this?

Example map setup:
1583300005221.png

*18 = tiles under this region will have a higher Z value than the player sprite. 19 = tiles under this region will be unpassable.

Once you change tilesets, the 18 region fails. (The ice roof tiles below should be covering the player sprite)
1583299804868.png
bump
bump
bump
I made a couple edits to the script by adding a new aliased method for whenever the tileset ID changes to reinitialize the script's map setup. You'll replace Game_Map#reset_map and adding a new method to the CP Terrain script:
Ruby:
  alias reset_map_change_tileset change_tileset
  def change_tileset(tileset_id)
    reset_map_change_tileset(tileset_id)
    reset_map(true)
  end

  def reset_map(keep_tileset_id = false)
    tf = @flip
    init_fold
    @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
    @tileset_id = @map.tileset_id unless keep_tileset_id
    init_setup
    id = tf ? CP::TERRAIN::LOWER : CP::TERRAIN::UPPER
    bridge_flip(id)
  end

Highly untested. Just seemed like the logical solution to me.
Add the following script call after your Change Tileset command:

Code:
$game_map.width.times do |x|
  $game_map.height.times do |y|
    $game_map.tileset.flags[$game_map.data[x, y, 2]] = 0x10
  end
end

Original thread: https://forums.rpgmakerweb.com/threads/rgss3-terrain-tags-refresh-glitch.118808/