Advertisement
dsiver144

Untitled

Feb 28th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.20 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)", 205] # [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 Maze", 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] = [7,5] # [Item_ID, Number]
  53. DUNGEONS[1][:picture] = "Dungeon1" # 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 legendary Ice Palace. Though the Deep within the ice caves lie the ancient ice caverns, said to lead to the ice palace of the snow queen."
  55. DUNGEONS[1][:description_font] = [18,22] # [Font size, Line Height]
  56. DUNGEONS[1][:gerenal_info] = {} # Don't remove this line!
  57. DUNGEONS[1][:gerenal_info][:tools] = [14,15,16,17,18,19,20] # Item ID of Tools
  58. DUNGEONS[1][:gerenal_info][:font] = [16,18] # [Font size, Line Height]
  59. DUNGEONS[1][:gerenal_info][:texts] = [ # Don't remove this line!
  60. ["\\c[5]Expected Monster\\c[0]:", "Ice Slime, Ice Hell Flower, ect"],
  61. ["\\c[6]Common Element Found\\c[0]:", "Ice Mage Cards"],
  62. ["\\c[7]Recommended Cards\\c[0]:", "Fire Mage Cards"],
  63. ["\\c[21]Number of Areas\\c[0]:", "6+"],
  64. ["\\c[9]Available Altars\\c[0]:", "Ice"],
  65. ["\\c[10]Save Point\\c[0]:", "Yes"],
  66. ["\\c[11]Teleportation Allowed\\c[0]:", "Yes"],
  67. ["\\c[12]Special Monster Encounters\\c[0]:", "Yes"],
  68. ["\\c[13]Quest Available\\c[0]:", "Yes"],
  69. ] # Don't remove this line!
  70. #-------------------------------------------------------------------------
  71.  
  72. end # DUNGEON_INFO
  73.  
  74. end # DSIVER144
  75.  
  76. class Game_Interpreter
  77. #-------------------------------------------------------------------------
  78. # * new method: show_dungeon_scene
  79. #-------------------------------------------------------------------------
  80. def show_dungeon_scene(id)
  81. SceneManager.call(Scene_DungeonInfo)
  82. SceneManager.scene.prepare(id)
  83. end
  84. end # Game_Interpreter
  85.  
  86. class Scene_DungeonInfo < Scene_Base
  87. include DSIVER144::DUNGEON_INFO
  88. #-------------------------------------------------------------------------
  89. # * new method: prepare
  90. #-------------------------------------------------------------------------
  91. def prepare(id)
  92. @dungeon_id = id
  93. end
  94. #-------------------------------------------------------------------------
  95. # * new method: start
  96. #-------------------------------------------------------------------------
  97. def start
  98. super
  99. @dungeon_id ||= 1
  100. create_background_image
  101. create_main_windows
  102. end
  103. #-------------------------------------------------------------------------
  104. # * new method: create_background_image
  105. #-------------------------------------------------------------------------
  106. def create_background_image
  107. @background_image = Sprite.new
  108. if SCENE_BACKGROUND != false
  109. begin
  110. @background_image.bitmap = Cache.parallax(SCENE_BACKGROUND)
  111. rescue
  112. @background_image.bitmap = SceneManager.background_bitmap
  113. @background_image.color.set(16, 16, 16, 128)
  114. end
  115. else
  116. @background_image.bitmap = SceneManager.background_bitmap
  117. @background_image.color.set(16, 16, 16, 128)
  118. end
  119. end
  120. #-------------------------------------------------------------------------
  121. # * new method: create_main_windows
  122. #-------------------------------------------------------------------------
  123. def create_main_windows
  124. @title_window = Window_Base.new(0,0,Graphics.width,48)
  125. @title_window.change_color(@title_window.text_color(DUNGEONS[@dungeon_id][:name][1]))
  126. @title_window.draw_text(0,0,@title_window.contents_width,@title_window.contents_height,DUNGEONS[@dungeon_id][:name][0],1)
  127. @help_window = Window_DungeonInfoHelp.new
  128. @command_window = Window_DungeonCommand.new(0,0,@dungeon_id)
  129. @command_window.y = @help_window.y - @command_window.height
  130. @command_window.set_handler(:normal, method(:process_normal))
  131. @command_window.set_handler(:hard, method(:process_hard))
  132. @command_window.set_handler(:cancel, method(:return_scene))
  133. wh = Graphics.height - @command_window.height - @title_window.height - @title_window.height
  134. @picture_window = Window_DungeonPicture.new(0,0,@command_window.width,wh) # 226 200
  135. @picture_window.y = @help_window.height
  136. wx = @picture_window.width
  137. wy = @picture_window.y
  138. ww = Graphics.width - @picture_window.width
  139. wh = @picture_window.height + @command_window.height
  140. @description_window = Window_DungeonDescription.new(wx,wy,ww,wh)
  141. @picture_window.draw_picture(@dungeon_id)
  142. @description_window.draw_description(@dungeon_id)
  143. @info_window = Window_DungeonInfo.new(wx,wy,ww,wh)
  144. @info_window.x = Graphics.width
  145. @info_window.draw_general_info(@dungeon_id)
  146. @page = 1
  147. end
  148. #-------------------------------------------------------------------------
  149. # * new method: process_normal
  150. #-------------------------------------------------------------------------
  151. def process_normal
  152. $game_temp.reserve_common_event(DUNGEONS[@dungeon_id][:normal_cme])
  153. SceneManager.goto(Scene_Map)
  154. end
  155. #-------------------------------------------------------------------------
  156. # * new method: process_hard
  157. #-------------------------------------------------------------------------
  158. def process_hard
  159. item = $data_items[DUNGEONS[@dungeon_id][:require_item][0]]
  160. num = DUNGEONS[@dungeon_id][:require_item][1]
  161. $game_party.lose_item(item, num)
  162. $game_temp.reserve_common_event(DUNGEONS[@dungeon_id][:hard_cme])
  163. SceneManager.goto(Scene_Map)
  164. end
  165. #-------------------------------------------------------------------------
  166. # * new method: update_swith_page
  167. #-------------------------------------------------------------------------
  168. def update_swith_page
  169. RPG::SE.new(*SWITCH_PAGE_SE).play
  170. if @page == 1
  171. des_x = Graphics.width
  172. des_x2 = Graphics.width - @description_window.width
  173. while @description_window.x < des_x
  174. @description_window.x += 10
  175. Graphics.update
  176. @command_window.update
  177. if @description_window.x > des_x
  178. @description_window.x = des_x
  179. end
  180. end
  181. while @info_window.x > des_x2
  182. @info_window.x -= 10
  183. Graphics.update
  184. @command_window.update
  185. if @info_window.x < des_x2
  186. @info_window.x = des_x2
  187. end
  188. end
  189. @page = 2
  190. else
  191. des_x = Graphics.width - @description_window.width
  192. des_x2 = Graphics.width
  193. while @info_window.x < des_x2
  194. @info_window.x += 10
  195. Graphics.update
  196. @command_window.update
  197. if @info_window.x > des_x2
  198. @info_window.x = des_x2
  199. end
  200. end
  201. while @description_window.x > des_x
  202. @description_window.x -= 10
  203. Graphics.update
  204. @command_window.update
  205. if @description_window.x < des_x
  206. @description_window.x = des_x
  207. end
  208. end
  209. @page = 1
  210. end
  211. end
  212. #-------------------------------------------------------------------------
  213. # * new method: update
  214. #-------------------------------------------------------------------------
  215. def update
  216. super
  217. if Input.trigger?(:X)
  218. update_swith_page
  219. end
  220. end
  221. #-------------------------------------------------------------------------
  222. # * new method: terminate
  223. #-------------------------------------------------------------------------
  224. def terminate
  225. super
  226. @background_image.bitmap.dispose
  227. @background_image.dispose
  228. end
  229. end # Scene_DungeonInfo
  230.  
  231. class Window_DungeonInfoHelp < Window_Base
  232. include DSIVER144::DUNGEON_INFO
  233. #-------------------------------------------------------------------------
  234. # * method: draw_info
  235. #-------------------------------------------------------------------------
  236. def initialize
  237. super(0,Graphics.height-48,Graphics.width,48)
  238. refresh
  239. end
  240. #--------------------------------------------------------------------------
  241. # * Draw Text with Control Characters
  242. #--------------------------------------------------------------------------
  243. def draw_text_ex(x, y, text)
  244. text = convert_escape_characters(text)
  245. pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  246. process_character(text.slice!(0, 1), text, pos) until text.empty?
  247. end
  248. #-------------------------------------------------------------------------
  249. # * new method: refresh
  250. #-------------------------------------------------------------------------
  251. def refresh(enable_altar=false)
  252. contents.clear
  253. change_color(normal_color,true)
  254. draw_text_ex(0,0,SWITCH_PAGE_TEXT)
  255. draw_text_ex(contents_width - OTHER_BUTTONS_MARGIN,0,OTHER_BUTTONS_TEXT)
  256. end
  257. end # Window_CursedHelp
  258.  
  259. class Window_DungeonPicture < Window_Base
  260. include DSIVER144::DUNGEON_INFO
  261. #-------------------------------------------------------------------------
  262. # * new method: terminate
  263. #-------------------------------------------------------------------------
  264. def draw_picture(dungeon_id)
  265. contents.clear
  266. file_name = DUNGEONS[dungeon_id][:picture]
  267. pic_bitmap = Cache.parallax(file_name)
  268. des_rect = Rect.new(0,0,contents_width,contents_height)
  269. contents.stretch_blt(des_rect,pic_bitmap,pic_bitmap.rect)
  270. end
  271. end # Window_DungeonPicture
  272.  
  273. class Window_DungeonDescription < Window_Base
  274. include DSIVER144::DUNGEON_INFO
  275. #-------------------------------------------------------------------------
  276. # * new method: terminate
  277. #-------------------------------------------------------------------------
  278. def draw_description(dungeon_id)
  279. contents.clear
  280. desc_text = TEXTS[:description_header]
  281. desc = DUNGEONS[dungeon_id][:description]
  282.  
  283. x = 0; y = 0;
  284. contents.draw_text_ex(x,y,desc_text,false,17)
  285. y += 20
  286. contents.fill_rect(x,y,contents_width,1,Color.new(64,64,255))
  287. y += 5
  288. contents.turn_on_wordwraping
  289. contents.font.size = DUNGEONS[dungeon_id][:description_font][0]
  290. contents.draw_text_ex(x,y,desc,false,DUNGEONS[dungeon_id][:description_font][1])
  291. end
  292. end # Window_DungeonDescription
  293.  
  294. class Window_DungeonInfo < Window_Base
  295. include DSIVER144::DUNGEON_INFO
  296. #-------------------------------------------------------------------------
  297. # * new method: terminate
  298. #-------------------------------------------------------------------------
  299. def draw_general_info(dungeon_id)
  300. contents.clear
  301. contents.turn_on_wordwraping
  302. desc_text = TEXTS[:general_info_header]
  303. general_info = DUNGEONS[dungeon_id][:gerenal_info]
  304. x = 0; y = 0;
  305. contents.draw_text_ex(x,y,desc_text,false,17)
  306. y += 20
  307. contents.fill_rect(x,y,contents_width,1,Color.new(64,64,255))
  308. y += 5
  309. if general_info[:tools]
  310. contents.draw_text_ex(x,y,"\\c[20]Useful Tools\\c[0]: ",false,17)
  311. y += 24
  312. start_x = 0.5*(contents_width - general_info[:tools].size * 35)
  313. x = start_x
  314. general_info[:tools].each_with_index do |id,index|
  315. draw_icon($data_items[id].icon_index, x, y)
  316. x += 35;
  317. end
  318. end
  319. y += 32
  320. x = 0
  321. contents.font.size = general_info[:font][0]
  322. if general_info[:texts]
  323. st = ""
  324. general_info[:texts].each do |line|
  325. st += line[0] + " " + line[1] + "\n"
  326. end
  327. contents.draw_text_ex(x,y,st,false,general_info[:font][1])
  328. end
  329. end
  330. end # Window_DungeonInfo
  331.  
  332. class Window_DungeonCommand < Window_Command
  333. include DSIVER144::DUNGEON_INFO
  334. #--------------------------------------------------------------------------
  335. # * new method: initialize
  336. #--------------------------------------------------------------------------
  337. def initialize(x,y,dungeon_id)
  338. @dungeon_id = dungeon_id
  339. super(x,y)
  340. end
  341. #--------------------------------------------------------------------------
  342. # * new method: window_width
  343. #--------------------------------------------------------------------------
  344. def window_width
  345. return 250
  346. end
  347. #--------------------------------------------------------------------------
  348. # * new method: add_command
  349. #--------------------------------------------------------------------------
  350. def add_command(name, symbol, icon_index = nil, enabled = true, ext = nil)
  351. @list.push({:name=>name, :symbol=>symbol, :icon_index=>icon_index, :enabled=>enabled, :ext=>ext})
  352. end
  353. #--------------------------------------------------------------------------
  354. # * new method: add_command
  355. #--------------------------------------------------------------------------
  356. def command_name(index)
  357. @list[index][:name]
  358. end
  359. #--------------------------------------------------------------------------
  360. # * new method: draw_item
  361. #--------------------------------------------------------------------------
  362. def draw_item(index)
  363. change_color(normal_color, command_enabled?(index))
  364. rect = item_rect_for_text(index)
  365. if command_icon(index)
  366. draw_icon(command_icon(index),rect.x, rect.y)
  367. rect.x += 26
  368. end
  369. draw_text(rect, command_name(index), 0)
  370. end
  371. #--------------------------------------------------------------------------
  372. # * new method: command_icon
  373. #--------------------------------------------------------------------------
  374. def command_icon(index)
  375. @list[index][:icon_index]
  376. end
  377. #--------------------------------------------------------------------------
  378. # * new method: make_command_list
  379. #--------------------------------------------------------------------------
  380. def make_command_list
  381. key = [:normal,:hard,:cancel]
  382. item = $data_items[DUNGEONS[@dungeon_id][:require_item][0]]
  383. hard_stt = $game_party.item_number(item) >= DUNGEONS[@dungeon_id][:require_item][1]
  384. COMMANDS.values.each_with_index do |command,index|
  385. if key[index] != :hard
  386. add_command(command[0],key[index],command[1])
  387. else
  388. add_command(command[0],key[index],command[1],hard_stt)
  389. end # end if
  390. end # end loop
  391. end # end make_command_list
  392.  
  393. end # Window_DungeonCommand
  394.  
  395. class Bitmap
  396. attr_accessor :last_line_height
  397. #--------------------------------------------------------------------------
  398. # * New Line Character Processing
  399. #--------------------------------------------------------------------------
  400. def process_new_line(text, pos)
  401. pos[:x] = pos[:new_x]
  402. pos[:y] += pos[:height]
  403. if @last_line_height
  404. pos[:height] = calc_line_height(text,true,@last_line_height)
  405. else
  406. pos[:height] = calc_line_height(text)
  407. end
  408. end
  409. #--------------------------------------------------------------------------
  410. # * Draw Text with Control Characters
  411. #--------------------------------------------------------------------------
  412. def draw_text_ex(x, y, text,reset_font=true,custom_size=false)
  413. reset_font_settings if reset_font == true
  414. #self.font.size -= 3
  415. text = convert_escape_characters(text)
  416. if !custom_size
  417. pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  418. else
  419. pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text, true, custom_size)}
  420. end
  421. process_character(text.slice!(0, 1), text, pos) until text.empty?
  422. end
  423. #--------------------------------------------------------------------------
  424. # * Calculate Line Height
  425. # restore_font_size : Return to original font size after calculating
  426. #--------------------------------------------------------------------------
  427. def calc_line_height(text, restore_font_size = true, custom_size=false)
  428. if custom_size
  429. @last_line_height = custom_size
  430. return [custom_size,line_height].max
  431. end
  432. result = [line_height, self.font.size].max
  433. last_font_size = self.font.size
  434. text.slice(/^.*$/).scan(/\e[\{\}]/).each do |esc|
  435. make_font_bigger if esc == "\e{"
  436. make_font_smaller if esc == "\e}"
  437. result = [result, self.font.size].max
  438. end
  439. self.font.size = last_font_size if restore_font_size
  440. result
  441. end
  442. end
  443. #===============================================================================
  444. # * END OF FILE
  445. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement