Zelda Style Map Transition

Zelda-Style Map ScrollVersion: 1.0
By: Glaciesflamma

Introduction

This is something I'm sure has been asked for before, but I hadn't seen anyone produce the script just yet - at least not quite in the way I had hoped for when I started looking around. So I set to work to make it myself.

This Script was possible only thanks to SephirothSpawn's Tilemap Class Rewrite. I Used his script as a base and edited it as needed

This script creates 2D Zelda-Style Map Transitioning. As the Game Player approaches the maps edge, and tries to move off it, the script will load and draw the adjacent map, pan the screen over, and then load the adjacent map completely once done. The only condition of these is that the adjacent edges of the map must be equal in size, and 'lined up' (i.e. if moving left/right, the x coordinates are parallel to each other.)

This is accomplished mostly through the script itself, though the Game Maker will have to make a single event on each map titled "Transfer" that indicates the map ids of the map located in each direction. Leaving a direction out will prevent the transition for attempting to happen.

Features
  • Zelda-Style Map scrolling from one map to another
  • Able to transition to maps with different tilesets
  • Will draw and support events located on new map as transition occurs

Screenshots

Currently, I do not have any screenshots [I feel this would be hard to demonstrate via screenshots anyhow]. However, feel free to check out the script at work in the demo!

Demo

Zelda Map Scroll Demo

Script


Tilemap Script Show
  1. #==============================================================================
  2. # Tilemap Class
  3. #------------------------------------------------------------------------------
  4. # Script by SephirothSpawn
  5. #==============================================================================
  6.  
  7.  
  8.  
  9.  
  10. class Tilemap
  11.   #--------------------------------------------------------------------------
  12.   Animated_Autotiles_Frames = 15
  13.   #--------------------------------------------------------------------------
  14.   Autotiles = [
  15.     [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27,  6, 33, 34], [ 5,  6, 33, 34],
  16.       [27, 28, 33, 12], [ 5, 28, 33, 12], [27,  6, 33, 12], [ 5,  6, 33, 12] ],
  17.     [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27,  6, 11, 34], [ 5,  6, 11, 34],
  18.       [27, 28, 11, 12], [ 5, 28, 11, 12], [27,  6, 11, 12], [ 5,  6, 11, 12] ],
  19.     [ [25, 26, 31, 32], [25,  6, 31, 32], [25, 26, 31, 12], [25,  6, 31, 12],
  20.       [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ],
  21.     [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
  22.       [39, 40, 45, 46], [ 5, 40, 45, 46], [39,  6, 45, 46], [ 5,  6, 45, 46] ],
  23.     [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
  24.       [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ],
  25.     [ [37, 38, 43, 44], [37,  6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
  26.       [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1,  2,  7,  8] ]
  27.   ]
  28.   #--------------------------------------------------------------------------
  29.   attr_reader   :layers
  30.   attr_accessor :tileset
  31.   attr_accessor :autotiles
  32.   attr_accessor :map_data
  33.   attr_accessor :flash_data
  34.   attr_accessor :priorities
  35.   attr_accessor :visible
  36.   attr_accessor :ox
  37.   attr_accessor :oy
  38.   #--------------------------------------------------------------------------
  39.   def initialize(viewport, map = $game_map.map)
  40.     @layers = []
  41.     for l in 0...6
  42.       layer = (true ? Plane.new(viewport) : Sprite.new(viewport))
  43.       layer.bitmap = Bitmap.new(map.width * 32, map.height * 32)
  44.       layer.z = l * 160
  45.       @layers << layer
  46.     end
  47.     @tileset    = nil  # Refers to Map Tileset Name
  48.     @autotiles  = []   # Refers to Tileset Auto-Tiles (Actual Auto-Tiles)
  49.     @map_data   = nil  # Refers to 3D Array Of Tile Settings
  50.     @flash_data = nil  # Refers to 3D Array of Tile Flashdata
  51.     @priorities = nil  # Refers to Tileset Priorities
  52.     @visible    = true # Refers to Tilest Visibleness
  53.     @ox         = 0    # Bitmap Offsets
  54.     @oy         = 0    # bitmap Offsets
  55.     @data       = nil  # Acts As Refresh Flag
  56.     @map         = map
  57.     @tone        = Tone.new(0,0,0,0)
  58.     @plane       = true
  59.     @zoom_x      = 1.0
  60.     @zoom_y      = 1.0
  61.     @tile_width  = 32
  62.     @tile_height = 32
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   def prepare_transition(new_map, dir, viewport)
  66.     @new_map = new_map
  67.     @new_data = @new_map.data
  68.     @dir = dir
  69.     for l in 0...6
  70.       @layers[l].dispose
  71.       @layers[l] = nil
  72.       layer = (true ? Plane.new(viewport) : Sprite.new(viewport))
  73.       layer.bitmap = Bitmap.new((@map.width + @new_map.width) * 32,
  74.                                 (@map.height + @new_map.height) * 32)
  75.       layer.z = l * 160
  76.       @layers[l] = layer
  77.     end
  78.     if @dir == 4
  79.       @ox = @new_data.xsize * 53
  80.     elsif @dir == 8
  81.       @oy = @new_data.ysize * 128
  82.     end
  83.     merge_refresh
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   def dispose
  87.     for layer in @layers
  88.       layer.dispose
  89.     end
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   def update
  93.     if @data != @map_data or (@new_map != nil and @new_data != @new_data)
  94.       if @new_map == nil
  95.         refresh
  96.       else
  97.         merge_refresh
  98.       end
  99.     end
  100.     unless @tone == $game_screen.tone
  101.       @tone = $game_screen.tone
  102.       @tone = Tone.new(0, 0, 0, 0) if @tone.nil?
  103.       for layer in @layers
  104.         layer.tone = @tone
  105.         layer.tone = @tone
  106.       end
  107.     end
  108.     for layer in @layers
  109.       layer.ox = @ox
  110.       layer.oy = @oy
  111.       layer.z = @layers.index(layer) * 32
  112.     end
  113.     if Graphics.frame_count % Animated_Autotiles_Frames == 0
  114.       refresh_autotiles
  115.     end
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   def refresh
  119.     @data = @map_data
  120.     for p in 0..5
  121.       for z in 0...@map_data.zsize
  122.         for x in 0...@map_data.xsize
  123.           for y in 0...@map_data.ysize
  124.             id = @map_data[x, y, z]
  125.             next if id == 0
  126.             next unless p == @priorities[id]
  127.             id < 384 ? draw_autotile(x, y, p, id) : draw_tile(x, y, p, id)
  128.           end
  129.         end
  130.       end
  131.     end
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   def merge_refresh
  135.     @data = @map_data
  136.     @new_data = @new_map.data
  137.     z_max = @map_data.zsize
  138.     if [2,8].include?(@dir)
  139.       x_max = @map_data.xsize
  140.       y_max = @map_data.ysize + @new_data.ysize
  141.     elsif [4,6].include?(@dir)
  142.       x_max = @map_data.xsize + @new_data.xsize
  143.       y_max = @map_data.ysize
  144.     end
  145.     for p in 0..5
  146.       for z in 0...z_max
  147.         for x in 0...x_max
  148.           for y in 0...y_max
  149.             if [2,8].include?(@dir)
  150.               if y < @map_data.ysize
  151.                 id = @map_data[x, y, z]
  152.                 draw_map = @map
  153.               else
  154.                 id = @new_data[x, y - @map_data.ysize, z]
  155.                 draw_map = @new_map
  156.               end
  157.             elsif [4,6].include?(@dir)
  158.               if x < @map_data.xsize
  159.                 id = @map_data[x, y, z]
  160.                 draw_map = @map
  161.               else
  162.                 id = @new_data[x - @map_data.xsize, y, z]
  163.                 draw_map = @new_map
  164.               end
  165.             end
  166.             next if id == 0
  167.             next unless p == $data_tilesets[draw_map.tileset_id].priorities[id]
  168.             id < 384 ? draw_autotile(x, y, p, id, draw_map) : draw_tile(x, y, p, id, draw_map)
  169.           end
  170.         end
  171.       end
  172.     end
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   def refresh_autotiles
  176.     autotile_locations = Table.new(@map_data.xsize, @map_data.ysize,
  177.       @map_data.zsize)
  178.     for p in 0..5
  179.       for z in 0...@map_data.zsize
  180.         for x in 0...@map_data.xsize
  181.           for y in 0...@map_data.ysize
  182.             id = @map_data[x, y, z]
  183.             next if id == 0
  184.             next unless p == @priorities[id]
  185.             if id < 384
  186.               next unless @autotiles[id / 48 - 1].width / 96 > 1
  187.               draw_autotile(x, y, p, id)
  188.               autotile_locations[x, y, 0] = 1
  189.               autotile_locations[x, y, 1] = 1
  190.               autotile_locations[x, y, 2] = 1
  191.             else
  192.               if autotile_locations[x, y, z] == 1
  193.                 draw_tile(x, y, p, id)
  194.               end
  195.             end
  196.           end
  197.         end
  198.       end
  199.     end
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   def draw_tile(x, y, z, id, source=@map)
  203.     tileset = RPG::Cache.tileset($data_tilesets[source.tileset_id].tileset_name)
  204.     rect = Rect.new((id - 384) % 8 * 32, (id - 384) / 8 * 32, 32, 32)
  205.     x *= @tile_width
  206.     y *= @tile_height
  207.     if @tile_width == 32 && @tile_height == 32
  208.       @layers[z].bitmap.blt(x, y, tileset, rect)
  209.     else
  210.       dest_rect = Rect.new(x, y, @tile_width, @tile_height)
  211.       @layers[z].bitmap.stretch_blt(dest_rect, tileset, rect)
  212.     end
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   def draw_autotile(x, y, z, tile_id, source = @map)
  216.     if source == @map
  217.       autotile = @autotiles[tile_id / 48 - 1]
  218.     else
  219.       autotile = RPG::Cache.autotile(@new_map.autotile_names[tile_id / 48 - 1])
  220.     end
  221.     tile_id %= 48
  222.     bitmap = Bitmap.new(32, 32)
  223.     tiles = Autotiles[tile_id / 8][tile_id % 8]
  224.     frames = autotile.width / 96
  225.     anim = (Graphics.frame_count / Animated_Autotiles_Frames) % frames * 96
  226.     for i in 0...4
  227.       tile_position = tiles[i] - 1
  228.       src_rect = Rect.new(tile_position % 6 * 16 + anim,
  229.         tile_position / 6 * 16, 16, 16)
  230.       bitmap.blt(i % 2 * 16, i / 2 * 16, autotile, src_rect)
  231.     end
  232.     x *= @tile_width
  233.     y *= @tile_height
  234.     if @tile_width == 32 && @tile_height == 32
  235.       @layers[z].bitmap.blt(x, y, bitmap, Rect.new(0, 0, 32, 32))
  236.     else
  237.       dest_rect = Rect.new(x, y, @tile_width, @tile_height)
  238.       @layers[z].bitmap.stretch_blt(dest_rect, bitmap, Rect.new(0, 0, 32, 32))
  239.     end
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   def bitmap
  243.     bitmap = Bitmap.new(@layers[0].bitmap.width, @layers[0].bitmap.height)
  244.     for layer in @layers
  245.       bitmap.blt(0, 0, layer.bitmap, Rect.new(0, 0,
  246.         bitmap.width, bitmap.height))
  247.     end
  248.     return bitmap
  249.   end
  250.   #--------------------------------------------------------------------------
  251. end
Expand to see the code.


Zelda Scroll Script Show
  1. class Game_Temp
  2.   attr_accessor :map_transitioning
  3.   alias original_initialize initialize
  4.   def initialize
  5.     original_initialize
  6.     @map_transitioning = false
  7.   end
  8. end
  9.  
  10. class Game_Map
  11.   attr_reader   :map_link
  12.   #--------------------------------------------------------------------------
  13.   # * Setup
  14.   #     map_id : map ID
  15.   #--------------------------------------------------------------------------
  16.   def setup(map_id)
  17.     # Put map ID in @map_id memory
  18.     @map_id = map_id
  19.     # Load map from file and set @map
  20.     @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
  21.     # set tile set information in opening instance variables
  22.     tileset = $data_tilesets[@map.tileset_id]
  23.     @tileset_name = tileset.tileset_name
  24.     @autotile_names = tileset.autotile_names
  25.     @panorama_name = tileset.panorama_name
  26.     @panorama_hue = tileset.panorama_hue
  27.     @fog_name = tileset.fog_name
  28.     @fog_hue = tileset.fog_hue
  29.     @fog_opacity = tileset.fog_opacity
  30.     @fog_blend_type = tileset.fog_blend_type
  31.     @fog_zoom = tileset.fog_zoom
  32.     @fog_sx = tileset.fog_sx
  33.     @fog_sy = tileset.fog_sy
  34.     @battleback_name = tileset.battleback_name
  35.     @passages = tileset.passages
  36.     @priorities = tileset.priorities
  37.     @terrain_tags = tileset.terrain_tags
  38.     # Initialize displayed coordinates
  39.     @display_x = 0
  40.     @display_y = 0
  41.     # Clear refresh request flag
  42.     @need_refresh = false
  43.     # Set map event data
  44.     @events = {}
  45.     @map_link = [nil,0,0,0,0]
  46.     for i in @map.events.keys
  47.       @events[i] = Game_Event.new(@map_id, @map.events[i])
  48.       if @map.events[i].name == "Transfer"
  49.         for command in @map.events[i].pages[0].list
  50.           if command.parameters[0].is_a?(String)
  51.             if command.parameters[0]upcase..include?("LEFT")
  52.               left = command.parameters[0].split(':')[1]
  53.             elsif command.parameters[0].upcase.include?("UP")
  54.               up = command.parameters[0].split(':')[1]
  55.             elsif command.parameters[0].upcase.include?("RIGHT")
  56.               right = command.parameters[0].split(':')[1]
  57.             elsif command.parameters[0].upcase.include?("DOWN")
  58.               down = command.parameters[0].split(':')[1]
  59.             end
  60.           else
  61.             break
  62.           end
  63.         end
  64.         @map_link[1] = down.to_i
  65.         @map_link[2] = left.to_i
  66.         @map_link[3] = right.to_i
  67.         @map_link[4] = up.to_i
  68.       end
  69.     end
  70.     # Set common event data
  71.     @common_events = {}
  72.     for i in 1...$data_common_events.size
  73.       @common_events[i] = Game_CommonEvent.new(i)
  74.     end
  75.     # Initialize all fog information
  76.     @fog_ox = 0
  77.     @fog_oy = 0
  78.     @fog_tone = Tone.new(0, 0, 0, 0)
  79.     @fog_tone_target = Tone.new(0, 0, 0, 0)
  80.     @fog_tone_duration = 0
  81.     @fog_opacity_duration = 0
  82.     @fog_opacity_target = 0
  83.     # Initialize scroll information
  84.     @scroll_direction = 2
  85.     @scroll_rest = 0
  86.     @scroll_speed = 4
  87.     @transition_direction = 2
  88.     @transition_rest = 0
  89.     @transition_speed = 4
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # * Get Map
  93.   #--------------------------------------------------------------------------
  94.   def map
  95.     return @map
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # * Get Map
  99.   #--------------------------------------------------------------------------
  100.   def tileset_id
  101.     return @map.tileset_id
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # * Scroll Up or Down (Map Transition)
  105.   #     distance : scroll distance
  106.   #--------------------------------------------------------------------------
  107.   def transition_up_down(distance)
  108.     @display_y = @display_y + distance
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # * Scroll Left or Right (Map Transition)
  112.   #     distance : scroll distance
  113.   #--------------------------------------------------------------------------
  114.   def transition_left_right(distance)
  115.     @display_x = @display_x + distance
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # * Start Map Transition
  119.   #     direction : scroll direction
  120.   #     distance  : scroll distance
  121.   #     speed     : scroll speed
  122.   #--------------------------------------------------------------------------
  123.   def start_transition(direction, distance, speed)
  124.     @transition_direction = direction
  125.     @transition_rest = distance
  126.     @transition_speed = speed
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # * Determine if Transitioning
  130.   #--------------------------------------------------------------------------
  131.   def transitioning?
  132.     return @transition_rest > 0
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Frame Update
  136.   #--------------------------------------------------------------------------
  137.   def update
  138.     # Refresh map if necessary
  139.     if $game_map.need_refresh
  140.       refresh
  141.     end
  142.     # If scrolling
  143.     if @scroll_rest > 0
  144.       # Change from scroll speed to distance in map coordinates
  145.       distance = 2 ** @scroll_speed
  146.       # Execute scrolling
  147.       case @scroll_direction
  148.       when 2  # Down
  149.         scroll_down(distance)
  150.       when 4  # Left
  151.         scroll_left(distance)
  152.       when 6  # Right
  153.         scroll_right(distance)
  154.       when 8  # Up
  155.         scroll_up(distance)
  156.       end
  157.       # Subtract distance scrolled
  158.       @scroll_rest -= distance
  159.     end
  160.     # If transitioning
  161.     if @transition_rest > 0
  162.       # Change from scroll speed to distance in map coordinates
  163.       distance = 2 ** @transition_speed
  164.       # Execute scrolling
  165.       case @transition_direction
  166.       when 2  # Down
  167.         transition_up_down(-1 * distance)
  168.       when 4  # Left
  169.         transition_left_right(distance)
  170.       when 6  # Right
  171.         transition_left_right(-1 * distance)
  172.       when 8  # Up
  173.         transition_up_down(distance)
  174.       end
  175.       # Subtract distance scrolled
  176.       @transition_rest -= distance
  177.     end
  178.     # Update map event
  179.     for event in @events.values
  180.       event.update
  181.     end
  182.     # Update common event
  183.     for common_event in @common_events.values
  184.       common_event.update
  185.     end
  186.     # Manage fog scrolling
  187.     @fog_ox -= @fog_sx / 8.0
  188.     @fog_oy -= @fog_sy / 8.0
  189.     # Manage change in fog color tone
  190.     if @fog_tone_duration >= 1
  191.       d = @fog_tone_duration
  192.       target = @fog_tone_target
  193.       @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
  194.       @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
  195.       @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
  196.       @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
  197.       @fog_tone_duration -= 1
  198.     end
  199.     # Manage change in fog opacity level
  200.     if @fog_opacity_duration >= 1
  201.       d = @fog_opacity_duration
  202.       @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
  203.       @fog_opacity_duration -= 1
  204.     end
  205.   end
  206. end
  207.  
  208. class Game_Character
  209.   attr_accessor :move_speed
  210.   #--------------------------------------------------------------------------
  211.   # * Get Screen X-Coordinates
  212.   #--------------------------------------------------------------------------
  213.   def screen_x(temp=false)
  214.     # Get screen coordinates from real coordinates and map display position
  215.     if temp and !self.is_a?(Game_Player)
  216.       if $game_player.direction == 4
  217.         return (@real_x - $game_map.display_x + 3) / 4 + 16 - 640
  218.       elsif $game_player.direction == 6
  219.         return (@real_x - $game_map.display_x + 3) / 4 + 16 + 640
  220.       end
  221.     end
  222.     return (@real_x - $game_map.display_x + 3) / 4 + 16
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # * Get Screen Y-Coordinates
  226.   #--------------------------------------------------------------------------
  227.   def screen_y(temp=false)
  228.     # Get screen coordinates from real coordinates and map display position
  229.     if temp and !self.is_a?(Game_Player)
  230.       if $game_player.direction == 2
  231.         y = (@real_y - $game_map.display_y + 3) / 4 + 32 + 480
  232.       elsif $game_player.direction == 8
  233.         y = (@real_y - $game_map.display_y + 3) / 4 + 32 - 480
  234.       end
  235.     end
  236.     y = (@real_y - $game_map.display_y + 3) / 4 + 32 if y == nil
  237.     # Make y-coordinate smaller via jump count
  238.     if @jump_count >= @jump_peak
  239.       n = @jump_count - @jump_peak
  240.     else
  241.       n = @jump_peak - @jump_count
  242.     end
  243.     return y - (@jump_peak * @jump_peak - n * n) / 2
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # * Get Screen Z-Coordinates
  247.   #     height : character height
  248.   #--------------------------------------------------------------------------
  249.   def screen_z(height = 0)
  250.     # If display flag on closest surface is ON
  251.     if @always_on_top
  252.       # 999, unconditional
  253.       return 999
  254.     end
  255.     # Get screen coordinates from real coordinates and map display position
  256.     z = 0#(@real_y - $game_map.display_y + 3) / 4 + 32
  257.     # If tile
  258.     if @tile_id > 0
  259.       # Add tile priority * 32
  260.       return z + $game_map.priorities[@tile_id] * 32
  261.     # If character
  262.     else
  263.       # If height exceeds 32, then add 31
  264.       return z #+ ((height > 32) ? 31 : 0)
  265.     end
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # * Move Down
  269.   #     turn_enabled : a flag permits direction change on that spot
  270.   #--------------------------------------------------------------------------
  271.   def move_down(turn_enabled = true, override = false)
  272.     # Turn down
  273.     if turn_enabled
  274.       turn_down
  275.     end
  276.     # If passable
  277.     if passable?(@x, @y, 2) or override
  278.       # Turn down
  279.       turn_down
  280.       # Update coordinates
  281.       @y += 1
  282.       # Increase steps
  283.       increase_steps
  284.     # If impassable
  285.     else
  286.       # Determine if touch event is triggered
  287.       check_event_trigger_touch(@x, @y+1)
  288.     end
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # * Move Left
  292.   #     turn_enabled : a flag permits direction change on that spot
  293.   #--------------------------------------------------------------------------
  294.   def move_left(turn_enabled = true, override = false)
  295.     # Turn left
  296.     if turn_enabled
  297.       turn_left
  298.     end
  299.     # If passable
  300.     if passable?(@x, @y, 4) or override
  301.       # Turn left
  302.       turn_left
  303.       # Update coordinates
  304.       @x -= 1
  305.       # Increase steps
  306.       increase_steps
  307.     # If impassable
  308.     else
  309.       # Determine if touch event is triggered
  310.       check_event_trigger_touch(@x-1, @y)
  311.     end
  312.   end
  313.   #--------------------------------------------------------------------------
  314.   # * Move Right
  315.   #     turn_enabled : a flag permits direction change on that spot
  316.   #--------------------------------------------------------------------------
  317.   def move_right(turn_enabled = true, override = false)
  318.     # Turn right
  319.     if turn_enabled
  320.       turn_right
  321.     end
  322.     # If passable
  323.     if passable?(@x, @y, 6) or override
  324.       # Turn right
  325.       turn_right
  326.       # Update coordinates
  327.       @x += 1
  328.       # Increase steps
  329.       increase_steps
  330.     # If impassable
  331.     else
  332.       # Determine if touch event is triggered
  333.       check_event_trigger_touch(@x+1, @y)
  334.     end
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # * Move up
  338.   #     turn_enabled : a flag permits direction change on that spot
  339.   #--------------------------------------------------------------------------
  340.   def move_up(turn_enabled = true, override = false)
  341.     # Turn up
  342.     if turn_enabled
  343.       turn_up
  344.     end
  345.     # If passable
  346.     if passable?(@x, @y, 8) or override
  347.       # Turn up
  348.       turn_up
  349.       # Update coordinates
  350.       @y -= 1
  351.       # Increase steps
  352.       increase_steps
  353.     # If impassable
  354.     else
  355.       # Determine if touch event is triggered
  356.       check_event_trigger_touch(@x, @y-1)
  357.     end
  358.   end
  359.   #--------------------------------------------------------------------------
  360.   # * 1 Step Forward
  361.   #--------------------------------------------------------------------------
  362.   def move_forward(override=false)
  363.     case @direction
  364.     when 2
  365.       move_down(false,override)
  366.     when 4
  367.       move_left(false,override)
  368.     when 6
  369.       move_right(false,override)
  370.     when 8
  371.       move_up(false,override)
  372.     end
  373.   end
  374. end
  375.  
  376. class Game_Player
  377.   #--------------------------------------------------------------------------
  378.   # * Frame Update
  379.   #--------------------------------------------------------------------------
  380.   def update
  381.     # Remember whether or not moving in local variables
  382.     last_moving = moving?
  383.     # If moving, event running, move route forcing, and message window
  384.     # display are all not occurring
  385.     unless moving? or $game_system.map_interpreter.running? or
  386.            @move_route_forcing or $game_temp.message_window_showing
  387.       # Move player in the direction the directional button is being pressed
  388.       case Input.dir4
  389.       when 2
  390.         if $game_map.valid?(@x, @y+1)
  391.           move_down
  392.         elsif !$game_temp.map_transitioning
  393.           @direction = 2
  394.           $scene.begin_transfer
  395.         end
  396.       when 4
  397.         if $game_map.valid?(@x-1, @y)
  398.           move_left
  399.         elsif !$game_temp.map_transitioning
  400.           @direction = 4
  401.           $scene.begin_transfer
  402.         end
  403.       when 6
  404.         if $game_map.valid?(@x+1, @y)
  405.           move_right
  406.         elsif !$game_temp.map_transitioning
  407.           @direction = 6
  408.           $scene.begin_transfer
  409.         end
  410.       when 8
  411.         if $game_map.valid?(@x, @y-1)
  412.           move_up
  413.         elsif !$game_temp.map_transitioning
  414.           @direction = 8
  415.           $scene.begin_transfer
  416.         end
  417.       end
  418.     end
  419.     # Remember coordinates in local variables
  420.     last_real_x = @real_x
  421.     last_real_y = @real_y
  422.     super
  423.     return if $game_temp.map_transitioning
  424.     # If character moves down and is positioned lower than the center
  425.     # of the screen
  426.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  427.       # Scroll map down
  428.       $game_map.scroll_down(@real_y - last_real_y)
  429.     end
  430.     # If character moves left and is positioned more let on-screen than
  431.     # center
  432.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  433.       # Scroll map left
  434.       $game_map.scroll_left(last_real_x - @real_x)
  435.     end
  436.     # If character moves right and is positioned more right on-screen than
  437.     # center
  438.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  439.       # Scroll map right
  440.       $game_map.scroll_right(@real_x - last_real_x)
  441.     end
  442.     # If character moves up and is positioned higher than the center
  443.     # of the screen
  444.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  445.       # Scroll map up
  446.       $game_map.scroll_up(last_real_y - @real_y)
  447.     end
  448.     # If not moving
  449.     unless moving?
  450.       # If player was moving last time
  451.       if last_moving
  452.         # Event determinant is via touch of same position event
  453.         result = check_event_trigger_here([1,2])
  454.         # If event which started does not exist
  455.         if result == false
  456.           # Disregard if debug mode is ON and ctrl key was pressed
  457.           unless $DEBUG and Input.press?(Input::CTRL)
  458.             # Encounter countdown
  459.             if @encounter_count > 0
  460.               @encounter_count -= 1
  461.             end
  462.           end
  463.         end
  464.       end
  465.       # If C button was pressed
  466.       if Input.trigger?(Input::C)
  467.         # Same position and front event determinant
  468.         check_event_trigger_here([0])
  469.         check_event_trigger_there([0,1,2])
  470.       end
  471.     end
  472.   end
  473. end
  474.  
  475. #==============================================================================
  476. # ** Sprite_Character
  477. #------------------------------------------------------------------------------
  478. #  This sprite is used to display the character.It observes the Game_Character
  479. #  class and automatically changes sprite conditions.
  480. #==============================================================================
  481.  
  482. class Character_Sprite < RPG::Sprite
  483.   #--------------------------------------------------------------------------
  484.   # * Public Instance Variables
  485.   #--------------------------------------------------------------------------
  486.   attr_accessor :character                # character
  487.   #--------------------------------------------------------------------------
  488.   # * Object Initialization
  489.   #     viewport  : viewport
  490.   #     character : character (Game_Character)
  491.   #--------------------------------------------------------------------------
  492.   def initialize(viewport, character = nil, section=0, temp=false)
  493.     super(viewport)
  494.     @character = character
  495.     @section = section
  496.     @temp = temp
  497.     update
  498.   end
  499.   #--------------------------------------------------------------------------
  500.   # * Frame Update
  501.   #--------------------------------------------------------------------------
  502.   def update
  503.     super
  504.     # If tile ID, file name, or hue are different from current ones
  505.     if @tile_id != @character.tile_id or
  506.        @character_name != @character.character_name or
  507.        @character_hue != @character.character_hue
  508.       # Remember tile ID, file name, and hue
  509.       @tile_id = @character.tile_id
  510.       @character_name = @character.character_name
  511.       @character_hue = @character.character_hue
  512.       # If tile ID value is valid
  513.       if @tile_id >= 384
  514.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  515.           @tile_id, @character.character_hue)
  516.         self.src_rect.set(0, 0, 32, 32)
  517.         self.ox = 16
  518.         self.oy = 32
  519.       # If tile ID value is invalid
  520.       else
  521.         self.bitmap = RPG::Cache.character(@character.character_name,
  522.           @character.character_hue)
  523.         @cw = bitmap.width / 4
  524.         @ch = bitmap.height / 4
  525.         self.ox = @cw / 2
  526.         self.oy = @ch
  527.       end
  528.     end
  529.     # Set visible situation
  530.     self.visible = (not @character.transparent)
  531.     # If graphic is character
  532.     if @tile_id == 0
  533.       # Set rectangular transfer
  534.       sx = @character.pattern * @cw
  535.       sy = (@character.direction - 2) / 2 * @ch
  536.       if @ch > 32
  537.         ty = sy + @ch - ((@section + 1) * 32)
  538.         if ty > sy
  539.           @th = 32
  540.         else
  541.           @th = 32 + ty - sy
  542.           ty = sy
  543.         end
  544.       else
  545.         ty = sy
  546.         @th = @ch
  547.       end
  548.       self.src_rect.set(sx, ty, @cw, @th)
  549.       self.oy = @th
  550.     end
  551.     # Set sprite coordinates
  552.     self.x = @character.screen_x(@temp)
  553.     self.y = @character.screen_y(@temp) - (@section * 32)
  554.     if $game_temp.map_transitioning
  555.       self.z = @character.screen_z(@ch) + (@section * 32) + (1 - @section)
  556.     else
  557.       self.z = @character.screen_z(@ch) + (@section * 32)
  558.     end
  559.     # Set opacity level, blend method, and bush depth
  560.     self.opacity = @character.opacity
  561.     self.blend_type = @character.blend_type
  562.     self.bush_depth = @section == 0 ? @character.bush_depth : 0
  563.     # Animation
  564.     if @character.animation_id != 0
  565.       animation = $data_animations[@character.animation_id]
  566.       animation(animation, true)
  567.       @character.animation_id = 0
  568.     end
  569.   end
  570. end
  571.  
  572. #==============================================================================
  573. # ** Sprite_Character
  574. #------------------------------------------------------------------------------
  575. #  This sprite is used to display the character.It observes the Game_Character
  576. #  class and automatically changes sprite conditions.
  577. #==============================================================================
  578.  
  579. class Sprite_Character
  580.   #--------------------------------------------------------------------------
  581.   # * Public Instance Variables
  582.   #--------------------------------------------------------------------------
  583.   attr_accessor :character                # character
  584.   #--------------------------------------------------------------------------
  585.   # * Object Initialization
  586.   #     viewport  : viewport
  587.   #     character : character (Game_Character)
  588.   #--------------------------------------------------------------------------
  589.   def initialize(viewport, character = nil, temp=false)
  590.     bitmap = RPG::Cache.character(character.character_name, character.character_hue)
  591.     @sprites = []
  592.     for i in 0..(bitmap.height / 4 / 32)
  593.       sprite = Character_Sprite.new(viewport, character, i, temp)
  594.       @sprites << sprite
  595.     end
  596.     @viewport = viewport
  597.     @character = character
  598.     @temp = temp
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # * Dispose
  602.   #--------------------------------------------------------------------------
  603.   def dispose
  604.     for sprite in @sprites
  605.       sprite.dispose
  606.     end
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # * Frame Update
  610.   #--------------------------------------------------------------------------
  611.   def update
  612.     for sprite in @sprites
  613.       sprite.update
  614.     end
  615.   end
  616. end
  617.  
  618.  
  619. class Spriteset_Map
  620.   alias original_dispose dispose
  621.   alias original_update update
  622.   #--------------------------------------------------------------------------
  623.   # * Dispose
  624.   #--------------------------------------------------------------------------
  625.   def dispose
  626.     if @new_panorama != nil
  627.       # Dispose of panorama plane
  628.       @new_panorama.dispose
  629.       # Dispose of fog plane
  630.       @new_fog.dispose
  631.       # Dispose of character sprites
  632.       for sprite in @new_character_sprites
  633.         sprite.dispose
  634.       end
  635.     end
  636.     original_dispose
  637.   end
  638.   #--------------------------------------------------------------------------
  639.   # * Transition
  640.   #--------------------------------------------------------------------------
  641.   def transition_to(new_sprite_source)
  642.     @new_sprite_source = new_sprite_source
  643.     # Make tilemap
  644.     # make_tilemap_sprites
  645.     @tilemap.prepare_transition(@new_sprite_source, $game_player.direction, @viewport1)
  646.     # Make panorama plane
  647.     @new_panorama = Plane.new(@viewport1)
  648.     @new_panorama.z = -1000
  649.     # Make fog plane
  650.     @new_fog = Plane.new(@viewport1)
  651.     @new_fog.z = 3000
  652.     # Make character sprites
  653.     left_x = @new_sprite_source.display_x / 128
  654.     top_y = @new_sprite_source.display_y / 128
  655.     @new_character_sprites = []
  656.     for i in @new_sprite_source.events.keys.sort
  657.       if (left_x <= @new_sprite_source.events[i].x and @new_sprite_source.events[i].x < left_x + 20) and
  658.          (top_y <= @new_sprite_source.events[i].y and @new_sprite_source.events[i].y < top_y + 15)
  659.         sprite = Sprite_Character.new(@viewport1, @new_sprite_source.events[i], true)
  660.         @new_character_sprites.push(sprite)
  661.       end
  662.     end
  663.     # Frame update
  664.     update
  665.   end
  666.   #--------------------------------------------------------------------------
  667.   # * Frame Update
  668.   #--------------------------------------------------------------------------
  669.   def update
  670.     # Check for Transfer Data
  671.     if @new_panorama != nil
  672.       # If panorama is different from current one
  673.       if @new_panorama_name != @new_sprite_source.panorama_name or
  674.          @new_panorama_hue != @new_sprite_source.panorama_hue
  675.         @new_panorama_name = @new_sprite_source.panorama_name
  676.         @new_panorama_hue = @new_sprite_source.panorama_hue
  677.         if @new_panorama.bitmap != nil
  678.           @new_panorama.bitmap.dispose
  679.           @new_panorama.bitmap = nil
  680.         end
  681.         if @new_panorama_name != ""
  682.           @new_panorama.bitmap = RPG::Cache.panorama(@new_panorama_name, @new_panorama_hue)
  683.         end
  684.         Graphics.frame_reset
  685.       end
  686.       # If fog is different than current fog
  687.       if @new_fog_name != @new_sprite_source.fog_name or
  688.          @new_fog_hue != @new_sprite_source.fog_hue
  689.         @new_fog_name = @new_sprite_source.fog_name
  690.         @new_fog_hue = @new_sprite_source.fog_hue
  691.         if @new_fog.bitmap != nil
  692.           @new_fog.bitmap.dispose
  693.           @new_fog.bitmap = nil
  694.         end
  695.         if @new_fog_name != ""
  696.           @new_fog.bitmap = RPG::Cache.fog(@new_fog_name, @new_fog_hue)
  697.         end
  698.         Graphics.frame_reset
  699.       end
  700.       # Update panorama plane
  701.       @new_panorama.ox = @new_sprite_source.display_x / 8
  702.       @new_panorama.oy = @new_sprite_source.display_y / 8
  703.       # Update fog plane
  704.       @new_fog.zoom_x = @new_sprite_source.fog_zoom / 100.0
  705.       @new_fog.zoom_y = @new_sprite_source.fog_zoom / 100.0
  706.       @new_fog.opacity = @new_sprite_source.fog_opacity
  707.       @new_fog.blend_type = @new_sprite_source.fog_blend_type
  708.       @new_fog.ox = @new_sprite_source.display_x / 4 + @new_sprite_source.fog_ox
  709.       @new_fog.oy = @new_sprite_source.display_y / 4 + @new_sprite_source.fog_oy
  710.       @new_fog.tone = @new_sprite_source.fog_tone
  711.       # Update character sprites
  712.       for sprite in @new_character_sprites
  713.         sprite.update
  714.       end
  715.     end
  716.     original_update
  717.   end
  718. end
  719.  
  720.  
  721. class Scene_Map
  722.   alias original_update update
  723.   #--------------------------------------------------------------------------
  724.   # * Frame Update
  725.   #--------------------------------------------------------------------------
  726.   def update
  727.     # Loop
  728.     loop do
  729.       # Update map, interpreter, and player order
  730.       # (this update order is important for when conditions are fulfilled
  731.       # to run any event, and the player isn't provided the opportunity to
  732.       # move in an instant)
  733.       $game_map.update
  734.       if $game_temp.map_transitioning
  735.         @transfer_map.update
  736.       end
  737.       $game_system.map_interpreter.update
  738.       $game_player.update
  739.       # Update system (timer), screen
  740.       $game_system.update
  741.       $game_screen.update
  742.       # Abort loop if player isn't place moving
  743.       unless $game_temp.player_transferring
  744.         break
  745.       end
  746.       # Run place move
  747.       transfer_player
  748.       # Abort loop if transition processing
  749.       if $game_temp.transition_processing
  750.         break
  751.       end
  752.     end
  753.     # Update sprite set
  754.     @spriteset.update
  755.     # Update message window
  756.     @message_window.update
  757.     # Check for Map Transition
  758.     if $game_temp.map_transitioning
  759.       unless $game_map.transitioning?
  760.         finish_transfer
  761.       end
  762.       return
  763.     end
  764.     # If game over
  765.     if $game_temp.gameover
  766.       # Switch to game over screen
  767.       $scene = Scene_Gameover.new
  768.       return
  769.     end
  770.     # If returning to title screen
  771.     if $game_temp.to_title
  772.       # Change to title screen
  773.       $scene = Scene_Title.new
  774.       return
  775.     end
  776.     # If transition processing
  777.     if $game_temp.transition_processing
  778.       # Clear transition processing flag
  779.       $game_temp.transition_processing = false
  780.       # Execute transition
  781.       if $game_temp.transition_name == ""
  782.         Graphics.transition(20)
  783.       else
  784.         Graphics.transition(40, "Graphics/Transitions/" +
  785.           $game_temp.transition_name)
  786.       end
  787.     end
  788.     # If showing message window
  789.     if $game_temp.message_window_showing
  790.       return
  791.     end
  792.     # If encounter list isn't empty, and encounter count is 0
  793.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  794.       # If event is running or encounter is not forbidden
  795.       unless $game_system.map_interpreter.running? or
  796.              $game_system.encounter_disabled
  797.         # Confirm troop
  798.         n = rand($game_map.encounter_list.size)
  799.         troop_id = $game_map.encounter_list[n]
  800.         # If troop is valid
  801.         if $data_troops[troop_id] != nil
  802.           # Set battle calling flag
  803.           $game_temp.battle_calling = true
  804.           $game_temp.battle_troop_id = troop_id
  805.           $game_temp.battle_can_escape = true
  806.           $game_temp.battle_can_lose = false
  807.           $game_temp.battle_proc = nil
  808.         end
  809.       end
  810.     end
  811.     # If B button was pressed
  812.     if Input.trigger?(Input::B)
  813.       # If event is running, or menu is not forbidden
  814.       unless $game_system.map_interpreter.running? or
  815.              $game_system.menu_disabled
  816.         # Set menu calling flag or beep flag
  817.         $game_temp.menu_calling = true
  818.         $game_temp.menu_beep = true
  819.       end
  820.     end
  821.     # If debug mode is ON and F9 key was pressed
  822.     if $DEBUG and Input.press?(Input::F9)
  823.       # Set debug calling flag
  824.       $game_temp.debug_calling = true
  825.     end
  826.     # If player is not moving
  827.     unless $game_player.moving?
  828.       # Run calling of each screen
  829.       if $game_temp.battle_calling
  830.         call_battle
  831.       elsif $game_temp.shop_calling
  832.         call_shop
  833.       elsif $game_temp.name_calling
  834.         call_name
  835.       elsif $game_temp.menu_calling
  836.         call_menu
  837.       elsif $game_temp.save_calling
  838.         call_save
  839.       elsif $game_temp.debug_calling
  840.         call_debug
  841.       end
  842.     end
  843.   end
  844.   #--------------------------------------------------------------------------
  845.   # * Player Place Move
  846.   #--------------------------------------------------------------------------
  847.   def begin_transfer
  848.     # Set map transition flag
  849.     $game_temp.map_transitioning = true
  850.     # Discover map to transfer to
  851.     new_map_id = $game_map.map_link[$game_player.direction/2]
  852.     # Check for validity
  853.     return if new_map_id == 0
  854.     # Set Up next map
  855.     @transfer_map = Game_Map.new
  856.     @transfer_map.setup(new_map_id)
  857.     @spriteset.transition_to(@transfer_map)
  858.     case $game_player.direction
  859.     when 2  # Moving Down
  860.       @transfer_map.display_x = $game_map.display_x
  861.       @transfer_map.display_y = -1920
  862.       $game_temp.player_new_x = $game_player.x
  863.       $game_temp.player_new_y = 0
  864.     when 4  # Moving Left
  865.       @transfer_map.display_x = 2560
  866.       @transfer_map.display_y = $game_map.display_y
  867.       $game_temp.player_new_x = @transfer_map.width - 1
  868.       $game_temp.player_new_y = $game_player.y
  869.     when 6  # Moving Right
  870.       @transfer_map.display_x = -2560
  871.       @transfer_map.display_y = $game_map.display_y
  872.       $game_temp.player_new_x = 0
  873.       $game_temp.player_new_y = $game_player.y
  874.     when 8  # Moving Up
  875.       @transfer_map.display_x = $game_map.display_x
  876.       @transfer_map.display_y = 1920
  877.       $game_temp.player_new_x = $game_player.x
  878.       $game_temp.player_new_y = @transfer_map.height - 1
  879.     end
  880.     dist = [2,8].include?($game_player.direction) ? 1920 : 2560
  881.     # Begin Transition
  882.     $game_map.start_transition(10 - $game_player.direction, dist, 5)
  883.     @transfer_map.start_transition(10 - $game_player.direction, dist, 5)
  884.     # Move $game_player
  885.     $game_player.move_speed = 1
  886.     $game_player.move_forward(true)
  887.   end
  888.   #--------------------------------------------------------------------------
  889.   # * Player Place Move
  890.   #--------------------------------------------------------------------------
  891.   def finish_transfer
  892.     # Clear map transition flag
  893.     $game_temp.map_transitioning = false
  894.     # Reassign variables
  895.     $game_map.setup(@transfer_map.map_id)
  896.     @transfer_map = nil
  897.     # Set up player position
  898.     $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
  899.     # Update map (run parallel process event)
  900.     $game_map.update
  901.     # Transition Spriteset
  902.     @spriteset.dispose
  903.     @spriteset = Spriteset_Map.new
  904.     # Run automatic change for BGM and BGS set on the map
  905.     $game_map.autoplay
  906.     # Frame reset
  907.     Graphics.frame_reset
  908.     # Update input information
  909.     Input.update
  910.     $game_player.move_speed = 4
  911.   end
  912. end
Expand to see the code.


Instructions

1) Create a new Script just above main and paste the Tilemap Script
2) Create a new Script above main but below the Tilemap Script and paste the Zelda Scroll Script
3) On any map you'd like to use it on, create an Event an call it "Transfer". I usually like to put it in the upper left corner, but that isn't required.
4) In the Event, create a comment of "<direction>:<map id>" for each edge you would like to connect to the map.

In this case, <direction> is the direction the $game_player would be heading as he left the current map [Left, Right, Up, Down]
<map id> is the ID of the map you want to connect to.

Make sure there are no spaces.

5) Enjoy!

FAQ

I will add to this as questions arise

Compatibility

This script is NOT SDK compatible.

That said, it edits a large number of methods and classes, so I'm sure there will be some compatibility issues.

As a note, it completely rewrites the Sprite_Character class. In also rewrites the update method for Game_Map, Game_Player, and Scene_Map completely.

Credits and Thanks

SephirothSpawn for his Tilemap Class

Author's Notes

This is a rough, general version without alot of thrills or extras. That said, it works pretty well.

If you have any questions or comments, I'd love to hear them. However, I don't stop by this board that often, so I would recommend PMing me or emailing me if you have any pressing concerns. Otherwise, I will reply whenever I happen by.

Terms and Conditions

Feel free to use the scripts however you like, so long as credit is given to SephirothSpawn for the Tilemap Class and myself for the rest. However, please do not post this anywhere else without my permission. Thanks!
I've already seen this kind of script before. But you didn't copy, that's what matters.
Very useful script, mainly for Zelda lovers / projects. (:

Good work!

  1. ################################################################################
  2. ################################################################################
  3. ##########################  RTH Zelda Transfer  ##################################
  4. ################################################################################
  5. ################################################################################
  6. #===============================================================================
  7. # Criado por : Renan Tsuneo Hangai Junior
  8. #===============================================================================
  9.  
  10. $RTHScript = {} if $RTHScript.nil?
  11. $RTHScript["Zelda_Transfer"] = true
  12.  
  13. class Tile_Maps_Transfer
  14.  
  15.   # Velocidade de mudança dos mapas
  16.  
  17.   CHANGE_MAP_SPEED = 17
  18.  
  19.   # Definição dos autotiles
  20.  
  21.   AUTOLTILES = [
  22.   26, 27, 32, 33, 4,  27, 32, 33, 26, 5,  32, 33, 4,  5,  32, 33,
  23.   26, 27, 32, 11, 4,  27, 32, 11, 26, 5,  32, 11, 4,  5,  32, 11,
  24.   26, 27, 10, 33, 4,  27, 10, 33, 26, 5,  10, 33, 4,  5,  10, 33,
  25.   26, 27, 10, 11, 4,  27, 10, 11, 26, 5,  10, 11, 4,  5,  10, 11,
  26.   24, 25, 30, 31, 24, 5,  30, 31, 24, 25, 30, 11, 24, 5,  30, 11,
  27.   14, 15, 20, 21, 14, 15, 20, 11, 14, 15, 10, 21, 14, 15, 10, 11,
  28.   28, 29, 34, 35, 28, 29, 10, 35, 4,  29, 34, 35, 4,  29, 10, 35,
  29.   38, 39, 44, 45, 4,  39, 44, 45, 38, 5,  44, 45, 4,  5,  44, 45,
  30.   24, 29, 30, 35, 14, 15, 44, 45, 12, 13, 18 ,19, 12, 13, 18, 11,
  31.   16, 17, 22, 23, 16, 17, 10, 23, 40, 41, 46, 47, 4,  41, 46, 47,
  32.   36, 37, 42, 43, 36, 5,  42, 43, 12, 17, 18, 23, 12, 13, 42, 43,
  33.   36, 41, 42, 47, 16, 17, 46, 47, 12, 17, 42, 47, 0,  1,  6,  7
  34.   ]
  35.  
  36.   attr_reader :dif_x
  37.   attr_reader :dif_y
  38.   attr_reader :ready
  39.   attr_reader :mapa
  40.  
  41.   def initialize(id, player, direction)
  42.     @player = player
  43.     @sprites = []
  44.     @direction_transfer = direction
  45.     @dif_x = (direction == 4 ? CHANGE_MAP_SPEED : direction == 6 ? -CHANGE_MAP_SPEED : 0)
  46.     @dif_y = (direction == 2 ? -CHANGE_MAP_SPEED : direction == 8 ? CHANGE_MAP_SPEED : 0)
  47.     @player_x_dif = $game_temp.player_pre_tel_x - $game_player.screen_x
  48.     @player_y_dif = $game_temp.player_pre_tel_y - $game_player.screen_y
  49.     @player_raise_rate_x = (@player_x_dif.abs.to_f / (640.0 / @dif_x.abs.to_f))
  50.     @player_raise_rate_y = (@player_y_dif.abs.to_f / (480.0 / @dif_y.abs.to_f))
  51.     if direction == 6
  52.       @player_raise_rate_x *= -1
  53.     elsif direction == 2
  54.       @player_raise_rate_y *= -1
  55.     end
  56.     for i in 0..2
  57.       @sprites[i] = Sprite.new
  58.     end
  59.     $bitmaps_maps = [] if $bitmaps_maps == nil
  60.     @mapa = Game_Map.new
  61.     @mapa.setup(id)
  62.     @autotiles = []
  63.     for i in 0..6
  64.       @autotiles[i] = RPG::Cache.autotile(mapa.autotile_names[i])
  65.     end
  66.     if $bitmaps_maps[id] == nil
  67.       $bitmaps_maps[id] = []
  68.       for i in 0..2
  69.         $bitmaps_maps[id][i] = Bitmap.new(mapa.width * 32, mapa.height * 32)
  70.       end
  71.       vx = [0, 1, 0, 1]
  72.       vy = [0, 0, 1, 1]
  73.       for i in 0...(mapa.width * mapa.height)
  74.         x = i % mapa.width
  75.         y = i / mapa.width
  76.         for level in 0..2
  77.           tile_id = mapa.data[x, y, level]
  78.           if tile_id >= 384
  79.             tileset_bitmap = RPG::Cache.tile(mapa.tileset_name, tile_id, 0)
  80.             src_rect = Rect.new(0, 0, 32, 32)
  81.             $bitmaps_maps[id][level].blt(x * 32, y * 32, tileset_bitmap, src_rect)
  82.           elsif tile_id >= 48 and tile_id < 384
  83.             aid = tile_id / 48 - 1
  84.             for j in 0..3
  85.               h = 4 * (tile_id % 48) + j
  86.               src_rect = Rect.new((AUTOLTILES[h] % 6) * 16, (AUTOLTILES[h] / 6 ) * 16, 16, 16)
  87.               ax = x * 32 + vx[j] * 16
  88.               ay = y * 32 + vy[j] * 16
  89.               $bitmaps_maps[id][level].blt(ax, ay, @autotiles[aid], src_rect)
  90.             end
  91.           end
  92.         end
  93.       end
  94.     end
  95.     for i in 0..2
  96.       @sprites[i].bitmap = $bitmaps_maps[id][i].dup
  97.     end
  98.     @pos_x = (direction == 4 ? -@sprites[0].bitmap.width : direction == 6 ? 640 : -($game_map.display_x / 4))
  99.     @pos_y = (direction == 2 ? 480 : direction == 8 ? -@sprites[0].bitmap.height : -($game_map.display_y / 4))
  100.     fx = (player ? (direction == 4 ? -640 : direction == 6 ? 640 : 0) :0)
  101.     fy = (player ? (direction == 2 ? 480 : direction == 8 ? -480 : 0) :0)
  102.     view = Viewport.new(0, 0, 640, 480)
  103.     view.z = 9999
  104.     @fog = Plane.new(view)
  105.     @fog.z = 9999
  106.     @fog.bitmap = RPG::Cache.fog(@mapa.fog_name, @mapa.fog_hue)
  107.     v2 = Viewport.new(0, 0, 640, 480)
  108.     v2.z = -1000
  109.     @panorama = Plane.new(v2)
  110.     @panorama.bitmap = RPG::Cache.panorama(@mapa.panorama_name, @mapa.panorama_hue)
  111.     @panorama.z = -1000000
  112.     for i in 0..2
  113.       @sprites[i].x = @pos_x
  114.       @sprites[i].y = @pos_y
  115.     end
  116.     @character_sprites = []
  117.     for i in mapa.events.keys.sort
  118.       sprite = Sprite_Character.new(@viewport1, mapa.events[i])
  119.       @character_sprites.push(sprite)
  120.     end
  121.     for sprite in @character_sprites
  122.       sprite.update
  123.       sprite.y += @pos_y
  124.       sprite.x += (direction == 2 ? 0 : @pos_x)
  125.     end
  126.     if @player
  127.       @train_actors_sprites = []
  128.       if $RTHScript["Train Actor"]
  129.         for i in 0...$train_actor.size
  130.           sprite = Sprite_Character.new(@viewport1, $train_actor[i])
  131.           sprite.x = $game_temp.train_actors_tel_x[i]
  132.           sprite.y = $game_temp.train_actors_tel_y[i]
  133.           @train_actors_sprites.push(sprite)
  134.         end
  135.       end
  136.       @player_sprite = Sprite_Character.new(@viewport1, $game_player)
  137.       @player_sprite.x = $game_temp.player_pre_tel_x
  138.       @player_sprite.y = $game_temp.player_pre_tel_y
  139.     end
  140.     @ready = false
  141.     update
  142.   end
  143.  
  144.   def update
  145.     @fog.ox -= @dif_x
  146.     @fog.oy -= @dif_x
  147.     for sprite in @sprites + @character_sprites
  148.       sprite.x += @dif_x
  149.       sprite.y += @dif_y
  150.     end    
  151.     if @player
  152.       for sprite in @train_actors_sprites
  153.         sprite.x += @player_raise_rate_x
  154.         sprite.y += @player_raise_rate_y
  155.       end
  156.       @player_sprite.x += @player_raise_rate_x
  157.       @player_sprite.y += @player_raise_rate_y
  158.     end
  159.     case @direction_transfer
  160.     when 2
  161.       @ready = (@sprites[0].y <= 0)
  162.     when 4
  163.       @ready = (@sprites[0].x >= (640 - @sprites[0].bitmap.width))
  164.     when 6
  165.       @ready = (@sprites[0].x <= 0)
  166.     when 8
  167.       @ready = (@sprites[0].y >= (480 - @sprites[0].bitmap.height))
  168.     end
  169.   end
  170.  
  171.   def dispose
  172.     for sprite in @sprites + @character_sprites
  173.       sprite.bitmap.dispose unless sprite.bitmap.nil?
  174.       sprite.dispose
  175.     end
  176.     @fog.bitmap.dispose
  177.     @fog.dispose
  178.     @panorama.bitmap.dispose
  179.     @panorama.dispose
  180.     if @player
  181.       for sprite in @train_actors_sprites
  182.         sprite.bitmap.dispose unless sprite.bitmap.nil?
  183.         sprite.dispose
  184.       end
  185.       @player_sprite.bitmap.dispose
  186.       @player_sprite.dispose
  187.     end
  188.   end
  189.  
  190. end
  191.  
  192. class Game_Temp
  193.   attr_accessor :zelda_transfer
  194.   attr_accessor :zelda_transfer_direction
  195.   attr_accessor :player_pre_tel_x
  196.   attr_accessor :player_pre_tel_y
  197.   attr_accessor :train_actors_tel_x
  198.   attr_accessor :train_actors_tel_y
  199.   @zelda_transfer
  200.   @zelda_transfer_direction
  201.   @player_pre_tel_x
  202.   @player_pre_tel_y
  203.   @train_actors_tel_x
  204.   @train_actors_tel_y
  205. end
  206.  
  207. class Interpreter
  208.  
  209.   alias rth_zelda_transfer_int_command_201 command_201
  210.   def command_201
  211.     if $game_temp.in_battle
  212.       return true
  213.     end
  214.     if $game_temp.player_transferring or
  215.        $game_temp.message_window_showing or
  216.        $game_temp.transition_processing
  217.       return false
  218.     end
  219.     item = @list[@index-1]
  220.     if item != nil and item.code == 108
  221.       if item.parameters[0].downcase =~ /zelda[ ]?transfer[ ]?(\d+)?/
  222.         $game_temp.zelda_transfer_direction = $1.to_i
  223.         $game_temp.zelda_transfer = true
  224.       end
  225.     end
  226.     return rth_zelda_transfer_int_command_201
  227.   end
  228.  
  229. end
  230.    
  231. class Spriteset_Map
  232.   attr_reader :character_sprites
  233.   attr_reader :tilemap
  234. end
  235.  
  236. class Scene_Map
  237.  
  238.   alias rth_zelda_transfer_scene_map_transfer_player transfer_player
  239.   def transfer_player
  240.     $game_temp.zelda_transfer = false if $game_temp.zelda_transfer == nil
  241.     if $game_temp.zelda_transfer == false
  242.       rth_zelda_transfer_scene_map_transfer_player
  243.       return
  244.     end  
  245.     $game_temp.zelda_transfer = false
  246.     $game_temp.player_pre_tel_x = $game_player.screen_x
  247.     $game_temp.player_pre_tel_y = $game_player.screen_y
  248.     if $RTHScript["Train Actor"]
  249.       $game_temp.train_actors_tel_x = []
  250.       $game_temp.train_actors_tel_y = []
  251.       for i in 0...$train_actor.size
  252.         $game_temp.train_actors_tel_x[i] = $train_actor[i].screen_x
  253.         $game_temp.train_actors_tel_y[i] = $train_actor[i].screen_y
  254.       end
  255.     end    
  256.     $game_temp.player_pre_tel_x = $game_player.screen_x
  257.     $game_temp.player_pre_tel_y = $game_player.screen_y
  258.     now_id = $game_map.map_id
  259.     # Limpar flag de teletransporte
  260.     $game_temp.player_transferring = false
  261.     # Se o destino for para outro mapa
  262.     if $game_map.map_id != $game_temp.player_new_map_id
  263.       # Definir o novo mapa
  264.       $game_map.setup($game_temp.player_new_map_id)
  265.     end
  266.     # Definir o destino de Jogador
  267.     $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
  268.     # Definir a direção
  269.     case $game_temp.player_new_direction
  270.     when 2  # Abaixo
  271.       $game_player.turn_down
  272.     when 4  # Esquerda
  273.       $game_player.turn_left
  274.     when 6  # Direita
  275.       $game_player.turn_right
  276.     when 8  # Acima
  277.       $game_player.turn_up
  278.     end
  279.     # Alinhar a posição do Jogador
  280.     $game_player.straighten
  281.     # Atualizar mapa (executar eventos de Processo Paralelo)
  282.     $game_map.update
  283.     # Recriar o Spriteset
  284.     tile_new_map = Tile_Maps_Transfer.new($game_temp.player_new_map_id, true, $game_temp.zelda_transfer_direction)
  285.     Graphics.transition(1)
  286.     loop {
  287.       Graphics.update
  288.       Input.update
  289.       tile_new_map.update
  290.       #@spriteset.tilemap.ox -= tile_new_map.dif_x
  291.       #@spriteset.tilemap.oy -= tile_new_map.dif_y
  292.       @spriteset.tilemap.viewport.rect.x += tile_new_map.dif_x
  293.       @spriteset.tilemap.viewport.rect.y += tile_new_map.dif_y
  294.       for sprite in @spriteset.character_sprites
  295.         if sprite.character.is_a?(Game_Player)
  296.           sprite.visible = false
  297.         end
  298.         if $RTHScript["Train Actor"] and sprite.character.is_a?(Train_Actor)
  299.           sprite.visible = false
  300.         end
  301.         #sprite.x += tile_new_map.dif_x
  302.         #sprite.y += tile_new_map.dif_y
  303.       end
  304.       break if tile_new_map.ready
  305.     }
  306.     tile_new_map.dispose
  307.     @spriteset.dispose
  308.     @spriteset = Spriteset_Map.new
  309.     # Se estiver processando uma transição
  310.     if $game_temp.transition_processing
  311.       # Limpar flag de transição
  312.       $game_temp.transition_processing = false
  313.       # Executar transição
  314.       Graphics.transition(20)
  315.     end
  316.     # Executar as definições do mapa como BGM e BGS
  317.     $game_map.autoplay
  318.     # Aqui os frames são resetados
  319.     Graphics.frame_reset
  320.     # Atualizar a entrada de informações
  321.     Input.update
  322.   end
  323.  
  324. end
Expand to see the code.
I've seen a few of these as well... iirc, one of them was from Yeyinde, but that's really all I remember... can't really comment on the script itself, as my smartphone won't display more than the first 18 lines, but I'll try to remember to tomorrow.

That aside, I really prefer this kind of transition to the generic teleportation, so I think people without Zelda projects should take a look as well.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=76038