class Scene_Title $map_names = load_data("Data/MapInfos.rxdata") for key in $map_names.keys $map_names[key] = $map_names[key].name end alias prexus_metroid_stitle_command_new_game command_new_game def command_new_game $map_objects = {} for key in $map_names.keys map_info = $map_names[key].split('-') next unless map_info next unless map_info[0].upcase == 'M' $map_objects[key] = Map_Object.new $map_objects[key].big_id = map_info[1] $map_objects[key].x = alpha_convert(map_info[2]) $map_objects[key].y = map_info[3].to_i - 1 $map_objects[key].type = type_convert(map_info[4]) if map_info[4] end prexus_metroid_stitle_command_new_game end def alpha_convert(letter) case letter.upcase when 'A' return 0 when 'B' return 1 when 'C' return 2 when 'D' return 3 when 'E' return 4 when 'F' return 5 when 'G' return 6 when 'H' return 7 when 'J' return 8 when 'K' return 9 end end def type_convert(letter) case letter.upcase when 'B' return 1 when 'E' return 2 end end end module Map_Colors BORDER = Color.new(255, 255, 255) UNVISITED = Color.new(96, 96, 96) VISITED = Color.new(255, 128, 255) START = Color.new(128, 255, 128) BOSS = Color.new(128, 128, 255) PLAYER = Color.new(255, 255, 0) end class Map_Object attr_accessor :big_id attr_accessor :x attr_accessor :y attr_accessor :visited attr_accessor :type def initialize @big_id = 0 @x = 0 @y = 0 @visited = false @type = 0 # 0 = Blank, 1 = Dungeon Entrance, 2 = Boss Area end end class Game_Map alias prexus_metroid_gmap_setup setup def setup(map_id) prexus_metroid_gmap_setup(map_id) if $map_objects[@map_id] unless $map_objects[@map_id].visited $map_objects[@map_id].visited = true end if $scene.is_a?(Scene_Map) if $scene.map.big_id != $map_objects[@map_id].big_id $scene.map.big_id = $map_objects[@map_id].big_id end $scene.map.refresh end end end def big_id return $map_objects[@map_id].big_id if $map_objects[@map_id] return 0 end end class Map < Sprite attr_accessor :big_id def initialize super() self.x, self.y = 0, 0 self.bitmap = Bitmap.new(640, 480) self.bitmap.font.name = 'Georgia' self.bitmap.font.bold = true self.bitmap.font.size = 14 self.opacity = 255 self.visible = true self.z = 9998 @offset = [32, 32] # [x, y] @room_size = [20, 16] # [width, height] @big_id = 0 refresh end def refresh self.bitmap.clear return unless @big_id != 0 maps = {} for object in $map_objects next unless object[1].big_id == @big_id maps[object[0]] = object[1] end top_x = 0 top_y = 0 for map in maps.values top_x = map.x if top_x < map.x top_y = map.y if top_y < map.y end for x in 0..top_x + 1 for y in 0..top_y + 1 map = find_map(maps, x, y) next unless map draw_x = @offset[0] + (x * @room_size[0]) draw_y = @offset[1] + (y * @room_size[1]) self.bitmap.fill_rect(draw_x, draw_y, @room_size[0], @room_size[1], Map_Colors::BORDER) fill_color = (map.visited ? Map_Colors::VISITED : Map_Colors::UNVISITED) self.bitmap.fill_rect(draw_x + 1, draw_y + 1, @room_size[0] - 2, @room_size[1] - 2, fill_color) case map.type when 1 self.bitmap.fill_rect(draw_x + 6, draw_y + 6, @room_size[0] - 12, @room_size[1] - 12, Map_Colors::START) when 2 self.bitmap.fill_rect(draw_x + 6, draw_y + 6, @room_size[0] - 12, @room_size[1] - 12, Map_Colors::BOSS) end if ($map_objects[$game_map.map_id].x == x) and ($map_objects[$game_map.map_id].y == y) self.bitmap.fill_rect(draw_x + 6, draw_y + 6, @room_size[0] - 12, @room_size[1] - 12, Map_Colors::PLAYER) end end end end def find_map(hash, x, y) for map in hash.values return map if (map.x == x) and (map.y == y) end return nil end def update if @big_id != $game_map.big_id @big_id = $game_map.big_id refresh end end end class Scene_Map attr_accessor :map alias prexus_metroid_smap_main main def main @map = Map.new prexus_metroid_smap_main @map.dispose end alias prexus_metroid_smap_update update def update @map.update prexus_metroid_smap_update end end class Scene_Save alias prexus_metroid_ssave_write_save_data write_save_data def write_save_data(file) prexus_metroid_ssave_write_save_data(file) Marshal.dump($map_objects, file) end end class Scene_Load def read_save_data(file) characters = Marshal.load(file) Graphics.frame_count = Marshal.load(file) $game_system = Marshal.load(file) $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_screen = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_map = Marshal.load(file) $game_player = Marshal.load(file) $map_objects = Marshal.load(file) # ADDED LINE if $game_system.magic_number != $data_system.magic_number $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end $game_party.refresh end end