Advertisement
Dekita

$D13x - Teleport v1.4

May 30th, 2013
965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.51 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Teleport
  5. # -- Author : Dekita
  6. # -- Version : 1.4
  7. # -- Level : Normal
  8. # -- Requires : $D13x - Core v1.8+
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Teleport]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 22/o5/2o13 - Updated Customisation Help Info,
  21. # 17/o5/2o13 - Compatibility, ($D13x WindowSkins)
  22. # - ($D13x Scene BackGrounds)
  23. # - Changed List From Array => Hash (for ease of use)
  24. # 16/o5/2o13 - Update, (improved disable/enable code)
  25. # - (added Hidden_Name feature's)
  26. # - (fixed typo's)
  27. # 14/o5/2o13 - Update, (added auto-jump selection cursor)
  28. # 12/o5/2o13 - Finished,
  29. # 1o/o5/2o13 - Started
  30. #
  31. #===============================================================================
  32. # ☆ Introduction
  33. #-------------------------------------------------------------------------------
  34. # This script enables a reasonably animated teleportation scene.
  35. # Each teleport location can cost gold.
  36. # Easy script calls to add/remove each teleport location and
  37. # disable/enable each available teleport location.
  38. #
  39. # This script also replicates the "Search" feature from FF10.
  40. # This feature allows the player to "search" the map for specific co-ordinates,
  41. # if certain co-ordinates are found it will activate/enable a new
  42. # location.
  43. #
  44. # Remember. This script needs images to function, Check the $D13x Master Demo
  45. # If you need the images.
  46. #
  47. # NOTE: You MUST!! have at least 1 telepoprt location available before calling
  48. # the teleport scene. the easiest way of doing this is to add a teleport before
  49. # calling the scene.
  50. # If party already has a location it cannot be re-added and will be ignored.
  51. #
  52. #===============================================================================
  53. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  54. #===============================================================================
  55. # 1. You MUST give credit to "Dekita" !!
  56. # 2. You are NOT allowed to repost this script.(or modified versions)
  57. # 3. You are NOT allowed to convert this script.
  58. # 4. You are NOT allowed to use this script for Commercial games.
  59. # 5. ENJOY!
  60. #
  61. # "FINE PRINT"
  62. # By using this script you hereby agree to the above terms and conditions,
  63. # if any violation of the above terms occurs "legal action" may be taken.
  64. # Not understanding the above terms and conditions does NOT mean that
  65. # they do not apply to you.
  66. # If you wish to discuss the terms and conditions in further detail you can
  67. # contact me at http://dekitarpg.wordpress.com/
  68. #
  69. #===============================================================================
  70. # ☆ Instructions
  71. #-------------------------------------------------------------------------------
  72. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  73. #
  74. #===============================================================================
  75. # ☆ Script Calls
  76. #-------------------------------------------------------------------------------
  77. # $game_party.can_port = BOOL
  78. # use this script call to disable ALL unocked teleport id's,
  79. # it will also disable the menu command(if enabled).
  80. #
  81. # $game_party.add_teleport(ID)
  82. # Script call to add a teleport location to the available list.
  83. #
  84. # $game_party.find_new_teleport(ID)
  85. # Script call to add a teleport location to the available list.
  86. # This call will make the name initially hidden.
  87. #
  88. # $game_party.del_teleport(ID)
  89. # Call to remove a Teleport Location from the current list.
  90. #
  91. # $game_party.disable_port(ID)
  92. # Call to Disable an available teleport location.
  93. #
  94. # $game_party.enable_port(ID)
  95. # Call to enable a disabled teleport location.
  96. #
  97. # $game_party.hide_teleport_name(ID)
  98. # Call to hide a teleport location's name.
  99. #
  100. # $game_party.show_teleport_name(ID)
  101. # Call to show a teleport location's name (if name is hidden).
  102. #
  103. # $game_party.auto_port(ID, Cost Gold)
  104. # Call to automatically teleport to a location, also adds the teleport id
  105. # into the available list if not already added.
  106. #
  107. # BOOL = true / false (default is true)
  108. # ID = The Teleport::List[ id ] (defined below)
  109. # Cost_Gold = true / false (autoport automatically reduce gold? default = false)
  110. #
  111. #-------------------------------------------------------------------------------
  112. # SceneManager.call(Scene_Teleport)
  113. # ^ To call teleport scene.
  114. #
  115. #===============================================================================
  116. module Teleport
  117. #===============================================================================
  118. List=[] # << Keep
  119. General={# << Keep
  120. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  121. # ☆ General Vocab
  122. #--------------------------------------------------------------------------
  123. # << Used for help wind while confirming travel.
  124. :confirm => "Confirm Travel To %s for %s Gold ?",
  125. :cancel => "Cancel Travel To %s ?",
  126. #--------------------------------------------------------------------------
  127. # << Used for confirm travel commands
  128. :conf_B => "Confirm",
  129. :canc_B => "Cancel",
  130. #--------------------------------------------------------------------------
  131. # << Used in Co-Ordinate Screen
  132. :co_ords => "Co-ords :",
  133. #--------------------------------------------------------------------------
  134. # << Used in gold Screen, format = [icon id, "Text" ]
  135. :gold => [361, "Gold :"],
  136. }# << Keep
  137.  
  138. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  139. # ☆ Command Settings
  140. #--------------------------------------------------------------------------
  141. # << Max visible Commands
  142. Max_Commands = 2
  143. #--------------------------------------------------------------------------
  144. # << Commands Alignment
  145. Command_Align = 1
  146. #--------------------------------------------------------------------------
  147. # << Commands Shown
  148. Commands=[
  149. [:teleport, "Teleport", "Select Teleport Destination."],
  150. [:search , "Find", "Search Map Co-Ordinates For New Locations." ],
  151. [:exit, "Exit", "Return To Map."],
  152. ]
  153. #--------------------------------------------------------------------------
  154. # Add Teleport command into menu ? format = [ show? , "Name" ]
  155. Add_2_Menu = [ true , "Teleport" ]
  156.  
  157. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  158. # ☆ Teleport Configuration
  159. #--------------------------------------------------------------------------
  160. # << Animation id's
  161. Start_Tele_Ani = 112
  162. End_Tele_Ani = 113
  163.  
  164. #--------------------------------------------------------------------------
  165. # This is where all teleport information is stored, things such as map id,
  166. # direction ect.. map img x/y are the map image display co-ordinates.
  167. # ie where you search to find the location and where the cursor moves to
  168. # when selecting location from available list.
  169. # [id] = {
  170. # :name => 'Name Of Location',
  171. # :map_ => [map id, x, y, dir],
  172. # :info => "Info shown for Location. \n Triggers a New Line",
  173. # :cost => cost to teleport to this location,
  174. # :img_ => ["Graphic Name", map image x, map image y],
  175. #--------------------------------------------------------------------------
  176. List[1] = {
  177. :name => 'Oak Forest',
  178. :map_ => [2, 18, 8, 2],
  179. :info => "Teleport To Oak Forest. \nPrice : Free",
  180. :cost => 0,
  181. :img_ => ["Teleport Map", 108, 86],
  182. }
  183. #--------------------------------------------------------------------------
  184. List[2] = {
  185. :name => 'Stone Cavern',
  186. :map_ => [4, 12, 16, 2],
  187. :info => "Teleport To Stone Cavern. \nPrice : Free",
  188. :cost => 0,
  189. :img_ => ["Teleport Map", 102, 80],
  190. }
  191. #--------------------------------------------------------------------------
  192. List[3] = {
  193. :name => 'Green Land',
  194. :map_ => [5, 8, 26, 8],
  195. :info => "Teleport To Green Land. \nPrice : Free",
  196. :cost => 0,
  197. :img_ => ["Teleport Map", 38, 271],
  198. }
  199. #--------------------------------------------------------------------------
  200. List[4] = {
  201. :name => 'UnderGround',
  202. :map_ => [3, 5, 5, 2],
  203. :info => "Teleport Deep Underground. \nPrice : Free",
  204. :cost => 0,
  205. :img_ => ["Teleport Map", 39, 272],
  206. }
  207. #--------------------------------------------------------------------------
  208. List[5] = {
  209. :name => 'Big Palace',
  210. :map_ => [3, 5, 5, 2],
  211. :info => "Teleport Inside The Big Palace. \nPrice : Free",
  212. :cost => 0,
  213. :img_ => ["Teleport Map", 40, 273],
  214. }
  215. #--------------------------------------------------------------------------
  216. # << ADD More List[ id ] here. Follow the same format as above.
  217. # REMEMBER TO CHANGE THE LIST ID NUMBER !!
  218. #--------------------------------------------------------------------------
  219.  
  220. #--------------------------------------------------------------------------
  221. # The items in this list are "hidden" ie they can be found by searching
  222. # the map image for locations, simply enter the List[ id ] number for the
  223. # list items that should be found by searching.
  224. Hidden_List = [ 3, 4, 5 ]
  225. #--------------------------------------------------------------------------
  226. # This will be the name for a newly found location using the search feature.
  227. # The name will change(to above setting) after teleporting to the area.
  228. Hidden_Name = '???'
  229. #--------------------------------------------------------------------------
  230. # Use Hidden_Name feature ? true = yes, false = no.
  231. Use_Hid_Nam = true
  232.  
  233. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  234. # ☆ Graphic Settings
  235. #--------------------------------------------------------------------------
  236. # Graphics used for Map and Selector. MUST Be In The Graphics\\System Folder.
  237. # Map image should be (396*284) pixels in size (for default vx ace resolution)
  238. Sel_Image = "Teleport Selector"
  239. #--------------------------------------------------------------------------
  240. # Map image opacity
  241. Opacity = 155
  242. #--------------------------------------------------------------------------
  243. # Selection Cursor Move Type. Can be :scroll or :select
  244. # :scroll = cursor slowly moves to set co-ordinates
  245. # :select = cursor auto-jumps to set co-ordinates
  246. # Does NOT effect Search feature.
  247. Sel_Type = :select
  248.  
  249. #--------------------------------------------------------------------------
  250. # This option only works if using my $D13x Scene Backgrounds Script.
  251. # The background folder is set in the Scene BackGrounds script.
  252. #--------------------------------------------------------------------------
  253. BGs=[
  254. # ['NAME' , x, y, x scroll, y scroll, z, hue, init opac, max opac],
  255. ['Sunbeam_Overlay_by ShinGamix',0,0, 0, 0, 1, 0, 105, 255],
  256. ['ShinGamox_by ShinGamix',0,0, 0, 0, 1, 0, 105, 245],
  257. ['Fog_By_hyde' , 100, 100, 2, -2, 1, 0, 74, 125],
  258. ['$Dekita_II' , 0, 0, 1, 1, 2, 0, 0, 255],
  259. ]# << end
  260.  
  261. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  262. # ☆ Window Settings
  263. #--------------------------------------------------------------------------
  264. # This is where you set the windowskin for each window.
  265. # Simply put a # at the start of lines you want to keep the default
  266. # NOTE : This setting requires $D13x Window Skins Script.
  267. # The windowskin folder is set in the WindowSkins script also.
  268. #--------------------------------------------------------------------------
  269. Skins={ # << KEEP !!
  270. # :window type => ["Skin Name" , hue, opacity]
  271. :command => ["PWI_Style_Blu", 0, 225],
  272. :help => ["PWI_Style_Blu", 0, 225],
  273. :tele_list => ["PWI_Style_Blu", 0, 225],
  274. :tele_map => ["PWI_Style_Blu", 0, 225],
  275. :tele_gold => ["PWI_Style_Blu", 0, 225],
  276. :tele_time => ["PWI_Style_Blu", 0, 225],
  277. :tele_posi => ["PWI_Style_Blu", 0, 225],
  278. } # << Keep
  279. #####################
  280. # CUSTOMISATION END #
  281. end #####################
  282. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  283. # #
  284. # http://dekitarpg.wordpress.com/ #
  285. # #
  286. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  287. #===============================================================================#
  288. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  289. # YES?\.\. #
  290. # OMG, REALLY? \| #
  291. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  292. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  293. #===============================================================================#
  294. class Game_Temp
  295. #===============================================================================
  296. #-----------------------------------------------------------------------------
  297. # Pi Variables
  298. #-----------------------------------------------------------------------------
  299. attr_accessor :tele_search
  300. #-----------------------------------------------------------------------------
  301. # Alias List
  302. #-----------------------------------------------------------------------------
  303. alias :init_de_tele :initialize
  304. #-----------------------------------------------------------------------------
  305. # Object Initialization
  306. #-----------------------------------------------------------------------------
  307. def initialize
  308. init_de_tele
  309. @tele_search = [0,0]
  310. end
  311.  
  312. end
  313.  
  314. #===============================================================================
  315. class Game_Party < Game_Unit
  316. #===============================================================================
  317. #-----------------------------------------------------------------------------
  318. # Pi Variables
  319. #-----------------------------------------------------------------------------
  320. attr_accessor :can_port
  321. attr_accessor :tp_list
  322. attr_accessor :new_tp_id
  323. attr_accessor :tps_disabled
  324. attr_accessor :just_ported
  325. #-----------------------------------------------------------------------------
  326. # Alias List
  327. #-----------------------------------------------------------------------------
  328. alias :init_tp_list :initialize
  329. #-----------------------------------------------------------------------------
  330. # Object Initialization
  331. #-----------------------------------------------------------------------------
  332. def initialize
  333. init_tp_list
  334. @can_port = true
  335. @just_ported = false
  336. @tp_list = Array.new
  337. @tps_disabled = Array.new(Teleport::List.size) {false}
  338. @new_tp_id = Array.new(Teleport::Hidden_List.size) {true}
  339. end
  340. #-----------------------------------------------------------------------------
  341. # Add Teleport To List
  342. #-----------------------------------------------------------------------------
  343. def add_teleport(id)
  344. return unless Teleport::List[id] != nil
  345. @tp_list << id unless @tp_list.include?(id)
  346. @new_tp_id[id] = false if @new_tp_id[id] != false
  347. @tp_list.sort!
  348. end
  349. #-----------------------------------------------------------------------------
  350. # Add Teleport To List (via search)
  351. #-----------------------------------------------------------------------------
  352. def find_new_teleport(id)
  353. add_teleport(id)
  354. @new_tp_id[id] = true
  355. end
  356. #-----------------------------------------------------------------------------
  357. # Remove Teleport From List
  358. #-----------------------------------------------------------------------------
  359. def del_teleport(id)
  360. return unless @tp_list[id] != nil
  361. @new_tp_id[id] = true if @new_tp_id[id] != true
  362. @tp_list.delete(id)
  363. @tp_list.sort!
  364. end
  365. #-----------------------------------------------------------------------------
  366. # Disable Available Teleport
  367. #-----------------------------------------------------------------------------
  368. def disable_port(id)
  369. @tps_disabled[id] = true if @tps_disabled[id] != true
  370. end
  371. #-----------------------------------------------------------------------------
  372. # Enable Disabled Teleport
  373. #-----------------------------------------------------------------------------
  374. def enable_port(id)
  375. @tps_disabled[id] = false if @tps_disabled[id] != false
  376. end
  377. #-----------------------------------------------------------------------------
  378. # Hide Teleport Name
  379. #-----------------------------------------------------------------------------
  380. def hide_teleport_name(id)
  381. @new_tp_id[id] = true if @new_tp_id[id] != true
  382. end
  383. #-----------------------------------------------------------------------------
  384. # Show Teleport Name
  385. #-----------------------------------------------------------------------------
  386. def show_teleport_name(id)
  387. @new_tp_id[id] = false if @new_tp_id[id] != false
  388. end
  389. #-----------------------------------------------------------------------------
  390. # Automatic Teleport (also adds teleport if not in list)
  391. #-----------------------------------------------------------------------------
  392. def auto_port(id, cost_gold = false)
  393. add_teleport(id)
  394. info = Teleport::List[id]
  395. $game_party.gain_gold(-info[:cost]) if (info[:cost] > 0) && (cost_gold)
  396. $game_player.reserve_transfer(info[:map_][0],info[:map_][1],info[:map_][2],info[:map_][3])
  397. $game_player.transparent = true
  398. $game_player.animation_id = Teleport::Start_Tele_Ani
  399. $game_player.followers.each do |char|
  400. next unless char.actor != nil
  401. char.transparent = true
  402. char.animation_id = Teleport::Start_Tele_Ani
  403. end
  404. @just_ported = true
  405. show_teleport_name(id)
  406. end
  407.  
  408. end
  409.  
  410. #===============================================================================
  411. class Window_MenuCommand < Window_Command
  412. #===============================================================================
  413. #-----------------------------------------------------------------------------
  414. # Alias List
  415. #-----------------------------------------------------------------------------
  416. alias :add_teleport_commands :add_original_commands
  417. #-----------------------------------------------------------------------------
  418. # For Adding Original Commands
  419. #-----------------------------------------------------------------------------
  420. def add_original_commands
  421. add_teleport_commands
  422. add_tele_command if Teleport::Add_2_Menu[0]
  423. end
  424. #-----------------------------------------------------------------------------
  425. # Add Teleport Command
  426. #-----------------------------------------------------------------------------
  427. def add_tele_command
  428. add_command(Teleport::Add_2_Menu[1], :teleport, can_add_tele)
  429. end
  430. #-----------------------------------------------------------------------------
  431. # Can Enable Teleport ?
  432. #-----------------------------------------------------------------------------
  433. def can_add_tele
  434. return false unless $game_party.can_port
  435. return false if $game_party.tp_list.empty?
  436. return true
  437. end
  438.  
  439. end
  440.  
  441. #===============================================================================
  442. class Window_TeleportCommand < Window_Command
  443. #===============================================================================
  444. #-----------------------------------------------------------------------------
  445. # Object Initialization
  446. #-----------------------------------------------------------------------------
  447. def initialize(x, y)
  448. @type = :normal
  449. super(x, y)
  450. end
  451. #-----------------------------------------------------------------------------
  452. # Get Window Width
  453. #-----------------------------------------------------------------------------
  454. def window_width
  455. return Graphics.width / 4
  456. end
  457. #--------------------------------------------------------------------------
  458. # Get Window Height
  459. #--------------------------------------------------------------------------
  460. def window_height
  461. fitting_height(Teleport::Max_Commands)
  462. end
  463. #-----------------------------------------------------------------------------
  464. # Alignment
  465. #-----------------------------------------------------------------------------
  466. def alignment
  467. return Teleport::Command_Align
  468. end
  469. #-----------------------------------------------------------------------------
  470. # Set Type
  471. #-----------------------------------------------------------------------------
  472. def type=(val)
  473. return unless @type != val
  474. @type = val
  475. refresh
  476. end
  477. #-----------------------------------------------------------------------------
  478. # Get Type
  479. #-----------------------------------------------------------------------------
  480. def type
  481. return @type
  482. end
  483. #-----------------------------------------------------------------------------
  484. # Create Command List
  485. #-----------------------------------------------------------------------------
  486. def make_command_list
  487. case @type
  488. when :normal
  489. for command in Teleport::Commands
  490. add_command(command[1],command[0])
  491. end
  492. when :confirm
  493. add_command(Teleport::General[:conf_B],:confirm)
  494. add_command(Teleport::General[:canc_B] ,:cancelC)
  495. end
  496. end
  497.  
  498. end
  499.  
  500. #===============================================================================
  501. class Window_TeleportList < Window_Command
  502. #===============================================================================
  503. #-----------------------------------------------------------------------------
  504. # Object Initialization
  505. #-----------------------------------------------------------------------------
  506. def initialize(x, y, height)
  507. @height = height
  508. super(x, y)
  509. select(-1)
  510. deactivate
  511. end
  512. #-----------------------------------------------------------------------------
  513. # Get Window Width
  514. #-----------------------------------------------------------------------------
  515. def window_width
  516. return Graphics.width / 4
  517. end
  518. #-----------------------------------------------------------------------------
  519. # Window Height
  520. #-----------------------------------------------------------------------------
  521. def window_height
  522. return @height
  523. end
  524. #-----------------------------------------------------------------------------
  525. # Create Command List
  526. #-----------------------------------------------------------------------------
  527. def make_command_list
  528. for c in $game_party.tp_list
  529. list = Teleport::List[c]
  530. bool = Teleport::Use_Hid_Nam
  531. inew = $game_party.new_tp_id[c]
  532. name = Teleport::Hidden_Name
  533. name = list[:name] unless (bool && inew)
  534. add_command(name,:location, cle?(c))
  535. end
  536. end
  537. #-----------------------------------------------------------------------------
  538. # Can Enable Command (meets gold requirement?)
  539. #-----------------------------------------------------------------------------
  540. def cle?(c)
  541. return false unless Teleport::List[c]
  542. return false unless $game_party.can_port
  543. return false unless $game_party.gold >= Teleport::List[c][:cost]
  544. return (!$game_party.tps_disabled[c])
  545. end
  546.  
  547. end
  548.  
  549. #===============================================================================
  550. class Window_TeleMap < Window_Selectable
  551. #===============================================================================
  552. #-----------------------------------------------------------------------------
  553. # Object Initialization
  554. #-----------------------------------------------------------------------------
  555. def initialize(x,y,w,h)
  556. super(x, y, w, h)
  557. refresh
  558. end
  559. #-----------------------------------------------------------------------------
  560. # Refresh
  561. #-----------------------------------------------------------------------------
  562. def refresh
  563. contents.clear
  564. end
  565. end
  566.  
  567. #===============================================================================
  568. class Window_TeleGold < Window_Base
  569. #===============================================================================
  570. #-----------------------------------------------------------------------------
  571. # Object Initialization
  572. #-----------------------------------------------------------------------------
  573. def initialize
  574. y = Graphics.height - fitting_height(1)
  575. super(0, y, Graphics.width/3, fitting_height(1))
  576. refresh
  577. end
  578. #-----------------------------------------------------------------------------
  579. # Refresh
  580. #-----------------------------------------------------------------------------
  581. def refresh
  582. contents.clear
  583. wid = self.width - (standard_padding*2)
  584. draw_de_icon(Teleport::General[:gold][0],-3,-3, 0, true)
  585. draw_text(22,0,wid,line_height, Teleport::General[:gold][1])
  586. draw_text(0 ,0,wid,line_height, $game_party.gold.to_i ,2)
  587. end
  588. #-----------------------------------------------------------------------------
  589. # Open Window
  590. #-----------------------------------------------------------------------------
  591. def open
  592. refresh
  593. super
  594. end
  595. end
  596.  
  597. #===============================================================================
  598. class Window_TeleTime < Window_Base
  599. #===============================================================================
  600. #-----------------------------------------------------------------------------
  601. # Object Initialization
  602. #-----------------------------------------------------------------------------
  603. def initialize
  604. y = Graphics.height - fitting_height(1)
  605. super(Graphics.width/3, y, Graphics.width/3, fitting_height(1))
  606. refresh
  607. end
  608. #-----------------------------------------------------------------------------
  609. # Refresh
  610. #-----------------------------------------------------------------------------
  611. def refresh
  612. contents.clear
  613. t = Time.now
  614. wid = self.width - (standard_padding*2)
  615. text = "#{t.strftime("%H")}:#{t.strftime("%M")}:#{t.strftime("%S")}"
  616. draw_text(0,0,wid,line_height, text, 1)
  617. end
  618. end
  619.  
  620. #===============================================================================
  621. class Window_TelePosi < Window_Base
  622. #===============================================================================
  623. #-----------------------------------------------------------------------------
  624. # Object Initialization
  625. #-----------------------------------------------------------------------------
  626. def initialize
  627. y = Graphics.height - fitting_height(1)
  628. super(Graphics.width/3*2, y, Graphics.width/3, fitting_height(1))
  629. refresh
  630. end
  631. #-----------------------------------------------------------------------------
  632. # Refresh
  633. #-----------------------------------------------------------------------------
  634. def refresh
  635. contents.clear
  636. wid = self.width - (standard_padding*2)
  637. text = "#{$game_temp.tele_search[0]-142}, #{$game_temp.tele_search[1]-78}"
  638. text = "0, 0" if $game_temp.tele_search == [0,0]
  639. draw_text(0,0,wid,line_height, Teleport::General[:co_ords])
  640. draw_text(0,0,wid,line_height, text, 2)
  641. end
  642. end
  643.  
  644. #===============================================================================
  645. class Scene_Map < Scene_Base
  646. #===============================================================================
  647. #-----------------------------------------------------------------------------
  648. # Alias List
  649. #-----------------------------------------------------------------------------
  650. alias :updt_tp_map :update
  651. #-----------------------------------------------------------------------------
  652. # Update
  653. #-----------------------------------------------------------------------------
  654. def update
  655. updt_tp_map
  656. update_port_ani
  657. end
  658. #-----------------------------------------------------------------------------
  659. # Update Teleport Animation
  660. #-----------------------------------------------------------------------------
  661. def update_port_ani
  662. return unless $game_party.just_ported
  663. $game_player.perform_transfer
  664. $game_map.autoplay
  665. $game_player.transparent = false
  666. $game_player.animation_id = Teleport::End_Tele_Ani
  667. $game_player.followers.each do |char|
  668. next unless char.actor != nil
  669. char.transparent = false
  670. char.animation_id = Teleport::End_Tele_Ani
  671. end
  672. $game_party.just_ported = false
  673. end
  674. end
  675.  
  676. #===============================================================================
  677. class Scene_Menu < Scene_MenuBase
  678. #===============================================================================
  679. #-----------------------------------------------------------------------------
  680. # Alias List
  681. #-----------------------------------------------------------------------------
  682. alias :teleport_create_command_window :create_command_window
  683. #-----------------------------------------------------------------------------
  684. # Create Command Window
  685. #-----------------------------------------------------------------------------
  686. def create_command_window
  687. teleport_create_command_window
  688. add_port_com if Teleport::Add_2_Menu[0]
  689. end
  690. #-----------------------------------------------------------------------------
  691. # Add Teleport command
  692. #-----------------------------------------------------------------------------
  693. def add_port_com
  694. @command_window.set_handler(:teleport, method(:call_teleport))
  695. end
  696. #-----------------------------------------------------------------------------
  697. # Call Teleport Scene
  698. #-----------------------------------------------------------------------------
  699. def call_teleport
  700. SceneManager.call(Scene_Teleport)
  701. end
  702. end
  703.  
  704. #===============================================================================
  705. class Scene_Teleport < Scene_MenuBase
  706. #===============================================================================
  707. #-----------------------------------------------------------------------------
  708. # Start Processing
  709. #-----------------------------------------------------------------------------
  710. def start
  711. super
  712. create_help_window
  713. create_command_window
  714. create_gold_window
  715. create_time_window
  716. create_posi_window
  717. create_list_window
  718. create_map
  719. end
  720. #-----------------------------------------------------------------------------
  721. # Create Halp Window
  722. #-----------------------------------------------------------------------------
  723. def create_help_window
  724. @help_window = Deki_Help.new
  725. @help_window.viewport = @viewport
  726. @help_window.x = Graphics.width / 4
  727. end
  728. #-----------------------------------------------------------------------------
  729. # Create Command Window
  730. #-----------------------------------------------------------------------------
  731. def create_command_window
  732. @command_window = Window_TeleportCommand.new(0, 0)
  733. @command_window.viewport = @viewport
  734. @command_window.help_window = @help_window
  735. @command_window.set_handler(:teleport,method(:command_sel_dest))
  736. @command_window.set_handler(:search, method(:command_search))
  737. @command_window.set_handler(:exit, method(:return_scene))
  738. @command_window.set_handler(:confirm, method(:confirm_tele))
  739. @command_window.set_handler(:cancelC, method(:cancel_tele))
  740. end
  741. #-----------------------------------------------------------------------------
  742. # Create Gold Window
  743. #-----------------------------------------------------------------------------
  744. def create_gold_window
  745. @gold_window = Window_TeleGold.new
  746. end
  747. #-----------------------------------------------------------------------------
  748. # Create Time Window
  749. #-----------------------------------------------------------------------------
  750. def create_time_window
  751. @time_window = Window_TeleTime.new
  752. @time_ref_ = Time.now.sec
  753. end
  754. #-----------------------------------------------------------------------------
  755. # Create Position Window
  756. #-----------------------------------------------------------------------------
  757. def create_posi_window
  758. @pos_window = Window_TelePosi.new
  759. end
  760. #-----------------------------------------------------------------------------
  761. # Create List Window
  762. #-----------------------------------------------------------------------------
  763. def create_list_window
  764. y = @command_window.height
  765. h = Graphics.height - y - @gold_window.height
  766. @list_window = Window_TeleportList.new(0,y,h)
  767. @list_window.viewport = @viewport
  768. @list_window.help_window = @help_window
  769. @list_window.set_handler(:location, method(:command_travel))
  770. @list_window.set_handler(:cancel, method(:back_to_coommand))
  771. end
  772. #-----------------------------------------------------------------------------
  773. # Create Map Window
  774. #-----------------------------------------------------------------------------
  775. def create_map
  776. x = @command_window.width
  777. y = @help_window.height
  778. w = Graphics.width - x
  779. h = Graphics.height - y - @gold_window.height
  780. @map_wind = Window_TeleMap.new(x,y,w,h)
  781. make_map_img(x,y,w,h)
  782. make_sel_img
  783. updae_map_image
  784. end
  785. #-----------------------------------------------------------------------------
  786. # Create Map Image
  787. #-----------------------------------------------------------------------------
  788. def make_map_img(x,y,w,h)
  789. p "#{x},#{y}"
  790. @map_view = Viewport.new(x+6,y+6,w-12,h-12)
  791. @map_view.z = 201
  792. @map_img = Plane.new
  793. @map_img.viewport = @map_view
  794. image = Teleport::List[$game_party.tp_list[0]][:img_][0]
  795. @map_img.bitmap = Cache.system(image)
  796. @map_img.opacity = Teleport::Opacity
  797. @map_image_data = image
  798. end
  799. #-----------------------------------------------------------------------------
  800. # Create Map Selector Image
  801. #-----------------------------------------------------------------------------
  802. def make_sel_img
  803. @map_sel = Sprite.new
  804. @map_sel.bitmap = Cache.system(Teleport::Sel_Image)
  805. wid = (@map_view.rect.width/2)-(@map_sel.bitmap.width/2)
  806. hei = (@map_view.rect.height/2)-(@map_sel.bitmap.height/2)
  807. @map_sel.ox = (@map_sel.bitmap.width/2)+6
  808. @map_sel.oy = (@map_sel.bitmap.height/2)+6
  809. @map_sel.opacity = Teleport::Opacity
  810. @map_sel.z = 201
  811. @map_sel.x = Teleport::List[$game_party.tp_list[0]][:img_][1]+(@map_view.rect.x)
  812. @map_sel.y = Teleport::List[$game_party.tp_list[0]][:img_][2]+(@map_view.rect.y)
  813. $game_temp.tele_search = [@map_sel.x,@map_sel.y]
  814. end
  815. #--------------------------------------------------------------------------
  816. # Termination Processing
  817. #--------------------------------------------------------------------------
  818. def terminate
  819. super
  820. @map_img.bitmap.dispose
  821. @map_img.dispose
  822. @map_sel.bitmap.dispose
  823. @map_sel.dispose
  824. @map_view.dispose
  825. $game_temp.tele_search = [0,0]
  826. end
  827. #-----------------------------------------------------------------------------
  828. # Command Select Destination
  829. #-----------------------------------------------------------------------------
  830. def command_sel_dest
  831. @command_window.deactivate
  832. @command_window.select(-1)
  833. @list_window.activate
  834. @list_window.select(0)
  835. end
  836. #-----------------------------------------------------------------------------
  837. # Command Search
  838. #-----------------------------------------------------------------------------
  839. def command_search
  840. @command_window.deactivate
  841. @command_window.select(-1)
  842. @map_wind.activate
  843. end
  844. #-----------------------------------------------------------------------------
  845. # Command Travel
  846. #-----------------------------------------------------------------------------
  847. def command_travel
  848. info = Teleport::List[$game_party.tp_list[@list_window.index]]
  849. return @list_window.activate unless info != nil
  850. return check_price(info)
  851. end
  852. #-----------------------------------------------------------------------------
  853. # Check Price
  854. #-----------------------------------------------------------------------------
  855. def check_price(info)
  856. cost = info[:cost]
  857. gold = $game_party.gold.to_i
  858. if gold >= cost
  859. confirm_price
  860. else
  861. @help_window.set_text('Not Enough Gold')
  862. 60.times { Graphics.update }
  863. @list_window.activate
  864. end
  865. end
  866. #-----------------------------------------------------------------------------
  867. # Confirm Price
  868. #-----------------------------------------------------------------------------
  869. def confirm_price
  870. @list_window.deactivate
  871. @command_window.type = :confirm
  872. @command_window.select(0)
  873. @command_window.activate
  874. end
  875. #-----------------------------------------------------------------------------
  876. # Confirm Teleport
  877. #-----------------------------------------------------------------------------
  878. def confirm_tele
  879. info = $game_party.tp_list[@list_window.index]
  880. perform_travel(info, true)
  881. end
  882. #-----------------------------------------------------------------------------
  883. # Cancel Teleport
  884. #-----------------------------------------------------------------------------
  885. def cancel_tele
  886. @command_window.type = :normal
  887. @command_window.select(-1)
  888. @command_window.deactivate
  889. @list_window.activate
  890. end
  891. #-----------------------------------------------------------------------------
  892. # Perform Travel
  893. #-----------------------------------------------------------------------------
  894. def perform_travel(info, bool)
  895. SceneManager.return
  896. $game_party.auto_port(info, bool)
  897. end
  898. #-----------------------------------------------------------------------------
  899. # Back To Command Window
  900. #-----------------------------------------------------------------------------
  901. def back_to_coommand
  902. @list_window.select(-1)
  903. @list_window.deactivate
  904. @command_window.select(0)
  905. @command_window.activate
  906. @map_wind.deactivate
  907. end
  908. #-----------------------------------------------------------------------------
  909. # Update
  910. #-----------------------------------------------------------------------------
  911. def update
  912. super
  913. updae_map_image
  914. update_cancel
  915. update_help
  916. update_time
  917. update_map
  918. update_map_II
  919. update_find
  920. end
  921. #-----------------------------------------------------------------------------
  922. # Update Map Image
  923. #-----------------------------------------------------------------------------
  924. def updae_map_image
  925. data = Teleport::List[$game_party.tp_list[@list_window.index]][:img_][0]
  926. return unless @map_image_data != data
  927. @map_img.bitmap.dispose
  928. @map_img.bitmap = Cache.system(data)
  929. @map_img.opacity = Teleport::Opacity
  930. @map_image_data = data
  931. end
  932. #-----------------------------------------------------------------------------
  933. # Update Cancel Key(s)
  934. #-----------------------------------------------------------------------------
  935. def update_cancel
  936. return unless @command_window.active
  937. return unless Input.trigger?(:B)
  938. return_scene if @command_window.type == :normal
  939. cancel_tele if @command_window.type == :confirm
  940. end
  941. #-----------------------------------------------------------------------------
  942. # Update Help
  943. #-----------------------------------------------------------------------------
  944. def update_help
  945. for data in Teleport::Commands
  946. if @command_window.current_symbol == data[0]
  947. @help_window.set_text(data[2])
  948. end
  949. end
  950. bool = Teleport::Use_Hid_Nam
  951. list = $game_party.tp_list[@list_window.index]
  952. info = Teleport::List[list]
  953. inew = $game_party.new_tp_id[list]
  954. case @command_window.current_symbol
  955. when :confirm
  956. name = Teleport::Hidden_Name
  957. name = info[:name] unless (bool && inew)
  958. text = sprintf(Teleport::General[:confirm], name, info[:cost])
  959. @help_window.set_text(text)
  960. when :cancelC
  961. info = Teleport::List[$game_party.tp_list[@list_window.index]]
  962. text = sprintf(Teleport::General[:cancel], info[:name])
  963. @help_window.set_text(text)
  964. end
  965. if @list_window.active
  966. name = Teleport::Hidden_Name
  967. name = info[:info] unless (bool && inew)
  968. @help_window.set_text(name)
  969. end
  970. end
  971. #-----------------------------------------------------------------------------
  972. # Update Time
  973. #-----------------------------------------------------------------------------
  974. def update_time
  975. return unless @time_ref_ != Time.now.sec
  976. @time_window.refresh
  977. end
  978. #-----------------------------------------------------------------------------
  979. # Update Map
  980. #-----------------------------------------------------------------------------
  981. def update_map
  982. return unless @list_window.active
  983. info = Teleport::List[$game_party.tp_list[@list_window.index]]
  984. @map_view.update
  985. case Teleport::Sel_Type
  986. when :scroll
  987. @map_sel.x += 1 if @map_sel.x < (info[:img_][1]+(@map_view.rect.x))
  988. @map_sel.x -= 1 if @map_sel.x > (info[:img_][1]+(@map_view.rect.x))
  989. @map_sel.y += 1 if @map_sel.y < (info[:img_][2]+(@map_view.rect.y))
  990. @map_sel.y -= 1 if @map_sel.y > (info[:img_][2]+(@map_view.rect.y))
  991. when :select
  992. @map_sel.x = (info[:img_][1]+(@map_view.rect.x))
  993. @map_sel.y = (info[:img_][2]+(@map_view.rect.y))
  994. end
  995. if $game_temp.tele_search != [@map_sel.x,@map_sel.y]
  996. $game_temp.tele_search = [@map_sel.x,@map_sel.y]
  997. @pos_window.refresh
  998. end
  999. end
  1000. #-----------------------------------------------------------------------------
  1001. # Update Map (search)
  1002. #-----------------------------------------------------------------------------
  1003. def update_map_II
  1004. return unless @map_wind.active
  1005. val = Input.press?(:SHIFT) ? 2 : 1
  1006. @map_sel.y -= val if Input.press?(:UP)
  1007. @map_sel.y += val if Input.press?(:DOWN)
  1008. @map_sel.x -= val if Input.press?(:LEFT)
  1009. @map_sel.x += val if Input.press?(:RIGHT)
  1010. back_to_coommand if Input.press?(:B)
  1011. @map_sel.x = @map_view.rect.x+12 if @map_sel.x <= (@map_view.rect.x+12)
  1012. if @map_sel.x >= (@map_view.rect.x+@map_view.rect.width)
  1013. @map_sel.x = (@map_view.rect.x+@map_view.rect.width)
  1014. end
  1015. @map_sel.y = @map_view.rect.y+12 if @map_sel.y <= (@map_view.rect.y+12)
  1016. if @map_sel.y >= (@map_view.rect.y+@map_view.rect.height)
  1017. @map_sel.y = (@map_view.rect.y+@map_view.rect.height)
  1018. end
  1019. if $game_temp.tele_search != [@map_sel.x,@map_sel.y]
  1020. $game_temp.tele_search = [@map_sel.x,@map_sel.y]
  1021. @pos_window.refresh
  1022. end
  1023. end
  1024. #-----------------------------------------------------------------------------
  1025. # Update Find
  1026. #-----------------------------------------------------------------------------
  1027. def update_find
  1028. return unless @map_wind.active
  1029. if Input.trigger?(:C)
  1030. Teleport::Hidden_List.each do |data|
  1031. next unless data != nil
  1032. info = Teleport::List[data]
  1033. if info[:img_][1] == ($game_temp.tele_search[0]-(@map_view.rect.x)) &&
  1034. info[:img_][2] == ($game_temp.tele_search[1]-(@map_view.rect.y))
  1035. if !$game_party.tp_list.include?(data)
  1036. text = sprintf("Found Hidden Location")
  1037. @help_window.set_text(text)
  1038. $game_party.find_new_teleport(data)
  1039. @list_window.refresh
  1040. return 60.times { Graphics.update }
  1041. end
  1042. end
  1043. end
  1044. end
  1045. Teleport::Commands.each do |com|
  1046. next unless com[0] == :search
  1047. @help_window.set_text(com[2])
  1048. end
  1049. end
  1050. #-----------------------------------------------------------------------------
  1051. # Create Backgrounds
  1052. #-----------------------------------------------------------------------------
  1053. def get_all_bgs
  1054. return unless $D13x[:Scene_BGs]
  1055. @bg_set = Teleport::BGs
  1056. end
  1057. end
  1058.  
  1059. #==============================================================================#
  1060. # http://dekitarpg.wordpress.com/ #
  1061. #==============================================================================#
  1062. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement