Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI Boss Scene
- # -- Last Updated: 2017.07.22
- # -- Author: dsiver144
- # -- Level: Normal
- # -- Requires: n/a
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-BossScene"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.07.22 - Finish first version.
- #==============================================================================
- # + Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ?? Materials/?f?? but above ?? Main. Remember to save.
- # Put this below all of my scripts.
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Script Call:
- # + open_boss_scene(phase_id) -> Open Boss Scene with specific phase
- # + defeat_boss(phase_id,boss_id) -> call this when you defeat a boss of a phase
- # + boss_defeated?(phase_id,boss_id)
- # -> Check if a specific boss of a specific phase is defeated.
- #==============================================================================
- module DSIVER144
- module BOSS_SCENE
- CURSOR_SE = ["CursorFF7",70,100]
- GRAPHICS_PATH = "Graphics/Boss Graphics"
- PHASES = {} # Don't remove this line
- #------------------------------------------------------------------------
- # * [Phase 1] - Setup
- #------------------------------------------------------------------------
- # PHASE[phase_id]
- #------------------------------------------------------------------------
- PHASES[1] = {} # Don't remove this line
- PHASES[1][:background] = "BG1"
- PHASES[1][:BGM] = ["Field2",70,100]
- PHASES[1][:static_img] = "Static"
- PHASES[1][:Bosses] = {} # Don't remove this line
- PHASES[1][:Bosses][1] = {} # Don't remove this line
- PHASES[1][:Bosses][1][:name] = "Testboss1"
- PHASES[1][:Bosses][1][:face_img] = "TestFace"
- PHASES[1][:Bosses][1][:location] = "Unknown"
- PHASES[1][:Bosses][1][:desc] = "This is a test box description!"
- PHASES[1][:Bosses][1][:common_ev_id] = 256
- PHASES[1][:Bosses][2] = {} # Don't remove this line
- PHASES[1][:Bosses][2][:name] = "\\c[5]Treant"
- PHASES[1][:Bosses][2][:face_img] = "Treant Boss Face"
- PHASES[1][:Bosses][2][:location] = "Cursed Forest"
- PHASES[1][:Bosses][2][:desc] = "This is a test box description for \\c[5]Treant!\\c[10]"
- PHASES[1][:Bosses][2][:common_ev_id] = 257
- PHASES[1][:Bosses][3] = {} # Don't remove this line
- PHASES[1][:Bosses][3][:name] = "Testboss3"
- PHASES[1][:Bosses][3][:face_img] = "TestFace"
- PHASES[1][:Bosses][3][:location] = "Unknown3"
- PHASES[1][:Bosses][3][:desc] = "This is a test box description 3!"
- PHASES[1][:Bosses][3][:common_ev_id] = 258
- PHASES[1][:Bosses][4] = {} # Don't remove this line
- PHASES[1][:Bosses][4][:name] = "Testboss4"
- PHASES[1][:Bosses][4][:face_img] = "TestFace"
- PHASES[1][:Bosses][4][:location] = "Unknown4"
- PHASES[1][:Bosses][4][:desc] = "This is a test box description 4!"
- PHASES[1][:Bosses][4][:common_ev_id] = 259
- #~ PHASES[1][:Bosses][5] = {} # Don't remove this line
- #~ PHASES[1][:Bosses][5][:name] = "Testboss5"
- #~ PHASES[1][:Bosses][5][:face_img] = "TestFace"
- #~ PHASES[1][:Bosses][5][:location] = "Unknown5"
- #~ PHASES[1][:Bosses][5][:desc] = "This is a test box description 5 asdw wheuiahwie awheuiahwri awheuiahweia awehuiawnanwawe ra!"
- #~ PHASES[1][:Bosses][5][:common_ev_id] = 260
- #~ PHASES[1][:Bosses][6] = {} # Don't remove this line
- #~ PHASES[1][:Bosses][6][:name] = "Testboss5"
- #~ PHASES[1][:Bosses][6][:face_img] = "TestFace"
- #~ PHASES[1][:Bosses][6][:location] = "Unknown5"
- #~ PHASES[1][:Bosses][6][:desc] = "This is a test box description 5!"
- #~ PHASES[1][:Bosses][6][:common_ev_id] = 261
- #~ PHASES[1][:Bosses][7] = {} # Don't remove this line
- #~ PHASES[1][:Bosses][7][:name] = "Testboss5"
- #~ PHASES[1][:Bosses][7][:face_img] = "TestFace"
- #~ PHASES[1][:Bosses][7][:location] = "Unknown5"
- #~ PHASES[1][:Bosses][7][:desc] = "This is a test box description 5!"
- #~ PHASES[1][:Bosses][7][:common_ev_id] = 262
- #~ PHASES[1][:Bosses][8] = {} # Don't remove this line
- #~ PHASES[1][:Bosses][8][:name] = "Testboss5"
- #~ PHASES[1][:Bosses][8][:face_img] = "TestFace"
- #~ PHASES[1][:Bosses][8][:location] = "Unknown5"
- #~ PHASES[1][:Bosses][8][:desc] = "This is a test box description 5!"
- #~ PHASES[1][:Bosses][8][:common_ev_id] = 263
- #------------------------------------------------------------------------
- # * [Phase 1] - END
- #------------------------------------------------------------------------
- end
- end
- class Game_System
- attr_accessor :boss_phase
- alias_method(:dsi_init_boss_phase, :initialize)
- def initialize
- @boss_phase = {}
- DSIVER144::BOSS_SCENE::PHASES.each_pair do |phase_id,phase_data|
- @boss_phase[phase_id] = {}
- phase_data[:Bosses].each_key do |boss_id|
- @boss_phase[phase_id][boss_id] = false
- end
- end
- dsi_init_boss_phase
- end
- end # Game_System
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # * new method: open_boss_scene
- #--------------------------------------------------------------------------
- def open_boss_scene(phase)
- SceneManager.call(Scene_BossSelect)
- SceneManager.scene.prepare(phase)
- end
- #--------------------------------------------------------------------------
- # * new method: defeat_boss
- #--------------------------------------------------------------------------
- def defeat_boss(phase_id,boss_id)
- $game_system.boss_phase[phase_id][boss_id] = true
- end
- #--------------------------------------------------------------------------
- # * new method: boss_defeated?
- #--------------------------------------------------------------------------
- def boss_defeated?(phase_id,boss_id)
- return $game_system.boss_phase[phase_id][boss_id]
- end
- end # Game_Interpreter
- module Cache
- include DSIVER144::BOSS_SCENE
- #--------------------------------------------------------------------------
- # * Get Animation Graphic
- #--------------------------------------------------------------------------
- def self.boss(filename)
- load_bitmap(GRAPHICS_PATH + "/", filename)
- end
- end # Cache
- class BossSquare
- include DSIVER144::BOSS_SCENE
- #--------------------------------------------------------------------------
- # * new method: prepare
- #--------------------------------------------------------------------------
- def initialize(x,y,boss_data,boss_id,phase_id)
- @x = x
- @y = y
- @defeated = $game_system.boss_phase[phase_id][boss_id]
- @name = boss_data[:name]
- @location = boss_data[:location]
- @face_img = boss_data[:face_img]
- @desc = boss_data[:desc]
- @box_sprite = Sprite.new
- @box_sprite.bitmap = Cache.boss("Boss Square")
- @box_sprite.x = @x
- @box_sprite.y = @y
- @box_sprite.z = 10
- @box_image = Sprite.new
- if !@defeated
- @box_image.bitmap = Cache.boss(@face_img)
- else
- @box_image.bitmap = Cache.boss(PHASES[phase_id][:static_img])
- end
- @box_image.x = @x + 13
- @box_image.y = @y + 14
- @box_image.z = 12
- end
- #--------------------------------------------------------------------------
- # * new method: is_defeated?
- #--------------------------------------------------------------------------
- def is_defeated?
- return @defeated
- end
- #--------------------------------------------------------------------------
- # * new method: name
- #--------------------------------------------------------------------------
- def name
- return @name
- end
- #--------------------------------------------------------------------------
- # * new method: x
- #--------------------------------------------------------------------------
- def x
- return @x
- end
- #--------------------------------------------------------------------------
- # * new method: y
- #--------------------------------------------------------------------------
- def y
- return @y
- end
- #--------------------------------------------------------------------------
- # * new method: location
- #--------------------------------------------------------------------------
- def location
- return @location
- end
- #--------------------------------------------------------------------------
- # * new method: desc
- #--------------------------------------------------------------------------
- def desc
- return @desc
- end
- #--------------------------------------------------------------------------
- # * new method: dispose
- #--------------------------------------------------------------------------
- def dispose
- @box_sprite.dispose
- @box_image.dispose
- end
- end # BossSquare
- class Scene_BossSelect < Scene_Base
- include DSIVER144::BOSS_SCENE
- #--------------------------------------------------------------------------
- # * new method: prepare
- #--------------------------------------------------------------------------
- def prepare(phase)
- @phase_id = phase
- @boss_num = PHASES[@phase_id][:Bosses].size
- end
- #--------------------------------------------------------------------------
- # * new method: calculate_square_position
- #--------------------------------------------------------------------------
- def calculate_square_position
- @sprite_boss_name = Sprite.new
- @sprite_boss_name.bitmap = Bitmap.new(Graphics.width,Graphics.height)
- @sprite_boss_name.z = 5
- @sprite_boss_name.y = 0
- @boss_boxes = []
- @box_width = 76
- @box_space = 30
- @offset = 0#-10
- if @boss_num > 4
- @row1_y = 85
- @row2_y = 85 + 76 + 30
- @total_width = @box_width*4 + @box_space*3
- @row1_x = 0.5*(Graphics.width - @total_width)
- for i in 1..4
- x = @row1_x + (@box_space+@box_width)*(i-1) + @offset
- y = @row1_y
- data = PHASES[@phase_id][:Bosses][i]
- boss = BossSquare.new(x,y,data,i,@phase_id)
- @boss_boxes << boss
- text_offset = 0.5*(76 - @dummy_window.text_width_ex(boss.name))
- @sprite_boss_name.bitmap.draw_text_ex(x + text_offset,y + 80,boss.name)
- end
- remain = @boss_num - 4
- if remain > 0
- @total_width = @box_width*remain + @box_space*(remain-1)
- @row2_x = 0.5*(Graphics.width - @total_width).abs
- for i in 1..remain
- x = @row2_x + (@box_space+@box_width)*(i-1) + @offset
- y = @row2_y
- data = PHASES[@phase_id][:Bosses][i + 4]
- boss = BossSquare.new(x,y,data,i+4,@phase_id)
- @boss_boxes << boss
- text_offset = 0.5*(76 - @dummy_window.text_width_ex(boss.name))
- @sprite_boss_name.bitmap.draw_text_ex(x + text_offset,y + 80,boss.name)
- end
- end
- else
- @row_y = 130
- @total_width = @box_width*@boss_num + @box_space*(@boss_num-1)
- @row_x = 0.5*(Graphics.width - @total_width)
- for i in 1..@boss_num
- x = @row_x + (@box_space+@box_width)*(i-1) + @offset
- y = @row_y
- data = PHASES[@phase_id][:Bosses][i]
- boss = BossSquare.new(x,y,data,i,@phase_id)
- @boss_boxes << boss
- text_offset = 0.5*(76 - @dummy_window.text_width_ex(boss.name))
- @sprite_boss_name.bitmap.draw_text_ex(x + text_offset,y + 80,boss.name)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * new method: start
- #--------------------------------------------------------------------------
- def start
- super
- create_background
- play_scene_bgm
- create_main_windows
- end
- #--------------------------------------------------------------------------
- # * new method: create_main_windows
- #--------------------------------------------------------------------------
- def create_main_windows
- @dummy_window = Window_Base.new(0,0,200,46)
- cw = @dummy_window.contents_width; ch = @dummy_window.contents_height
- @dummy_window.draw_text(0,0,cw,ch,"Boss Select",1)
- @dummy_window.x = 0.5*(Graphics.width - @dummy_window.width)
- @dummy_window.y = 10
- @info_window = Boss_Info_Window.new(0,0,Graphics.width - 10,117 - 10)
- @info_window.y = Graphics.height - 117 + 10 - 5
- @info_window.x = 0.5*(Graphics.width - @info_window.width)
- calculate_square_position
- @cursor_sprite = Sprite.new
- @cursor_sprite.bitmap = Cache.boss("Cursor")
- @cursor_index = 0
- @confirm_window = Boss_Confirm_Window.new(0,0)
- @sprite_black = Sprite.new
- @sprite_black.z = 250
- @sprite_black.opacity = 0
- @sprite_black.bitmap = Bitmap.new(Graphics.width,Graphics.height)
- @sprite_black.bitmap.fill_rect(@sprite_black.bitmap.rect, Color.new(0,0,0))
- @confirm_window.x = (Graphics.width - @confirm_window.width)*0.5
- @confirm_window.y = (Graphics.height - @confirm_window.height)*0.5
- @confirm_window.z = 300
- @confirm_window.deactivate
- @confirm_window.openness = 0
- @confirm_window.close
- @confirm_window.set_handler(:enter, method(:enter_stage))
- @confirm_window.set_handler(:cancel, method(:cancel_window))
- @confirm_window.set_handler(:exit, method(:return_scene))
- corret_cursor_position
- end
- #-------------------------------------------------------------------------
- # * new method: enter_stage
- #-------------------------------------------------------------------------
- def cancel_window
- @confirm_window.deactivate
- @confirm_window.close
- while @sprite_black.opacity > 0
- @confirm_window.update
- @sprite_black.opacity -= 10
- Graphics.update
- end
- @disable_cursor = false
- end
- #-------------------------------------------------------------------------
- # * new method: enter_stage
- #-------------------------------------------------------------------------
- def enter_stage
- common_ev_id = PHASES[@phase_id][:Bosses][@cursor_index+1][:common_ev_id]
- $game_temp.reserve_common_event(common_ev_id)
- return_scene
- end
- #-------------------------------------------------------------------------
- # * new method: play_cursor_sound
- #-------------------------------------------------------------------------
- def play_cursor_sound
- RPG::SE.new(*CURSOR_SE).play
- end
- #-------------------------------------------------------------------------
- # * new method: corret_cursor_position
- #-------------------------------------------------------------------------
- def corret_cursor_position
- return if @boss_boxes[@cursor_index].nil?
- @cursor_sprite.x = @boss_boxes[@cursor_index].x - 7
- @cursor_sprite.y = @boss_boxes[@cursor_index].y - 7
- @info_window.draw_info(@boss_boxes[@cursor_index])
- end
- #-------------------------------------------------------------------------
- # * new method: play_scene_bgm
- #-------------------------------------------------------------------------
- def play_scene_bgm
- $game_system.save_bgm
- bgm_array = PHASES[@phase_id][:BGM]
- RPG::BGM.new(*bgm_array).play
- end
- #-------------------------------------------------------------------------
- # * new method: stop_scene_bgm
- #-------------------------------------------------------------------------
- def stop_scene_bgm
- RPG::BGM.stop
- $game_system.replay_bgm
- end
- #--------------------------------------------------------------------------
- # * Create Background
- #--------------------------------------------------------------------------
- def create_background
- background_name = PHASES[@phase_id][:background]
- @background_sprite = Sprite.new
- @background_sprite.bitmap = Cache.boss(background_name)
- end
- #--------------------------------------------------------------------------
- # * Free Background
- #--------------------------------------------------------------------------
- def dispose_background
- @background_sprite.dispose
- end
- #-------------------------------------------------------------------------
- # * new method: update
- #-------------------------------------------------------------------------
- def update
- super
- if Input.repeat?(:RIGHT) && !@disable_cursor
- @cursor_index += 1
- if @cursor_index >= @boss_boxes.size
- @cursor_index = 0
- end
- play_cursor_sound
- corret_cursor_position
- end
- if Input.repeat?(:LEFT) && !@disable_cursor
- @cursor_index -= 1
- if @cursor_index < 0
- @cursor_index = @boss_boxes.size - 1
- end
- play_cursor_sound
- corret_cursor_position
- end
- if @boss_num > 4
- if Input.repeat?(:UP) && !@disable_cursor
- if @cursor_index >= 4
- @cursor_index -= 4
- if @cursor_index <= 0
- @cursor_index = 0
- end
- else
- @cursor_index += 4
- if @cursor_index >= @boss_boxes.size
- @cursor_index = @boss_boxes.size - 1
- end
- end
- play_cursor_sound
- corret_cursor_position
- end
- if Input.repeat?(:DOWN) && !@disable_cursor
- if @cursor_index >= 4
- @cursor_index -= 4
- if @cursor_index <= 0
- @cursor_index = 0
- end
- else
- @cursor_index += 4
- if @cursor_index >= @boss_boxes.size
- @cursor_index = @boss_boxes.size - 1
- end
- end
- play_cursor_sound
- corret_cursor_position
- end
- end
- if Input.trigger?(:C)
- if @boss_boxes[@cursor_index].is_defeated?
- Sound.play_buzzer
- return
- end
- return if @confirm_window.active
- while @sprite_black.opacity < 120
- @sprite_black.opacity += 10
- Graphics.update
- end
- @disable_cursor = true
- @confirm_window.open
- @confirm_window.activate
- end
- if Input.trigger?(:B) && !@disable_cursor
- return_scene
- end
- end
- #-------------------------------------------------------------------------
- # * new method: terminate
- #-------------------------------------------------------------------------
- def terminate
- super
- stop_scene_bgm
- dispose_background
- @sprite_black.bitmap.dispose
- @sprite_black.dispose
- @cursor_sprite.bitmap.dispose
- @cursor_sprite.dispose
- @sprite_boss_name.bitmap.dispose
- @sprite_boss_name.dispose
- @boss_boxes.each do |boss|
- boss.dispose
- end
- end
- end # Scene_BossSelect
- class Boss_Info_Window < Window_Base
- #-------------------------------------------------------------------------
- # * new method: draw_info
- #-------------------------------------------------------------------------
- def draw_info(boss_data)
- contents.clear
- x = 0; y = 0
- if boss_data.is_defeated?
- draw_text(0,0,contents_width,contents_height,"- Defeated -",1)
- return
- end
- draw_text_ex(x,y,"\\i[495]\\c[5] Name:\\c[0] " + boss_data.name)
- x = contents_width / 2
- draw_text_ex(x,y,"\\i[2824]\\c[5] Location:\\c[0] " + boss_data.location)
- des_bitmap = Bitmap.new(contents_width,contents_height - 24)
- des_bitmap.turn_on_wordwraping
- des_bitmap.draw_text_ex(0,0,"\\i[2804]\\c[5] Description:\\c[0] " + boss_data.desc, false)
- y += 24; x = 0
- contents.blt(x,y,des_bitmap,des_bitmap.rect)
- end
- end # Boss_Info_Window
- class Boss_Confirm_Window < Window_Command
- #-------------------------------------------------------------------------
- # * new method: window_width
- #-------------------------------------------------------------------------
- def window_width
- return 200
- end
- #-------------------------------------------------------------------------
- # * new method: make_command_list
- #-------------------------------------------------------------------------
- def make_command_list
- add_command("Enter this stage", :enter)
- add_command("Back to select", :cancel)
- add_command("Exit", :exit)
- end
- end # Boss_Confirm_Window
- #===============================================================================
- # * END OF THE SCRIPT
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement