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.

Find what graphics a map uses before transfer player

Im trying to find a way to make an hash of graphics used in a map before the player goes there. i tried reading through all the code but im not really seeing an easy way to do this. I use a custom data type and a cache(for faster loading since its slightly slower then bitmap.new) I just want to be able try to cut down the time by loading the files into the cache before the player even trys to transfer. I know ive seen scripts that open and read the contents of the map.rxdata files before, i just couldnt find one. can anyone help me out?

Thanks for any help you can offer
 
Here's a little thing I made long ago to do just that:

[rgss]class MapGraphics
 
  def tileset(map_id = nil)
    # Returns the name of the tileset of map with MAP_ID
    return get_tileset(map_id).tileset_name
  end
 
  def autotiles(map_id = nil)
    # Returns an array of autotile names of map with MAP_ID
    return get_tileset(map_id).autotile_names
  end
 
  def fog(map_id = nil)
    # Returns the name of the fog of map with MAP_ID
    return get_tileset(map_id).fog_name
  end
 
  def panorama(map_id = nil)
    # Returns the name of the panorama of map with MAP_ID
    return get_tileset(map_id).panorama_name
  end
 
  def characters(map_id = nil)
    # Returns a array of character graphics of map with MAP_ID
    graphics = []
    pages = (get_map(map_id).events.values.collect {|e| e.pages }).flatten
    graphics = pages.collect {|page| page.graphic.character_name }
    return (graphics - ['']).uniq
  end
 
  def get_tileset(map_id)
    map_id = $game_map.map_id if map_id == nil
    map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
    return $data_tilesets[map.tileset_id]
  end
 
  def get_map(map_id)
    map_id = $game_map.map_id if map_id == nil
    return load_data(sprintf("Data/Map%03d.rxdata", map_id))
  end
 
end
 
$mapinfo= MapGraphics.new
 
[/rgss]

Its stored in the global variable $mapinfo.
Usage is as follows:

  • $mapinfo.tileset(MAP_ID)
  • $mapinfo.autotiles(MAP_ID)
  • $mapinfo.fog(MAP_ID)
  • $mapinfo.panorama(MAP_ID)
  • $mapinfo.characters(MAP_ID)

If the MAP_ID argument is omitted, it will use the current map ID as default.

If you really want to get in-depth with it, you could add a few methods to enumerate through the event code and find picture graphics, etc.
 

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