iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> Continuous Maps Vx v.0.9, Want to make your maps connect completely?
FenixFyreX
post Oct 22 2010, 09:43 PM
Post #1


I'm on fire 24/7 >:3
Group Icon


Type: Coder
Alignment: Lawful Good




Continuous Maps Vx
Version 0.9


Introduction

Do you want your maps to connect to each other, Pokemon style? This script gets rid of having to create one huge map. Instead, you can make several small maps and connect them to each other.

Script

Here's the script, but I suggest you use the demo, it shows you how to do stuff.

Spoiler:
CODE
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Continuous Maps by Blizzard
# Version: 1.2
# Type: Custom Map System
# Date: 14.12.2009
# Date v1.2: 11.9.2010
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
#   - possible incompatibility in this script will lie in scripts that modify
#       map transfers.
#
# Features:
#
#   - virtually creates one continuous map from any number of map fragments
#   - easy to configure
#
# Instructions:
#
# - Explanation:
#
#   This Script will allow you to make the game simulate a continuous map using
#   smaller maps. The system displays the current map and the neighbor maps.
#   Walking over a map border will cause the new map to be loaded as main map
#   and the neighbor maps will be changed.
#
#
# Notes:
#
#   - You may notice lag when walking over a map border.
#   - Do not use too big maps as it increases loading time and the short moment
#     of lag will become more and more visible.
#   - Remember to connect ALL neighbor maps or you might experience bugs.
#   - For Vx, the most noticable bug is the centering of the screen; if you
#   - Move from a map onto a map that is connected to a map that is taller or
#       wider, the screen will 'jerk' to the player to center around them. This
#
# If you find any bugs, please report them at rpgmakervx.net's Continuous Map
# topic.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

module CTMAPS
  
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # define all neighbor maps here
  MAP_DATA = [
    # [MAP_ID1, MAP_ID2, X_OFFSET, Y_OFFSET]
    [1, 2, 17, 0], # connected map 1 and 2 where 2 has an X, Y offset of 25, 0
    [2, 3, 17, 0],
    [3, 4, 0, 29]
  ]
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  MAP_DATA.compact!
  MAPS = {}
  MAP_DATA.each {|data|
      MAPS[data[0]] = [] if MAPS[data[0]] == nil
      MAPS[data[0]] |= [data[1, 3]]
      MAPS[data[1]] = [] if MAPS[data[1]] == nil
      MAPS[data[1]] |= [[data[0], -data[2], -data[3]]]}
  MAP_DATA = nil
  $ctmaps = 1.2
  
end


#==============================================================================
# Game_Temp
#==============================================================================

class Game_Temp
  
  attr_accessor :player_no_straighten
  attr_accessor :normal_transfer
  attr_accessor :display_scroll_limit
  
  alias cont_maps_init initialize unless $@
  def initialize
    cont_maps_init
    @player_no_straighten = true
    @normal_transfer = false
    @display_scroll_limit = false
  end
  
end
  
#==============================================================================
# Game_Character
#==============================================================================

class Game_Character
  
  attr_accessor :x
  attr_accessor :y
  attr_accessor :real_x
  attr_accessor :real_y
  
  alias straighten_ctmaps_later straighten
  def straighten
    if $game_temp.player_no_straighten
      $game_temp.player_no_straighten = nil
      return
    end
    straighten_ctmaps_later
  end
  
  alias moveto_ctmaps_later moveto
  def moveto(x, y)
    ox, oy = $game_map.upper_left;
    moveto_ctmaps_later(x - ox, y - oy)
  end
  
end

#==============================================================================
# Game_Player
#==============================================================================

class Game_Player < Game_Character
  
  alias center_ctmaps_later center
  def center(x, y)
    ox, oy = $game_map.upper_left
    center_ctmaps_later(x - ox, y - oy)
  end
end

#==============================================================================
# Game_Map
#==============================================================================

class Game_Map
  
  attr_reader :upper_left
  attr_reader :lower_right
  attr_reader :maps
    
  alias init_ctmaps_later initialize
  def initialize
    @maps = {}
    @events = {}
    init_ctmaps_later
  end
  
  alias setup_ctmaps_later setup
  def setup(map_id)
    last_maps = @maps
    last_map_id = @map_id
    @upper_left = [0, 0]
    @lower_right = [0, 0]
    events = @events
    setup_ctmaps_later(map_id)
    @maps = get_neighbor_maps
    if !@maps.has_key?(last_map_id)
      @events = {}
      last_maps = {}
      last_map_id = 0
    else
      @events = events
    end
    setup_continuous_map
    setup_continuous_events(last_maps, last_map_id)
  end

  def get_neighbor_maps
    maps = {}
    maps[@map_id] = [@map, 0, 0]
    @upper_left = [0, 0]
    @lower_right = [@map.width, @map.height]
    if CTMAPS::MAPS.has_key?(@map_id)
      CTMAPS::MAPS[@map_id].each {|data|
          id, x, y = data
          if @maps[id] != nil
            map = @maps[id][0]
          else
            map = load_data(sprintf('Data/Map%03d.rvdata', id))
          end
          maps[id] = [map, x, y]
          @upper_left[0] = x if @upper_left[0] > x
          @upper_left[1] = y if @upper_left[1] > y
          width, height = x + map.width, y + map.height
          @lower_right[0] = width if @lower_right[0] < width
          @lower_right[1] = height if @lower_right[1] < height}
      maps.each_value {|data|
          data[1] -= @upper_left[0]
          data[2] -= @upper_left[1]}
    end
    return maps
  end
  
  def setup_continuous_map
    width = @lower_right[0] - @upper_left[0]
    height = @lower_right[1] - @upper_left[1]
    data = Table.new(width, height, 3)
    @map = @map.clone
    @map.events = {}
    @maps.each_key {|id|
        map, ox, oy = @maps[id]
        if id == @map_id
          map.events.each_key {|i| @map.events[i] = map.events[i]}
        else
          map.events.each_key {|i| @map.events[id * 1000 + i] = map.events[i]}
        end
        (0...map.width).each {|x| (0...map.height).each {|y| (0...3).each {|z|
            data[x + ox, y + oy, z] = map.data[x, y, z]}}}}
    @map.width = width
    @map.height = height
    @map.data = data
  end
  
  def setup_continuous_events(last_maps, last_map_id)
    correct_event_positions(last_maps) if last_maps[@map_id] != nil
    delete_removed_events(last_maps, last_map_id)
    shift_events_from_last_map(last_maps, last_map_id) if last_map_id != 0
    shift_events_for_new_map
    add_new_events(last_maps)
  end
  
  def delete_removed_events(last_maps, last_map_id)
    keys = []
    @maps.each_key {|id|
        keys += @events.keys.find_all {|key|
            @events[key].real_x < 0 || @events[key].real_y < 0 ||
            @events[key].real_x >= (@lower_right[0] - @upper_left[0]) * 256 ||
            @events[key].real_y >= (@lower_right[1] - @upper_left[1]) * 256}}
    (keys | keys).each {|key| @events.delete(key)}
  end
  
  def shift_events_from_last_map(last_maps, last_map_id)
    @events.each_key {|key|
        if key < 1000
          @events[last_map_id * 1000 + key] = @events[key]
          @events.delete(key)
        end}
  end
  
  def shift_events_for_new_map
    @events.each_key {|key|
        if key >= @map_id * 1000 && key < (@map_id + 1) * 1000
          @events[key % 1000] = @events[key]
          @events.delete(key)
        end}
  end
  
  def correct_event_positions(last_maps)
    sx = @maps[@map_id][1] - last_maps[@map_id][1]
    sy = @maps[@map_id][2] - last_maps[@map_id][2]
    @events.each_value {|event|
    x, y = sx, sy
    event.x += x
    event.y += y
    event.real_x += sx * 256
    event.real_y += sy * 256}
  end
  
  def add_new_events(last_maps = {})
    if last_maps[@map_id] == nil
      @maps[@map_id][0].events.each_key {|i|
          if @events[i] == nil
            @events[i] = Game_Event.new(@map_id, @maps[@map_id][0].events[i])
          end}
    end
    (@maps.keys - last_maps.keys - [@map_id]).each {|id|
        map, sx, sy = @maps[id]
        sx -= @maps[@map_id][1]
        sy -= @maps[@map_id][2]
        map.events.each_key {|i|
            if @events[id * 1000 + i] == nil
              @events[id * 1000 + i] = event = Game_Event.new(id, map.events[i])
              x, y = sx, sy
              event.x += x
              event.y += y
              event.real_x += sx * 256
              event.real_y += sy * 256
            end}}
  end
  
  alias update_ctmaps_later update
  def update
    update_ctmaps_later
    return if $game_player.moving? || @maps.size <= 1
    map, x, y = @maps[@map_id]
    if $game_player.real_x < x * 256 || $game_player.real_y < y * 256 ||
        $game_player.real_x >= x * 256 + map.width * 256 ||
        $game_player.real_y >= y * 256 + map.height * 256
      (@maps.keys - [@map_id]).each {|id|
          map, x, y = @maps[id]
          if $game_player.real_x >= x * 256 && $game_player.real_y >= y * 256 &&
              $game_player.real_x < x * 256 + map.width * 256 &&
              $game_player.real_y < y * 256 + map.height * 256
              $game_temp.player_no_straighten = true
              nx = $game_player.real_x / 256 - x
              ny = $game_player.real_y / 256 - y
              p "map_id = #{map_id}, new_map_id = #{id}, ox,oy = #{$game_player.x},#{$game_player.y}, nx,ny = #{nx},#{ny}" if Input.press?(Input::F5)
            $game_player.reserve_transfer(id, nx, ny, 0)
            break
          end}
    end
  end
  
end

class Scene_Map < Scene_Base
  
  alias cont_map_updt_transfer update_transfer_player unless $@
  def update_transfer_player
    if !$game_temp.normal_transfer
      do_new_transfer
      $game_temp.normal_transfer = false
    else
      cont_map_updt_transfer
    end
  end
  
  def do_new_transfer
    return unless $game_player.transfer?
    @spriteset.dispose              # Dispose of sprite set
    $game_player.perform_transfer   # Execute player transfer
    $game_map.autoplay              # Automatically switch BGM and BGS
    $game_map.update
    Graphics.wait(0)
    @spriteset = Spriteset_Map.new  # Recreate sprite set
    Input.update
  end
end
  
class Game_Interpreter
  
  def normal_transfer(boolean)
    $game_temp.normal_transfer = boolean
  end
  
end


Demo

Here's the demo:

Continuous Maps Vx version 0.9

Questions, Queries, and Explanations / Notes

Is there any changed things about checking x and y position?

I do believe that the player's x and y are determined by the map and it's neighbors. However, this might not be the case. If you find your events are not working while doing this, tell me and I'll try and fix it.

Is there any debug features to make sure the script is working?

Press and hold F5 whil walking onto another map. A window will pop up and tell you 4 things, the map id, the new map id, your old x, old y, and new x, new y for the new map.

The screen jerks when I transfer between maps.

Spoiler:
If you have a map that is horizontal, and transitions into a vertical map, any map connected to it will cause a slight jump in the centering of the screen when you transfer between them. For example:



If map 1 is connected to map 2, and map two(connected to map 1 already) is connected to map 3 as well, then:

if you walk from map 1 near the bottom-right of map 1 into the bottom-left of map 2, the screen will jerk itself to center around the player, because map 2 is connected to map 3, which is taller, so map 2 makes itself match that height.

So, the closer you get to width and height between maps, the less likely you will encounter this.

I am working on smoothing the center out, to make it gradually center instead of jerk like it does.

A quick fix for this could be making the maps as wide or tall as the ones next to it...though that would half-defeat the purpose..that's why I'm working on a fix. Possible the camera centers, even if you are near the edge of the map.


This script was originally created by Blizzard, over on chaos-project.com. Here's the link to the original: Blizzard's Continuous Maps - XP

You are to follow every rule he states, and credit is to go to him.


Credit to me would be nice, but all I did was port it. You don't have to credit me if you don't want. But make sure to credit Blizzard.

This post has been edited by FenixFyreX: Oct 25 2010, 12:38 AM
Go to the top of the page
 
+Quote Post
   
AZN Pride
post Oct 23 2010, 06:23 AM
Post #2


First Asian Judge in Ivalice
Group Icon


Type: Musician
Alignment: Unaligned




this looks pretty cool dude...Ill use this script in my game! smile.gif


--------------------
What my friend, Korean4Life, likes to say,"A bird in the hand...will hurt like hell..."
lol...
And that friend is totally ninja...I didnt see him hiding in my carpet!!!


My Poem i created for L.A...its gay...
Spoiler:
As I was walking
down a field
I saw a flower
that I could wield.
As it shined
in a patch,
I thought I could
find a batch.
The flower was
shiny as gold,
and it looked
very bold.
When I picked it,
I could see
Many memories
of the life of Me.

Random Stuff
Spoiler:
Can you read this?
Spoiler:
Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.

WhAt?!
Spoiler:
OMFGosh!!!

CLICK THIS QUICK!!!
Spoiler:
...YAY!!! MICKEY MOUSE!!!

Click!
Spoiler:
So MaNy DaMn SpOiLeRs!!!

WTF?!?! How iz that poszibl?!
Spoiler:

Damn...
Spoiler:
Things to do:
  1. Finish Game (15.94% Done... :( ...)
  2. Learn how to Parallax Map
  3. New Game in Progress...(Stopped till Next Halloween)
  4. ...List is done being edited...Future edits are on it's way.. :)


I'm not gay. I just like Anime.
Spoiler:







True Things
Spoiler:

Why i hate

...because it never happens to me...



Which Final Fantasy Character Are You?
Final Fantasy 7

Supports:
Spoiler:


Go to the top of the page
 
+Quote Post
   
FenixFyreX
post Oct 23 2010, 04:45 PM
Post #3


I'm on fire 24/7 >:3
Group Icon


Type: Coder
Alignment: Lawful Good




Thanks! Remember, if you have any bugs other than the ones I've mentioned, or requests for patches with other scripts, let me know. I'll see what I can do.

Generally though, I've noticed if you put things like Wall Tile Extension below this script, they work fine together.

This post has been edited by FenixFyreX: Oct 23 2010, 04:46 PM
Go to the top of the page
 
+Quote Post
   
bradz12
post Dec 4 2010, 06:34 PM
Post #4


Dun Dun Durrrrrn
Group Icon


Type: Spriter
Alignment: Neutral Good




Gunna put this into my game. Does it work with scripts that show map name upon entering, like pokemon style?


--------------------
Visit my game wiki - holostudiosquest.wikia.com
Go to the top of the page
 
+Quote Post
   
FenixFyreX
post Dec 4 2010, 06:40 PM
Post #5


I'm on fire 24/7 >:3
Group Icon


Type: Coder
Alignment: Lawful Good




Yes, I specifically modded it to accomodate VX's areas. Also, for 100% compatibility with a map and area name popup, I recommend my script in my library. However, there shouldn't be any problems anyways.

However, I just realized that my Library has an updated version of this. :x
Go to the top of the page
 
+Quote Post
   
Supergodjesus
post Dec 4 2010, 07:24 PM
Post #6



Group Icon


Type: Designer
Alignment: Unaligned




I highly doubt it is possible, but can this be modified to be compatible with the SwapXT system? Not sure if it would be possible since the neighboring maps would need to be read and have their swapped tiles taken into account.

I did play around with this script for fun though, and it works pretty well overall. Nice job.

This post has been edited by Supergodjesus: Dec 4 2010, 08:19 PM


--------------------
Keep up-to-date with the greatest RPGs ever: Pioneer Valley Games

Need inexpensive art resources? Let me know!


Need AMAZING game music? Note by Note Studios
Go to the top of the page
 
+Quote Post
   
Unfamiliar
post Dec 5 2010, 01:58 AM
Post #7


Feliz Navidad!
Group Icon


Type: Designer
Alignment: Lawful Evil




Thanks for this, It will be so awesomely handy in my game! You are teh most handsomest scripter ever, don't you forget it!


--------------------
SUPPORT:
The Ranger's Chronicles
Spoiler:

Pokemon Version VX
Spoiler:
http://www.rpgmakervx.net/index.php?showtopic=39278

Mijuku
Spoiler:

Go to the top of the page
 
+Quote Post
   
zitser of darkne...
post May 29 2014, 04:05 AM
Post #8


Godlike Overlord of all HUD and Scriptlets of Divine +12
Group Icon


Type: Coder
Alignment: Chaotic Good




fun trivia. you can use this to simulate a skyrim-like(or even fallout 3/NV) like map system. since Skyrim loads map by chuck, a 34x43 map can be considred a chuck. using this script, ive learn a special map trick that will be utilized by this script well. if you do plan on using the chuck system, consider this. your map should have 2 extra tiles x and y. the 1 extra tile on all side will be use as boundary referrence. try to make a box island and surround it with sea to make a small beach effect and then add another square island but make it all sea. you will see what i mean when adding the 1 extra tile as border.


--------------------
Go to the top of the page
 
+Quote Post
   
MASH_MX
post May 29 2014, 05:53 AM
Post #9


"Everyone Is Unique In There Own Defined Way."
Group Icon


Type: Writer
Alignment: Chaotic Good




Very neat script. happy.gif


--------------------
My Projects:
My User bar for the thread is broken click this instead. >.> (Project XeroMX)

My new incoming Community Terraria Server! =)
Other:

Other People and things I support:
Spoiler:


Go to the top of the page
 
+Quote Post
   
Neosky
post May 31 2014, 07:09 PM
Post #10


Master of the DarkSyde of Cheese!
Group Icon


Type: Undisclosed
Alignment: Lawful Evil




@mash really.... date.

@zitser of darkness that was posted in 2010, that last post that is, I seriously doubt they are even there anymore, or care. XD. please look at dates before posting. Thanks for your input though. wink.gif


--------------------


Remember, Remember the 5th of November...
Spoiler:



If you are new, please go through this spoiler for VERY useful links.
Spoiler:





Tarris Thread || User Forum || Tarris Hold Website || Twitch.tv
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd July 2014 - 04:53 AM

RPGMakerVX.net is an Privacy Policy, Legal.