Advertisement
dsiver144

Untitled

Mar 11th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.62 KB | None | 0 0
  1. #==============================================================================
  2. # DSI Dungeon Infomation
  3. # -- Last Updated: 2017.02.28
  4. # -- Author: dsiver144
  5. # -- Level: Normal
  6. # -- Requires: DSI-Bitmap
  7. # -- Commission for: MHRob
  8. #==============================================================================
  9. $imported = {} if $imported.nil?
  10. $imported["DSI-DungeonInfo"] = true
  11. #==============================================================================
  12. # + Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2017.02.28 - Finish first version.
  15. #==============================================================================
  16. # + Instructions
  17. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  18. # To install this script, open up your script editor and copy/paste this script
  19. # to an open slot below ?? Materials/?f?? but above ?? Main. Remember to save.
  20. # Remember to put this script below: DSI-Bitmap.
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # Script Call:
  23. # show_dungeon_scene(id) # Open Scene with specific dungeon ID (See below)
  24. #==============================================================================
  25. module DSIVER144
  26. module DUNGEON_INFO
  27.  
  28. COMMANDS = {} # Don't remove this line!
  29. COMMANDS[1] = ["Enter Dungeon (Normal)", 1606] # [Name, Icon_index]
  30. COMMANDS[2] = ["Enter Dungeon (Hard)", 1699] # [Name, Icon_index]
  31. COMMANDS[3] = ["Exit", 137] # [Name, Icon_index]
  32.  
  33. SWITCH_PAGE_TEXT = "\\i[1609]:Switch Page"
  34. OTHER_BUTTONS_TEXT = "\\i[1600]:Choose - \\i[1602]:Cancel"
  35. OTHER_BUTTONS_MARGIN = 170
  36.  
  37. SWITCH_PAGE_SE = ["Confirm2 (Final Fantasy 7).wav", 100, 100]
  38. SCENE_BACKGROUND = "StarlitSky" # Located in Parallax Folder. Set to false if don't want to use it.
  39.  
  40. TEXTS = {} # Don't remove this line!
  41. TEXTS[:description_header] = "\\c[5]Dungeon Description: \\c[0]"
  42. TEXTS[:general_info_header] = "\\c[5]General Infomation: \\c[0]"
  43.  
  44. DUNGEONS = {} # Don't remove this line!
  45. #-------------------------------------------------------------------------
  46. # -> DUNGEONS[dungeon_id] <-
  47. #-------------------------------------------------------------------------
  48. DUNGEONS[1] = {} # Don't remove this line!
  49. DUNGEONS[1][:name] = ["Ice Caves", 3] # [Name , Color Code]
  50. DUNGEONS[1][:normal_cme] = 25 # Normal Dungeon Common Event
  51. #DUNGEONS[1][:hard_cme] = 26 # Hard Dungeon Common Event
  52. DUNGEONS[1][:require_item] = [15,5] # [Item_ID, Number]
  53. DUNGEONS[1][:picture] = "BlueSky" # Located in Parallaxes Folder (226x200). It will automatically resize to 226x200.
  54. DUNGEONS[1][:description] = "There are a series of Man made Ice Caves that were made long ago in the hopes of finding a path to the
  55. legendary Ice Palace. Though, Deep within the Ice Caves lie the ancient Ice Caverns, said to lead to the Ice Palace of the forgotten Snow Queen."
  56. DUNGEONS[1][:description_font] = [16,20] # [Font size, Line Height]
  57. DUNGEONS[1][:gerenal_info] = {} # Don't remove this line!
  58. DUNGEONS[1][:gerenal_info][:tools] = [13,14,15,16,17,18] # Item ID of Tools
  59. DUNGEONS[1][:gerenal_info][:font] = [15,18] # [Font size, Line Height]
  60. DUNGEONS[1][:gerenal_info][:texts] = [ # Don't remove this line!
  61. ["\\c[5]Expected Monster\\c[0]:", "Ice Slime, Ice Hell Flower, ect"],
  62. ["\\c[6]Common Element Found\\c[0]:", "Ice Mage Cards"],
  63. ["\\c[7]Recommended Cards\\c[0]:", "Fire Mage Cards"],
  64. ["\\c[21]Number of Areas\\c[0]:", "6+"],
  65. ["\\c[9]Available Altars\\c[0]:", "Ice"],
  66. ["\\c[10]Save Point\\c[0]:", "Yes"],
  67. ["\\c[11]Teleportation Allowed\\c[0]:", "Yes"],
  68. ["\\c[12]Special Monster Encounters\\c[0]:", "Yes"],
  69. ["\\c[13]Quest Available\\c[0]:", "Yes"],
  70. ] # Don't remove this line!
  71. DUNGEONS[2] = {} # Don't remove this line!
  72. DUNGEONS[2][:name] = ["Earth", 3] # [Name , Color Code]
  73. DUNGEONS[2][:normal_cme] = 25 # Normal Dungeon Common Event
  74. DUNGEONS[2][:hard_cme] = 26 # Hard Dungeon Common Event
  75. DUNGEONS[2][:require_item] = [15,10] # [Item_ID, Number]
  76. DUNGEONS[2][:picture] = "Dungeon1" # Located in Parallaxes Folder (226x200). It will automatically resize to 226x200.
  77. DUNGEONS[2][:description] = "Something"
  78. DUNGEONS[2][:description_font] = [16,20] # [Font size, Line Height]
  79. DUNGEONS[2][:gerenal_info] = {} # Don't remove this line!
  80. DUNGEONS[2][:gerenal_info][:tools] = [14,15,16,17,18,19,20] # Item ID of Tools
  81. DUNGEONS[2][:gerenal_info][:font] = [15,18] # [Font size, Line Height]
  82. DUNGEONS[2][:gerenal_info][:texts] = [ # Don't remove this line!
  83. ["\\c[5]Expected Monster\\c[0]:", "Ice Slime, Ice Hell Flower, ect"],
  84. ["\\c[6]Common Element Found\\c[0]:", "Ice Mage Cards"],
  85. ["\\c[7]Recommended Cards\\c[0]:", "Fire Mage Cards"],
  86. ["\\c[21]Number of Areas\\c[0]:", "6+"],
  87. ["\\c[9]Available Altars\\c[0]:", "Ice"],
  88. ["\\c[10]Save Point\\c[0]:", "Yes"],
  89. ["\\c[11]Teleportation Allowed\\c[0]:", "Yes"],
  90. ["\\c[12]Special Monster Encounters\\c[0]:", "Yes"],
  91. ["\\c[13]Quest Available\\c[0]:", "Yes"],
  92. ] # Don't remove this line!
  93. #-------------------------------------------------------------------------
  94.  
  95. end # DUNGEON_INFO
  96.  
  97. end # DSIVER144
  98.  
  99. class Game_Interpreter
  100. #-------------------------------------------------------------------------
  101. # * new method: show_dungeon_scene
  102. #-------------------------------------------------------------------------
  103. def show_dungeon_scene(id)
  104. SceneManager.call(Scene_DungeonInfo)
  105. SceneManager.scene.prepare(id)
  106. end
  107. end # Game_Interpreter
  108.  
  109. class Scene_DungeonInfo < Scene_Base
  110. include DSIVER144::DUNGEON_INFO
  111. #-------------------------------------------------------------------------
  112. # * new method: prepare
  113. #-------------------------------------------------------------------------
  114. def prepare(id)
  115. @dungeon_id = id
  116. end
  117. #-------------------------------------------------------------------------
  118. # * new method: start
  119. #-------------------------------------------------------------------------
  120. def start
  121. super
  122. @dungeon_id ||= 1
  123. create_background_image
  124. create_main_windows
  125. end
  126. #-------------------------------------------------------------------------
  127. # * new method: create_background_image
  128. #-------------------------------------------------------------------------
  129. def create_background_image
  130. @background_image = Sprite.new
  131. if SCENE_BACKGROUND != false
  132. begin
  133. @background_image.bitmap = Cache.parallax(SCENE_BACKGROUND)
  134. rescue
  135. @background_image.bitmap = SceneManager.background_bitmap
  136. @background_image.color.set(16, 16, 16, 128)
  137. end
  138. else
  139. @background_image.bitmap = SceneManager.background_bitmap
  140. @background_image.color.set(16, 16, 16, 128)
  141. end
  142. end
  143. #-------------------------------------------------------------------------
  144. # * new method: create_main_windows
  145. #-------------------------------------------------------------------------
  146. def create_main_windows
  147. @title_window = Window_Base.new(0,0,Graphics.width,48)
  148. @title_window.change_color(@title_window.text_color(DUNGEONS[@dungeon_id][:name][1]))
  149. @title_window.draw_text(0,0,@title_window.contents_width,@title_window.contents_height,DUNGEONS[@dungeon_id][:name][0],1)
  150. @help_window = Window_DungeonInfoHelp.new
  151. @command_window = Window_DungeonCommand.new(0,0,@dungeon_id)
  152. @command_window.y = @help_window.y - @command_window.height
  153. @command_window.set_handler(:normal, method(:process_normal))
  154. @command_window.set_handler(:hard, method(:process_hard))
  155. @command_window.set_handler(:cancel, method(:return_scene))
  156. wh = Graphics.height - @command_window.height - @title_window.height - @title_window.height
  157. @picture_window = Window_DungeonPicture.new(0,0,@command_window.width,wh) # 226 200
  158. @picture_window.y = @help_window.height
  159. wx = @picture_window.width
  160. wy = @picture_window.y
  161. ww = Graphics.width - @picture_window.width
  162. wh = @picture_window.height + @command_window.height
  163. @description_window = Window_DungeonDescription.new(wx,wy,ww,wh)
  164. @picture_window.draw_picture(@dungeon_id)
  165. @description_window.draw_description(@dungeon_id)
  166. @info_window = Window_DungeonInfo.new(wx,wy,ww,wh)
  167. @info_window.x = Graphics.width
  168. @info_window.draw_general_info(@dungeon_id)
  169. @page = 1
  170. end
  171. #-------------------------------------------------------------------------
  172. # * new method: process_normal
  173. #-------------------------------------------------------------------------
  174. def process_normal
  175. $game_temp.reserve_common_event(DUNGEONS[@dungeon_id][:normal_cme])
  176. SceneManager.goto(Scene_Map)
  177. end
  178. #-------------------------------------------------------------------------
  179. # * new method: process_hard
  180. #-------------------------------------------------------------------------
  181. def process_hard
  182. item = $data_items[DUNGEONS[@dungeon_id][:require_item][0]]
  183. num = DUNGEONS[@dungeon_id][:require_item][1]
  184. $game_party.lose_item(item, num)
  185. $game_temp.reserve_common_event(DUNGEONS[@dungeon_id][:hard_cme])
  186. SceneManager.goto(Scene_Map)
  187. end
  188. #-------------------------------------------------------------------------
  189. # * new method: easeInOutQuad
  190. #-------------------------------------------------------------------------
  191. def easeInOutQuad(t, b, c, d)
  192. t = t / (d/2.0)
  193. if (t < 1)
  194. return c/2*t*t + b
  195. end
  196. t -= 1
  197. return -c/2.0 * (t*(t-2) - 1) + b
  198. end
  199. #-------------------------------------------------------------------------
  200. # * new method: update_swith_page
  201. #-------------------------------------------------------------------------
  202. def update_swith_page
  203. RPG::SE.new(*SWITCH_PAGE_SE).play
  204. if @page == 1
  205. start_x = Graphics.width - @description_window.width
  206. des_x = Graphics.width - start_x
  207. start_time = Graphics.frame_count
  208. while (current_time = Graphics.frame_count - start_time) < 45
  209. @description_window.x = easeInOutQuad(current_time, start_x, des_x, 45)
  210. Graphics.update
  211. @command_window.update
  212. end
  213. start_x = Graphics.width
  214. des_x = - @description_window.width
  215. start_time = Graphics.frame_count
  216. while (current_time = Graphics.frame_count - start_time) < 45
  217. @info_window.x = easeInOutQuad(current_time, start_x, des_x, 45)
  218. Graphics.update
  219. @command_window.update
  220. end
  221. @page = 2
  222. else
  223. start_x = Graphics.width - @description_window.width
  224. des_x = Graphics.width - start_x
  225. start_time = Graphics.frame_count
  226. while (current_time = Graphics.frame_count - start_time) < 45
  227. @info_window.x = easeInOutQuad(current_time, start_x, des_x, 45)
  228. Graphics.update
  229. @command_window.update
  230. end
  231. start_x = Graphics.width
  232. des_x = - @description_window.width
  233. start_time = Graphics.frame_count
  234. while (current_time = Graphics.frame_count - start_time) < 45
  235. @description_window.x = easeInOutQuad(current_time, start_x, des_x, 45)
  236. Graphics.update
  237. @command_window.update
  238. end
  239. @page = 1
  240. end
  241. end
  242. #-------------------------------------------------------------------------
  243. # * new method: update
  244. #-------------------------------------------------------------------------
  245. def update
  246. super
  247. if Input.trigger?(:X)
  248. update_swith_page
  249. end
  250. end
  251. #-------------------------------------------------------------------------
  252. # * new method: terminate
  253. #-------------------------------------------------------------------------
  254. def terminate
  255. super
  256. @background_image.bitmap.dispose
  257. @background_image.dispose
  258. end
  259. end # Scene_DungeonInfo
  260.  
  261. class Window_DungeonInfoHelp < Window_Base
  262. include DSIVER144::DUNGEON_INFO
  263. #-------------------------------------------------------------------------
  264. # * method: draw_info
  265. #-------------------------------------------------------------------------
  266. def initialize
  267. super(0,Graphics.height-48,Graphics.width,48)
  268. refresh
  269. end
  270. #--------------------------------------------------------------------------
  271. # * Draw Text with Control Characters
  272. #--------------------------------------------------------------------------
  273. def draw_text_ex(x, y, text)
  274. text = convert_escape_characters(text)
  275. pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  276. process_character(text.slice!(0, 1), text, pos) until text.empty?
  277. end
  278. #-------------------------------------------------------------------------
  279. # * new method: refresh
  280. #-------------------------------------------------------------------------
  281. def refresh(enable_altar=false)
  282. contents.clear
  283. change_color(normal_color,true)
  284. draw_text_ex(0,0,SWITCH_PAGE_TEXT)
  285. draw_text_ex(contents_width - OTHER_BUTTONS_MARGIN,0,OTHER_BUTTONS_TEXT)
  286. end
  287. end # Window_CursedHelp
  288.  
  289. class Window_DungeonPicture < Window_Base
  290. include DSIVER144::DUNGEON_INFO
  291. #-------------------------------------------------------------------------
  292. # * new method: terminate
  293. #-------------------------------------------------------------------------
  294. def draw_picture(dungeon_id)
  295. contents.clear
  296. file_name = DUNGEONS[dungeon_id][:picture]
  297. pic_bitmap = Cache.parallax(file_name)
  298. des_rect = Rect.new(0,0,contents_width,contents_height)
  299. contents.stretch_blt(des_rect,pic_bitmap,pic_bitmap.rect)
  300. end
  301. end # Window_DungeonPicture
  302.  
  303. class Window_DungeonDescription < Window_Base
  304. include DSIVER144::DUNGEON_INFO
  305. #-------------------------------------------------------------------------
  306. # * new method: terminate
  307. #-------------------------------------------------------------------------
  308. def draw_description(dungeon_id)
  309. contents.clear
  310. desc_text = TEXTS[:description_header]
  311. desc = DUNGEONS[dungeon_id][:description]
  312.  
  313. x = 0; y = 0;
  314. contents.draw_text_ex(x,y,desc_text,false,17)
  315. y += 20
  316. contents.fill_rect(x,y,contents_width,1,Color.new(64,64,255))
  317. y += 5
  318. contents.turn_on_wordwraping
  319. contents.font.size = DUNGEONS[dungeon_id][:description_font][0]
  320. contents.draw_text_ex(x,y,desc,false,DUNGEONS[dungeon_id][:description_font][1])
  321. end
  322. end # Window_DungeonDescription
  323.  
  324. class Window_DungeonInfo < Window_Base
  325. include DSIVER144::DUNGEON_INFO
  326. #-------------------------------------------------------------------------
  327. # * new method: terminate
  328. #-------------------------------------------------------------------------
  329. def draw_general_info(dungeon_id)
  330. contents.clear
  331. contents.turn_on_wordwraping
  332. desc_text = TEXTS[:general_info_header]
  333. general_info = DUNGEONS[dungeon_id][:gerenal_info]
  334. x = 0; y = 0;
  335. contents.draw_text_ex(x,y,desc_text,false,17)
  336. y += 20
  337. contents.fill_rect(x,y,contents_width,1,Color.new(64,64,255))
  338. y += 5
  339. if general_info[:tools]
  340. contents.draw_text_ex(x,y,"\\c[20]Tools for Full Exploration\\c[0]: ",false,17)
  341. y += 24
  342. start_x = 0.5*(contents_width - general_info[:tools].size * 35)
  343. x = start_x
  344. general_info[:tools].each_with_index do |id,index|
  345. draw_icon($data_weapons[id].icon_index, x, y)
  346. x += 35;
  347. end
  348. end
  349. y += 32
  350. x = 0
  351. contents.font.size = general_info[:font][0]
  352. if general_info[:texts]
  353. st = ""
  354. general_info[:texts].each do |line|
  355. st += line[0] + " " + line[1] + "\n"
  356. end
  357. contents.draw_text_ex(x,y,st,false,general_info[:font][1])
  358. end
  359. end
  360. end # Window_DungeonInfo
  361.  
  362. class Window_DungeonCommand < Window_Command
  363. include DSIVER144::DUNGEON_INFO
  364. #--------------------------------------------------------------------------
  365. # * new method: initialize
  366. #--------------------------------------------------------------------------
  367. def initialize(x,y,dungeon_id)
  368. @dungeon_id = dungeon_id
  369. super(x,y)
  370. end
  371. #--------------------------------------------------------------------------
  372. # * new method: window_width
  373. #--------------------------------------------------------------------------
  374. def window_width
  375. return 250
  376. end
  377. #--------------------------------------------------------------------------
  378. # * new method: add_command
  379. #--------------------------------------------------------------------------
  380. def add_command(name, symbol, icon_index = nil, enabled = true, ext = nil)
  381. @list.push({:name=>name, :symbol=>symbol, :icon_index=>icon_index, :enabled=>enabled, :ext=>ext})
  382. end
  383. #--------------------------------------------------------------------------
  384. # * new method: add_command
  385. #--------------------------------------------------------------------------
  386. def command_name(index)
  387. @list[index][:name]
  388. end
  389. #--------------------------------------------------------------------------
  390. # * new method: draw_item
  391. #--------------------------------------------------------------------------
  392. def draw_item(index)
  393. change_color(normal_color, command_enabled?(index))
  394. rect = item_rect_for_text(index)
  395. if command_icon(index)
  396. draw_icon(command_icon(index),rect.x, rect.y)
  397. rect.x += 26
  398. end
  399. draw_text(rect, command_name(index), 0)
  400. end
  401. #--------------------------------------------------------------------------
  402. # * new method: command_icon
  403. #--------------------------------------------------------------------------
  404. def command_icon(index)
  405. @list[index][:icon_index]
  406. end
  407. #--------------------------------------------------------------------------
  408. # * Get Window Height
  409. #--------------------------------------------------------------------------
  410. def window_height
  411. fitting_height(3)
  412. end
  413. #--------------------------------------------------------------------------
  414. # * new method: make_command_list
  415. #--------------------------------------------------------------------------
  416. def make_command_list
  417. key = [:normal,:hard,:cancel]
  418. hide_stt = DUNGEONS[@dungeon_id].has_key?(:hard_cme)
  419. if DUNGEONS[@dungeon_id].has_key?(:require_item)
  420. item = $data_items[DUNGEONS[@dungeon_id][:require_item][0]]
  421. hard_stt = $game_party.item_number(item) >= DUNGEONS[@dungeon_id][:require_item][1]
  422. else
  423. hard_stt = false
  424. end
  425. COMMANDS.values.each_with_index do |command,index|
  426. if key[index] != :hard
  427. add_command(command[0],key[index],command[1])
  428. elsif hide_stt
  429. add_command(command[0],key[index],command[1],hard_stt)
  430. end # end if
  431. end # end loop
  432. end # end make_command_list
  433.  
  434. end # Window_DungeonCommand
  435.  
  436. class Bitmap
  437. attr_accessor :last_line_height
  438. #--------------------------------------------------------------------------
  439. # * New Line Character Processing
  440. #--------------------------------------------------------------------------
  441. def process_new_line(text, pos)
  442. pos[:x] = pos[:new_x]
  443. pos[:y] += pos[:height]
  444. if @last_line_height
  445. pos[:height] = calc_line_height(text,true,@last_line_height)
  446. else
  447. pos[:height] = calc_line_height(text)
  448. end
  449. end
  450. #--------------------------------------------------------------------------
  451. # * Draw Text with Control Characters
  452. #--------------------------------------------------------------------------
  453. def draw_text_ex(x, y, text,reset_font=true,custom_size=false)
  454. reset_font_settings if reset_font == true
  455. #self.font.size -= 3
  456. text = convert_escape_characters(text)
  457. if !custom_size
  458. pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  459. else
  460. pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text, true, custom_size)}
  461. end
  462. process_character(text.slice!(0, 1), text, pos) until text.empty?
  463. end
  464. #--------------------------------------------------------------------------
  465. # * Calculate Line Height
  466. # restore_font_size : Return to original font size after calculating
  467. #--------------------------------------------------------------------------
  468. def calc_line_height(text, restore_font_size = true, custom_size=false)
  469. if custom_size
  470. @last_line_height = custom_size
  471. return custom_size
  472. end
  473. result = [line_height, self.font.size].max
  474. last_font_size = self.font.size
  475. text.slice(/^.*$/).scan(/\e[\{\}]/).each do |esc|
  476. make_font_bigger if esc == "\e{"
  477. make_font_smaller if esc == "\e}"
  478. result = [result, self.font.size].max
  479. end
  480. self.font.size = last_font_size if restore_font_size
  481. result
  482. end
  483. end
  484. #===============================================================================
  485. # * END OF FILE
  486. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement