Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Change map tileset by event.

I'd like to change the map tileset by event. I'd like to create multiple tilesets with small differences between them, winter/fall/summer/spring, night/day, peace/ruin, etc. I could even see this used for animated water. However the closest option I see is "Change Map Settings" on page two of the event buttons, which contain Panorama graphic, Fog graphic and Battleback graphic. Is there a script text I can paste in to change the tileset graphic?

I did some searching and came across @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name). Replacing the variable with a specific tileset name in quotes fails.
 
This could look pretty freaky if you just casually switch between tilesets-- they don't map onto each other very well.

Suggested alternative: Don't use a script, make more than one map! Change it so that the Transfer Player events that take a character to a map will take that character to another, similar map when a switch or variable is set. That'll be much easier to deal with.
 
You can do this by script, it is somewhat of a hassle given the ammount gained.

You could put all the tiles on one tileset, then use a script to change the tiles, rather than changing the tileset; it would be a little time consuming, but would be a better route.

On the other hand, supposing you only plan to use this on a few maps; you can take screenshots of the maps for each tileset, then adjust the fog settings in Game_Map for
those maps, and just use the screen shots with dummy tiles in place of actual tiles.
 
This could look pretty freaky if you just casually switch between tilesets-- they don't map onto each other very well.
That's why I'm making custom tilesets that map onto each other identically; If you need an example, Warcraft 2 had such a thing. You could change from winter to summer to wasteland in the editor and the mountains trees and water stayed put.

Yes, I'd like to use many maps, and large maps that take advantage of this.

You can do this by script, it is somewhat of a hassle given the ammount gained.
I'm willing to dig into it, I just need to know the relevant commands.

You could put all the tiles on one tileset, then use a script to change the tiles, rather than changing the tileset; it would be a little time consuming, but would be a better route.
Loop through every tile in the map and add X to the tile value? I suppose that's a good last resort if there's no way to do it any other way.
 
By scripts is just a matter or changing the tileset graphics as far as I remember , not all that hassle you were saying I think. If I am not mistaken, what Velocir_X sent to you is what you need =)
 

Rylius

Member

Ruby:
class Game_Map

  # ---------------

  attr_accessor :new_tileset

 

  #--------------------------------------------------------------------------

  # * Setup (Modified for Change Tileset routine)

  #     map_id : map ID

  #--------------------------------------------------------------------------

  alias chgtileset_setup setup

  def setup(map_id)

    @new_tileset = false

     chgtileset_setup(map_id)

  end

  #--------------------------------------------------------------------------

  # * Replace Tileset (New Routine)

  #-------------------------------------------------------------------------- 

  def replace_tileset(new_tiles) # New Method

    tileset = $data_tilesets[new_tiles]

    @tileset_name = tileset.tileset_name

    @autotile_names = tileset.autotile_names

    @panorama_name = tileset.panorama_name

    @panorama_hue = tileset.panorama_hue

    @fog_name = tileset.fog_name

    @fog_hue = tileset.fog_hue

    @fog_opacity = tileset.fog_opacity

    @fog_blend_type = tileset.fog_blend_type

    @fog_zoom = tileset.fog_zoom

    @fog_sx = tileset.fog_sx

    @fog_sy = tileset.fog_sy

    @battleback_name = tileset.battleback_name

    @passages = tileset.passages

    @priorities = tileset.priorities

    @terrain_tags = tileset.terrain_tags

    $game_map.new_tileset = true

  end

end

 

class Spriteset_Map

  #--------------------------------------------------------------------------

  # * Update

  #-------------------------------------------------------------------------- 

  alias chgtileset_update update

  def update

    if $game_map.new_tileset == true

      @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)

      @tilemap.priorities = $game_map.priorities

      for i in 0..6

        autotile_name = $game_map.autotile_names[i]

        @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)

      end

      $game_map.new_tileset = false

    end

  chgtileset_update

  end

end
I dont know the credits anymore, sorry.
Use $game_map.replace_tileset(4), where 4 is an id of a tileset in the database.
 
That looks like a slightly modified version of Ccoa's "Tileset Swap" script.
She created the script as a solution for bridges (et.al.) so you could walk both over & under a bridge depending on what level (elevation) your player was.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top