Advertisement
dsiver144

DSI Boss Scene

Jul 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.20 KB | None | 0 0
  1. #==============================================================================
  2. # DSI Boss Scene
  3. # -- Last Updated: 2017.07.22
  4. # -- Author: dsiver144
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #==============================================================================
  8. $imported = {} if $imported.nil?
  9. $imported["DSI-BossScene"] = true
  10. #==============================================================================
  11. # + Updates
  12. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  13. # 2017.07.22 - Finish first version.
  14. #==============================================================================
  15. # + Instructions
  16. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. # To install this script, open up your script editor and copy/paste this script
  18. # to an open slot below ?? Materials/?f?? but above ?? Main. Remember to save.
  19. # Put this below all of my scripts.
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # Script Call:
  22. # + open_boss_scene(phase_id) -> Open Boss Scene with specific phase
  23. # + defeat_boss(phase_id,boss_id) -> call this when you defeat a boss of a phase
  24. # + boss_defeated?(phase_id,boss_id)
  25. # -> Check if a specific boss of a specific phase is defeated.
  26. #==============================================================================
  27. module DSIVER144
  28. module BOSS_SCENE
  29. CURSOR_SE = ["CursorFF7",70,100]
  30. GRAPHICS_PATH = "Graphics/Boss Graphics"
  31. PHASES = {} # Don't remove this line
  32. #------------------------------------------------------------------------
  33. # * [Phase 1] - Setup
  34. #------------------------------------------------------------------------
  35. # PHASE[phase_id]
  36. #------------------------------------------------------------------------
  37. PHASES[1] = {} # Don't remove this line
  38. PHASES[1][:background] = "BG1"
  39. PHASES[1][:BGM] = ["Field2",70,100]
  40. PHASES[1][:static_img] = "Static"
  41. PHASES[1][:Bosses] = {} # Don't remove this line
  42. PHASES[1][:Bosses][1] = {} # Don't remove this line
  43. PHASES[1][:Bosses][1][:name] = "Testboss1"
  44. PHASES[1][:Bosses][1][:face_img] = "TestFace"
  45. PHASES[1][:Bosses][1][:location] = "Unknown"
  46. PHASES[1][:Bosses][1][:desc] = "This is a test box description!"
  47. PHASES[1][:Bosses][1][:common_ev_id] = 256
  48. PHASES[1][:Bosses][2] = {} # Don't remove this line
  49. PHASES[1][:Bosses][2][:name] = "\\c[5]Treant"
  50. PHASES[1][:Bosses][2][:face_img] = "Treant Boss Face"
  51. PHASES[1][:Bosses][2][:location] = "Cursed Forest"
  52. PHASES[1][:Bosses][2][:desc] = "This is a test box description for \\c[5]Treant!\\c[10]"
  53. PHASES[1][:Bosses][2][:common_ev_id] = 257
  54. PHASES[1][:Bosses][3] = {} # Don't remove this line
  55. PHASES[1][:Bosses][3][:name] = "Testboss3"
  56. PHASES[1][:Bosses][3][:face_img] = "TestFace"
  57. PHASES[1][:Bosses][3][:location] = "Unknown3"
  58. PHASES[1][:Bosses][3][:desc] = "This is a test box description 3!"
  59. PHASES[1][:Bosses][3][:common_ev_id] = 258
  60. PHASES[1][:Bosses][4] = {} # Don't remove this line
  61. PHASES[1][:Bosses][4][:name] = "Testboss4"
  62. PHASES[1][:Bosses][4][:face_img] = "TestFace"
  63. PHASES[1][:Bosses][4][:location] = "Unknown4"
  64. PHASES[1][:Bosses][4][:desc] = "This is a test box description 4!"
  65. PHASES[1][:Bosses][4][:common_ev_id] = 259
  66. #~ PHASES[1][:Bosses][5] = {} # Don't remove this line
  67. #~ PHASES[1][:Bosses][5][:name] = "Testboss5"
  68. #~ PHASES[1][:Bosses][5][:face_img] = "TestFace"
  69. #~ PHASES[1][:Bosses][5][:location] = "Unknown5"
  70. #~ PHASES[1][:Bosses][5][:desc] = "This is a test box description 5 asdw wheuiahwie awheuiahwri awheuiahweia awehuiawnanwawe ra!"
  71. #~ PHASES[1][:Bosses][5][:common_ev_id] = 260
  72. #~ PHASES[1][:Bosses][6] = {} # Don't remove this line
  73. #~ PHASES[1][:Bosses][6][:name] = "Testboss5"
  74. #~ PHASES[1][:Bosses][6][:face_img] = "TestFace"
  75. #~ PHASES[1][:Bosses][6][:location] = "Unknown5"
  76. #~ PHASES[1][:Bosses][6][:desc] = "This is a test box description 5!"
  77. #~ PHASES[1][:Bosses][6][:common_ev_id] = 261
  78. #~ PHASES[1][:Bosses][7] = {} # Don't remove this line
  79. #~ PHASES[1][:Bosses][7][:name] = "Testboss5"
  80. #~ PHASES[1][:Bosses][7][:face_img] = "TestFace"
  81. #~ PHASES[1][:Bosses][7][:location] = "Unknown5"
  82. #~ PHASES[1][:Bosses][7][:desc] = "This is a test box description 5!"
  83. #~ PHASES[1][:Bosses][7][:common_ev_id] = 262
  84. #~ PHASES[1][:Bosses][8] = {} # Don't remove this line
  85. #~ PHASES[1][:Bosses][8][:name] = "Testboss5"
  86. #~ PHASES[1][:Bosses][8][:face_img] = "TestFace"
  87. #~ PHASES[1][:Bosses][8][:location] = "Unknown5"
  88. #~ PHASES[1][:Bosses][8][:desc] = "This is a test box description 5!"
  89. #~ PHASES[1][:Bosses][8][:common_ev_id] = 263
  90. #------------------------------------------------------------------------
  91. # * [Phase 1] - END
  92. #------------------------------------------------------------------------
  93. end
  94. end
  95.  
  96. class Game_System
  97. attr_accessor :boss_phase
  98. alias_method(:dsi_init_boss_phase, :initialize)
  99. def initialize
  100. @boss_phase = {}
  101. DSIVER144::BOSS_SCENE::PHASES.each_pair do |phase_id,phase_data|
  102. @boss_phase[phase_id] = {}
  103. phase_data[:Bosses].each_key do |boss_id|
  104. @boss_phase[phase_id][boss_id] = false
  105. end
  106. end
  107. dsi_init_boss_phase
  108. end
  109. end # Game_System
  110.  
  111. class Game_Interpreter
  112. #--------------------------------------------------------------------------
  113. # * new method: open_boss_scene
  114. #--------------------------------------------------------------------------
  115. def open_boss_scene(phase)
  116. SceneManager.call(Scene_BossSelect)
  117. SceneManager.scene.prepare(phase)
  118. end
  119. #--------------------------------------------------------------------------
  120. # * new method: defeat_boss
  121. #--------------------------------------------------------------------------
  122. def defeat_boss(phase_id,boss_id)
  123. $game_system.boss_phase[phase_id][boss_id] = true
  124. end
  125. #--------------------------------------------------------------------------
  126. # * new method: boss_defeated?
  127. #--------------------------------------------------------------------------
  128. def boss_defeated?(phase_id,boss_id)
  129. return $game_system.boss_phase[phase_id][boss_id]
  130. end
  131. end # Game_Interpreter
  132.  
  133. module Cache
  134. include DSIVER144::BOSS_SCENE
  135. #--------------------------------------------------------------------------
  136. # * Get Animation Graphic
  137. #--------------------------------------------------------------------------
  138. def self.boss(filename)
  139. load_bitmap(GRAPHICS_PATH + "/", filename)
  140. end
  141. end # Cache
  142.  
  143. class BossSquare
  144. include DSIVER144::BOSS_SCENE
  145. #--------------------------------------------------------------------------
  146. # * new method: prepare
  147. #--------------------------------------------------------------------------
  148. def initialize(x,y,boss_data,boss_id,phase_id)
  149. @x = x
  150. @y = y
  151. @defeated = $game_system.boss_phase[phase_id][boss_id]
  152. @name = boss_data[:name]
  153. @location = boss_data[:location]
  154. @face_img = boss_data[:face_img]
  155. @desc = boss_data[:desc]
  156. @box_sprite = Sprite.new
  157. @box_sprite.bitmap = Cache.boss("Boss Square")
  158. @box_sprite.x = @x
  159. @box_sprite.y = @y
  160. @box_sprite.z = 10
  161. @box_image = Sprite.new
  162. if !@defeated
  163. @box_image.bitmap = Cache.boss(@face_img)
  164. else
  165. @box_image.bitmap = Cache.boss(PHASES[phase_id][:static_img])
  166. end
  167. @box_image.x = @x + 13
  168. @box_image.y = @y + 14
  169. @box_image.z = 12
  170. end
  171. #--------------------------------------------------------------------------
  172. # * new method: is_defeated?
  173. #--------------------------------------------------------------------------
  174. def is_defeated?
  175. return @defeated
  176. end
  177. #--------------------------------------------------------------------------
  178. # * new method: name
  179. #--------------------------------------------------------------------------
  180. def name
  181. return @name
  182. end
  183. #--------------------------------------------------------------------------
  184. # * new method: x
  185. #--------------------------------------------------------------------------
  186. def x
  187. return @x
  188. end
  189. #--------------------------------------------------------------------------
  190. # * new method: y
  191. #--------------------------------------------------------------------------
  192. def y
  193. return @y
  194. end
  195. #--------------------------------------------------------------------------
  196. # * new method: location
  197. #--------------------------------------------------------------------------
  198. def location
  199. return @location
  200. end
  201. #--------------------------------------------------------------------------
  202. # * new method: desc
  203. #--------------------------------------------------------------------------
  204. def desc
  205. return @desc
  206. end
  207. #--------------------------------------------------------------------------
  208. # * new method: dispose
  209. #--------------------------------------------------------------------------
  210. def dispose
  211. @box_sprite.dispose
  212. @box_image.dispose
  213. end
  214. end # BossSquare
  215.  
  216. class Scene_BossSelect < Scene_Base
  217. include DSIVER144::BOSS_SCENE
  218. #--------------------------------------------------------------------------
  219. # * new method: prepare
  220. #--------------------------------------------------------------------------
  221. def prepare(phase)
  222. @phase_id = phase
  223. @boss_num = PHASES[@phase_id][:Bosses].size
  224. end
  225. #--------------------------------------------------------------------------
  226. # * new method: calculate_square_position
  227. #--------------------------------------------------------------------------
  228. def calculate_square_position
  229. @sprite_boss_name = Sprite.new
  230. @sprite_boss_name.bitmap = Bitmap.new(Graphics.width,Graphics.height)
  231. @sprite_boss_name.z = 5
  232. @sprite_boss_name.y = 0
  233. @boss_boxes = []
  234. @box_width = 76
  235. @box_space = 30
  236. @offset = 0#-10
  237. if @boss_num > 4
  238. @row1_y = 85
  239. @row2_y = 85 + 76 + 30
  240. @total_width = @box_width*4 + @box_space*3
  241. @row1_x = 0.5*(Graphics.width - @total_width)
  242. for i in 1..4
  243. x = @row1_x + (@box_space+@box_width)*(i-1) + @offset
  244. y = @row1_y
  245. data = PHASES[@phase_id][:Bosses][i]
  246. boss = BossSquare.new(x,y,data,i,@phase_id)
  247. @boss_boxes << boss
  248. text_offset = 0.5*(76 - @dummy_window.text_width_ex(boss.name))
  249. @sprite_boss_name.bitmap.draw_text_ex(x + text_offset,y + 80,boss.name)
  250. end
  251. remain = @boss_num - 4
  252. if remain > 0
  253. @total_width = @box_width*remain + @box_space*(remain-1)
  254. @row2_x = 0.5*(Graphics.width - @total_width).abs
  255. for i in 1..remain
  256. x = @row2_x + (@box_space+@box_width)*(i-1) + @offset
  257. y = @row2_y
  258. data = PHASES[@phase_id][:Bosses][i + 4]
  259. boss = BossSquare.new(x,y,data,i+4,@phase_id)
  260. @boss_boxes << boss
  261. text_offset = 0.5*(76 - @dummy_window.text_width_ex(boss.name))
  262. @sprite_boss_name.bitmap.draw_text_ex(x + text_offset,y + 80,boss.name)
  263. end
  264. end
  265. else
  266. @row_y = 130
  267. @total_width = @box_width*@boss_num + @box_space*(@boss_num-1)
  268. @row_x = 0.5*(Graphics.width - @total_width)
  269. for i in 1..@boss_num
  270. x = @row_x + (@box_space+@box_width)*(i-1) + @offset
  271. y = @row_y
  272. data = PHASES[@phase_id][:Bosses][i]
  273. boss = BossSquare.new(x,y,data,i,@phase_id)
  274. @boss_boxes << boss
  275. text_offset = 0.5*(76 - @dummy_window.text_width_ex(boss.name))
  276. @sprite_boss_name.bitmap.draw_text_ex(x + text_offset,y + 80,boss.name)
  277. end
  278. end
  279. end
  280. #--------------------------------------------------------------------------
  281. # * new method: start
  282. #--------------------------------------------------------------------------
  283. def start
  284. super
  285. create_background
  286. play_scene_bgm
  287. create_main_windows
  288. end
  289. #--------------------------------------------------------------------------
  290. # * new method: create_main_windows
  291. #--------------------------------------------------------------------------
  292. def create_main_windows
  293. @dummy_window = Window_Base.new(0,0,200,46)
  294. cw = @dummy_window.contents_width; ch = @dummy_window.contents_height
  295. @dummy_window.draw_text(0,0,cw,ch,"Boss Select",1)
  296. @dummy_window.x = 0.5*(Graphics.width - @dummy_window.width)
  297. @dummy_window.y = 10
  298. @info_window = Boss_Info_Window.new(0,0,Graphics.width - 10,117 - 10)
  299. @info_window.y = Graphics.height - 117 + 10 - 5
  300. @info_window.x = 0.5*(Graphics.width - @info_window.width)
  301. calculate_square_position
  302. @cursor_sprite = Sprite.new
  303. @cursor_sprite.bitmap = Cache.boss("Cursor")
  304. @cursor_index = 0
  305. @confirm_window = Boss_Confirm_Window.new(0,0)
  306. @sprite_black = Sprite.new
  307. @sprite_black.z = 250
  308. @sprite_black.opacity = 0
  309. @sprite_black.bitmap = Bitmap.new(Graphics.width,Graphics.height)
  310. @sprite_black.bitmap.fill_rect(@sprite_black.bitmap.rect, Color.new(0,0,0))
  311. @confirm_window.x = (Graphics.width - @confirm_window.width)*0.5
  312. @confirm_window.y = (Graphics.height - @confirm_window.height)*0.5
  313. @confirm_window.z = 300
  314. @confirm_window.deactivate
  315. @confirm_window.openness = 0
  316. @confirm_window.close
  317. @confirm_window.set_handler(:enter, method(:enter_stage))
  318. @confirm_window.set_handler(:cancel, method(:cancel_window))
  319. @confirm_window.set_handler(:exit, method(:return_scene))
  320. corret_cursor_position
  321. end
  322. #-------------------------------------------------------------------------
  323. # * new method: enter_stage
  324. #-------------------------------------------------------------------------
  325. def cancel_window
  326. @confirm_window.deactivate
  327. @confirm_window.close
  328. while @sprite_black.opacity > 0
  329. @confirm_window.update
  330. @sprite_black.opacity -= 10
  331. Graphics.update
  332. end
  333. @disable_cursor = false
  334. end
  335. #-------------------------------------------------------------------------
  336. # * new method: enter_stage
  337. #-------------------------------------------------------------------------
  338. def enter_stage
  339. common_ev_id = PHASES[@phase_id][:Bosses][@cursor_index+1][:common_ev_id]
  340. $game_temp.reserve_common_event(common_ev_id)
  341. return_scene
  342. end
  343. #-------------------------------------------------------------------------
  344. # * new method: play_cursor_sound
  345. #-------------------------------------------------------------------------
  346. def play_cursor_sound
  347. RPG::SE.new(*CURSOR_SE).play
  348. end
  349. #-------------------------------------------------------------------------
  350. # * new method: corret_cursor_position
  351. #-------------------------------------------------------------------------
  352. def corret_cursor_position
  353. return if @boss_boxes[@cursor_index].nil?
  354. @cursor_sprite.x = @boss_boxes[@cursor_index].x - 7
  355. @cursor_sprite.y = @boss_boxes[@cursor_index].y - 7
  356. @info_window.draw_info(@boss_boxes[@cursor_index])
  357. end
  358. #-------------------------------------------------------------------------
  359. # * new method: play_scene_bgm
  360. #-------------------------------------------------------------------------
  361. def play_scene_bgm
  362. $game_system.save_bgm
  363. bgm_array = PHASES[@phase_id][:BGM]
  364. RPG::BGM.new(*bgm_array).play
  365. end
  366. #-------------------------------------------------------------------------
  367. # * new method: stop_scene_bgm
  368. #-------------------------------------------------------------------------
  369. def stop_scene_bgm
  370. RPG::BGM.stop
  371. $game_system.replay_bgm
  372. end
  373. #--------------------------------------------------------------------------
  374. # * Create Background
  375. #--------------------------------------------------------------------------
  376. def create_background
  377. background_name = PHASES[@phase_id][:background]
  378. @background_sprite = Sprite.new
  379. @background_sprite.bitmap = Cache.boss(background_name)
  380. end
  381. #--------------------------------------------------------------------------
  382. # * Free Background
  383. #--------------------------------------------------------------------------
  384. def dispose_background
  385. @background_sprite.dispose
  386. end
  387. #-------------------------------------------------------------------------
  388. # * new method: update
  389. #-------------------------------------------------------------------------
  390. def update
  391. super
  392. if Input.repeat?(:RIGHT) && !@disable_cursor
  393. @cursor_index += 1
  394. if @cursor_index >= @boss_boxes.size
  395. @cursor_index = 0
  396. end
  397. play_cursor_sound
  398. corret_cursor_position
  399. end
  400. if Input.repeat?(:LEFT) && !@disable_cursor
  401. @cursor_index -= 1
  402. if @cursor_index < 0
  403. @cursor_index = @boss_boxes.size - 1
  404. end
  405. play_cursor_sound
  406. corret_cursor_position
  407. end
  408. if @boss_num > 4
  409. if Input.repeat?(:UP) && !@disable_cursor
  410. if @cursor_index >= 4
  411. @cursor_index -= 4
  412. if @cursor_index <= 0
  413. @cursor_index = 0
  414. end
  415. else
  416. @cursor_index += 4
  417. if @cursor_index >= @boss_boxes.size
  418. @cursor_index = @boss_boxes.size - 1
  419. end
  420. end
  421. play_cursor_sound
  422. corret_cursor_position
  423. end
  424. if Input.repeat?(:DOWN) && !@disable_cursor
  425. if @cursor_index >= 4
  426. @cursor_index -= 4
  427. if @cursor_index <= 0
  428. @cursor_index = 0
  429. end
  430. else
  431. @cursor_index += 4
  432. if @cursor_index >= @boss_boxes.size
  433. @cursor_index = @boss_boxes.size - 1
  434. end
  435. end
  436. play_cursor_sound
  437. corret_cursor_position
  438. end
  439. end
  440. if Input.trigger?(:C)
  441. if @boss_boxes[@cursor_index].is_defeated?
  442. Sound.play_buzzer
  443. return
  444. end
  445. return if @confirm_window.active
  446. while @sprite_black.opacity < 120
  447. @sprite_black.opacity += 10
  448. Graphics.update
  449. end
  450. @disable_cursor = true
  451. @confirm_window.open
  452. @confirm_window.activate
  453. end
  454. if Input.trigger?(:B) && !@disable_cursor
  455. return_scene
  456. end
  457. end
  458. #-------------------------------------------------------------------------
  459. # * new method: terminate
  460. #-------------------------------------------------------------------------
  461. def terminate
  462. super
  463. stop_scene_bgm
  464. dispose_background
  465. @sprite_black.bitmap.dispose
  466. @sprite_black.dispose
  467. @cursor_sprite.bitmap.dispose
  468. @cursor_sprite.dispose
  469. @sprite_boss_name.bitmap.dispose
  470. @sprite_boss_name.dispose
  471. @boss_boxes.each do |boss|
  472. boss.dispose
  473. end
  474. end
  475. end # Scene_BossSelect
  476.  
  477. class Boss_Info_Window < Window_Base
  478. #-------------------------------------------------------------------------
  479. # * new method: draw_info
  480. #-------------------------------------------------------------------------
  481. def draw_info(boss_data)
  482. contents.clear
  483. x = 0; y = 0
  484. if boss_data.is_defeated?
  485. draw_text(0,0,contents_width,contents_height,"- Defeated -",1)
  486. return
  487. end
  488. draw_text_ex(x,y,"\\i[495]\\c[5] Name:\\c[0] " + boss_data.name)
  489. x = contents_width / 2
  490. draw_text_ex(x,y,"\\i[2824]\\c[5] Location:\\c[0] " + boss_data.location)
  491. des_bitmap = Bitmap.new(contents_width,contents_height - 24)
  492. des_bitmap.turn_on_wordwraping
  493. des_bitmap.draw_text_ex(0,0,"\\i[2804]\\c[5] Description:\\c[0] " + boss_data.desc, false)
  494. y += 24; x = 0
  495. contents.blt(x,y,des_bitmap,des_bitmap.rect)
  496. end
  497. end # Boss_Info_Window
  498.  
  499. class Boss_Confirm_Window < Window_Command
  500. #-------------------------------------------------------------------------
  501. # * new method: window_width
  502. #-------------------------------------------------------------------------
  503. def window_width
  504. return 200
  505. end
  506. #-------------------------------------------------------------------------
  507. # * new method: make_command_list
  508. #-------------------------------------------------------------------------
  509. def make_command_list
  510. add_command("Enter this stage", :enter)
  511. add_command("Back to select", :cancel)
  512. add_command("Exit", :exit)
  513. end
  514. end # Boss_Confirm_Window
  515. #===============================================================================
  516. # * END OF THE SCRIPT
  517. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement