#============================================================================# Map Auto Transfer v1.0# Shaz#============================================================================# This script monitors the player's location, and when the edge of a map# is reached, it auto-transfers to the next map, if an auto-transfer is# set up in map notes#============================================================================# The script works on the assumption that all maps where a transfer is set# up have similar dimensions (transferring right from one map to another,# both maps must have the same height; transferring up/down between maps,# both maps must have the same width; transferring left from one map to the# top of another, the first map's height must be the same as the second# map's width#============================================================================# To set up a transfer between maps, enter a series of exit statements on# the map notes as follows# exit direction map side# direction = left, right, up, down (will transfer when you reach that edge)# map = map id to transfer to# side = left, right, top, bottom (where to transfer to on new map)# # exit right 5 left - go right from current map to left side of map 5# exit up 8 bottom - go up from current map to bottom of map 8# exit left 12 bottom - go left from current map to bottom of map 12# # If exit is not defined for any side of the current map, no auto-transfer# will happen#============================================================================class Game_Map #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- # map exit directions and links for auto-transfers on edge of map attr_reader :exit_left attr_reader :left_map attr_reader :left_side attr_reader :exit_bottom attr_reader :bottom_map attr_reader :bottom_side attr_reader :exit_right attr_reader :right_map attr_reader :right_side attr_reader :exit_top attr_reader :top_map attr_reader :top_side attr_reader :map_id #-------------------------------------------------------------------------- # * Setup #-------------------------------------------------------------------------- alias shaz_autotransfer_map_setup setup def setup(map_id) shaz_autotransfer_map_setup(map_id) setup_notes end #-------------------------------------------------------------------------- # * Setup Notes #-------------------------------------------------------------------------- def setup_notes @exit_left = @exit_right = @exit_top = @exit_bottom = false @map.note.split(/[\r\n+]/).each do |line| case line when /exit\s*(\w+)\s*(\d+)\s*(\w+)/i case $1 when 'left' @exit_left = true @left_map = $2.to_i @left_side = $3 when 'right' @exit_right = true @right_map = $2.to_i @right_side = $3 when 'down' @exit_bottom = true @bottom_map = $2.to_i @bottom_side = $3 when 'up' @exit_top = true @top_map = $2.to_i @top_side = $3 end end end endendclass Game_Player < Game_Character #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- alias shaz_autotransfer_game_player_update update def update shaz_autotransfer_game_player_update update_autotransfer end def update_autotransfer return unless $game_map.exit_left && @x == 0 || $game_map.exit_right && @x == $game_map.width - 1 || $game_map.exit_top && @y == 0 || $game_map.exit_bottom && @y == $game_map.height - 1 # we're transferring, so get new coordinate if @x == 0 map = $game_map.left_map old = @y dir = $game_map.left_side elsif @x == $game_map.width - 1 map = $game_map.right_map old = @y dir = $game_map.right_side elsif @y == 0 map = $game_map.top_map old = @x dir = $game_map.top_side else map = $game_map.bottom_map old = @x dir = $game_map.bottom_side end m = load_data(sprintf('Data/Map%03d.rvdata2', map)) if dir == 'left' reserve_transfer(map, 1, old, 6) elsif dir == 'right' reserve_transfer(map, m.width - 2, old, 4) elsif dir == 'top' reserve_transfer(map, old, 1, 2) elsif dir == 'bottom' reserve_transfer(map, old, m.height - 2, 8) end endend