Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - Script to swap tilesets

Save-Point

Full Version: Script to swap tilesets
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using Pokémon Essentials made by Poccil. Though I don't think this has anything to do with what I need.
All I need is a snippet of code that allows me to change the current tileset to another depending on the time of day.

Thank you,
Sesshomaru
Code:
#===============================================================================
# ** Game_Map
#===============================================================================

class Game_Map
  #-----------------------------------------------------------------------------
  # * Public Instance Variables
  #-----------------------------------------------------------------------------
  attr_accessor :change_tileset
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method  :changetileset_gmmap_setup, :setup
  #-----------------------------------------------------------------------------
  # * Setup
  #-----------------------------------------------------------------------------
  def setup(map_id)
    @new_tileset = false
    changetileset_gmmap_setup(map_id)
  end
  #-----------------------------------------------------------------------------
  # * Change Tileset
  #-----------------------------------------------------------------------------
  def tileset=(new_tileset)
    tileset = $data_tilesets[new_tileset]
    @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
    @change_tileset = true
  end
end

#===============================================================================
# ** Spriteset_Map
#===============================================================================

class Spriteset_Map
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :changetileset_ssmap_update, :update
  #-----------------------------------------------------------------------------
  # * Update
  #-----------------------------------------------------------------------------
  def update
    if $game_map.change_tileset
      @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
      @tilemap.priorities = $game_map.priorities
      for i in 0..6
        autotile = $game_map.autotile_names[i]
        @tilemap.autotiles[i] = RPG::Cache.autotile(autotile)
      end
      $game_map.change_tileset = false
    end
    changetileset_ssmap_update
  end
end

Call with $game_map.tileset = n, where n is the ID number of the tileset as set up in the database.
That's pretty much a duplicate of the Change Map Tileset script by Ryethe (May 5, 2005). But it has a flaw. Hey, it's over 6 years old, right?

I'd recommend the Tileset Swap script by Ccoa (February 3, 2007). She noticed that if you change the tileset to your map and left, the map would revert to the original tileset. Her script saves the map and its new tileset so you can leave the map without any problem.
I was able to get Kain Nobel's script to work. Thank you very much.