Advertisement
pigu_6

TDS| Quick travel

Dec 10th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.79 KB | None | 0 0
  1. #==============================================================================
  2. # ** TDS Quick Travel
  3. # Ver: 1.2
  4. #------------------------------------------------------------------------------
  5. # * Description:
  6. # This script allows you to quickly travel to pre determined locations on a
  7. # map.
  8. #------------------------------------------------------------------------------
  9. # * Features:
  10. # Quickly changing locations in a map.
  11. #------------------------------------------------------------------------------
  12. # * Instructions:
  13. #
  14. # To add a quick travel location to a map use this in a script call:
  15. #
  16. # add_map_quick_travel(name, map_id, x, y, dir, index)
  17. #
  18. # name = name of the quick travel location
  19. # map_id = map id to add quick travel location to
  20. # x = X coordinate of the quick travel location on the map
  21. # y = Y coordinate of the quick travel location on the map
  22. # dir = facing direction after quick traveling (2, 4, 6, 8)
  23. #
  24. # To disable quick travel use this on a script call:
  25. #
  26. # disable_map_quick_travel
  27. #
  28. # To enable quick travel use this on a script call:
  29. #
  30. # disable_map_quick_travel
  31. #
  32. # To call the quick travel menu directly from an event use this in a script
  33. # call:
  34. #
  35. # call_map_quick_travel_menu
  36. #------------------------------------------------------------------------------
  37. # * Notes:
  38. # None.
  39. #------------------------------------------------------------------------------
  40. # WARNING:
  41. #
  42. # Do not release, distribute or change my work without my expressed written
  43. # consent, doing so violates the terms of use of this work.
  44. #
  45. # If you really want to share my work please just post a link to the original
  46. # site.
  47. #
  48. # * Not Knowing English or understanding these terms will not excuse you in any
  49. # way from the consequenses.
  50. #==============================================================================
  51. # * Import to Global Hash *
  52. #==============================================================================
  53. ($imported ||= {})[:TDS_Quick_Travel] = true
  54.  
  55. #==============================================================================
  56. # ** Game_System
  57. #------------------------------------------------------------------------------
  58. # This class handles system-related data. Also manages vehicles and BGM, etc.
  59. # The instance of this class is referenced by $game_system.
  60. #==============================================================================
  61.  
  62. class Game_System
  63. #--------------------------------------------------------------------------
  64. # * Public Instance Variables
  65. #--------------------------------------------------------------------------
  66. attr_accessor :map_quick_travel
  67. attr_accessor :disable_quick_travel
  68. #--------------------------------------------------------------------------
  69. # * Alias Listings
  70. #--------------------------------------------------------------------------
  71. alias tds_quick_travel_game_system_initialize initialize
  72. #--------------------------------------------------------------------------
  73. # * Object Initialization
  74. #--------------------------------------------------------------------------
  75. def initialize
  76. # Run Original Method
  77. tds_quick_travel_game_system_initialize
  78. # Initialize Quick Travel Values
  79. init_quick_travel
  80. end
  81. #--------------------------------------------------------------------------
  82. # * Initialize Map Quick Travel
  83. #--------------------------------------------------------------------------
  84. def init_quick_travel
  85. # Disable Quick Travel Flag
  86. @disable_quick_travel = false
  87. # Make Map Quick Travel Hash
  88. @map_quick_travel = {}
  89. end
  90. #--------------------------------------------------------------------------
  91. # * Determine if Map Quick Travel is possible
  92. #--------------------------------------------------------------------------
  93. def can_quick_travel?
  94. # Return false if map quick travel is disabled
  95. return false if @disable_quick_travel
  96. # Return false if Map Quick Travel has no quick travel points
  97. return false if !has_quick_travel? #@map_quick_travel[$game_map.map_id].nil? or @map_quick_travel[$game_map.map_id].empty?
  98. # Return true by default
  99. return true
  100. end
  101. #--------------------------------------------------------------------------
  102. # * Determine if Map has Quick Travel points
  103. #--------------------------------------------------------------------------
  104. def has_quick_travel?
  105. # Return false if Map Quick Travel List is nil or empty
  106. return false if @map_quick_travel[$game_map.map_id].nil? or @map_quick_travel[$game_map.map_id].empty?
  107. # Return true by default
  108. return true
  109. end
  110. #--------------------------------------------------------------------------
  111. # * Get Quick Travel Map List
  112. #--------------------------------------------------------------------------
  113. def quick_travel_map_list
  114. # Map List
  115. list = []
  116. quick_travel = @map_quick_travel[$game_map.map_id]
  117. # Go Through Quick Travel Points
  118. quick_travel.keys.each {|n|
  119. # Add Quick Travel Point to list
  120. list << [n] + quick_travel[n]
  121. }
  122. # Return list sorted by Index
  123. return list.sort {|a,b| a.at(4) <=> b.at(4)}
  124. end
  125. end
  126.  
  127.  
  128. #==============================================================================
  129. # ** Game_Interpreter
  130. #------------------------------------------------------------------------------
  131. # An interpreter for executing event commands. This class is used within the
  132. # Game_Map, Game_Troop, and Game_Event classes.
  133. #==============================================================================
  134.  
  135. class Game_Interpreter
  136. #--------------------------------------------------------------------------
  137. # * Enable or Disable Map Quick Travel
  138. #--------------------------------------------------------------------------
  139. def enable_map_quick_travel ; $game_system.disable_quick_travel = false end
  140. def disable_map_quick_travel ; $game_system.disable_quick_travel = true end
  141. #--------------------------------------------------------------------------
  142. # * Call Map Quick Travel Menu
  143. #--------------------------------------------------------------------------
  144. def call_map_quick_travel_menu
  145. # If on Scene Map and there are quick travel points
  146. if SceneManager.scene_is?(Scene_Map) and $game_system.has_quick_travel?
  147. # Call Quick Travel Menu Process
  148. SceneManager.scene.process_quick_travel
  149. end
  150. end
  151. #--------------------------------------------------------------------------
  152. # * Add Map Quick Travel
  153. #--------------------------------------------------------------------------
  154. def add_map_quick_travel(name, map_id, x, y, dir = 2, index = 0)
  155. # Make Empty hash
  156. $game_system.map_quick_travel[map_id] ||= {}
  157. # Set Map Quick Travel Point
  158. $game_system.map_quick_travel[map_id][name] = [x, y, dir, index]
  159. end
  160. #--------------------------------------------------------------------------
  161. # * Remove Map Quick Travel
  162. #--------------------------------------------------------------------------
  163. def remove_map_quick_travel(name, map_id)
  164. # Return if there are quick travel points in the map
  165. return if $game_system.map_quick_travel[map_id].nil?
  166. # Delete Map Quick Travel Point
  167. $game_system.map_quick_travel[map_id].delete(name)
  168. end
  169. end
  170.  
  171.  
  172. #==============================================================================
  173. # ** Scene_Map
  174. #------------------------------------------------------------------------------
  175. # This class performs the map screen processing.
  176. #==============================================================================
  177.  
  178. class Scene_Map < Scene_Base
  179. #--------------------------------------------------------------------------
  180. # * Alias Listings
  181. #--------------------------------------------------------------------------
  182. alias tds_quick_travel_scene_map_update update
  183. #--------------------------------------------------------------------------
  184. # * Frame Update
  185. #--------------------------------------------------------------------------
  186. def update
  187. # Update Quick Travel Input
  188. update_quick_travel_input
  189. # Run Original Method
  190. tds_quick_travel_scene_map_update
  191. end
  192. #--------------------------------------------------------------------------
  193. # * Update Quick Travel Input
  194. #--------------------------------------------------------------------------
  195. def update_quick_travel_input
  196. # Return if Interpreter is running or messages
  197. return if !$game_system.can_quick_travel? or $game_map.interpreter.running? or ($game_message.busy? or $game_message.visible)
  198. # If Input Trigger A
  199. if Input.trigger?(:X)
  200. # Play Ok Sound
  201. Sound.play_ok
  202. # Process Quick Travel
  203. process_quick_travel
  204. end
  205. end
  206. #--------------------------------------------------------------------------
  207. # * Process Quick Travel
  208. #--------------------------------------------------------------------------
  209. def process_quick_travel
  210. # Make Cutscene Cover Sprite
  211. @scene_cover = Sprite.new
  212. @scene_cover.bitmap = Graphics.snap_to_bitmap
  213. @scene_cover.bitmap.blur
  214. @scene_cover.opacity = 0
  215. @scene_cover.tone.set(-30, -30, -30)
  216. @scene_cover.z = 5000
  217.  
  218. # Make Cutscene Skip Window
  219. @quick_travel_list_window = Window_Quick_Travel_List.new
  220. @quick_travel_list_window.x = (Graphics.width - @quick_travel_list_window.width) / 2
  221. @quick_travel_list_window.y = (Graphics.height - @quick_travel_list_window.height) / 2
  222. @quick_travel_list_window.z = 5100
  223. @quick_travel_list_window.openness = 0
  224. @quick_travel_list_window.open
  225.  
  226. # Scene Cover Fade In
  227. 15.times do Graphics.update ; @scene_cover.opacity += 17 end
  228. # Opem Quick Travel Window
  229. 10.times do Graphics.update ; @quick_travel_list_window.update end
  230.  
  231. loop do
  232. # Update Graphics and Input
  233. Graphics.update ; Input.update
  234. # Update Quick Travel List Window
  235. @quick_travel_list_window.update
  236. # If Input Trigger C (Confirm)
  237. if Input.trigger?(:C)
  238. # Play Ok Sound
  239. Sound.play_ok
  240. # Get Transfer Information
  241. transfer_info = @quick_travel_list_window.selected_transfer
  242. # Deactivate and Close Quick Travel List window
  243. @quick_travel_list_window.deactivate ; @quick_travel_list_window.close
  244. # Fadeout All Windows
  245. 10.times do Graphics.update ; @scene_cover.opacity -= 17 ; @quick_travel_list_window.update end
  246. # Dispose of Scene Cover
  247. @scene_cover.bitmap.dispose ; @scene_cover.dispose ; @scene_cover = nil
  248. # Dispose of Quick Travel List Window
  249. @quick_travel_list_window.dispose ; @quick_travel_list_window = nil
  250. # Start Transfer
  251. $game_player.reserve_transfer($game_map.map_id, transfer_info.at(1), transfer_info.at(2), transfer_info.at(3))
  252. $game_temp.fade_type = 0
  253. # Update Input
  254. Input.update
  255. break
  256. end
  257.  
  258. # If Input Trigger B (Cancel)
  259. if Input.trigger?(:B)
  260. # Play Cancel Sound
  261. Sound.play_cancel
  262. # Deactivate and Close Quick Travel List window
  263. @quick_travel_list_window.deactivate ; @quick_travel_list_window.close
  264. # Fadeout All Windows
  265. 10.times do Graphics.update ; @scene_cover.opacity -= 17 ; @quick_travel_list_window.update end
  266. # Dispose of Scene Cover
  267. @scene_cover.bitmap.dispose ; @scene_cover.dispose ; @scene_cover = nil
  268. # Dispose of Quick Travel List Window
  269. @quick_travel_list_window.dispose ; @quick_travel_list_window = nil
  270. # Update Input
  271. Input.update
  272. break
  273. end
  274. end
  275. end
  276. end
  277.  
  278.  
  279. #==============================================================================
  280. # ** Window_Quick_Travel_List
  281. #------------------------------------------------------------------------------
  282. # This window handles Quick Travel List selection.
  283. #==============================================================================
  284.  
  285. class Window_Quick_Travel_List < Window_Command
  286. #--------------------------------------------------------------------------
  287. # * Public Instance Variables
  288. #--------------------------------------------------------------------------
  289. attr_reader :quick_travel_list
  290. #--------------------------------------------------------------------------
  291. # * Object Initialization
  292. #--------------------------------------------------------------------------
  293. def initialize
  294. # Get Quick Travel List
  295. @quick_travel_list = $game_system.quick_travel_map_list
  296. super(0, 0)
  297. end
  298. #--------------------------------------------------------------------------
  299. # * Window Width and Height
  300. #--------------------------------------------------------------------------
  301. def window_width ; 300 end
  302. def window_height ; 48 + @quick_travel_list.size * item_height end
  303. #--------------------------------------------------------------------------
  304. # * Item Rect
  305. #--------------------------------------------------------------------------
  306. def item_rect(index)
  307. rect = Rect.new
  308. rect.width = item_width
  309. rect.height = item_height
  310. rect.x = index % col_max * item_width
  311. rect.y = 24 + index / col_max * item_height
  312. rect
  313. end
  314. #--------------------------------------------------------------------------
  315. # * Ok Enabled Handling
  316. #--------------------------------------------------------------------------
  317. def ok_enabled? ; false end
  318. #--------------------------------------------------------------------------
  319. # * Max Columns
  320. #--------------------------------------------------------------------------
  321. def col_max ; 1 end
  322. #--------------------------------------------------------------------------
  323. # * Command Text Alignment
  324. #--------------------------------------------------------------------------
  325. def alignment ; 0 end
  326. #--------------------------------------------------------------------------
  327. # * Make Commands List
  328. #--------------------------------------------------------------------------
  329. def make_command_list
  330. # Make Command List
  331. @quick_travel_list.each {|i| add_command(i.at(0), :i, true)}
  332. end
  333. #--------------------------------------------------------------------------
  334. # * Get Selected Transfer Information
  335. #--------------------------------------------------------------------------
  336. def selected_transfer ; @quick_travel_list[@index] end
  337. #--------------------------------------------------------------------------
  338. # * Refresh
  339. #--------------------------------------------------------------------------
  340. def refresh
  341. super
  342. contents.font.color = system_color
  343. draw_text(0, 0, contents_width, 24, "Quick travel list", 1)
  344. end
  345. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement