Advertisement
Black_Mage

Fast Travel Script

May 3rd, 2017
1,354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.93 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Fast Travel Script By Black Mage (Credit required to use)
  3. # Version : 1.3
  4. #
  5. # https://burningwizard.wordpress.com/2017/05/03/fast-travel-script/
  6. #-------------------------------------------------------------------------------
  7. #
  8. # * The script creates a map that hover through listed locations.
  9. #
  10. # * The background image is named "Map_Select", and placed inside
  11. # Graphics/System folder.
  12. #
  13. # * The image named "Empty" is required as dummy and placeholder in several cases.
  14. # You can use an empty PNG files for it.
  15. # The image is placed inside Graphics/System folder.
  16. #
  17. # * The image named "Window_Map" is used as the location selection window.
  18. # The image is placed inside Graphics/System folder.
  19. #
  20. #-------------------------------------------------------------------------------
  21. #
  22. # * How to use:
  23. #
  24. # * Enlist every available location into MAP_LIST.
  25. #
  26. # * Assign a switch for each location. Put them on SWITCH_LIST.
  27. #
  28. # * When you want a map is listed on the Map Select menu, simply turn their
  29. # respective switch value to "true".
  30. #
  31. # * Assign x and y variables for the screen to hover when a location is
  32. # highlighted. Put them on LOCATION_COORDINATE
  33. #
  34. # * Assign where to teleport when a location is selected. Put them on
  35. # TELEPORT_LIST.
  36. #
  37. # * Call the map using this script call:
  38. # fast_travel
  39. # use fast_travel(int) to highlight certain choice. The int value are taken
  40. # from MAP_LIST order.
  41. #
  42. # * Enjoy your map select menu.
  43. #
  44. #-------------------------------------------------------------------------------
  45. #
  46. # * There's several additional option below. Feel free to edit them.
  47. #
  48. #-------------------------------------------------------------------------------
  49.  
  50. module BLACK_MAP_LIST
  51.  
  52. #-----------------------------------------------------------------------------
  53. # Map name list. This is needed for metaprogramming.
  54. #-----------------------------------------------------------------------------
  55. MAP_LIST = ["Australia",
  56. "Russia",
  57. "America"]
  58.  
  59. #-----------------------------------------------------------------------------
  60. # Switches that enable the map.
  61. #-----------------------------------------------------------------------------
  62. SWITCH_LIST = [1, # When switch 01 is on, you can transfer to Australia.
  63. 1, # When switch 03 is on, you can transfer to Russia.
  64. 2] # And so on.
  65.  
  66. #-----------------------------------------------------------------------------
  67. # Assign each map name where to teleport.
  68. #-----------------------------------------------------------------------------
  69. # Map ID, x, y, player direction
  70. TELEPORT_LIST = [[2, 8, 1, 2], # This is where "Australia" is going to be.
  71. [3, 8, 11, 8], # "Russia".
  72. [1, 15, 7, 4]] # and so on.
  73.  
  74. #-----------------------------------------------------------------------------
  75. # Assign overworld location coordinate.
  76. #-----------------------------------------------------------------------------
  77. LOCATION_COORDINATE = [[-470,-100], #The map will move here when "Australia" is highlighted
  78. [-120,560],
  79. [880,300]]
  80.  
  81. #-----------------------------------------------------------------------------
  82. # Assign text color for location selection. The color depends on Window
  83. # graphic that you use. 0 is the default color.
  84. #-----------------------------------------------------------------------------
  85. TEXT_LOCA_COLOR = [0,
  86. 3,
  87. 2]
  88.  
  89. #-----------------------------------------------------------------------------
  90. # Position of the background image.
  91. #-----------------------------------------------------------------------------
  92. MAP_POSITION = [0,0] #[x,y]
  93. #-----------------------------------------------------------------------------
  94. # How far the background image is zoomed out.
  95. #-----------------------------------------------------------------------------
  96. MAP_ZOOM_OUT = [0.25, 0.25] #[zoom_x, zoom_y]
  97. #-----------------------------------------------------------------------------
  98. # How far the background image is zoomed in when a location is selected.
  99. #-----------------------------------------------------------------------------
  100. MAP_ZOOM_IN = [1, 1] #[x, y]
  101. #-----------------------------------------------------------------------------
  102. # Maximum magnify speed when the scene is started.
  103. #-----------------------------------------------------------------------------
  104. MAX_ZOOM_SPEED = 0.01
  105.  
  106. #-----------------------------------------------------------------------------
  107. # Position of the available choices.
  108. #-----------------------------------------------------------------------------
  109. CHOICE_POSITION = [0,0] #[x,y]
  110. #-----------------------------------------------------------------------------
  111. # Position of window that hold list of the available choices.
  112. #-----------------------------------------------------------------------------
  113. WINDOW_POSITION = [0,10] #[x,y]
  114. #-----------------------------------------------------------------------------
  115. # The width for location selection choices.
  116. #-----------------------------------------------------------------------------
  117. MAP_WINDOW_WIDTH = 132
  118. #-----------------------------------------------------------------------------
  119. # The height for location selection choices.
  120. #-----------------------------------------------------------------------------
  121. MAP_WINDOW_HEIGHT = 10 # Amount of visible choices in the window.
  122. #-----------------------------------------------------------------------------
  123. # Maximum scroll speed when scrolling through the map.
  124. #-----------------------------------------------------------------------------
  125. MAX_SCROLL_SPEED = 20
  126. #-----------------------------------------------------------------------------
  127. # The map won't scrolled until the zoom are above this number for x and y.
  128. #-----------------------------------------------------------------------------
  129. SCROLL_BOUNDARY = [0.5, 0.5] #[zoom_x, zoom_y]
  130.  
  131. #-----------------------------------------------------------------------------
  132. # Position of location selection window picture.
  133. #-----------------------------------------------------------------------------
  134. WINDOW_PIC_POSITION = [0, 0] #[x, y]
  135. #-----------------------------------------------------------------------------
  136. # Opacity of location selection window picture.
  137. #-----------------------------------------------------------------------------
  138. WINDOW_PIC_OPACITY = 200
  139.  
  140. #-----------------------------------------------------------------------------
  141. # Map Menu BGM.
  142. #-----------------------------------------------------------------------------
  143. MAP_MENU_BGM = ["Field3", 100, 100] #["BGM name", Volume, Pitch]
  144.  
  145. #-----------------------------------------------------------------------------
  146. # SFX played when the selection is changed.
  147. #-----------------------------------------------------------------------------
  148. MAP_MENU_SFX = ["Wind1", 100, 100] #["SFX name", Volume, Pitch]
  149.  
  150.  
  151. #-----------------------------------------------------------------------------
  152. #
  153. # * Below is the configuration of additional information window.
  154. #
  155. #-----------------------------------------------------------------------------
  156.  
  157. #-----------------------------------------------------------------------------
  158. # Location name.
  159. #-----------------------------------------------------------------------------
  160. ADD_LOC_NAME = true # Set this to true to enable the location name info
  161. #-----------------------------------------------------------------------------
  162. # Location name info position.
  163. #-----------------------------------------------------------------------------
  164. ADD_LOC_NAME_POS = [347,0]
  165. #-----------------------------------------------------------------------------
  166. # Location name info width & height.
  167. #-----------------------------------------------------------------------------
  168. ADD_LOC_NAME_W_H = [200,100] # [width, height]
  169. #-----------------------------------------------------------------------------
  170. # Location name font size.
  171. #-----------------------------------------------------------------------------
  172. ADD_LOC_NAME_F_SIZE = 20
  173.  
  174.  
  175. #-----------------------------------------------------------------------------
  176. # Location description.
  177. #-----------------------------------------------------------------------------
  178. ADD_LOC_DESC = true # Set this to true to enable the location description info
  179. #-----------------------------------------------------------------------------
  180. # Location description position.
  181. #-----------------------------------------------------------------------------
  182. ADD_LOC_DESC_POS = [347,155] # [x, y]
  183. #-----------------------------------------------------------------------------
  184. # Location description width & height.
  185. #-----------------------------------------------------------------------------
  186. ADD_LOC_DESC_W_H = [300,100] # [width, height]
  187. #-----------------------------------------------------------------------------
  188. # Location description font size.
  189. #-----------------------------------------------------------------------------
  190. ADD_LOC_DESC_F_SIZE = 20
  191. #-----------------------------------------------------------------------------
  192. # Description for each location.
  193. #-----------------------------------------------------------------------------
  194. ADD_LOC_DESC_VALUE = ["Australia is, well," + "\n" + "Australia.", # Desc. for Australia.
  195. "Russia..." + "\n" + "Yeah, Russia.", # Desc. for Russia.
  196. "America is America."] # and so on.
  197.  
  198. #-----------------------------------------------------------------------------
  199. # Location thumbnail.
  200. #-----------------------------------------------------------------------------
  201. ADD_LOC_THUMB = true # Set this to true to enable the location thumbnail.
  202. #-----------------------------------------------------------------------------
  203. # Location description position.
  204. #-----------------------------------------------------------------------------
  205. ADD_LOC_THUMB_POS = [376,47] # [x, y]
  206.  
  207. #-----------------------------------------------------------------------------
  208. # Location quests.
  209. #-----------------------------------------------------------------------------
  210. ADD_LOC_QUEST = true
  211. #-----------------------------------------------------------------------------
  212. # Location quests switches.
  213. #-----------------------------------------------------------------------------
  214. ADD_LOC_QUEST_S = [[],
  215. [6],
  216. [4,5]]
  217. #-----------------------------------------------------------------------------
  218. # Location quests text.
  219. #-----------------------------------------------------------------------------
  220. # [switch number, text to show when the value is true]
  221. ADD_LOC_Q_TEXT = [[4, "* Find a way to" + "\n" + "Russia!"],
  222. [5, "* Get the package!"],
  223. [6, "* Deliver the package"]]
  224. #-----------------------------------------------------------------------------
  225. # Location quests position.
  226. #-----------------------------------------------------------------------------
  227. ADD_LOC_QUEST_POS = [347,200] # [x, y]
  228. #-----------------------------------------------------------------------------
  229. # Location quests width & height.
  230. #-----------------------------------------------------------------------------
  231. ADD_LOC_QUEST_W_H = [300,300] # [width, height]
  232. #-----------------------------------------------------------------------------
  233. # Location quests font size.
  234. #-----------------------------------------------------------------------------
  235. ADD_LOC_QUEST_F_SIZE = 20
  236.  
  237. #-----------------------------------------------------------------------------
  238. # Information Window Picture.
  239. #-----------------------------------------------------------------------------
  240. ADD_WIN_PIC = true # Set this to true to enable the information window picture.
  241. #-----------------------------------------------------------------------------
  242. # Position of additional information window picture.
  243. #-----------------------------------------------------------------------------
  244. ADD_WIN_PIC_POS = [350, 3] #[x, y]
  245. #-----------------------------------------------------------------------------
  246. # Opacity of additional information window picture.
  247. #-----------------------------------------------------------------------------
  248. ADD_WIN_PIC_OPA = 200
  249.  
  250. #-----------------------------------------------------------------------------
  251. # Current Party Window.
  252. #-----------------------------------------------------------------------------
  253. ADD_CUR_PARTY = true
  254. #-----------------------------------------------------------------------------
  255. # Location quests position.
  256. #-----------------------------------------------------------------------------
  257. ADD_CUR_PARTY_POS = [352,340] # [x, y]
  258. #-----------------------------------------------------------------------------
  259. # Location quests width & height.
  260. #-----------------------------------------------------------------------------
  261. ADD_CUR_PARTY_W_H = [180,80] # [width, height]
  262.  
  263. #-----------------------------------------------------------------------------
  264. # This is an instruction if you want to use an icon for your location. This
  265. # icon also can serve as a cursor. Note that the icon use different files for
  266. # each location.
  267. # * First, the icon canvas mus be as big as the overworld canvas. This is
  268. # the case to make sure the scrolling is as smooth as possible.
  269. # * Second, the icon must be named after the location found in MAP_LIST.
  270. # * Third, after the icon name, put the frame number of the icon. The number
  271. # is start from 0.
  272. #-----------------------------------------------------------------------------
  273. #-----------------------------------------------------------------------------
  274. # * Location animated icon.
  275. #-----------------------------------------------------------------------------
  276. LOC_ANI_ICON = true
  277. #-----------------------------------------------------------------------------
  278. # * Set this to false to disable the icon fade. Note that the fade might
  279. # conflict with the frame animation.
  280. #-----------------------------------------------------------------------------
  281. LOC_ANI_ICON_FADE = true
  282. #-----------------------------------------------------------------------------
  283. # * Location animated icon delay.
  284. # You can call this animation speed. Decrease the value to make the
  285. # animation faster.
  286. #-----------------------------------------------------------------------------
  287. LOC_ANI_ICON_DELAY = 10
  288. #-----------------------------------------------------------------------------
  289. # Previously, we fix the maximum frame for each icon, that is 1000 frames.
  290. # However, this cause some problems with Krosk's "unable to find" script.
  291. # To make sure that this script compatible with script similar with Krosk's,
  292. # we add an additional configuration to specify how many frames will be used
  293. # in total for the icon animation.
  294. #-----------------------------------------------------------------------------
  295. LOC_ANI_ICON_TOTAL = [2, # Numbers of total frame used for 1st location icon.
  296. 2,
  297. 2,
  298. ] # Note that the file name start with zero, so you'll
  299. # end up with frame numbered n-1 if you put n as the
  300. # frame number.
  301.  
  302. #-----------------------------------------------------------------------------
  303. # This section is for static location icon. Unlike the animated icon, this
  304. # icon will always appear on the map as long as it's unlocked. The files are
  305. # named the same as the location found in MAP_LIST, followed by "STAT".
  306. # ex. your location is "America", then the file should be named "AmericaSTAT".
  307. #-----------------------------------------------------------------------------
  308. #-----------------------------------------------------------------------------
  309. # * Set this to true to enable the static location icon.
  310. #-----------------------------------------------------------------------------
  311. LOC_STATIC_ICON = true
  312. end
  313.  
  314. #-------------------------------------------------------------------------------
  315. # * Beyond this is the sacred land of code. You need programming qualification
  316. # to dwelve deeper, or it'll cause many unnecessary problems. Proceed on your
  317. # own risk.
  318. #-------------------------------------------------------------------------------
  319.  
  320. class Game_Interpreter
  321. def fast_travel(int = -1)
  322. $game_system.fast_travel_index = int
  323. SceneManager.call(Scene_Map_Select)
  324. end
  325. end
  326. class Game_System
  327. attr_accessor :fast_travel_index
  328. alias b_fst_trvl_initialize initialize
  329. def initialize; b_fst_trvl_initialize; @fast_travel_index = -1; end
  330. end
  331.  
  332. class Scene_Map_Select < Scene_Base
  333.  
  334. include BLACK_MAP_LIST
  335.  
  336. def start
  337. super
  338. @last_map = "placeholder"
  339. @first_sfx = false
  340.  
  341. @last_position = [MAP_POSITION[0], MAP_POSITION[1]]
  342. @distance_x = 0; @distance_y = 0
  343. @last_zoom = [MAP_ZOOM_OUT[0], MAP_ZOOM_OUT[1]]
  344. @icon_max = 0; @icon_current = 0; @icon_delay_cur = 0
  345. create_maplist
  346. create_information_window
  347. create_command_window
  348. create_background
  349. create_map_icon
  350. create_stat_icon if LOC_STATIC_ICON
  351. create_map_window
  352.  
  353. load_icon_pic if LOC_ANI_ICON
  354.  
  355. # Method to set starting position of map index
  356. @starting_index_list = @command_window.get_map_list
  357. for i in 0..(@starting_index_list.size - 1)
  358. break if $game_system.fast_travel_index == -1
  359. if @starting_index_list[i].to_s == MAP_LIST[$game_system.fast_travel_index].to_s
  360. @command_window.index = i
  361. end
  362. end
  363.  
  364. location_update_index
  365. RPG::BGM.new(MAP_MENU_BGM[0], MAP_MENU_BGM[1], MAP_MENU_BGM[2]).play
  366. end
  367.  
  368. # Load all icon frame into the RAM so the next load shall be faster.
  369. def load_icon_pic
  370. for i in 0..(@map_list.size - 1)
  371. @map_name = @map_list[i].to_s
  372. for index in 0..0
  373. picture = Cache.system(@map_name + index.to_s).nil?
  374. end
  375. end
  376. end
  377.  
  378. def create_information_window
  379. if ADD_LOC_NAME
  380. @information_window_1 = Window_Information_1.new
  381. @information_window_1.opacity = 0
  382. end
  383. if ADD_LOC_DESC
  384. @information_window_2 = Window_Information_2.new
  385. @information_window_2.opacity = 0
  386. end
  387. if ADD_LOC_THUMB
  388. @information_window_3 = Sprite.new
  389. @information_window_3.bitmap = Cache.system("Empty")
  390. @information_window_3.ox = 0
  391. @information_window_3.oy = 0
  392. @information_window_3.x = ADD_LOC_THUMB_POS[0]
  393. @information_window_3.y = ADD_LOC_THUMB_POS[1]
  394. @information_window_3.z = 2
  395. end
  396. if ADD_LOC_QUEST
  397. @information_window_4 = Window_Information_4.new
  398. @information_window_4.opacity = 0
  399. end
  400. if ADD_WIN_PIC
  401. @info_window = Sprite.new
  402. @info_window.bitmap = Cache.system("Window_Info")
  403. @info_window.ox = 0
  404. @info_window.oy = 0
  405. @info_window.x = ADD_WIN_PIC_POS[0]
  406. @info_window.y = ADD_WIN_PIC_POS[1]
  407. @info_window.z = 2
  408. @info_window.opacity = 0
  409. end
  410. if ADD_CUR_PARTY
  411. @current_party_window = Window_Current_Party.new
  412. @current_party_window.opacity = 0; @current_party_window.refresh
  413. end
  414. end
  415.  
  416. def create_map_window
  417. @map_window = Sprite.new
  418. @map_window.bitmap = Cache.system("Window_Map")
  419. @map_window.ox = 0
  420. @map_window.oy = 0
  421. @map_window.x = WINDOW_PIC_POSITION[0]
  422. @map_window.y = WINDOW_PIC_POSITION[1]
  423. @map_window.z = 2
  424. @map_window.opacity = 0
  425. end
  426.  
  427. def create_maplist
  428. @map_list = []
  429. for i in 0..MAP_LIST.size - 1
  430. @map_list.push(MAP_LIST[i]) if $game_switches[SWITCH_LIST[i]] == true
  431. end
  432. end
  433.  
  434. alias black_update update
  435. def update
  436. black_update
  437. if @map_list.size != 0
  438. icon_update if @map_window != nil
  439. end
  440. end
  441.  
  442. def location_update_index
  443. if @command_window != nil
  444. @last_map = @map_list[@command_window.index].to_s
  445.  
  446. if LOC_ANI_ICON
  447. @map_name = assigned_number(@map_list[@command_window.index].to_s)
  448. @map_name = @map_list[@command_window.index].to_s
  449. @map_icon.bitmap = Cache.system(@map_name + "0")
  450. @icon_max = pic_list_number
  451. @icon_current = 0
  452. else
  453. @map_icon.bitmap = Cache.system("Empty")
  454. end
  455.  
  456. end
  457. if @first_sfx == true
  458. RPG::SE.new(MAP_MENU_SFX[0], MAP_MENU_SFX[1], MAP_MENU_SFX[2]).play
  459. end
  460. end
  461.  
  462. def pic_list_number
  463. @pic_frames = []
  464. total_frame = LOC_ANI_ICON_TOTAL[assigned_number(@map_name)]
  465. for index in 0..(total_frame - 1)
  466. begin
  467. picture = Cache.system(@map_name + index.to_s).nil?
  468. rescue
  469. nil
  470. else
  471. @pic_frames[index] = index
  472. end
  473. break if @pic_frames[index] == nil
  474. end
  475. return @pic_frames.size
  476. end
  477.  
  478. def icon_update
  479. if @background_sprite.zoom_x > SCROLL_BOUNDARY[0] and @background_sprite.zoom_y > SCROLL_BOUNDARY[1]
  480. if LOC_ANI_ICON
  481. if @icon_delay_cur < LOC_ANI_ICON_DELAY
  482. @icon_delay_cur += 1
  483. else
  484. @icon_delay_cur = 0
  485. if @icon_current.to_i < (@icon_max - 1)
  486. @map_icon.bitmap = Cache.system(@map_name + (@icon_current.to_i + 1).to_s)
  487. @icon_current += 1
  488. else
  489. @map_icon.bitmap = Cache.system(@map_name + "0")
  490. @icon_current = 0
  491. end
  492. end
  493. end
  494. end
  495.  
  496. if @map_icon != nil && @map_icon.bitmap != nil && LOC_ANI_ICON_FADE
  497. if @map_icon.opacity < 255 && @map_icon_opa == false
  498. @map_icon.opacity += 7
  499. @map_icon_opa = true if @map_icon.opacity > 254
  500. else
  501. @map_icon.opacity -= 7
  502. @map_icon_opa = false if @map_icon.opacity < 1
  503. end
  504. end
  505.  
  506. @map_window.opacity = WINDOW_PIC_OPACITY
  507. @info_window.opacity = ADD_WIN_PIC_OPA if ADD_WIN_PIC
  508.  
  509. @map_index = assigned_number(@map_list[@command_window.index].to_s)
  510. map_move(@last_position[0], @last_position[1],
  511. LOCATION_COORDINATE[@map_index][0], LOCATION_COORDINATE[@map_index][1],
  512. 255)
  513.  
  514. #---------------------------------------------------------------------------
  515. # Define the magnifying speed.
  516. #---------------------------------------------------------------------------
  517. @magnify_x = (MAP_ZOOM_IN[0] - @last_zoom[0])/10
  518.  
  519. if @magnify_x > 0
  520. @magnify_x = [MAX_ZOOM_SPEED, @magnify_x].min
  521. end
  522. if @magnify_x < 0
  523. @magnify_x = [MAX_ZOOM_SPEED, @magnify_x].max
  524. end
  525.  
  526. if @magnify_x < 0.005 and @magnify_x > 0
  527. @magnify_x = 0.005
  528. elsif @magnify_x > -0.005 and @magnify_x < 0
  529. @magnify_x = -0.005
  530. end
  531.  
  532. @magnify_y = (MAP_ZOOM_IN[1] - @last_zoom[1])/10
  533.  
  534. if @magnify_y > 0
  535. @magnify_y = [MAX_ZOOM_SPEED, @magnify_y].min
  536. end
  537. if @magnify_y < 0
  538. @magnify_y = [MAX_ZOOM_SPEED, @magnify_y].max
  539. end
  540.  
  541. if @magnify_y < 0.005 and @magnify_y > 0
  542. @magnify_y = 0.005
  543. elsif @magnify_y > -0.005 and @magnify_y < 0
  544. @magnify_y = -0.005
  545. end
  546.  
  547. #---------------------------------------------------------------------------
  548. # Scrolling.
  549. #---------------------------------------------------------------------------
  550. if @background_sprite.zoom_x > SCROLL_BOUNDARY[0] and @background_sprite.zoom_y > SCROLL_BOUNDARY[1]
  551. if @first_sfx == false
  552. RPG::SE.new(MAP_MENU_SFX[0], MAP_MENU_SFX[1], MAP_MENU_SFX[2]).play
  553. @first_sfx = true
  554. end
  555. @background_sprite.x = @background_sprite.x + @distance_x
  556. @background_sprite.y = @background_sprite.y + @distance_y
  557. @map_icon.x = @map_icon.x + @distance_x
  558. @map_icon.y = @map_icon.y + @distance_y
  559. @stat_icon.each do |pic|
  560. pic.x = pic.x + @distance_x
  561. pic.y = pic.y + @distance_y
  562. end
  563. end
  564.  
  565. @background_sprite.zoom_x = @background_sprite.zoom_x + @magnify_x
  566. @map_icon.zoom_x = @map_icon.zoom_x + @magnify_x
  567. @stat_icon.each do |pic|
  568. pic.zoom_x = pic.zoom_x + @magnify_x
  569. end
  570.  
  571. if @magnify_x == 0.005
  572. if @background_sprite.zoom_x > MAP_ZOOM_IN[0]
  573. @background_sprite.zoom_x = MAP_ZOOM_IN[0]
  574. @map_icon.zoom_x = MAP_ZOOM_IN[0]
  575. @stat_icon.each do |pic|
  576. pic.zoom_x = MAP_ZOOM_IN[0]
  577. end
  578. end
  579. elsif @magnify_x == -0.005
  580. if @background_sprite.zoom_x < MAP_ZOOM_IN[0]
  581. @background_sprite.zoom_x = MAP_ZOOM_IN[0]
  582. @map_icon.zoom_x = MAP_ZOOM_IN[0]
  583. @stat_icon.each do |pic|
  584. pic.zoom_x = MAP_ZOOM_IN[0]
  585. end
  586. end
  587. end
  588.  
  589. @background_sprite.zoom_y = @background_sprite.zoom_y + @magnify_y
  590. @map_icon.zoom_y = @map_icon.zoom_y + @magnify_y
  591. @stat_icon.each do |pic|
  592. pic.zoom_y = pic.zoom_y + @magnify_y
  593. end
  594. if @magnify_y == 0.005
  595. if @background_sprite.zoom_y > MAP_ZOOM_IN[1]
  596. @background_sprite.zoom_y = MAP_ZOOM_IN[1]
  597. @map_icon.zoom_y = MAP_ZOOM_IN[1]
  598. @stat_icon.each do |pic|
  599. pic.zoom_y = MAP_ZOOM_IN[1]
  600. end
  601. end
  602. elsif @magnify_y == -0.005
  603. if @background_sprite.zoom_y < MAP_ZOOM_IN[1]
  604. @background_sprite.zoom_y = MAP_ZOOM_IN[1]
  605. @map_icon.zoom_y = MAP_ZOOM_IN[1]
  606. @stat_icon.each do |pic|
  607. pic.zoom_y = MAP_ZOOM_IN[1]
  608. end
  609. end
  610. end
  611.  
  612. #---------------------------------------------------------------------------
  613. # Adjust the position.
  614. #---------------------------------------------------------------------------
  615. @last_position[0] = @background_sprite.x
  616. @last_position[1] = @background_sprite.y
  617. @last_zoom[0] = @background_sprite.zoom_x
  618. @last_zoom[1] = @background_sprite.zoom_y
  619. end
  620.  
  621. def map_move(f_x, f_y, x, y, opacity)
  622.  
  623. @distance_x = (x - f_x)/10
  624. if @distance_x > 0
  625. @distance_x = [MAX_SCROLL_SPEED, @distance_x].min
  626. end
  627. if @distance_x < 0
  628. @distance_x = [(MAX_SCROLL_SPEED*(-1)), @distance_x].max
  629. end
  630.  
  631. if @distance_x == 0
  632. if @last_position[0] == LOCATION_COORDINATE[@map_index][0]
  633. elsif (x - f_x) < 0
  634. @distance_x = -1
  635. else
  636. @distance_x = 1
  637. end
  638. end
  639.  
  640. @distance_y = (y - f_y)/10
  641. if @distance_y > 0
  642. @distance_y = [MAX_SCROLL_SPEED, @distance_y].min
  643. end
  644. if @distance_y < 0
  645. @distance_y = [(MAX_SCROLL_SPEED*(-1)), @distance_y].max
  646. end
  647.  
  648. if @distance_y == 0
  649. if @last_position[1] == LOCATION_COORDINATE[@map_index][1]
  650. elsif (y - f_y) < 0
  651. @distance_y = -1
  652. else
  653. @distance_y = 1
  654. end
  655. end
  656.  
  657. end
  658.  
  659. def create_command_window
  660. @command_window = Window_MapSelect.new
  661. @command_window.x = WINDOW_POSITION[0]
  662. @command_window.y = WINDOW_POSITION[1]
  663. for i in 0..MAP_LIST.size - 1
  664. @command_window.set_handler(MAP_LIST[i].to_sym, method(MAP_LIST[i].to_sym))
  665. end
  666. @command_window.set_handler(:cancel, method(:return_scene))
  667. @command_window.information_window_1 = @information_window_1
  668. @command_window.information_window_2 = @information_window_2
  669. @command_window.information_window_4 = @information_window_4
  670. @command_window.information_1_update if ADD_LOC_NAME
  671. @command_window.information_2_update if ADD_LOC_DESC
  672. information_3_update if ADD_LOC_THUMB
  673. @command_window.information_4_update if ADD_LOC_QUEST
  674. end
  675.  
  676. def information_3_update
  677. if @information_window_3 != nil and @command_window !=nil
  678. bitmap_pic = @map_list[@command_window.index].to_s + "_Thumb"
  679. @information_window_3.bitmap = Cache.system(bitmap_pic)
  680. end
  681. end
  682.  
  683. def create_background
  684. @background_sprite = Sprite.new
  685. @background_sprite.bitmap = Cache.system("Map_Select")
  686. @background_sprite.ox = @background_sprite.bitmap.width / 2
  687. @background_sprite.oy = @background_sprite.bitmap.height / 2
  688. @background_sprite.x = Graphics.width / 2
  689. @background_sprite.y = Graphics.height / 2
  690. @background_sprite.zoom_x = MAP_ZOOM_OUT[0]
  691. @background_sprite.zoom_y = MAP_ZOOM_OUT[1]
  692. end
  693.  
  694. def create_stat_icon
  695. @stat_icon = []
  696. @map_list.each do |loc|
  697. a = Sprite.new
  698. a.bitmap = Cache.system(loc + "STAT")
  699. a.ox = @background_sprite.bitmap.width / 2
  700. a.oy = @background_sprite.bitmap.height / 2
  701. a.zoom_x = MAP_ZOOM_OUT[0]
  702. a.zoom_y = MAP_ZOOM_OUT[1]
  703. a.x = Graphics.width / 2
  704. a.y = Graphics.height / 2
  705. a.z = 1
  706. @stat_icon.push(a)
  707. end
  708. end
  709.  
  710. def create_map_icon
  711. @map_icon = Sprite.new
  712. @map_icon.bitmap = Cache.system("Empty")
  713. @map_icon.ox = @background_sprite.bitmap.width / 2
  714. @map_icon.oy = @background_sprite.bitmap.height / 2
  715. @map_icon.zoom_x = MAP_ZOOM_OUT[0]
  716. @map_icon.zoom_y = MAP_ZOOM_OUT[1]
  717. @map_icon.x = Graphics.width / 2
  718. @map_icon.y = Graphics.height / 2
  719. @map_icon.z = 2
  720. end
  721.  
  722. MAP_LIST.each do |map_name|
  723. define_method(map_name) do
  724. list_number = assigned_number(map_name)
  725. p map_name
  726. transfer_map(list_number)
  727. end
  728. end
  729.  
  730. def assigned_number(map_name)
  731. for i in 0..MAP_LIST.size - 1
  732. return i if MAP_LIST[i] == map_name
  733. end
  734. end
  735.  
  736. def transfer_map(a)
  737. b = TELEPORT_LIST; $game_temp.fade_type = 2
  738. $game_player.reserve_transfer(b[a][0],b[a][1],b[a][2],b[a][3])
  739. return_scene
  740. end
  741.  
  742. def close_command_window
  743. @command_window.close
  744. update until @command_window.close?
  745. fadeout_all
  746. @background_sprite.bitmap = nil
  747. end
  748.  
  749. def black_dispose
  750. @map_window.bitmap.dispose ; @map_window.dispose ; @map_window = nil
  751. @map_icon.bitmap.dispose ; @map_icon.dispose ; @map_icon = nil
  752.  
  753. if ADD_WIN_PIC
  754. @info_window.bitmap.dispose
  755. @info_window.dispose
  756. @info_window = nil
  757. end
  758.  
  759. if @background_sprite.bitmap != nil
  760. @background_sprite.bitmap.dispose
  761. end
  762. @background_sprite.dispose
  763. @background_sprite = nil
  764.  
  765. @information_window_1.dispose if ADD_LOC_NAME
  766. @information_window_2.dispose if ADD_LOC_DESC
  767.  
  768. if ADD_LOC_THUMB
  769. @information_window_3.bitmap.dispose
  770. @information_window_3.dispose
  771. @information_window_3 = nil
  772. end
  773.  
  774. if LOC_STATIC_ICON
  775. @stat_icon.each do |pic|
  776. pic.bitmap.dispose; pic.dispose; pic = nil
  777. end
  778. end
  779.  
  780. @information_window_4.dispose if ADD_LOC_QUEST
  781. @current_party_window.dispose if ADD_CUR_PARTY
  782. end
  783.  
  784. def return_scene
  785. close_command_window; black_dispose
  786. super; RPG::BGM.fade(500)
  787. $game_map.autoplay; Cache.clear
  788. end
  789.  
  790. end
  791.  
  792. #-------------------------------------------------------------------------------
  793. # * Map Command List Window
  794. #-------------------------------------------------------------------------------
  795. class Window_MapSelect < Window_Command
  796. include BLACK_MAP_LIST
  797. #-----------------------------------------------------------------------------
  798. # * Object Initialization
  799. #-----------------------------------------------------------------------------
  800. def initialize
  801. create_maplist; super(0, 0); self.openness = 0; open; self.opacity = 0
  802. end
  803. def window_height; fitting_height(MAP_WINDOW_HEIGHT); end
  804. def window_width; return MAP_WINDOW_WIDTH; end
  805.  
  806. #-----------------------------------------------------------------------------
  807. # * Create Command List
  808. #-----------------------------------------------------------------------------
  809. def make_command_list
  810. for i in 0..@map_list.size - 1
  811. add_command(@map_list[i], @map_list[i].to_sym) if @map_list.size != 0
  812. end
  813. end
  814.  
  815. #-----------------------------------------------------------------------------
  816. # * Get unlocked map list
  817. #-----------------------------------------------------------------------------
  818. def create_maplist
  819. @map_list = []
  820. for i in 0..MAP_LIST.size - 1
  821. @map_list.push(MAP_LIST[i]) if $game_switches[SWITCH_LIST[i]] == true
  822. end
  823. end
  824.  
  825. def index=(index)
  826. super
  827. SceneManager.scene.location_update_index
  828. information_1_update if ADD_LOC_NAME
  829. information_2_update if ADD_LOC_DESC
  830. SceneManager.scene.information_3_update if ADD_LOC_THUMB
  831. information_4_update if ADD_LOC_QUEST
  832. end
  833.  
  834. #-----------------------------------------------------------------------------
  835. # * Draw Item
  836. #-----------------------------------------------------------------------------
  837. def draw_item(index)
  838. font_color = assigned_number(command_name(index))
  839. change_color(text_color(TEXT_LOCA_COLOR[font_color]), command_enabled?(index))
  840. draw_text(item_rect_for_text(index), command_name(index), alignment)
  841. end
  842.  
  843. #-----------------------------------------------------------------------------
  844. # * Information Window stuff
  845. #-----------------------------------------------------------------------------
  846. def information_window_1=(information_window)
  847. @information_window_1 = information_window
  848. end
  849.  
  850. def information_window_2=(information_window)
  851. @information_window_2 = information_window
  852. end
  853.  
  854. def information_window_4=(information_window)
  855. @information_window_4 = information_window
  856. end
  857.  
  858. def information_1_update
  859. if @information_window_1 != nil
  860. @information_window_1.clear
  861. text = @map_list[self.index].to_s
  862. @information_window_1.set_text(text)
  863. end
  864. end
  865.  
  866. def information_2_update
  867. if @information_window_2 != nil
  868. @information_window_2.clear
  869. text = ADD_LOC_DESC_VALUE[assigned_number(@map_list[self.index].to_s)]
  870. @information_window_2.set_text(text)
  871. end
  872. end
  873.  
  874. def information_4_update
  875. if @information_window_4 != nil
  876. @information_window_4.clear; text = ""
  877. map_num = assigned_number(@map_list[self.index].to_s)
  878. for i in 0..ADD_LOC_QUEST_S[map_num].size - 1
  879. if ADD_LOC_QUEST_S[map_num].size != -1
  880. if $game_switches[ADD_LOC_QUEST_S[map_num][i]]
  881. quest_desc = assigned_quest(ADD_LOC_QUEST_S[map_num][i])
  882. text = text + "\n" + ADD_LOC_Q_TEXT[quest_desc][1]
  883. end
  884. end
  885. end
  886. @information_window_4.set_text(text)
  887. end
  888. end
  889. #-----------------------------------------------------------------------------
  890.  
  891. #-----------------------------------------------------------------------------
  892. # * Return location number from location name
  893. #-----------------------------------------------------------------------------
  894. def assigned_number(map_name)
  895. for i in 0..MAP_LIST.size - 1
  896. return i if MAP_LIST[i] == map_name
  897. end
  898. end
  899.  
  900. #-----------------------------------------------------------------------------
  901. # * Return quest number from quest switch
  902. #-----------------------------------------------------------------------------
  903. def assigned_quest(quest_switch)
  904. for i in 0..ADD_LOC_Q_TEXT.size - 1
  905. return i if ADD_LOC_Q_TEXT[i][0] == quest_switch
  906. end
  907. end
  908.  
  909. def get_map_list; return @map_list; end
  910. end
  911. #-------------------------------------------------------------------------------
  912.  
  913.  
  914. #-------------------------------------------------------------------------------
  915. # * Map Additional Location Name Window
  916. #-------------------------------------------------------------------------------
  917. class Window_Inf_Base < Window_Base
  918. include BLACK_MAP_LIST
  919. def set_text(text); (@text = text; refresh) if text != @text; end
  920. def clear; set_text(""); end
  921. def refresh; contents.clear; draw_text_ex(4, 0, @text); end
  922. end
  923.  
  924. class Window_Information_1 < Window_Inf_Base
  925. include BLACK_MAP_LIST
  926. def initialize
  927. super(ADD_LOC_NAME_POS[0], ADD_LOC_NAME_POS[1], ADD_LOC_NAME_W_H[0], ADD_LOC_NAME_W_H[1])
  928. end
  929. def reset_font_settings
  930. super # run's Window_Base's reset_font_settings
  931. contents.font.size = ADD_LOC_NAME_F_SIZE
  932. end
  933. end
  934.  
  935. class Window_Information_2 < Window_Inf_Base
  936. include BLACK_MAP_LIST
  937. def initialize
  938. super(ADD_LOC_DESC_POS[0], ADD_LOC_DESC_POS[1], ADD_LOC_DESC_W_H[0], ADD_LOC_DESC_W_H[1])
  939. end
  940. def reset_font_settings
  941. super # run's Window_Base's reset_font_settings
  942. contents.font.size = ADD_LOC_DESC_F_SIZE
  943. end
  944. end
  945.  
  946. # Where is Window_Information_3, you ask? Good question, as I too wondering
  947. # why there isn't any here. Why the fuck do I skipped over it?
  948.  
  949. class Window_Information_4 < Window_Inf_Base
  950. include BLACK_MAP_LIST
  951. def initialize
  952. super(ADD_LOC_QUEST_POS[0], ADD_LOC_QUEST_POS[1], ADD_LOC_QUEST_W_H[0], ADD_LOC_QUEST_W_H[1])
  953. end
  954. def reset_font_settings
  955. super # run's Window_Base's reset_font_settings
  956. contents.font.size = ADD_LOC_QUEST_F_SIZE
  957. end
  958. end
  959. #-------------------------------------------------------------------------------
  960.  
  961.  
  962. #-------------------------------------------------------------------------------
  963. # * Window Current Party
  964. #-------------------------------------------------------------------------------
  965. class Window_Current_Party < Window_Base
  966. include BLACK_MAP_LIST
  967. def initialize
  968. super(ADD_CUR_PARTY_POS[0], ADD_CUR_PARTY_POS[1], ADD_CUR_PARTY_W_H[0], ADD_CUR_PARTY_W_H[1])
  969. end
  970. def item_max; return $game_party.members.size; end
  971. def draw_all_items; item_max.times {|i| draw_item(i) }; end
  972. def draw_item(index)
  973. @actor = $game_party.members[index]
  974. (x_pos = 60; draw_actor_graphic(@actor, index*40 + 20, 45)) if @actor != nil
  975. end
  976. def refresh; contents.clear; draw_all_items end
  977. end
  978. #-------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement