Jump to content
Nataxinus

Automatized Map Transfer Script

Recommended Posts

Automatized Map Transfer Script 

 

Don't you think it is really annoying that you have to make a ton of events in order to go to the next screen? Well no more, just make one parallel process event and make a script call:

MapTransfer.new.check(north, west, south, east) directions are replaced by the map id's of the map you want to transfer to when reaching the edge of the screen in that direction. Write 0 if you don't want to be transferred to a map in that direction.

 

This script also scales so if there is a difference in the size of two maps you transfer to the corresponding coordinates based on the difference in the length or width of the two maps.

 

Make sure that nothing is in the way when transferring, else the player might get stuck. Tiles with a region id that you specify will not transfer the player.

 

Here it is:

 

 

#===============================================================================
# Automatized Map Transfer Script 
# By Nataxinus
#===============================================================================
#===============================================================================
# Description
# Don't you think it is really annoying that you have to make a ton of events in 
# order to go to the next screen? Well no more, just make one parallel process 
# event and make a script call: 
# MapTransfer.new.check(north, west, south, east) directions are replaced by the 
# map id's of the map you want to transfer to when reaching the edge of the 
# screen in that direction. Write 0 if you don't want to be transferred to a 
# map in that direction.
#
# This script also scales so if there is a difference in the size of two maps 
# you transfer to the corresponding coordinates based on the difference in the 
# length or width of the two maps.
#
# Make sure that nothing is in the way when transferring, else the player might 
# get stuck. Tiles with a region id that you specify will not transfer the player.
#===============================================================================
#===============================================================================
# Terms of use
# Free for non-commercial and commercial projects, but credit me
#===============================================================================

module Nataxinus
  module Transfer
    # The region id to use for exceptional tiles change at your leisure
    REGION_ID = 62
  end
end
  
class MapTransfer
  include Nataxinus::Transfer
  def check(north, west, south, east)
    return if $game_map.region_id($game_player.x, $game_player.y) == REGION_ID
    if $game_player.x == 0 && west != 0 
      player_y = $game_player.y
      @map = load_data(sprintf("Data/Map%03d.rvdata2", west))
      player_y *= ((@map.height - 1) / ($game_map.height - 1).to_f)
      player_y = player_y.round(0).to_i
      player_y = @map.height - 2 if player_y >= @map.height - 1
      player_y += 1 if player_y == 0
      $game_temp.fade_type = 0
      $game_player.reserve_transfer(west, (@map.width - 2), player_y, 0)
    elsif $game_player.y == 0 && north != 0 && $game_player.x > 0 && $game_player.x < $game_map.width - 1
      player_x = $game_player.x
      @map = load_data(sprintf("Data/Map%03d.rvdata2", north))
      player_x *= ((@map.width - 1) / ($game_map.width - 1).to_f)
      player_x = player_x.round(0).to_i
      player_x = @map.width - 2 if player_x >= @map.width - 1
      player_x += 1 if player_x == 0
      $game_temp.fade_type = 0
      $game_player.reserve_transfer(north, player_x, (@map.height - 2), 0)
    elsif $game_player.x == $game_map.width - 1 && east != 0 
      player_y = $game_player.y
      @map = load_data(sprintf("Data/Map%03d.rvdata2", east))
      player_y *= ((@map.height - 1) / ($game_map.height - 1).to_f)
      player_y = player_y.round(0).to_i
      player_y = @map.height - 2 if player_y >= @map.height - 1
      player_y += 1 if player_y == 0
      $game_temp.fade_type = 0
      $game_player.reserve_transfer(east, 1, player_y, 0)
    elsif $game_player.y == $game_map.height - 1 && south != 0 && $game_player.x < $game_map.width - 1 && $game_player.x > 0
      player_x = $game_player.x
      @map = load_data(sprintf("Data/Map%03d.rvdata2", south))
      player_x *= ((@map.width - 1) / ($game_map.width - 1).to_f)
      player_x = player_x.round(0).to_i
      player_x = @map.width - 2 if player_x >= @map.width - 1
      player_x += 1 if player_x == 0
      $game_temp.fade_type = 0
      $game_player.reserve_transfer(south, player_x, 1, 0)
    end
  end
end 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted