Code:
###############################################################################
# Map Menu (View map & transfer player) Beta 1.2 #
###############################################################################
# Edited by Artofmin #
# Beta Released Date: 11 October 2009 (Beta 1.0) #
# Date Update: 1 December 2009 #
#=============================================================================#
# Beta 1.2 #
# Originally updated/edited by: Fox536 #
# Date: 30 November 2009 #
#=============================================================================#
# Intro: #
# To use item 029: Map as a map (view map etc). #
# This script is base from Moghunter’s MOG_Character Select Screen V1.1. #
# http://atelier-rgss.com/Index.html). I’ve edit it so it can be use for #
# viewing Map, Location List, Current Location and Transfer player. #
#=============================================================================#
# Credits: #
# #
# Moghunter = I use the MOG_Character Select Screen V1.1 #
# as reference. #
# #
# Fox536 (Creation Asylum) = Making this script more user friendly and #
# solved things/feature that I would never #
# figured out. #
# #
# Sid Meier’s Civilization III = currently use its map graphic as sample. #
#=============================================================================#
# Thanks: #
# #
# Khattar (Creation Asylum) = I’ve read his post about player transfer & #
# some tutorial. #
# GubiD (Creation Asylum) = I’ve read his post about transfer script. #
#=============================================================================#
# Note: #
# Don’t have to credit me. I edited/implemented this script as practice. #
# BTW, I’m NOT a scripter, if you have any problem with this script…well, #
# I’ll try to help. If you’re a scripter, feel free to edit this script. #
# This script is free (commercial or non commercial). #
# #
# If you’re using this script, please CREDITS to: #
# Fox536 (Creation Asylum) #
# #
# Fox536: I did minor edits to the script but it still runs completely #
# the same in game... just made edits to make it easier for game creation. #
# #
###############################################################################
# MAP_PLACES[Map ID] = [true, Map ID, Player X, Player Y, Player Direction}
MAP_PLACES = {}
MAP_PLACES[1] = [true, 1, 9, 13, 8]
MAP_PLACES[2] = [true, 2, 9, 1, 2]
MAP_PLACES[3] = [true, 3, 18, 5, 4]
MAP_PLACES[4] = [true, 4, 9, 12, 8]
MAP_PLACES[5] = [true, 5, 2, 8, 6]
# to add a map use
# $game_temp.add_map(x)
# to remove a map use
# $game_temp.remove_map(x)
###################
# Window Location # Create the Current Location window.
###################
class Window_Location < Window_Base
###################
# initialize #
###################
def initialize
super(0, 0, 160, 76)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 15
refresh
end
###################
# refresh #
###################
def refresh
self.contents.clear
data = load_data("Data/MapInfos.rxdata")
self.contents.font.color = system_color
self.contents.draw_text(0, -8, 120, 32, "Current Location", 3)
self.contents.font.color = normal_color
self.contents.draw_text(0, 18, 140, 32,data[$game_map.map_id].name, 3)
end
end
###############
# Window List # Create the Location List window.
###############
class Window_List < Window_Base
###################
# initialize #
###################
def initialize
super(0, 0, 160, 404)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 15
refresh
end
###################
# Refresh #
###################
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, -10, 150, 32, "Location List", 3)
end
end
###############
# Win Maplist # Create the Location List index.
###############
class Win_Maplist < Window_Selectable
###################
# initialize #
###################
def initialize
super(0, 32, 160, 372)
@column_max = 1
self.opacity = 0
refresh
self.index = 1
self.visible = false
end
###################
# item #
###################
def item
return @data[self.index]
end
###################
# refresh #
###################
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@item_max = $game_temp.map_size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = "Arial"
self.contents.font.size = 15
self.contents.clear
data = load_data("Data/MapInfos.rxdata")
self.contents.font.color = normal_color
# Display Location Name
for i in 0...$game_temp.map_size
if $game_temp.map_check($game_temp.tele_maps[i]) == true
self.contents.draw_text(4, 32*i, 150, 32, data[$game_temp.tele_maps[i]].name, 3)
else
self.contents.draw_text(4, 32*i, 150, 32, "???", 3)
end
end
end
end
end
################# This is the main script.
# Scene_Maplist # Call using “$scene = Scene_Maplist.new”
################# (without “”).
class Scene_Maplist
###################
# main #
###################
def main
# Display Current Location Window
@window_location = Window_Location.new
@window_location.y = 404
@window_location.x = 0
# Display Location List Window
@window_list = Window_List.new
@window_list.y = 0
@window_list.x = 0
# Display Map Menu System
@command_window = Win_Maplist.new
@command_window.back_opacity = 0
@command_window.visible = true
@command_window.index = 0
@maplist_back = Sprite.new
@maplist_back.bitmap = RPG::Cache.picture("mp_menu0")
@maplist_back.opacity = 255
@maplist_sel = Sprite.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
@maplist_back.dispose
@maplist_sel.dispose
@window_location.dispose
@window_list.dispose
$game_map.autoplay
$game_map.update
end
###################
# update #
###################
def update
@command_window.update
@maplist_sel.opacity += 10
# Display Location Picture/Image
if $game_temp.map_check($game_temp.tele_maps[@command_window.index]) == true
@maplist_sel.bitmap = RPG::Cache.picture(sprintf("Map%03d", $game_temp.tele_maps[@command_window.index])) rescue @a = 1
end
if Input.trigger?(Input::B)
Audio.se_play("Audio/SE/003-System03", 80,100)
$scene = Scene_Item.new
end
if Input.trigger?(Input::C)
Audio.se_play("Audio/SE/007-System07", 80,100)
case @command_window.index
# Transfer the Player
when 0..4
if $game_temp.map_check($game_temp.tele_maps[@command_window.index]) == true
$game_screen.start_flash(Color.new(0, 0, 0, 255), 30)
$game_temp.player_transferring = MAP_PLACES[$game_temp.tele_maps[@command_window.index]][0]
$game_temp.player_new_map_id = MAP_PLACES[$game_temp.tele_maps[@command_window.index]][1]
$game_temp.player_new_x = MAP_PLACES[$game_temp.tele_maps[@command_window.index]][2]
$game_temp.player_new_y = MAP_PLACES[$game_temp.tele_maps[@command_window.index]][3]
$game_temp.player_new_direction = MAP_PLACES[$game_temp.tele_maps[@command_window.index]][4]
$scene = Scene_Map.new
end
end
end
end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
# use this to add a map to the array
# $game_temp.add_map(x)
# use this to check if the map has been added
# $game_temp.map_check(x)
# use this to check the size of the array
# $game_temp.map_size
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :availible_maps_tele # maps the player can teleport to
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias map_tele_initialize initialize
###################
# initialize # Adds the variable to the game_temp class
###################
def initialize
map_tele_initialize
@availible_maps_tele = []
end
###################
# add_map # Adds the map to the teleport list and sorts
###################
def add_map(x)
unless map_check(x)
@availible_maps_tele += [x]
@availible_maps_tele.sort!
end
end
###################
# remove_map # Removes the map from the teleport list and sorts
###################
def remove_map(x)
if map_check(x)
@availible_maps_tele -= [x]
@availible_maps_tele.sort!
end
end
###################
# map_check # Checks the teleport list for the map id
###################
def map_check(x=0)
return @availible_maps_tele.include?(x)
end
###################
# map_size # Checks the amount of maps availiable to teleport to
###################
def map_size
return [@availible_maps_tele.size, 0].max
end
###################
# tele_maps # Returns the array of map_ids:@availible_maps_tele
###################
def tele_maps
return @availible_maps_tele
end
end