Advertisement
dsiver144

Untitled

Jul 22nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.90 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. @sprite_boss_name.bitmap.draw_text(x,y + 80,76,24,boss.name,1)
  262. end
  263. end
  264. else
  265. @row_y = 130
  266. @total_width = @box_width*@boss_num + @box_space*(@boss_num-1)
  267. @row_x = 0.5*(Graphics.width - @total_width)
  268. for i in 1..@boss_num
  269. x = @row_x + (@box_space+@box_width)*(i-1) + @offset
  270. y = @row_y
  271. data = PHASES[@phase_id][:Bosses][i]
  272. boss = BossSquare.new(x,y,data,i,@phase_id)
  273. @boss_boxes << boss
  274. end
  275. end
  276. end
  277. #--------------------------------------------------------------------------
  278. # * new method: start
  279. #--------------------------------------------------------------------------
  280. def start
  281. super
  282. create_background
  283. play_scene_bgm
  284. create_main_windows
  285. end
  286. #--------------------------------------------------------------------------
  287. # * new method: create_main_windows
  288. #--------------------------------------------------------------------------
  289. def create_main_windows
  290. @dummy_window = Window_Base.new(0,0,200,46)
  291. cw = @dummy_window.contents_width; ch = @dummy_window.contents_height
  292. @dummy_window.draw_text(0,0,cw,ch,"Boss Select",1)
  293. @dummy_window.x = 0.5*(Graphics.width - @dummy_window.width)
  294. @dummy_window.y = 10
  295. @info_window = Boss_Info_Window.new(0,0,Graphics.width - 10,117 - 10)
  296. @info_window.y = Graphics.height - 117 + 10 - 5
  297. @info_window.x = 0.5*(Graphics.width - @info_window.width)
  298. calculate_square_position
  299. @cursor_sprite = Sprite.new
  300. @cursor_sprite.bitmap = Cache.boss("Cursor")
  301. @cursor_index = 0
  302. @confirm_window = Boss_Confirm_Window.new(0,0)
  303. @sprite_black = Sprite.new
  304. @sprite_black.z = 250
  305. @sprite_black.opacity = 0
  306. @sprite_black.bitmap = Bitmap.new(Graphics.width,Graphics.height)
  307. @sprite_black.bitmap.fill_rect(@sprite_black.bitmap.rect, Color.new(0,0,0))
  308. @confirm_window.x = (Graphics.width - @confirm_window.width)*0.5
  309. @confirm_window.y = (Graphics.height - @confirm_window.height)*0.5
  310. @confirm_window.z = 300
  311. @confirm_window.deactivate
  312. @confirm_window.openness = 0
  313. @confirm_window.close
  314. @confirm_window.set_handler(:enter, method(:enter_stage))
  315. @confirm_window.set_handler(:cancel, method(:cancel_window))
  316. @confirm_window.set_handler(:exit, method(:return_scene))
  317. corret_cursor_position
  318. end
  319. #-------------------------------------------------------------------------
  320. # * new method: enter_stage
  321. #-------------------------------------------------------------------------
  322. def cancel_window
  323. @confirm_window.deactivate
  324. @confirm_window.close
  325. while @sprite_black.opacity > 0
  326. @confirm_window.update
  327. @sprite_black.opacity -= 10
  328. Graphics.update
  329. end
  330. @disable_cursor = false
  331. end
  332. #-------------------------------------------------------------------------
  333. # * new method: enter_stage
  334. #-------------------------------------------------------------------------
  335. def enter_stage
  336. common_ev_id = PHASES[@phase_id][:Bosses][@cursor_index+1][:common_ev_id]
  337. $game_temp.reserve_common_event(common_ev_id)
  338. return_scene
  339. end
  340. #-------------------------------------------------------------------------
  341. # * new method: play_cursor_sound
  342. #-------------------------------------------------------------------------
  343. def play_cursor_sound
  344. RPG::SE.new(*CURSOR_SE).play
  345. end
  346. #-------------------------------------------------------------------------
  347. # * new method: corret_cursor_position
  348. #-------------------------------------------------------------------------
  349. def corret_cursor_position
  350. return if @boss_boxes[@cursor_index].nil?
  351. @cursor_sprite.x = @boss_boxes[@cursor_index].x - 7
  352. @cursor_sprite.y = @boss_boxes[@cursor_index].y - 7
  353. @info_window.draw_info(@boss_boxes[@cursor_index])
  354. end
  355. #-------------------------------------------------------------------------
  356. # * new method: play_scene_bgm
  357. #-------------------------------------------------------------------------
  358. def play_scene_bgm
  359. $game_system.save_bgm
  360. bgm_array = PHASES[@phase_id][:BGM]
  361. RPG::BGM.new(*bgm_array).play
  362. end
  363. #-------------------------------------------------------------------------
  364. # * new method: stop_scene_bgm
  365. #-------------------------------------------------------------------------
  366. def stop_scene_bgm
  367. RPG::BGM.stop
  368. $game_system.replay_bgm
  369. end
  370. #--------------------------------------------------------------------------
  371. # * Create Background
  372. #--------------------------------------------------------------------------
  373. def create_background
  374. background_name = PHASES[@phase_id][:background]
  375. @background_sprite = Sprite.new
  376. @background_sprite.bitmap = Cache.boss(background_name)
  377. end
  378. #--------------------------------------------------------------------------
  379. # * Free Background
  380. #--------------------------------------------------------------------------
  381. def dispose_background
  382. @background_sprite.dispose
  383. end
  384. #-------------------------------------------------------------------------
  385. # * new method: update
  386. #-------------------------------------------------------------------------
  387. def update
  388. super
  389. if Input.repeat?(:RIGHT) && !@disable_cursor
  390. @cursor_index += 1
  391. if @cursor_index >= @boss_boxes.size
  392. @cursor_index = 0
  393. end
  394. play_cursor_sound
  395. corret_cursor_position
  396. end
  397. if Input.repeat?(:LEFT) && !@disable_cursor
  398. @cursor_index -= 1
  399. if @cursor_index < 0
  400. @cursor_index = @boss_boxes.size - 1
  401. end
  402. play_cursor_sound
  403. corret_cursor_position
  404. end
  405. if @boss_num > 4
  406. if Input.repeat?(:UP) && !@disable_cursor
  407. if @cursor_index >= 4
  408. @cursor_index -= 4
  409. if @cursor_index <= 0
  410. @cursor_index = 0
  411. end
  412. else
  413. @cursor_index += 4
  414. if @cursor_index >= @boss_boxes.size
  415. @cursor_index = @boss_boxes.size - 1
  416. end
  417. end
  418. play_cursor_sound
  419. corret_cursor_position
  420. end
  421. if Input.repeat?(:DOWN) && !@disable_cursor
  422. if @cursor_index >= 4
  423. @cursor_index -= 4
  424. if @cursor_index <= 0
  425. @cursor_index = 0
  426. end
  427. else
  428. @cursor_index += 4
  429. if @cursor_index >= @boss_boxes.size
  430. @cursor_index = @boss_boxes.size - 1
  431. end
  432. end
  433. play_cursor_sound
  434. corret_cursor_position
  435. end
  436. end
  437. if Input.trigger?(:C)
  438. if @boss_boxes[@cursor_index].is_defeated?
  439. Sound.play_buzzer
  440. return
  441. end
  442. return if @confirm_window.active
  443. while @sprite_black.opacity < 120
  444. @sprite_black.opacity += 10
  445. Graphics.update
  446. end
  447. @disable_cursor = true
  448. @confirm_window.open
  449. @confirm_window.activate
  450. end
  451. if Input.trigger?(:B) && !@disable_cursor
  452. return_scene
  453. end
  454. end
  455. #-------------------------------------------------------------------------
  456. # * new method: terminate
  457. #-------------------------------------------------------------------------
  458. def terminate
  459. super
  460. stop_scene_bgm
  461. dispose_background
  462. @sprite_black.bitmap.dispose
  463. @sprite_black.dispose
  464. @cursor_sprite.bitmap.dispose
  465. @cursor_sprite.dispose
  466. @sprite_boss_name.bitmap.dispose
  467. @sprite_boss_name.dispose
  468. @boss_boxes.each do |boss|
  469. boss.dispose
  470. end
  471. end
  472. end # Scene_BossSelect
  473.  
  474. class Boss_Info_Window < Window_Base
  475. #-------------------------------------------------------------------------
  476. # * new method: draw_info
  477. #-------------------------------------------------------------------------
  478. def draw_info(boss_data)
  479. contents.clear
  480. x = 0; y = 0
  481. if boss_data.is_defeated?
  482. draw_text(0,0,contents_width,contents_height,"- Defeated -",1)
  483. return
  484. end
  485. draw_text_ex(x,y,"\\i[495]\\c[5] Name:\\c[0] " + boss_data.name)
  486. x = contents_width / 2
  487. draw_text_ex(x,y,"\\i[2824]\\c[5] Location:\\c[0] " + boss_data.location)
  488. des_bitmap = Bitmap.new(contents_width,contents_height - 24)
  489. des_bitmap.turn_on_wordwraping
  490. des_bitmap.draw_text_ex(0,0,"\\i[2804]\\c[5] Description:\\c[0] " + boss_data.desc, false)
  491. y += 24; x = 0
  492. contents.blt(x,y,des_bitmap,des_bitmap.rect)
  493. end
  494. end # Boss_Info_Window
  495.  
  496. class Boss_Confirm_Window < Window_Command
  497. #-------------------------------------------------------------------------
  498. # * new method: window_width
  499. #-------------------------------------------------------------------------
  500. def window_width
  501. return 200
  502. end
  503. #-------------------------------------------------------------------------
  504. # * new method: make_command_list
  505. #-------------------------------------------------------------------------
  506. def make_command_list
  507. add_command("Enter this stage", :enter)
  508. add_command("Back to select", :cancel)
  509. add_command("Exit", :exit)
  510. end
  511. end # Boss_Confirm_Window
  512. #===============================================================================
  513. # * END OF THE SCRIPT
  514. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement