[Script] Dynamic Maps Expanded

Share resources for RPG Maker XP. Uploads must be your own work or have permission to share. Do not share game rips.
Post Reply
User avatar
DerVVulfman
Posts: 31
Joined: Sat Dec 08, 2018 4:25 am
Location: PG, Maryland
Contact:

[Script] Dynamic Maps Expanded

Post by DerVVulfman » Sun Dec 16, 2018 4:32 am

Dynamic Maps Expanded
Version: 1.0


Introduction
This script allows the user to allow the contents of their maps retain their settings prior to exiting or teleporting. This means that events that have moved on a map, or have changed their graphics through a simple self-switch, do not reset if the player leaves the map and later returns.


Screenshots
Yeeeaaahhhhh.... no. Nothing visible for a screenie.


Script

Code: Select all

#==============================================================================
# ** Dynamic Maps Expanded
#------------------------------------------------------------------------------
#    Expanded version by DerVVulfman
#    Version 1.0
#    07-26-2017 (MM/DD/YYYY)
#    RGSS / RPGMaker XP
#==============================================================================
#    Original Version by Near Fantastica - September 5, 2005
#    * First Revision by Wachunga - November 7, 2005
#    * Wachunga's initial work modified it for use with other Game_Map edits
#      while replacing global values with cleaner instance variable usage.
#==============================================================================
#
#  This script allows the user  to allow  the contents  of their maps retain
#  their settings prior to exiting or teleporting.   This means  that events
#  that have moved on a map, or have changed their graphics through a simple
#  self-switch, do not reset if the player leaves the map and later returns.
#
#  * Revisions by DerVVulfman
#    - Stores the saved  'dynamic maps'  values in with the save games. The 
#      original version did have issues if switching between saves.
#    - Added compatability for Big Maps (by DerVVulfman) 
#
#
#==============================================================================



#==============================================================================
# ** BigMaps
#------------------------------------------------------------------------------
#  This module handles routines executed without the need of the Game_Map
#  class being loaded to test validity of Big Map data
#==============================================================================

module BigMaps
  def self.exists?
    return BigMaps.const_defined? :Map
  end
end



#==============================================================================
# ** Game_MapD
#------------------------------------------------------------------------------
#  This class handles the storage and retrieval of Dynamic Map Data.
#  Refer to "$game_map_d" for the instance of this class.
#==============================================================================

class Game_MapD
  #--------------------------------------------------------------------------
  # * Private Instance Variables
  #--------------------------------------------------------------------------
  def initialize
    @map_data = {}
  end
  #--------------------------------------------------------------------------
  # * Set Map
  #     map    : map data
  #     map_id : Map ID
  #--------------------------------------------------------------------------  
  def set_map(map, map_id)
    map_id = big_map?(map_id)
    @map_data[map_id] = map
  end
  #--------------------------------------------------------------------------
  # * Get Map
  #     map_id : Map ID
  #--------------------------------------------------------------------------  
  def get_map(map_id)
    map_id = big_map?(map_id)
    return @map_data[map_id]
  end
  #--------------------------------------------------------------------------
  # * Big Map Test ?
  #     map_id : Map ID
  #--------------------------------------------------------------------------
  def big_map?(map_id)
    # Reset the test array
    map_list  = []
    # Exit unless Big Maps Exist
    unless BigMaps.exists?
      # Exit Method
      return map_id
    end
    # IF Big Map System exists
    map_key   = BigMaps.map_test(map_id)
    # If within a Big Map
    unless map_key.nil?
      # Change the map ID
      map_list  = BigMaps::Map[map_key]    
      map_id    = map_list[1][0]
    end
    # Exit Method
    return map_id
  end
end



#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles the map. It includes scrolling and passable determining
#  functions. Refer to "$game_map" for the instance of this class.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Alias Listingd
  #--------------------------------------------------------------------------
  alias dm_orig_setup setup
  #--------------------------------------------------------------------------
  # * Setup
  #     map_id : map ID
  #--------------------------------------------------------------------------
  def setup(map_id)
    # Save current map
    save_map(@map_id)
    # If test for Dynamic Map fails
    if $game_map_d.get_map(map_id) == nil
      # Perform the original call
      dm_orig_setup(map_id)
      # Exit method
      return
    end
    # Load Dynamic Map
    load_map(map_id)
  end
  #--------------------------------------------------------------------------
  # * Load Dynamic Map
  #     map_id : map ID
  #--------------------------------------------------------------------------
  def load_map(map_id)
    # Restore map game object from Dynamic Map Module by ID
    $game_map = $game_map_d.get_map(map_id)
  end
  #--------------------------------------------------------------------------
  # * Save Dynamic Map
  #     map_id : map ID
  #--------------------------------------------------------------------------
  def save_map(map_id)
    # Exit method if no active map ID
    return if map_id == 0
    # Set Current Map into Dynamic Map Module
    $game_map_d.set_map(self.dup, map_id)
  end
end



#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs title screen processing.
#==============================================================================

class Scene_Title
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias data_command_new_game command_new_game
  #--------------------------------------------------------------------------
  # * Command: New Game
  #--------------------------------------------------------------------------
  def command_new_game
    # Create the ABS object
    $game_map_d = Game_MapD.new
    # Perform the original call
    data_command_new_game
  end
end



#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
#  This class performs load screen processing.
#==============================================================================

class Scene_Load < Scene_File
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias lycan_scene_load_read_save_data read_save_data
  #--------------------------------------------------------------------------
  # * Read Save Data
  #     file : file object for reading (opened)
  #--------------------------------------------------------------------------
  def read_save_data(file)
    # Create the ABS object
    $game_map_d = Game_MapD.new    
    # The original call
    lycan_scene_load_read_save_data(file)
    # Load map
  end
end
[/spoiler]


Instructions
Post this Below Scene_Debug and above Main. If used with either Big Maps (by DerVVulfman) and/or Fog of War (by Wachunga), it must be below 'em'. It should take effect after that.


FAQ
I only did this rewrite after testing Near's early 2007 era work, only to see it didn't function properly between different game saves under specific conditions.


Compatibility
Designed for RPGMaker XP. As a bonus, compatible with my Big Maps at no extra cost.


Credits and Thanks
Credits definitely to Near Fantastica for the initial work and Wachunga for his edit to make Near's original work more compliant with other map scripts.

Terms and Conditions
Free for use, even in commercial projects. Due credit is required, not only for me but for Near Fantastica and Wachunga.
Up is down. Left is right. And sideways is straight ahead.
Image

Post Reply