DerVVulfman
Sponsor
version 1.1
by Ryethe (not DerVVulfman)
(05-05-2005)
This script restores yet another missing feature in RPG Maker XP relative to RPG Maker 2000 and 2003. This script allows you to change the tileset used by the current map. This is especially useful on maps that use multiple elevations, since you can change the tileset priorities as the player changes elevation. Adding this feature merely requires you to insert this script above main.
To use this script, you call it like so:
Script: $game_map.replace_tileset(3)[/FONT]
Where the "3" indicates that the tileset will be changed to the third tileset in your database.
aka... 003: Forest[/FONT] if you use the RTP.
Code:
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