KINGARTHUR'S PROFILE
Just your average game and anime loving computer addict who idles a lot on IRC. ;D
# ============================== # Map Info v1.0 # by GreatRedSpirit # ============================== # Modifies the Game_Map structure so access to the map info of the current # map is available class Game_Map alias initialize_mapinfo_ori initialize def initialize # If the map data hasn't been loaded yet, do so now $map_info = load_data("Data/MapInfos.rvdata") if $map_info == nil # Load the map data initialize_mapinfo_ori end # Get the map info structure for the current map def map_info return $map_info[@map_id] end end #------------------------------------------------------------------------------- # ============================== # Change Tileset v1.1 # by GreatRedSpirit # ============================== # Set the tileset of the next map # The tileset for a map to use is embedded in the map name # # Requires the MapInfo script so the map name can be grabbed # # This script must come before Anaryu's Anti-Lag Script for it to function # properly #------------------------------------------------------------------------------- # Change the MapInfo class so the tileset to use is embedded in the map name # and when getting the map name it removed that embedded data. module RPG class MapInfo # Regex that has where the map name and map data is MAP_REGEX = /(.*)\|(.*)/i # Cut out the embedded data from a map name and return it def name # If the name hasn't been parsed yet, do so now self.parse_name if @map_name == nil return @map_name end # Get the data embedded in the map name def name_data # If the name hasn't been parsed yet, do so now self.parse_name if @name_data == nil return @name_data end def parse_name # Match the regex to see if there's any map data if @name =~ MAP_REGEX # Dump the matched data into the name and data section respectively @map_name = $1 @name_data = $2 else # No match so there's no embedded data @map_name = @name @name_data = "" end end end end #------------------------------------------------------------------------------- # Changes to the game system to load the new tileset graphics and passability # When loading a map see if the map uses a different tileset and if so load # the passage data for that tileset class Game_Map alias setup_cut_ori setup unless $@ def setup(map_id) # Call original method so map is set up (except possible passage data) setup_cut_ori(map_id) # See if the map uses a different tileset and if not return tileset = $game_map.map_info.name_data return if tileset.empty? # Load the passability data from TilesetNamePassability.rvdata file_name = "Graphics/System/" + tileset + "Passage.rvdata" file = File.open(file_name, "rb") @passages = Marshal.load(file) file.close end end # When loading the graphics for a map, check and see if the map uses a different # tileset and load the appropriate tileset class Spriteset_Map # Give read access to the tilemap so it can be read what tileset is being # used by the map attr_reader :tilemap alias initialize_cut_ori initialize unless $@ def initialize # Set $spriteset_map to point to this object so it can be referenced # when creating characters for the current map $spriteset_map = self # Now start creating the spriteset_map initialize_cut_ori end alias create_tilemap_cut_ori create_tilemap unless $@ def create_tilemap #create_tilemap_cut_ori # Get map data where the tileset data is embedded tileset = $game_map.map_info.name_data # If it's empty, call the original method if tileset.empty? create_tilemap_cut_ori else # A tileset is defined in the map name data, use that tileset! # Load the new tileset @tilemap = Tilemap.new(@viewport1) @tilemap.bitmaps[0] = Cache.system(tileset + "TileA1") @tilemap.bitmaps[1] = Cache.system(tileset + "TileA2") @tilemap.bitmaps[2] = Cache.system(tileset + "TileA3") @tilemap.bitmaps[3] = Cache.system(tileset + "TileA4") @tilemap.bitmaps[4] = Cache.system(tileset + "TileA5") @tilemap.bitmaps[5] = Cache.system(tileset + "TileB") @tilemap.bitmaps[6] = Cache.system(tileset + "TileC") @tilemap.bitmaps[7] = Cache.system(tileset + "TileD") @tilemap.bitmaps[8] = Cache.system(tileset + "TileE") # Load the passability data from TilesetNamePassability.rvdata file_name = "Graphics/System/" + tileset + "Passage.rvdata" file = File.open(file_name, "rb") @tilemap.passages = Marshal.load(file) file.close # Load the map data @tilemap.map_data = $game_map.data end end # Dump the passability of the map into a single file: Used for saving the # passability setting of a tileset and saving it in RMVX's format dumped # into a byte stream so it can be unmarshaled and used easily. # Only saves the default passabilty settings def self.save_passage begin file_name = "Graphics/System/passage.rvdata" file = File.open(file_name, "wb") Marshal.dump($game_map.passages, file) file.close print "Successfully saved passage data to "#{file_name}" " rescue print "Could not save passage data: Exception #{$!} occured" end end end #------------------------------------------------------------------------------- # Change to Sprite_Character so map events use the map's tileset instead of # the default tilesets class Sprite_Character < Sprite_Base alias tileset_bitmap_cut_ori tileset_bitmap unless $@ def tileset_bitmap(tile_id) result = nil # If a map spriteset is defined if $spriteset_map != nil # Use its tilemap bitmaps when getting the character bitmap set_number = tile_id / 256 result = $spriteset_map.tilemap.bitmaps[5] if set_number == 0 result = $spriteset_map.tilemap.bitmaps[6] if set_number == 1 result = $spriteset_map.tilemap.bitmaps[7] if set_number == 2 result = $spriteset_map.tilemap.bitmaps[8] if set_number == 3 else # Call the original method result = tileset_bitmap_cut_ori(tile_id) end return result end end