Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # TheoAllen - Fast Travel (2nd Edition)
- # Version : 1.0
- # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
- # (This script documentation is written in informal indonesian language)
- # -----------------------------------------------------------------------------
- # Scripted for :
- # - The Contract : Truth
- # - The Trail of Horizon
- # =============================================================================
- ($imported ||= {})[:Theo_FastTravel2] = true
- # =============================================================================
- # Change Logs:
- # -----------------------------------------------------------------------------
- # 2014.02.15 - Finished script
- # =============================================================================
- =begin
- -----------------------------------------------------------------------------
- Perkenalan :
- Script ini nambahin fitur buat fast travel atau teleport dari peta satu ke
- peta lain.
- -----------------------------------------------------------------------------
- Cara penggunaan :
- Pasang script ini di bawah material namun di atas main
- Untuk nambahin peta pada list, gunakan script call
- add_travelmap(map_id, x, y, d, snapshot)
- Keterangan :
- map_id >> ID map yang akan dituju
- x >> Posisi X yang akan dituju di map baru
- y >> Posisi Y yang akan dituju di map baru
- d >> Posisi hadap player (2 = bawah, 8 = atas, 4 = kiri, 6 = kanan)
- snapshot >> Screenshot dari peta. Gambar harus ada pada Graphics/system.
- Direkomendasikan dimensi gambar adalah 240 x 200
- Contoh script call :
- add_travelmap(3,15,15,2,"map001")
- Untuk nambahin menu fast travel pada main menu, gunakan script call.
- $game_system.travel_menu = true
- Dan untuk nge-disable akses fast travel pada beberapa map, gunakan notetag
- <no travel> pada notebox map properties
- -----------------------------------------------------------------------------
- Terms of use :
- Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
- keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
- dipake buat komersil, jangan lupa, gw dibagi gratisannya.
- =end
- # =============================================================================
- # Konfigurasi :
- # =============================================================================
- module Theo
- module TravelMap
- # Text untuk header
- Header = "Fast Travel"
- # Text untuk nunjukin map saat ini player berada di mana
- CurrentMap = "Current Map :"
- # Title untuk info map
- MapInfo = "Map Infos"
- # Vokab untuk map name
- MapName = "Name :"
- # Vokab untuk snapshot map
- Snapshot = "Snapshot :"
- # Nama command pada menu
- MenuCommand = "Fast Travel"
- # Format angka peta. Contoh penulisan format angka
- # >> %d:%s ---> 1:nama, 2:nama, 20:nama
- # >> %03d:%s ---> 001:nama, 002:nama, 034:nama
- # >> %02d:%s ---> 01:nama, 02:nama, 34:nama
- Format = "%02d:%s"
- end
- end
- # =============================================================================
- # Akhir dari konfigurasi. Dilarang mengubah apapun di bawah ini kecuali ente
- # tanggung sendiri semua resikonye... :v
- # =============================================================================
- # =============================================================================
- # ▼ Game_Interpreter
- # =============================================================================
- class Game_Interpreter
- def add_travelmap(id, x, y, d = 2, snapshot = '')
- new_map = MapList.new(id, x, y, d, snapshot)
- return if $game_system.travel_maps.any? do |map|
- map == new_map
- end
- $game_system.travel_maps.push(new_map)
- end
- end
- # =============================================================================
- # ▼ New Class : MapList
- # =============================================================================
- class MapList
- attr_accessor :id
- attr_accessor :x
- attr_accessor :y
- attr_accessor :d
- attr_accessor :snapshot
- def initialize(id, x, y, d, snapshot)
- @id = id
- @x = x
- @y = y
- @d = d
- @snapshot = snapshot
- end
- def name
- load_data(sprintf("Data/Map%03d.rvdata2", id)).display_name
- end
- def transfer_player
- $game_player.reserve_transfer(id, x, y, d)
- SceneManager.clear
- SceneManager.goto(Scene_Map)
- end
- def ==(other)
- self.id == other.id && self.x == other.x && self.y == other.y
- end
- end
- # =============================================================================
- # ▼ Game_System
- # =============================================================================
- class Game_System
- attr_accessor :travel_menu
- attr_reader :travel_maps
- alias theo_travelmap_init initialize
- def initialize
- theo_travelmap_init
- @travel_maps = []
- @travel_menu = true
- end
- end
- # =============================================================================
- # ▼ Game_Map
- # =============================================================================
- class Game_Map
- def can_travel?
- @map.note[/<no[\s_]+travel>/].nil?
- end
- end
- # =============================================================================
- # ▼ Window_MenuCommand
- # =============================================================================
- class Window_MenuCommand < Window_Command
- alias theo_travelmap_ori_command add_original_commands
- def add_original_commands
- theo_travelmap_ori_command
- add_command(Theo::TravelMap::MenuCommand, :travel,
- $game_map.can_travel?) if $game_system.travel_menu
- end
- end
- # =============================================================================
- # ▼ Scene_Menu
- # =============================================================================
- class Scene_Menu < Scene_MenuBase
- alias theo_travelmap_cmn_window create_command_window
- def create_command_window
- theo_travelmap_cmn_window
- @command_window.set_handler(:travel, method(:on_travel_ok))
- end
- def on_travel_ok
- SceneManager.call(Scene_Travel)
- end
- end
- # =============================================================================
- # ▼ New Class : Window_TravelHeader
- # =============================================================================
- class Window_TravelHeader < Window_Base
- def initialize
- super(0,0,window_width, window_height)
- refresh
- end
- def window_width
- Graphics.width
- end
- def window_height
- fitting_height(1)
- end
- def refresh
- contents.clear
- draw_text(contents.rect, Theo::TravelMap::Header, 1)
- end
- end
- # =============================================================================
- # ▼ New Class : Window_TravelList
- # =============================================================================
- class Window_TravelList < Window_Selectable
- def col_max
- return 1
- end
- def item_max
- @data ? @data.size : 1
- end
- def item
- @data && index >= 0 ? @data[index] : nil
- end
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- def make_item_list
- @data = $game_system.travel_maps
- end
- def draw_item(index)
- map = @data[index]
- draw_map_name(map,index) if map
- end
- def draw_map_name(map, index)
- rect = item_rect(index)
- rect.x += 4
- name = map.name
- number = index + 1
- text = sprintf(Theo::TravelMap::Format,number,name)
- draw_text(rect,text)
- end
- def update_help
- @help_window.set_item(item) if @help_window
- end
- def current_item_enabled?
- enable?(item)
- end
- def enable?(item)
- !item.nil?
- end
- end
- # =============================================================================
- # ▼ New Class : Window_TravelInfo
- # =============================================================================
- class Window_TravelInfo < Window_Base
- def set_item(item)
- @item = item
- refresh
- end
- def refresh
- contents.clear
- return unless @item
- change_color(system_color)
- draw_text(line_rect(0), Theo::TravelMap::MapInfo, 1)
- draw_text(line_rect(1), Theo::TravelMap::MapName)
- draw_text(line_rect(3), Theo::TravelMap::Snapshot)
- change_color(normal_color)
- draw_text(line_rect(2), @item.name)
- bmp = Cache.system(@item.snapshot)
- contents.blt(0,4 * line_height, bmp, bmp.rect)
- end
- def line_rect(line)
- Rect.new(0, line * line_height, contents.width, line_height)
- end
- end
- # =============================================================================
- # ▼ New Class : Window_CurrentMap
- # =============================================================================
- class Window_CurrentMap < Window_Base
- def initialize(y)
- super(0,y,window_width, window_height)
- refresh
- end
- def window_width
- Graphics.width
- end
- def window_height
- fitting_height(1)
- end
- def refresh
- contents.clear
- rect = contents.rect
- change_color(system_color)
- draw_text(rect, Theo::TravelMap::CurrentMap)
- change_color(normal_color)
- draw_text(rect, $game_map.display_name, 2)
- end
- end
- # =============================================================================
- # ▼ New Class : Scene_Travel
- # =============================================================================
- class Scene_Travel < Scene_MenuBase
- def start
- super
- create_header
- create_maplist
- create_mapinfo
- create_footer
- end
- def create_header
- @header = Window_TravelHeader.new
- end
- def create_maplist
- y = @header.height
- w = Graphics.width/2
- h = Graphics.height - @header.height*2
- @maplist = Window_TravelList.new(0,y,w,h)
- @maplist.set_handler(:ok, method(:on_map_ok))
- @maplist.set_handler(:cancel, method(:on_map_cancel))
- @maplist.refresh
- @maplist.activate
- @maplist.select(0)
- end
- def create_mapinfo
- x = @maplist.width
- y = @maplist.y
- w = @maplist.width
- h = @maplist.height
- @mapinfo = Window_TravelInfo.new(x,y,w,h)
- @maplist.help_window = @mapinfo
- end
- def create_footer
- y = @header.height + @maplist.height
- @footer = Window_CurrentMap.new(y)
- end
- def on_map_ok
- @maplist.item.transfer_player
- end
- def on_map_cancel
- return_scene
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment