Dekita

$D13x Teleport v1.2

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