Dekita

$D13x Teleport v1.0

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