07-06-2010, 08:43 AM
Try this script to add looping maps (add [L] in maps names) :
Code:
#============================================================================
# Map Looping
# Extracted from Neo Mode 7 script
# MGC
#
# Add [L] in the maps names to define looping maps
#============================================================================
# To access maps names
$data_maps = load_data("Data/MapInfos.rxdata")
#============================================================================
# ** RPG::MapInfo
#============================================================================
class RPG::MapInfo
# defines the map's name as the name without anything within brackets,
# including brackets
def name
return @name.gsub(/\[.*\]/) {""}
end
#--------------------------------------------------------------------------
# the original name with the codes
def fullname
return @name
end
end
#============================================================================
# ** Game_System
#----------------------------------------------------------------------------
# Add attributes to this class
#============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Aliased methods (F12 compatibility)
#--------------------------------------------------------------------------
unless @already_aliased
alias initialize_mapLooping_game_system initialize
@already_aliased = true
end
#--------------------------------------------------------------------------
# * Attributes
#--------------------------------------------------------------------------
attr_accessor :mapLooping # true : map looping mode
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
initialize_mapLooping_game_system
self.mapLooping = false
end
end
#============================================================================
# ** Game_Map
#----------------------------------------------------------------------------
# Methods modifications to handle map looping
#============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Aliased methods (F12 compatibility)
#--------------------------------------------------------------------------
unless @already_aliased
alias scroll_down_mapLooping_game_map scroll_down
alias scroll_left_mapLooping_game_map scroll_left
alias scroll_right_mapLooping_game_map scroll_right
alias scroll_up_mapLooping_game_map scroll_up
alias valid_mapLooping_game_map? valid?
alias passable_mapLooping_game_map? passable?
alias old_setup_mapLooping setup
@already_aliased = true
end
#--------------------------------------------------------------------------
# * Scroll Down
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_down(distance)
unless $game_system.mapLooping
scroll_down_mapLooping_game_map(distance)
return
end
@display_y = @display_y + distance
end
#--------------------------------------------------------------------------
# * Scroll Left
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_left(distance)
unless $game_system.mapLooping
scroll_left_mapLooping_game_map(distance)
return
end
@display_x = @display_x - distance
end
#--------------------------------------------------------------------------
# * Scroll Right
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_right(distance)
unless $game_system.mapLooping
scroll_right_mapLooping_game_map(distance)
return
end
@display_x = @display_x + distance
end
#--------------------------------------------------------------------------
# * Scroll Up
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_up(distance)
unless $game_system.mapLooping
scroll_up_mapLooping_game_map(distance)
return
end
@display_y = @display_y - distance
end
#--------------------------------------------------------------------------
# * Determine Valid Coordinates
# x : x-coordinate
# y : y-coordinate
# Allow the hero to go out of the map when map looping
#--------------------------------------------------------------------------
def valid?(x, y)
unless $game_system.mapLooping
return valid_mapLooping_game_map?(x, y)
end
if $game_system.mapLooping then return true end
return (x >= 0 && x < width && y >= 0&& y < height)
end
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8,10)
# * 0,10 = determine if all directions are impassable
# self_event : Self (If event is determined passable)
#--------------------------------------------------------------------------
def passable?(x, y, d, self_event = nil)
unless $game_system.mapLooping
return passable_mapLooping_game_map?(x, y, d, self_event)
end
unless valid?(x, y)
return false
end
bit = (1 << (d / 2 - 1)) & 0x0f
for event in events.values
if event.tile_id >= 0 and event != self_event and
event.x == x and event.y == y and not event.through
if @passages[event.tile_id] & bit != 0
return false
elsif @passages[event.tile_id] & 0x0f == 0x0f
return false
elsif @priorities[event.tile_id] == 0
return true
end
end
end
for i in [2, 1, 0]
tile_id = data[x % width, y % height, i] # handle map looping
if tile_id == nil
return false
elsif @passages[tile_id] & bit != 0
return false
elsif @passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
end
return true
end
#--------------------------------------------------------------------------
# * Setup
# map_id : map ID
#--------------------------------------------------------------------------
def setup(map_id)
old_setup_mapLooping(map_id)
map_data = $data_maps[$game_map.map_id]
$game_system.mapLooping = map_data.fullname.include?("[L]")
end
end
#============================================================================
# ** Game_Character
#----------------------------------------------------------------------------
# "update" method modifications to handle map looping
#============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Aliased methods (F12 compatibility)
#--------------------------------------------------------------------------
unless @already_aliased
alias initialize_mapLooping_game_character initialize
alias update_mapLooping_game_character update
@already_aliased = true
end
#--------------------------------------------------------------------------
# * Attributes
#--------------------------------------------------------------------------
attr_accessor :x
attr_accessor :y
attr_accessor :real_x
attr_accessor :real_y
attr_accessor :map_number_x # map's number with X-looping
attr_accessor :map_number_y # map's number with Y-looping
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
initialize_mapLooping_game_character
self.map_number_x = 0
self.map_number_y = 0
end
#--------------------------------------------------------------------------
# * Update : handle map looping
#--------------------------------------------------------------------------
def update
unless $game_system.mapLooping
update_mapLooping_game_character
return
end
# if x-coordinate is out of the map
unless (x.between?(0, $game_map.width - 1))
difference = 128 * x - real_x
if self.is_a?(Game_Player)
# increase or decrease map's number
self.map_number_x += difference / (difference.abs)
end
# x-coordinate is equal to its equivalent in the map
self.x %= $game_map.width
self.real_x = 128 * x - difference
end
# if y-coordinate is out of the map
unless (y.between?(0, $game_map.height - 1))
difference = 128 * y - real_y
if self.is_a?(Game_Player)
# increase or decrease map's number
self.map_number_y += difference / (difference.abs)
end
# y-coordinate is equal to its equivalent in the map
self.y %= $game_map.height
self.real_y = 128 * y - difference
end
update_mapLooping_game_character
end
end
#============================================================================
# ** Game_Player
#============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Aliased methods (F12 compatibility)
#--------------------------------------------------------------------------
unless @already_aliased
alias center_mapLooping_game_player center
@already_aliased = true
end
#--------------------------------------------------------------------------
# * Always center around the hero if map looping
#--------------------------------------------------------------------------
def center(x, y)
unless $game_system.mapLooping
center_mapLooping_game_player(x, y)
return
end
$game_map.display_x = x * 128 - CENTER_X
$game_map.display_y = y * 128 - CENTER_Y
end
end
#============================================================================
# ** Sprite_Character
#============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# * Aliased methods (F12 compatibility)
#--------------------------------------------------------------------------
unless @already_aliased
alias update_mapLooping_sprite_character update
@already_aliased = true
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
update_mapLooping_sprite_character
if $game_system.mapLooping
unless x + computed_right_width >= 0 && x - computed_left_width < 640
self.x %= $game_map.width << 5
end
while y + computed_lower_height < 0
self.y += $game_map.height << 5
self.z += $game_map.height << 5
end
while y - computed_upper_height >= 480
self.y -= $game_map.height << 5
self.z -= $game_map.height << 5
end
end
end
#--------------------------------------------------------------------------
# * Sprite's upper height (doesn't handle rotation)
#--------------------------------------------------------------------------
def computed_upper_height
return (oy * zoom_y).to_i
end
#--------------------------------------------------------------------------
# * Sprite's lower height
#--------------------------------------------------------------------------
def computed_lower_height
return ((src_rect.height - oy) * zoom_y).to_i
end
#--------------------------------------------------------------------------
# * Sprite's left width
#--------------------------------------------------------------------------
def computed_left_width
return (ox * zoom_x).to_i
end
#--------------------------------------------------------------------------
# * Sprite's right width
#--------------------------------------------------------------------------
def computed_right_width
return ((src_rect.width - ox) * zoom_x).to_i
end
end
Some scripts :
Working on :