Fast Travel Script

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by BlackMage, May 4, 2017.

  1. BlackMage

    BlackMage The Warlock of Darkness Veteran

    Messages:
    56
    Likes Received:
    24
    Location:
    Fantasy Realm
    First Language:
    Bahasa
    Primarily Uses:
    RMVXA
    Fast Travel Script 1.1
    by Black Mage
    Introduction
    Fast travel is a concept where you have several locations in a map (Usually this map is called an overworld map) and by selecting one of those locations, you’re transported to their respective location. That's this script's main function.

    Features
    1. Allow you to fast travel between location.
    2. You can use big map for your overworld.
    3. Customizable BGM & SFX for the map.
    4. Several additional windows for the map.
    5. Animated location icon.

    Screenshots
    I'll put a video instead. It's showing how the map selection works.


    How to Use
    1. Put the script on your game.
    2. Put the map graphic inside Graphics/System folder. Make sure you named the graphics “Map_Select”.
    3. Put the location selection window graphic inside Graphics/System folder. Make sure you named the graphic “Window_Map”.
    4. Put an empty graphic named “Empty”. This graphic is needed to run the script, mostly as a placeholder.
    5. Put the locations on the script.
    6. Customize where each location will transfer the player when they're selected.
    7. Customize a lot of other variables found within the script.
    8. Call the map using this script call:
    SceneManager.call(Scene_Map_Select)

    Demo
    Demo using Script V-1.0 (Mediafire)
    Demo using Script V-1.1 (Mediafire)

    Script
    Code:
    #----------------------------------------------------------------------------
    # Fast Travel Script By Black Mage (Credit required to use)
    # Version: 1.1
    #----------------------------------------------------------------------------
    #
    # * The script creates a map that hovers through listed locations.
    #
    # * The background image is named "Map_Select", and placed inside
    #   Graphics/System folder.
    #
    # * The image named "Empty" is required as dummy and placeholder in several cases.
    #   You can use an empty PNG file for it.
    #   The image is placed inside Graphics/System folder.
    #
    # * The image named "Window_Map" is used as the location selection window.
    #   The image is placed inside Graphics/System folder.
    #
    #----------------------------------------------------------------------------
    #
    # * How to use:
    #
    # * Enlist every available location into MAP_LIST.
    #
    # * Assign a switch for each location. Put them on SWITCH_LIST.
    #
    # * When you want a map is listed on the Map Select menu, simply turn their
    #   respective switch value to "true".
    #
    # * Assign x and y variables for the screen to hover when a location is
    #   highlighted. Put them on LOCATION_COORDINATE
    #
    # * Assign where to teleport when a location is selected. Put them on
    #   TELEPORT_LIST.
    #
    # * Enjoy your map select menu.
    #
    #----------------------------------------------------------------------------
    #
    # * There's several additional option below. Feel free to edit them.
    #
    #----------------------------------------------------------------------------
    
    module BLACK_MAP_LIST
     
      #--------------------------------------------------------------------------
      # Map name list. This is needed for metaprogramming.
      #--------------------------------------------------------------------------
      MAP_LIST = ["Australia",
                 "Russia",
                 "America"]
     
      #--------------------------------------------------------------------------
      # Switches that enable the map.
      #--------------------------------------------------------------------------
      SWITCH_LIST = [1, # When switch 01 is on, you can transfer to Australia.
                    3, # When switch 03 is on, you can transfer to Russia.
                    2] # And so on.
    
      #--------------------------------------------------------------------------
      # Assign each map name where to teleport.
      #--------------------------------------------------------------------------
      #                 Map ID, x,  y,  player direction
      TELEPORT_LIST = [[2,      8,  1,  2], # This is where "Australia" is going to be.
                      [3,      8, 11,  8], # "Russia".
                      [1,     15,  7,  4]] # and so on.
      
      #--------------------------------------------------------------------------
      # Assign overworld location coordinate.
      #--------------------------------------------------------------------------
      LOCATION_COORDINATE = [[-470,-100], #The map will move here when "Australia" is highlighted
                            [-120,560],
                            [880,300]]
    
      #--------------------------------------------------------------------------
      # Assign text color for location selection. The color depends on Window
      # graphic that you use. 0 is the default color.
      #--------------------------------------------------------------------------
      TEXT_LOCA_COLOR = [0,
                        3,
                        2]
    
      #--------------------------------------------------------------------------
      # Position of the background image.
      #--------------------------------------------------------------------------
      MAP_POSITION = [0,0] #[x,y]
      #--------------------------------------------------------------------------
      # How far the background image is zoomed out.
      #--------------------------------------------------------------------------
      MAP_ZOOM_OUT = [0.25, 0.25] #[zoom_x, zoom_y]
      #--------------------------------------------------------------------------
      # How far the background image is zoomed in when a location is selected.
      #--------------------------------------------------------------------------
      MAP_ZOOM_IN = [1, 1] #[x, y]
      #--------------------------------------------------------------------------
      # Maximum magnify speed when the scene is started.
      #--------------------------------------------------------------------------
      MAX_ZOOM_SPEED = 0.01
     
      #--------------------------------------------------------------------------
      # Position of the available choices.
      #--------------------------------------------------------------------------
      CHOICE_POSITION = [0,0] #[x,y]
      #--------------------------------------------------------------------------
      # Position of the window that holds list of the available choices.
      #--------------------------------------------------------------------------
      WINDOW_POSITION = [0,10] #[x,y]
      #--------------------------------------------------------------------------
      # The width for location selection choices.
      #--------------------------------------------------------------------------
      MAP_WINDOW_WIDTH = 132
      #--------------------------------------------------------------------------
      # The height for location selection choices.
      #--------------------------------------------------------------------------
      MAP_WINDOW_HEIGHT = 10 # Amount of visible choices in the window.
      #--------------------------------------------------------------------------
      # Maximum scroll speed when scrolling through the map.
      #--------------------------------------------------------------------------
      MAX_SCROLL_SPEED = 20
      #--------------------------------------------------------------------------
      # The map won't scrolled until the zoom is above this number for x and y.
      #--------------------------------------------------------------------------
      SCROLL_BOUNDARY = [0.5, 0.5] #[zoom_x, zoom_y]
    
      #--------------------------------------------------------------------------
      # Position of location selection window picture.
      #--------------------------------------------------------------------------
      WINDOW_PIC_POSITION = [0, 0] #[x, y]
      #--------------------------------------------------------------------------
      # Opacity of location selection window picture.
      #--------------------------------------------------------------------------
      WINDOW_PIC_OPACITY = 200
     
      #--------------------------------------------------------------------------
      # Map Menu BGM.
      #--------------------------------------------------------------------------
      MAP_MENU_BGM = ["Field3", 100, 100] #["BGM name", Volume, Pitch]
     
      #--------------------------------------------------------------------------
      # SFX played when the selection is changed.
      #--------------------------------------------------------------------------
      MAP_MENU_SFX = ["Wind1", 100, 100] #["SFX name", Volume, Pitch]
     
     
      #--------------------------------------------------------------------------
      #
      # * Below is the configuration of additional information window.
      #
      #--------------------------------------------------------------------------
     
      #--------------------------------------------------------------------------
      # Location name.
      #--------------------------------------------------------------------------
      ADD_LOC_NAME = true # Set this to true to enable the location name info
      #--------------------------------------------------------------------------
      # Location name info position.
      #--------------------------------------------------------------------------
      ADD_LOC_NAME_POS = [347,0]
      #--------------------------------------------------------------------------
      # Location name info width & height.
      #--------------------------------------------------------------------------
      ADD_LOC_NAME_W_H = [200,100] # [width, height]
      #--------------------------------------------------------------------------
      # Location name font size.
      #--------------------------------------------------------------------------
      ADD_LOC_NAME_F_SIZE = 20
    
     
      #--------------------------------------------------------------------------
      # Location description.
      #--------------------------------------------------------------------------
      ADD_LOC_DESC = true # Set this to true to enable the location description info
      #--------------------------------------------------------------------------
      # Location description position.
      #--------------------------------------------------------------------------
      ADD_LOC_DESC_POS = [347,155] # [x, y]
      #--------------------------------------------------------------------------
      # Location description width & height.
      #--------------------------------------------------------------------------
      ADD_LOC_DESC_W_H = [300,100] # [width, height]
      #--------------------------------------------------------------------------
      # Location description font size.
      #--------------------------------------------------------------------------
      ADD_LOC_DESC_F_SIZE = 20
      #--------------------------------------------------------------------------
      # Description for each location.
      #--------------------------------------------------------------------------
      ADD_LOC_DESC_VALUE = ["Australia is, well," + "\n" + "Australia.",  # Desc. for Australia.
                           "Russia..." + "\n" + "Yeah, Russia.",         # Desc. for Russia.
                           "America is America."]                        # and so on.
                          
      #--------------------------------------------------------------------------
      # Location thumbnail.
      #--------------------------------------------------------------------------
      ADD_LOC_THUMB = true # Set this to true to enable the location thumbnail.
      #--------------------------------------------------------------------------
      # Location description position.
      #--------------------------------------------------------------------------
      ADD_LOC_THUMB_POS = [376,47] # [x, y]
     
      #--------------------------------------------------------------------------
      # Location quests.
      #--------------------------------------------------------------------------
      ADD_LOC_QUEST = true
      #--------------------------------------------------------------------------
      # Location quests switches.
      #--------------------------------------------------------------------------
      ADD_LOC_QUEST_S = [[],
                        [6],
                        [4,5]]
      #--------------------------------------------------------------------------
      # Location quests text.
      #--------------------------------------------------------------------------
      #                 [switch number,   text to show when the value is true]
      ADD_LOC_Q_TEXT = [[4,               "* Find a way to" + "\n" + "Russia!"],
                       [5,               "* Get the package!"],
                       [6,               "* Deliver the package"]]
      #--------------------------------------------------------------------------
      # Location quests position.
      #--------------------------------------------------------------------------
      ADD_LOC_QUEST_POS = [347,200] # [x, y]
      #--------------------------------------------------------------------------
      # Location quests width & height.
      #--------------------------------------------------------------------------
      ADD_LOC_QUEST_W_H = [300,300] # [width, height]
      #--------------------------------------------------------------------------
      # Location quests font size.
      #--------------------------------------------------------------------------
      ADD_LOC_QUEST_F_SIZE = 20
     
      #--------------------------------------------------------------------------
      # Information Window Picture.
      #--------------------------------------------------------------------------
      ADD_WIN_PIC = true # Set this to true to enable the information window picture.
      #--------------------------------------------------------------------------
      # Position of additional information window picture.
      #--------------------------------------------------------------------------
      ADD_WIN_PIC_POS = [350, 3] #[x, y]
      #--------------------------------------------------------------------------
      # Opacity of additional information window picture.
      #--------------------------------------------------------------------------
      ADD_WIN_PIC_OPA = 200
     
      #--------------------------------------------------------------------------
      # Current Party Window.
      #--------------------------------------------------------------------------
      ADD_CUR_PARTY = true
      #--------------------------------------------------------------------------
      # Location quests position.
      #--------------------------------------------------------------------------
      ADD_CUR_PARTY_POS = [352,340] # [x, y]
      #--------------------------------------------------------------------------
      # Location quests width & height.
      #--------------------------------------------------------------------------
      ADD_CUR_PARTY_W_H = [180,80] # [width, height]
    
      #--------------------------------------------------------------------------
      # * This is an instruction if you want to use an icon for your location.
      # * First, the icon canvas mus be as big as the overworld canvas. This is
      #   the case to make sure the scrolling is as smooth as possible.
      # * Second, the icon must be named after the location found in MAP_LIST.
      # * Third, after the icon name, put the frame number of the icon. The number
      #   starts from 0.
      #--------------------------------------------------------------------------
      #--------------------------------------------------------------------------
      # * Location animated icon.
      #--------------------------------------------------------------------------
      LOC_ANI_ICON = true
      #--------------------------------------------------------------------------
      # * Location animated icon delay.
      #   You can call this animation speed. Decrease the value to make the animation
      #   faster.
      #--------------------------------------------------------------------------
      LOC_ANI_ICON_DELAY = 10
     
     
    end
    
    #----------------------------------------------------------------------------
    # * Beyond this is the sacred land of code. You need programming qualification
    #   to delve deeper, or it'll cause many unnecessary problems. Proceed on your
    #   own risk.
    #----------------------------------------------------------------------------
    
    class Scene_Map_Select < Scene_Base
     
      include BLACK_MAP_LIST
      
      def start
       super
       @last_map = "placeholder"
       @first_sfx = false
    
       @last_position = [MAP_POSITION[0], MAP_POSITION[1]]
       @distance_x = 0
       @distance_y = 0
      
       @last_zoom = [MAP_ZOOM_OUT[0], MAP_ZOOM_OUT[1]]
      
       @icon_max = 0
       @icon_current = 0
       @icon_delay_cur = 0
      
       create_maplist
      
       create_information_window
       create_command_window
      
       create_background
       create_map_icon
       create_map_window
       location_update_index
       RPG::BGM.new(MAP_MENU_BGM[0], MAP_MENU_BGM[1], MAP_MENU_BGM[2]).play
      end
      
      def create_information_window
       if ADD_LOC_NAME
         @information_window_1 = Window_Information_1.new
         @information_window_1.opacity = 0
       end
       if ADD_LOC_DESC
         @information_window_2 = Window_Information_2.new
         @information_window_2.opacity = 0
       end
       if ADD_LOC_THUMB
         @information_window_3 = Sprite.new
         @information_window_3.bitmap = Cache.system("Empty")  
         @information_window_3.ox = 0
         @information_window_3.oy = 0
         @information_window_3.x = ADD_LOC_THUMB_POS[0]
         @information_window_3.y = ADD_LOC_THUMB_POS[1]
         @information_window_3.z = 2
       end
       if ADD_LOC_QUEST
         @information_window_4 = Window_Information_4.new
         @information_window_4.opacity = 0
       end
       if ADD_WIN_PIC
         @info_window = Sprite.new
         @info_window.bitmap = Cache.system("Window_Info")  
         @info_window.ox = 0
         @info_window.oy = 0
         @info_window.x = ADD_WIN_PIC_POS[0]
         @info_window.y = ADD_WIN_PIC_POS[1]
         @info_window.z = 2
         @info_window.opacity = 0
       end
       if ADD_CUR_PARTY
         @current_party_window = Window_Current_Party.new
         @current_party_window.opacity = 0
         @current_party_window.refresh
       end
      end
     
      def create_map_window
       @map_window = Sprite.new
       @map_window.bitmap = Cache.system("Window_Map")  
       @map_window.ox = 0
       @map_window.oy = 0
       @map_window.x = WINDOW_PIC_POSITION[0]
       @map_window.y = WINDOW_PIC_POSITION[1]
       @map_window.z = 2
       @map_window.opacity = 0
      end
      
      def create_maplist
       @map_list = []
       for i in 0..MAP_LIST.size - 1
         if $game_switches[SWITCH_LIST[i]] == true
           @map_list.push(MAP_LIST[i])
         end
       end
      end
     
      alias black_update update
      def update
       black_update
       if @map_list.size != 0
         icon_update if @map_window != nil
       end
      end
     
      def location_update_index
       if @command_window != nil
         @last_map = @map_list[@command_window.index].to_s
        
         if LOC_ANI_ICON
           @map_name = assigned_number(@map_list[@command_window.index].to_s)
           @map_name = @map_list[@command_window.index].to_s
           @map_icon.bitmap = Cache.system(@map_name + "0")
           @icon_max = pic_list_number
           @icon_current = 0
         else
           @map_icon.bitmap = Cache.system("Empty")
         end
        
       end
       if @first_sfx == true
         RPG::SE.new(MAP_MENU_SFX[0], MAP_MENU_SFX[1], MAP_MENU_SFX[2]).play
       end
      end
      
      def pic_list_number
       @map_name
       @pic_frames = []
       for index in 0..999
         begin
           picture = Cache.system(@map_name + index.to_s).nil?
         rescue
           nil
         else
           @pic_frames[index] = index
         end
         break if @pic_frames[index] == nil
       end
       return @pic_frames.size
      end
     
      def icon_update
       if LOC_ANI_ICON
         if @icon_delay_cur < LOC_ANI_ICON_DELAY
           @icon_delay_cur += 1
         else
           @icon_delay_cur = 0
           if @icon_current.to_i < (@icon_max - 1)
             @map_icon.bitmap = Cache.system(@map_name + (@icon_current.to_i + 1).to_s)
             @icon_current += 1
           else
             @map_icon.bitmap = Cache.system(@map_name + "0")
             @icon_current = 0
           end
         end
       end
      
       @map_window.opacity = WINDOW_PIC_OPACITY
       @info_window.opacity = ADD_WIN_PIC_OPA if ADD_WIN_PIC
      
       @map_index = assigned_number(@map_list[@command_window.index].to_s)
       map_move(@last_position[0], @last_position[1],
                LOCATION_COORDINATE[@map_index][0], LOCATION_COORDINATE[@map_index][1],
                255)
              
       #--------------------------------------------------------------------------
       # Define the magnifying speed.
       #--------------------------------------------------------------------------
       @magnify_x = (MAP_ZOOM_IN[0] - @last_zoom[0])/10
      
       if @magnify_x > 0
         @magnify_x = [MAX_ZOOM_SPEED, @magnify_x].min
       end
       if @magnify_x < 0
         @magnify_x = [MAX_ZOOM_SPEED, @magnify_x].max
       end
        
       if @magnify_x < 0.005 and @magnify_x > 0
           @magnify_x = 0.005
       elsif @magnify_x > -0.005 and @magnify_x < 0
           @magnify_x = -0.005
       end
              
       @magnify_y = (MAP_ZOOM_IN[1] - @last_zoom[1])/10
      
       if @magnify_y > 0
         @magnify_y = [MAX_ZOOM_SPEED, @magnify_y].min
       end
       if @magnify_y < 0
         @magnify_y = [MAX_ZOOM_SPEED, @magnify_y].max
       end
      
       if @magnify_y < 0.005 and @magnify_y > 0
           @magnify_y = 0.005
       elsif @magnify_y > -0.005 and @magnify_y < 0
           @magnify_y = -0.005
       end
          
       #--------------------------------------------------------------------------
       # Scrolling.
       #--------------------------------------------------------------------------
       if @background_sprite.zoom_x > SCROLL_BOUNDARY[0] and @background_sprite.zoom_y > SCROLL_BOUNDARY[1]
         if @first_sfx == false
           RPG::SE.new(MAP_MENU_SFX[0], MAP_MENU_SFX[1], MAP_MENU_SFX[2]).play
           @first_sfx = true
         end
         @background_sprite.x = @background_sprite.x + @distance_x
         @background_sprite.y = @background_sprite.y + @distance_y
         @map_icon.x = @map_icon.x + @distance_x
         @map_icon.y = @map_icon.y + @distance_y
       end
      
       @background_sprite.zoom_x = @background_sprite.zoom_x + @magnify_x
       @map_icon.zoom_x = @map_icon.zoom_x + @magnify_x
       if @magnify_x == 0.005
         if @background_sprite.zoom_x > MAP_ZOOM_IN[0]
           @background_sprite.zoom_x = MAP_ZOOM_IN[0]
           @map_icon.zoom_x = MAP_ZOOM_IN[0]
         end
       elsif @magnify_x == -0.005
         if @background_sprite.zoom_x < MAP_ZOOM_IN[0]
           @background_sprite.zoom_x = MAP_ZOOM_IN[0]
           @map_icon.zoom_x = MAP_ZOOM_IN[0]
         end
       end
      
       @background_sprite.zoom_y = @background_sprite.zoom_y + @magnify_y
       @map_icon.zoom_y = @map_icon.zoom_y + @magnify_y
       if @magnify_y == 0.005
         if @background_sprite.zoom_y > MAP_ZOOM_IN[1]
           @background_sprite.zoom_y = MAP_ZOOM_IN[1]
           @map_icon.zoom_y = MAP_ZOOM_IN[1]
         end
       elsif @magnify_y == -0.005
         if @background_sprite.zoom_y < MAP_ZOOM_IN[1]
           @background_sprite.zoom_y = MAP_ZOOM_IN[1]
           @map_icon.zoom_y = MAP_ZOOM_IN[1]
         end
       end
          
       #--------------------------------------------------------------------------
       # Adjust the position.
       #--------------------------------------------------------------------------
       @last_position[0] = @background_sprite.x
       @last_position[1] = @background_sprite.y
       @last_zoom[0] = @background_sprite.zoom_x
       @last_zoom[1] = @background_sprite.zoom_y
      
      end
     
      def map_move(f_x, f_y, x, y, opacity)
    
       @distance_x = (x - f_x)/10
       if @distance_x > 0
         @distance_x = [MAX_SCROLL_SPEED, @distance_x].min
       end
       if @distance_x < 0
         @distance_x = [(MAX_SCROLL_SPEED*(-1)), @distance_x].max
       end
      
       if @distance_x == 0
         if @last_position[0] == LOCATION_COORDINATE[@map_index][0]
         elsif (x - f_x) < 0
           @distance_x = -1
         else
           @distance_x = 1      
         end
       end
      
       @distance_y = (y - f_y)/10
       if @distance_y > 0
         @distance_y = [MAX_SCROLL_SPEED, @distance_y].min
       end
       if @distance_y < 0
         @distance_y = [(MAX_SCROLL_SPEED*(-1)), @distance_y].max
       end
    
       if @distance_y == 0
         if @last_position[1] == LOCATION_COORDINATE[@map_index][1]
         elsif (y - f_y) < 0
           @distance_y = -1
         else
           @distance_y = 1      
         end
       end
      
      end
      
      def create_command_window
       @command_window = Window_MapSelect.new
       @command_window.x = WINDOW_POSITION[0]
       @command_window.y = WINDOW_POSITION[1]
       for i in 0..MAP_LIST.size - 1
         @command_window.set_handler(MAP_LIST[i].to_sym, method(MAP_LIST[i].to_sym))
       end
       @command_window.set_handler(:cancel,    method(:return_scene))
       @command_window.information_window_1 = @information_window_1
       @command_window.information_window_2 = @information_window_2
       @command_window.information_window_4 = @information_window_4
       @command_window.information_1_update if ADD_LOC_NAME
       @command_window.information_2_update if ADD_LOC_DESC
       information_3_update if ADD_LOC_THUMB
       @command_window.information_4_update if ADD_LOC_QUEST
      end
     
      def information_3_update
       if @information_window_3 != nil and @command_window !=nil
         bitmap_pic = @map_list[@command_window.index].to_s + "_Thumb"
         @information_window_3.bitmap = Cache.system(bitmap_pic)
       end
      end
     
      def create_background
       @background_sprite = Sprite.new
       @background_sprite.bitmap = Cache.system("Map_Select")  
       @background_sprite.ox = @background_sprite.bitmap.width / 2
       @background_sprite.oy = @background_sprite.bitmap.height / 2
       @background_sprite.x = Graphics.width / 2
       @background_sprite.y = Graphics.height / 2
       @background_sprite.zoom_x = MAP_ZOOM_OUT[0]
       @background_sprite.zoom_y = MAP_ZOOM_OUT[1]
      end
    
      def create_map_icon
       @map_icon = Sprite.new
       @map_icon.bitmap = Cache.system("Empty")  
       @map_icon.ox = @background_sprite.bitmap.width / 2
       @map_icon.oy = @background_sprite.bitmap.height / 2
       @map_icon.zoom_x = MAP_ZOOM_OUT[0]
       @map_icon.zoom_y = MAP_ZOOM_OUT[1]
       @map_icon.x = Graphics.width / 2
       @map_icon.y = Graphics.height / 2
       @map_icon.z = 1
      end
     
      MAP_LIST.each do |map_name|
       define_method(map_name) do
         list_number = assigned_number(map_name)
         transfer_map(list_number)
       end
      end
     
      def assigned_number(map_name)
       for i in 0..MAP_LIST.size - 1
         if MAP_LIST[i] == map_name
           return i
         end
       end
      end
     
      def transfer_map(a)
       b = TELEPORT_LIST
       $game_temp.fade_type = 2
       $game_player.reserve_transfer(b[a][0],b[a][1],b[a][2],b[a][3])
       return_scene
      end
      
      def close_command_window
       @command_window.close
       update until @command_window.close?
       fadeout_all
       @command_window.dispose
       @background_sprite.bitmap = nil
      end
     
      def black_dispose
       @command_window.dispose
       @map_window.bitmap.dispose ; @map_window.dispose ; @map_window = nil
       @map_icon.bitmap.dispose ; @map_icon.dispose ; @map_icon = nil
      
       if ADD_WIN_PIC
         @info_window.bitmap.dispose
         @info_window.dispose
         @info_window = nil
       end
      
       if @background_sprite.bitmap != nil
         @background_sprite.bitmap.dispose
       end
       @background_sprite.dispose
       @background_sprite = nil
      
       @information_window_1.dispose if ADD_LOC_NAME
       @information_window_2.dispose if ADD_LOC_DESC
      
       if ADD_LOC_THUMB
         @information_window_3.bitmap.dispose
         @information_window_3.dispose
         @information_window_3 = nil
       end
      
       @information_window_4.dispose if ADD_LOC_QUEST
       @current_party_window.dispose if ADD_CUR_PARTY
      end
     
      def return_scene
       close_command_window
       black_dispose
       super
       RPG::BGM.fade(500)
       $game_map.autoplay
      end
    
    end
    
    #--------------------------------------------------------------------------
    # * Map Command List Window
    #--------------------------------------------------------------------------
    class Window_MapSelect < Window_Command
     
      include BLACK_MAP_LIST
     
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
       create_maplist
       super(0, 0)
       self.openness = 0
       open
       self.opacity = 0
      end
      
      #--------------------------------------------------------------------------
      # * Get Window Width
      #--------------------------------------------------------------------------
      def window_width
       return MAP_WINDOW_WIDTH
      end
      #--------------------------------------------------------------------------
      # * Create Command List
      #--------------------------------------------------------------------------
      def make_command_list
       for i in 0..@map_list.size - 1
         if @map_list.size != 0
           add_command(@map_list[i], @map_list[i].to_sym)
         end
       end
      end
     
      #--------------------------------------------------------------------------
      # * Get unlocked map list
      #--------------------------------------------------------------------------
      def create_maplist
       @map_list = []
       for i in 0..MAP_LIST.size - 1
         if $game_switches[SWITCH_LIST[i]] == true
           @map_list.push(MAP_LIST[i])
         end
       end
      end
     
      def index=(index)
       super
       SceneManager.scene.location_update_index
       information_1_update if ADD_LOC_NAME
       information_2_update if ADD_LOC_DESC
       SceneManager.scene.information_3_update if ADD_LOC_THUMB
       information_4_update if ADD_LOC_QUEST
      end
     
      #--------------------------------------------------------------------------
      # * Draw Item
      #--------------------------------------------------------------------------
      def draw_item(index)
       font_color = assigned_number(command_name(index))
       change_color(text_color(TEXT_LOCA_COLOR[font_color]), command_enabled?(index))
       draw_text(item_rect_for_text(index), command_name(index), alignment)
      end
      
      #--------------------------------------------------------------------------
      # * Get Window Height
      #--------------------------------------------------------------------------
      def window_height
       fitting_height(MAP_WINDOW_HEIGHT)
      end
     
      #--------------------------------------------------------------------------
      # * Information Window
      #--------------------------------------------------------------------------
      def information_window_1=(information_window)
       @information_window_1 = information_window
      end
     
      def information_window_2=(information_window)
       @information_window_2 = information_window
      end
     
      def information_window_4=(information_window)
       @information_window_4 = information_window
      end
     
      def information_1_update
       if @information_window_1 != nil
         @information_window_1.clear
         text = @map_list[self.index].to_s
         @information_window_1.set_text(text)
       end
      end
     
      def information_2_update
       if @information_window_2 != nil
         @information_window_2.clear
         text = ADD_LOC_DESC_VALUE[assigned_number(@map_list[self.index].to_s)]
         @information_window_2.set_text(text)
       end
      end
     
      def information_4_update
       if @information_window_4 != nil
         @information_window_4.clear
         text = ""
         map_num = assigned_number(@map_list[self.index].to_s)
         for i in 0..ADD_LOC_QUEST_S[map_num].size - 1
           if ADD_LOC_QUEST_S[map_num].size != -1
             if $game_switches[ADD_LOC_QUEST_S[map_num][i]]
               quest_desc = assigned_quest(ADD_LOC_QUEST_S[map_num][i])
               text = text + "\n" + ADD_LOC_Q_TEXT[quest_desc][1]
             end
           end
         end
         @information_window_4.set_text(text)
       end
      end
     
      #--------------------------------------------------------------------------
      # * Return location number from location name
      #--------------------------------------------------------------------------
      def assigned_number(map_name)
       for i in 0..MAP_LIST.size - 1
         if MAP_LIST[i] == map_name
           return i
         end
       end
      end
     
      #--------------------------------------------------------------------------
      # * Return quest number from quest switch
      #--------------------------------------------------------------------------
      def assigned_quest(quest_switch)
       for i in 0..ADD_LOC_Q_TEXT.size - 1
         if ADD_LOC_Q_TEXT[i][0] == quest_switch
           return i
         end
       end
      end
     
    end
    
    #--------------------------------------------------------------------------
    # * Map Additional Location Name Window
    #--------------------------------------------------------------------------
    class Window_Information_1 < Window_Base
     
      include BLACK_MAP_LIST
     
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
       super(ADD_LOC_NAME_POS[0], ADD_LOC_NAME_POS[1], ADD_LOC_NAME_W_H[0], ADD_LOC_NAME_W_H[1])
      end
      #--------------------------------------------------------------------------
      # * Set Text
      #--------------------------------------------------------------------------
      def set_text(text)
       if text != @text
         @text = text
         refresh
       end
      end
      #--------------------------------------------------------------------------
      # * Clear
      #--------------------------------------------------------------------------
      def clear
       set_text("")
      end
      #--------------------------------------------------------------------------
      # * Refresh
      #--------------------------------------------------------------------------
      def refresh
       contents.clear
       draw_text_ex(4, 0, @text)
      end
    
      def reset_font_settings
       super # run's Window_Base's reset_font_settings
       contents.font.size = ADD_LOC_NAME_F_SIZE
      end
    
    end
    
    class Window_Information_2 < Window_Base
     
      include BLACK_MAP_LIST
     
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
       super(ADD_LOC_DESC_POS[0], ADD_LOC_DESC_POS[1], ADD_LOC_DESC_W_H[0], ADD_LOC_DESC_W_H[1])
      end
      #--------------------------------------------------------------------------
      # * Set Text
      #--------------------------------------------------------------------------
      def set_text(text)
       if text != @text
         @text = text
         refresh
       end
      end
      #--------------------------------------------------------------------------
      # * Clear
      #--------------------------------------------------------------------------
      def clear
       set_text("")
      end
      #--------------------------------------------------------------------------
      # * Refresh
      #--------------------------------------------------------------------------
      def refresh
       contents.clear
       draw_text_ex(4, 0, @text)
      end
    
      def reset_font_settings
       super # run's Window_Base's reset_font_settings
       contents.font.size = ADD_LOC_DESC_F_SIZE
      end
     
    end
    
    class Window_Information_4 < Window_Base
     
      include BLACK_MAP_LIST
     
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
       super(ADD_LOC_QUEST_POS[0], ADD_LOC_QUEST_POS[1], ADD_LOC_QUEST_W_H[0], ADD_LOC_QUEST_W_H[1])
      end
      #--------------------------------------------------------------------------
      # * Set Text
      #--------------------------------------------------------------------------
      def set_text(text)
       if text != @text
         @text = text
         refresh
       end
      end
      #--------------------------------------------------------------------------
      # * Clear
      #--------------------------------------------------------------------------
      def clear
       set_text("")
      end
      #--------------------------------------------------------------------------
      # * Refresh
      #--------------------------------------------------------------------------
      def refresh
       contents.clear
       draw_text_ex(4, 0, @text)
      end
    
      def reset_font_settings
       super # run's Window_Base's reset_font_settings
       contents.font.size = ADD_LOC_QUEST_F_SIZE
      end
     
    end
    
    #--------------------------------------------------------------------------
    # * Window Current Party
    #--------------------------------------------------------------------------
    class Window_Current_Party < Window_Base
     
      include BLACK_MAP_LIST
    
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
       super(ADD_CUR_PARTY_POS[0], ADD_CUR_PARTY_POS[1], ADD_CUR_PARTY_W_H[0], ADD_CUR_PARTY_W_H[1])
      end
      #--------------------------------------------------------------------------
      # * Draw Item
      #--------------------------------------------------------------------------
      def item_max
       return $game_party.members.size
      end
      def draw_all_items
       item_max.times {|i| draw_item(i) }
      end
     
      def draw_item(index)
       @actor = $game_party.members[index]
       if @actor != nil
         x_pos = 60
         draw_actor_graphic(@actor, index*40 + 20, 45)
       end
      end
     
      #--------------------------------------------------------------------------
      # * Refresh
      #--------------------------------------------------------------------------
      def refresh
       contents.clear
       draw_all_items
      end
     
    end
    
    FAQ
    None yet.

    Credit and Thanks
    Black Mage.
    Thanks to Sixth for reminding me that I forgot to put the dispose method inside the script. Also for several other contributions. ;)

    Author's Note
    If you having trouble on using this script, and it seems that I rarely appeared here, you can go directly to my wordpress, and ask something there. I mostly roaming around there so there's no need to worry that your question will be left unanswered.

    Here's a link to the pages of this script in my wordpress.
    Fast Travel Script
     
    Last edited: May 13, 2017
    #1
    BCj likes this.
  2. Sixth

    Sixth Veteran Veteran

    Messages:
    2,121
    Likes Received:
    789
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    Nice script!
    I noticed some things in it though:
    The check you use ( File.file?(filename) ) will not work in encrypted project, it will trigger a nice crash.
    More importantly, checks like that shouldn't even be needed in the end product at all.
    It should be the developer's responsibility to put the image files where they belong for the scripts, the script itself should never check for them.
    There are some cases where file checks can and need to be used (NOT for image files used), but they can still only check for files outside of the encrypted archive.

    Still related to the previous paragraph, you don't need to explicitly state the file extension for image files.
    PNG or JPEG, doesn't matter (in most cases, at least), just use the filename without the extension.
    Just like you did with the "Empty" image, which makes me wonder why did you specify the file type for the other ones? o_O

    You didn't dispose the sprites you made in the scene, so every time this menu is opened, 3 new sprite will be created but never disposed, which means memory leak.
    You must always dispose the sprites you create.
    Same for bitmaps, although if needed, you can keep them in the memory (you don't really need it in this script).
    So, dispose their bitmaps, than the sprites themselves to solve the memory leaks.
    People usually put these in the terminate method in the scene class, but I prefer the dispose_all_windows method instead, because that is always executed before the main viewport is disposed, but after the Graphics.freeze method, which ensures that your images will stay on the screen during the whole transition.

    Windows, on the other hand, if created in a scene class, and if they are stored in simple instance variables (so, not inside arrays, hashes, etc), do not need to be disposed, they will be automatically get disposed.

    The stuffs happening in the icon_update method are running constantly. Most of those things should not be set all the time, only on command change.
    Regardless of what you code, you should always consider performance and how you can improve your code to eliminate updating not necessary things in it.
    The method update_help in any kind of default selectable window class will be run only once whenever the cursor changes position. That is an optimal place to set whatever you want on cursor changes. Leave only what is necessary in your update method.
    Sorry about the wall of text, just wanted to make something productive yet relaxing during my coffee break. :p
     
    #2
  3. BlackMage

    BlackMage The Warlock of Darkness Veteran

    Messages:
    56
    Likes Received:
    24
    Location:
    Fantasy Realm
    First Language:
    Bahasa
    Primarily Uses:
    RMVXA
    Whoa, what a detailed responses! I'll try to reply each addressed subject as best as I can. :rhappy:
    The ( File.file?(filename) ) check are used for a feature I planned but the concept for the system is not finished yet (it's the one on FAQ). The feature is implemented but it's inferior to what I had in my imagination. I'm planned to get the perfected feature implemented sometimes later in the future, so I left the code for it intact in case someone wants to use it anyway. However, since this feature required other graphic files to work, It'll give an error when the graphic files are not found. I know I can put a boolean trigger for it on the module, but that's mean the feature will be documented somehow, and I don't want it. Thus, this became the reason why I do a file check on that method, to check whether the system uses the undocumented feature or not while obscuring the feature for public use.

    Thanks for the heads up on the syntax that it won't work on an encrypted project. Now I realized that it's a bad decision on my side. :rswt

    The File.file?(filename) syntax returns false when the filename variable are just the file name without the extension even though the files exist. Thus I gave them the extension.

    I was writing one for the script. However, I encounter an error when making them. Since I had another problem which tops the priority over the dispose method to solve on the script, I scrapped the whole dispose method (because the script is still working without them) and start working on another problem. It turns out that I forgot to work on the dispose method again. :rswt

    Thanks for the quick explanation about the disposing of sprites & bitmaps. All I know was to put .dispose to dispose an objects that can cause memory leaks. :rswt

    No, it needs to be constantly run to get the smooth scrolling effect.

    I'll put an example to show my point. Let say that I have 3 location (1,2,3) at the script, they are placed on coordinate [a1,a2], [b1,b2], and [c1,c2] respectively. If the stuff that happening inside Icon_Update are run only when the command change, I need to put them inside a loop to get the appropriate scrolling effect.

    Now consider the case where I change command from 1 to 2 followed to 3 before the map finished scrolling from coordinate [a1,a2] to [b1,b2]. What will happen is the picture would scroll into [b1,b2] first and then scroll into [c1,c2], instead of stopping in the middle of scrolling to [b1,b2] and went directly to [c1,c2], because the scrolling is done inside a loop. Thus the constant update on destination along with the scrolling (the stuff that happened inside Icon_Update) is needed. There is a little part of the script that doesn't need to be constantly updated though.

    Correct me if there's something wrong with my explanation.:rhappy:

    I think that's all I can think about. Thank you very much for your detailed responses. I highly appreciate it. :thumbsup-left:
     
    Last edited: May 5, 2017
    #3
  4. Sixth

    Sixth Veteran Veteran

    Messages:
    2,121
    Likes Received:
    789
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    Variables not needed to be updated constantly (or at all):
    1. @map_window.opacity - This doesn't really do anything. Why not set the opacity right when it's created?
    2. @last_map
    3. @map_icon.bitmap
    4. @map_index
    You can set all of these only once at each cursor change. That's 4 less things to update constantly. :p
     
    #4
  5. BlackMage

    BlackMage The Warlock of Darkness Veteran

    Messages:
    56
    Likes Received:
    24
    Location:
    Fantasy Realm
    First Language:
    Bahasa
    Primarily Uses:
    RMVXA
    True. They are the small part that I mentioned above that doesn't need to constantly updated. I'll move them to a better place. :rswt

    I have a question though.

    You're suggesting to run it on update_help method, however, that method belongs to the window class, while the variables 2 and 4 are instance variables on scene class, thus I can't change them directly from the window class. They can be modified though, by defining a new method inside the scene class and call them from the window class on update_help method using SceneManager syntax. However, I just feel the code seems weird because it's an object (the window class) inside a scene class that governed by SceneManager class, tried to change a value from another object inside the same scene class, through syntax from the SceneManager class. Perhaps it's just me.:rswt

    The only other way I can think to achieve that is by constantly checking the window object index from the scene class, and execute it when the index changed. Perhaps there's another way?
     
    #5
  6. Sixth

    Sixth Veteran Veteran

    Messages:
    2,121
    Likes Received:
    789
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    Why would that be a problem?
    As a matter of fact, you do the same with many other objects already.
    Whenever you change a property of a sprite, you do the same, manipulate an instance variable outside of it's object, or when you call a refresh method for a window in the scene class, for example.

    It's the same with SceneManager.scene.method_to_run.
    It performs a method on an object, just like all of your code. Scene classes are simple objects too, no need to worry about them.
    SceneManager is a module, accessible from anywhere, so use it if you need to, no need to hold back.
    How you get to the object is entirely up to you, but always try to do it the simplest way, don't over-complicate it, and don't make new variables if you don't really need them.
     
    #6
  7. BlackMage

    BlackMage The Warlock of Darkness Veteran

    Messages:
    56
    Likes Received:
    24
    Location:
    Fantasy Realm
    First Language:
    Bahasa
    Primarily Uses:
    RMVXA
    I see. I was thinking that the SceneManager is some higher hierarchy in the object hierarchy in the code. That's why I have some bad feeling when using it like the aforementioned example. It turns out that it's just a module, and like you said, it's accessible from anywhere.

    I'll fix the code to add the stuff we've been discussed. :D
     
    #7
  8. Tetsune

    Tetsune Professional Procrastinator™ Veteran

    Messages:
    51
    Likes Received:
    10
    First Language:
    English
    Primarily Uses:
    RMVXA
    This script is awesome! Is there a way you can add like a preview screenshot for any of the locations? Like, just a small box either above or below the map preview when you select a location?
     
    #8
  9. BlackMage

    BlackMage The Warlock of Darkness Veteran

    Messages:
    56
    Likes Received:
    24
    Location:
    Fantasy Realm
    First Language:
    Bahasa
    Primarily Uses:
    RMVXA
    Actually, I was working for a new version of the script. Coincidently, it was finished yesterday and it has the feature that you ask. I've updated the first post with these change.

    Version 1.1 (13 May 2017)
    – Bugfix for select location window position.
    – Add dispose method to the script to prevent memory leaks.
    – Add customized BGM & SFX for the map.
    – Add customized location color feature.
    – Add location name window.
    – Add location description window.
    – Add location thumbnail feature.
    – Add available quest window for location.
    – Add current party window feature.
    – Add animated location icon feature.

    New video to show how the new script works:


    And new demo, for studying purposes:
    Demo using Script V-1.1 (Mediafire)
     
    Last edited: May 13, 2017
    #9
  10. ydoolb

    ydoolb Veteran Veteran

    Messages:
    37
    Likes Received:
    17
    Nice script) Thank You.
     
    #10
  11. Tetsune

    Tetsune Professional Procrastinator™ Veteran

    Messages:
    51
    Likes Received:
    10
    First Language:
    English
    Primarily Uses:
    RMVXA
    After forever, I actually found an issue with this script.
    It seems to be with Blackmorning's Base script with this line
    #--------------------------------------------------------------------------
    # * Overwrite: draw_actor_graphic
    #--------------------------------------------------------------------------
    def draw_actor_graphic(actor, x, y, ani = false)
    draw_character(actor.character_name, actor.character_index, x, y, ani)
    end
     
    #11
  12. BlackMage

    BlackMage The Warlock of Darkness Veteran

    Messages:
    56
    Likes Received:
    24
    Location:
    Fantasy Realm
    First Language:
    Bahasa
    Primarily Uses:
    RMVXA
    I've put both script in a fresh project and no error happened. Perhaps the conflict is not between my script and blackmorning, but another script with blackmorning's instead.
     
    #12

Share This Page