Pokeminer20
PDM20, Coder of Chaos!
- 412
- Posts
- 10
- Years
- On Earth
- Seen Nov 27, 2024
Originally found here:https://forum.chaos-project.com/index.php?topic=1634.0 this script allows one to exceed the natural limit of RPG Maker's 999 Map limit. with major help from Vendily and NettoHikari we have also allowed for more than the limited 5000 Variables and Switches, and even some of them being synced with all discs(Your choice which ones become synced).
Paste the script above main.
Auto Version (Novice)
Spoiler:
Code:
#==============================================================================
# ** Disc Changer script (Designed for Legend of Harpine)
#------------------------------------------------------------------------------
# Zeriab
# 1.05
# 2008-09-20
#------------------------------------------------------------------------------
# Allows you to change the disc, where each disc can contain 999 maps
#==============================================================================
=begin
INSTRUCTIONS
------------
If you do not have the SDK then you have to change Game_Map
In the Game_Map setup method change the load_data line to this: (Line 50)
# Load map from file and set @map
@map = load_data(sprintf("Data/%sMap%03d.rxdata", $game_system.disc, @map_id))
After you have done this the below will work.
This script enables the change_disc command. Use script calls to change the disc.
For disc 1 create a subfolder in your data folder called 'disc1' and place the
map files for disc 1 in there.
For disc 2 you should create a subfolder called 'disc2' and place the map files
for disc 2 in there. And so on for each of your discs.
The syntax is:
change_disc(number, id = nil, x = nil, y = nil, direction = nil)
The nil numbers mean that those arguments are optional. When you don't use them
then they are set to whatever the current map_id, x, y and direction are at the
moment.
If you want to change to disc 2 then you can put this in a script call:
change_disc(2)
You will then be transferred to disc 2 with the same map id and coordinates as
what the player currently has.
If you want to be more precise and say you want to change to disc 2 on the map
with id 10 and the player must be placed at the tile with x = 6 and y = 13 then
you should put this in a call script:
change_disc(2, 10, 6, 13)
Note that when you start the game the maps directly in the data folder is used.
You can back to them by changing to disc number 0.
Basically, disc number 0 is the maps directly in the data folder and not in any
of the sub folders.
The final argument is the direction. By default the player retains the current
direction. You can put 6 different values as direction:
0, 10 : No change
2 : Turn Down
4 : Turn Left
6 : Turn Right
8 : Turn Up
If you for example want to transfer the player to disc 1, map 43 at x = 30 and
y = 4 with the player looking down you should put this in a call script:
change_disc(1, 43, 30, 4, 2)
*hugs*
- Created by Zeriab
Modded by NettoHikari
Perfected by Vendily
Variable Sync added by Pokeminer20
=end
class Game_System
attr_accessor :discdata
attr_accessor :disc
alias _MDN_initialize initialize
def initialize
_MDN_initialize
@discdata = Hash.new
end
def disc
@disc ||= ''
@disc
end
end
class Game_Temp
attr_accessor :disc_changing
end
class Game_Map
attr_writer :map_id
if Module.constants.include?('SDK')
def setup_load
# Load map from file and set @map
@map = load_data(sprintf("Data/%sMap%03d.rxdata", $game_system.disc, @map_id))
end
end
def setup(map_id)
@map_id = map_id
@map = load_data(sprintf("Data/%sMap%03d.rxdata", $game_system.disc, @map_id))
tileset = $data_tilesets[@map.tileset_id]
updateTileset
@fog_ox = 0
@fog_oy = 0
@fog_tone = Tone.new(0, 0, 0, 0)
@fog_tone_target = Tone.new(0, 0, 0, 0)
@fog_tone_duration = 0
@fog_opacity_duration = 0
@fog_opacity_target = 0
self.display_x = 0
self.display_y = 0
@need_refresh = false
Events.onMapCreate.trigger(self,map_id,@map,tileset)
@events = {}
for i in @map.events.keys
@events[i] = Game_Event.new(@map_id, @map.events[i],self)
end
@common_events = {}
for i in 1...$data_common_events.size
@common_events[i] = Game_CommonEvent.new(i)
end
@scroll_direction = 2
@scroll_rest = 0
@scroll_speed = 4
end
end
def change_disc(number, id = nil, x = nil, y = nil, direction = nil)
discno = $game_system.disc.length < 6 ? "0" : $game_system.disc[4...$game_system.disc.length-1]
if !$game_system.discdata[discno]
$game_system.discdata[discno] = [$game_switches.clone, $game_variables.clone, $game_self_switches.clone]
end
# Change disc
if number == 0
$game_system.disc = "/"
elsif number.is_a?(Integer)
$game_system.disc = "disc#{number}/"
else
disc = number.to_s
disc += '/'
$game_system.disc = disc
end
# Process arguments
num="#{number}"
if !$game_system.discdata[num]
$game_system.discdata[num]=[Game_Switches.new,Game_Variables.new,Game_SelfSwitches.new]
end
synchronizeSwitches
synchronizeVariables
$game_switches = $game_system.discdata[num][0]
$game_variables = $game_system.discdata[num][1]
$game_self_switches = $game_system.discdata[num][2]
map_id = id.is_a?(Integer) ? id : $game_map.map_id
x = $game_player.x unless x.is_a?(Integer)
y = $game_player.y unless y.is_a?(Integer)
direction = $game_player.direction unless direction.is_a?(Integer)
# Set transferring player flag
$game_temp.player_transferring = true
# Set transferring player flag
$game_temp.disc_changing = true
# Set player move destination
$game_temp.player_new_map_id = map_id
$game_temp.player_new_x = x
$game_temp.player_new_y = y
$game_temp.player_new_direction = direction
# Change the current map id in case the new and old are identical.
$game_map.map_id = 0
$game_map.refresh
end
SYNCRONIZED_SWITCHES=[ 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60]#all ID's go here
SYNCRONIZED_VARIABLES=[ 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25]#all ID's go here
def synchronizeSwitches
$game_system.discdata.each_value{|data|
switches=data[0]
SYNCRONIZED_SWITCHES.each{|id|
switches[id]=$game_switches[id]
}
}
end
def synchronizeVariables
$game_system.discdata.each_value{|data|
variables=data[1]
SYNCRONIZED_VARIABLES.each{|id|
variables[id]=$game_variables[id]
}
}
end
#===============================================================================
# Method to get Town Map data.
#===============================================================================
def pbLoadTownMapData
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.townMapData
$PokemonTemp.townMapData = load_data(sprintf("Data/%stown_map.dat", $game_system.disc))
end
return $PokemonTemp.townMapData
end
#===============================================================================
# Method relating to map infos data.
#===============================================================================
def pbLoadMapInfos
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.mapInfos
if $DEBUG
$PokemonTemp.mapInfos = load_data("Data/MapInfos.rxdata")
else
$PokemonTemp.mapInfos = load_data(sprintf("Data/%sMapInfos.rxdata", $game_system.disc))
end
end
return $PokemonTemp.mapInfos
end
#===============================================================================
# Map Factory Helper (stores map connection and size data and calculations
# involving them)
#===============================================================================
module MapFactoryHelper
def self.getMapConnections
if !@@MapConnections
@@MapConnections = []
conns = load_data(sprintf("Data/%smap_connections.dat", $game_system.disc))
conns.each do |conn|
# Ensure both maps in a connection are valid
dimensions = getMapDims(conn[0])
next if dimensions[0] == 0 || dimensions[1] == 0
dimensions = getMapDims(conn[3])
next if dimensions[0] == 0 || dimensions[1] == 0
# Convert first map's edge and coordinate to pair of coordinates
edge = getMapEdge(conn[0], conn[1])
case conn[1]
when "N", "S"
conn[1] = conn[2]
conn[2] = edge
when "E", "W"
conn[1] = edge
end
# Convert second map's edge and coordinate to pair of coordinates
edge = getMapEdge(conn[3], conn[4])
case conn[4]
when "N", "S"
conn[4] = conn[5]
conn[5] = edge
when "E", "W"
conn[4] = edge
end
# Add connection to arrays for both maps
@@MapConnections[conn[0]] = [] if !@@MapConnections[conn[0]]
@@MapConnections[conn[0]].push(conn)
@@MapConnections[conn[3]] = [] if !@@MapConnections[conn[3]]
@@MapConnections[conn[3]].push(conn)
end
end
return @@MapConnections
end
end
module Compiler
def write_connections
conndata = load_data(sprintf("Data/%smap_connections.dat", $game_system.disc))
return if !conndata
mapinfos = pbLoadMapInfos
File.open("PBS/connections.txt","wb") { |f|
add_PBS_header_to_file(f)
f.write("\#-------------------------------\r\n")
for conn in conndata
if mapinfos
# Skip if map no longer exists
next if !mapinfos[conn[0]] || !mapinfos[conn[3]]
f.write(sprintf("# %s (%d) - %s (%d)\r\n",
(mapinfos[conn[0]]) ? mapinfos[conn[0]].name : "???", conn[0],
(mapinfos[conn[3]]) ? mapinfos[conn[3]].name : "???", conn[3]))
end
if conn[1].is_a?(String) || conn[4].is_a?(String)
f.write(sprintf("%d,%s,%d,%d,%s,%d", conn[0], conn[1], conn[2],
conn[3], conn[4], conn[5]))
else
ret = normalize_connection(conn)
f.write(get_connection_text(ret[0], ret[1], ret[2], ret[3], ret[4], ret[5]))
end
f.write("\r\n")
end
}
Graphics.update
end
end
module GameData
#=============================================================================
# A mixin module for data classes which provides common class methods (called
# by GameData::Thing.method) that provide access to data held within.
# Assumes the data class's data is stored in a class constant hash called DATA.
# For data that is known by a symbol or an ID number.
#=============================================================================
module ClassMethods
def load
const_set(:DATA, load_data(sprintf("Data/%s#{self::DATA_FILENAME}", $game_system.disc)))
end
def save
if $DEBUG
save_data(self::DATA, "Data/#{self::DATA_FILENAME}")
else
save_data(sprintf(self::DATA, "Data/%s#{self::DATA_FILENAME}", $game_system.disc))
end
end
end
#=============================================================================
# A mixin module for data classes which provides common class methods (called
# by GameData::Thing.method) that provide access to data held within.
# Assumes the data class's data is stored in a class constant hash called DATA.
# For data that is only known by a symbol.
#=============================================================================
module ClassMethodsSymbols
def load
const_set(:DATA, load_data(sprintf("Data/%s#{self::DATA_FILENAME}", $game_system.disc)))
end
def save
if $DEBUG
save_data(self::DATA, "Data/#{self::DATA_FILENAME}")
else
save_data(sprintf(self::DATA, "Data/%s#{self::DATA_FILENAME}", $game_system.disc))
end
end
end
#=============================================================================
# A mixin module for data classes which provides common class methods (called
# by GameData::Thing.method) that provide access to data held within.
# Assumes the data class's data is stored in a class constant hash called DATA.
# For data that is only known by an ID number.
#=============================================================================
module ClassMethodsIDNumbers
def load
const_set(:DATA, load_data(sprintf("Data/%s#{self::DATA_FILENAME}", $game_system.disc)))
end
def save
if $DEBUG
save_data(self::DATA, "Data/#{self::DATA_FILENAME}")
else
save_data(sprintf(self::DATA, "Data/%s#{self::DATA_FILENAME}", $game_system.disc))
end
end
end
end
Spoiler:
Spoiler:
Code:
#==============================================================================
# ** Disc Changer script (Designed for Legend of Harpine)
#------------------------------------------------------------------------------
# Zeriab
# 1.05
# 2008-09-20
#------------------------------------------------------------------------------
# Allows you to change the disc, where each disc can contain 999 maps
#==============================================================================
=begin
INSTRUCTIONS
------------
If you do not have the SDK then you have to change Game_Map
In the Game_Map setup method change the load_data line to this: (Line 50)
# Load map from file and set @map
@map = load_data(sprintf("Data/%sMap%03d.rxdata", $game_system.disc, @map_id))
After you have done this the below will work.
This script enables the change_disc command. Use script calls to change the disc.
For disc 1 create a subfolder in your data folder called 'disc1' and place the
map files for disc 1 in there.
For disc 2 you should create a subfolder called 'disc2' and place the map files
for disc 2 in there. And so on for each of your discs.
The syntax is:
change_disc(number, id = nil, x = nil, y = nil, direction = nil)
The nil numbers mean that those arguments are optional. When you don't use them
then they are set to whatever the current map_id, x, y and direction are at the
moment.
If you want to change to disc 2 then you can put this in a script call:
change_disc(2)
You will then be transferred to disc 2 with the same map id and coordinates as
what the player currently has.
If you want to be more precise and say you want to change to disc 2 on the map
with id 10 and the player must be placed at the tile with x = 6 and y = 13 then
you should put this in a call script:
change_disc(2, 10, 6, 13)
Note that when you start the game the maps directly in the data folder is used.
You can back to them by changing to disc number 0.
Basically, disc number 0 is the maps directly in the data folder and not in any
of the sub folders.
The final argument is the direction. By default the player retains the current
direction. You can put 6 different values as direction:
0, 10 : No change
2 : Turn Down
4 : Turn Left
6 : Turn Right
8 : Turn Up
If you for example want to transfer the player to disc 1, map 43 at x = 30 and
y = 4 with the player looking down you should put this in a call script:
change_disc(1, 43, 30, 4, 2)
*hugs*
- Created by Zeriab
Modded by NettoHikari
Perfected by Vendily
Variable Sync added by Pokeminer20
=end
class Game_System
attr_accessor :disc
def disc
@disc ||= ''
@disc
end
end
class Game_Temp
attr_accessor :disc_changing
end
class Game_Map
attr_writer :map_id
if Module.constants.include?('SDK')
def setup_load
# Load map from file and set @map
@map = load_data(sprintf("Data/%sMap%03d.rxdata", $game_system.disc, @map_id))
end
end
end
def change_disc(number, id = nil, x = nil, y = nil, direction = nil)
discno = $game_system.disc.length < 6 ? "0" : $game_system.disc[4...$game_system.disc.length-1]
if !$game_system.discdata[discno]
$game_system.discdata[discno] = [$game_switches.clone, $game_variables.clone, $game_self_switches.clone]
end
# Change disc
if number == 0
$game_system.disc = "/"
elsif number.is_a?(Integer)
$game_system.disc = "disc#{number}/"
else
disc = number.to_s
disc += '/'
$game_system.disc = disc
end
# Process arguments
num="#{number}"
if !$game_system.discdata[num]
$game_system.discdata[num]=[Game_Switches.new,Game_Variables.new,Game_SelfSwitches.new]
end
synchronizeSwitches
synchronizeVariables
$game_switches = $game_system.discdata[num][0]
$game_variables = $game_system.discdata[num][1]
$game_self_switches = $game_system.discdata[num][2]
map_id = id.is_a?(Integer) ? id : $game_map.map_id
x = $game_player.x unless x.is_a?(Integer)
y = $game_player.y unless y.is_a?(Integer)
direction = $game_player.direction unless direction.is_a?(Integer)
# Set transferring player flag
$game_temp.player_transferring = true
# Set transferring player flag
$game_temp.disc_changing = true
# Set player move destination
$game_temp.player_new_map_id = map_id
$game_temp.player_new_x = x
$game_temp.player_new_y = y
$game_temp.player_new_direction = direction
# Change the current map id in case the new and old are identical.
$game_map.map_id = 0
$game_map.refresh
end
SYNCRONIZED_SWITCHES=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,
22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,
47,48,49,50,51,52,53,54,55,56,57,58]#all ID's go here
SYNCRONIZED_VARIABLES=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,
22,23,24,25]#all ID's go here
def synchronizeSwitches
$game_system.discdata.each_value{|data|
switches=data[0]
SYNCRONIZED_SWITCHES.each{|id|
switches[id]=$game_switches[id]
}
}
end
def synchronizeVariables
$game_system.discdata.each_value{|data|
variables=data[1]
SYNCRONIZED_VARIABLES.each{|id|
variables[id]=$game_variables[id]
}
}
end
Spoiler:
Find Game_Map in the script editor.
Go to the setup method to around line 50 (assuming the default script)
It should look like this:
Code:
# Load map from file and set @map
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
Code:
# Load map from file and set @map
@map = load_data(sprintf("Data/%sMap%03d.rxdata", $game_system.disc, @map_id))
Code:
attr_accessor :bgm_position # Find this
attr_accessor :discdata # Add this
@bgs_position = 0 # Find this
@discdata = Hash.new # Add this
The best way to truly tell you how this script works is with a small flowchart I made while working on this. The Black circle is your project, the blue circle is your switches and variables, the purple are your maps
The First chart represents essentials in it's base, one project, one set of global data, one set of maps. the second chart was what was added when the default disc changer is placed into the game, a theoretical number of 'Discs' containing it's own maps. The 3rd is what NettoHikari Added, multiple sets global data. The last is the perfected vision, with the Sync feature by Vendily. to simplyfy it down, with this you can combine all your projects into one version and can even place benefits to players who start to 100% each of your games.(the Infinity symbols are only there to indicate 3 or more discs)
the Original thread mentioned something about an SDK to make your job easier, but I could never found it, so aside from this script there will be something to note. this script alone will cause conflict with essentials custom data, like the popup box for maps, the connections, and the encounters. luckily, there is an easy fix for that.
Locate all instances of the following:
V18 and below:
Spoiler:
Code:
load_data("Data/MapInfos.rxdata")
Code:
load_data("Data/connections.dat")
Code:
load_data("Data/encounters.dat")
replace the above variants with the ones below
Code:
load_data(sprintf("Data/%sMapInfos.rxdata", $game_system.disc))
Code:
load_data(sprintf("Data/%sconnections.dat", $game_system.disc))
Code:
load_data(sprintf("Data/%sencounters.dat", $game_system.disc))
v19 and above:
Spoiler:
Code:
load_data("Data/MapInfos.rxdata")
Code:
load_data("Data/map_connections.dat")
Code:
load_data("Data/#{self::DATA_FILENAME}")
Code:
save_data(self::DATA, "Data/#{self::DATA_FILENAME}")
replace the above variants with the ones below
Code:
load_data(sprintf("Data/%sMapInfos.rxdata", $game_system.disc))
Code:
load_data(sprintf("Data/%smap_connections.dat", $game_system.disc))
Code:
load_data(sprintf("Data/%s#{self::DATA_FILENAME}", $game_system.disc))
Code:
save_data(sprintf(self::DATA, "Data/%s#{self::DATA_FILENAME}", $game_system.disc))
For this to work DO NOT INSTALL THIS AS A PLUGIN! also, delete ALL Save Files for your project. To see changes to your project, create an event with the disc changer command and target the map and disc like in the blurb at the top of the script. remember to create a return command in the disc you are warping to.
Last edited: