Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Window_SkillBattle
- #------------------------------------------------------------------------------
- # This window displays usable skills on the skill and battle screens.
- #==============================================================================
- class Window_SkillBattle < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- # actor : actor
- #--------------------------------------------------------------------------
- def initialize(actor)
- super(0, 128, 640, 352)
- @actor = actor
- @column_max = 2
- refresh
- self.index = 0
- # If in battle, move window to center of screen
- # and make it semi-transparent
- if $game_temp.in_battle
- self.y = 64
- self.height = 256
- self.back_opacity = 160
- end
- end
- #--------------------------------------------------------------------------
- # * Acquiring Skill
- #--------------------------------------------------------------------------
- def skill
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh(actor=nil)
- if actor != nil
- @actor = actor
- end
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- for i in 0...@actor.skills.size
- skill = $data_skills[@actor.skills[i]]
- if skill != nil
- @data.push(skill)
- end
- end
- # If item count is not 0, make a bit map and draw all items
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- self.get_column_width(width - 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- # index : item number
- #--------------------------------------------------------------------------
- def draw_item(index)
- skill = @data[index]
- if @actor.skill_can_use?(skill.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4 + index % 2 * (288 + 32)
- y = index / 2 * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(skill.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
- self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # * Help Text Update
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.skill == nil ? "" : self.skill.description)
- end
- end
- #==============================================================================
- # ■ Window_SkillBattle
- #==============================================================================
- class Window_SkillBattle < Window_Selectable
- #--------------------------------------------------------------------------
- def initialize(actor)
- @actor = actor
- initialize_scroll if !$game_temp.in_battle
- super(0, 128, 640, 352)
- @actor = actor
- @column_max = 2
- get_column_width if !$game_temp.in_battle
- @thin = $game_temp.in_battle ? 0 : 32#38
- @decrease = $game_temp.in_battle ? 0 : 20
- @move_x_right = $game_temp.in_battle ? 0 : -3
- @sld = $game_temp.in_battle ? false : true
- @actor = $game_party.actors[@actor] if @actor.is_a?(Fixnum)
- self.index = 0
- if $game_temp.in_battle
- self.y = 320
- self.height = 160
- self.z = 2100
- self.back_opacity = MENU_OPACITY
- else
- # SLD
- self.x = 54
- self.y = 103 - 16
- self.width = 520
- self.height = 290
- self.back_opacity = 0
- self.opacity = 0
- end
- refresh
- end
- def initialize_scroll
- @scrolling = true # just saying to the script that there'll be scrolling
- @scroll_x = 550 # where the scroll should be horizontally (note that you CAN'T use self.x, as it's not specified yet)
- @scroll_y = 105 # where the scroll should be vertically (note that you CAN'T use self.y, as it's not specified yet)
- @scroll_width = 24 # the scroll's width. if going vertically, you still need to specify the width, which is the width of the scroll's images. Otherwise, it should be self.width - 32 (but don't use self.width, not specified)
- @scroll_height = 255 # the scroll's height. if going horizontally, you still need to specify the height, which is the height of the scroll's images. Otherwise, it should be self.height - 32 (but don't use self.height, not specified)
- @scroll_dir = :ver # :hor => horizontally, :ver => vertically
- @scroll_max_size = 452 # this is used so that the scroll understands how many pixels there are to scroll. Use the width (or height if going vertically) of the window's bitmap (self.contents). Not specified yet, so don't use the bitmap directly!
- @scroll_row_max = @actor.skills.size / 2 - 7 # this sets the number of scrolls there are. If you put 5 for example, you'll have 4 clicks to do to get from the first items to the last ones. I suggest going like this:
- # if you go horizontally, take (not directly, not specified yet!) @column_max, and substract the number of columns shown in one page - 1.
- # Example : @column_max = 12, @column_width = 50, window's width = 200. I'll see 4 items per page, so: 12 - (4 - 1) = 9.
- # Same thing when you go vertically, except you'll use self.row_max (which is @item_max / @column_max) instead (not directly, again!). May not be very clear at first, but you'll figure this out! o/
- @scroll_z = 200 # the z value of the scroll.
- end
- #--------------------------------------------------------------------------
- def draw_item(index)
- skill = @data[index]
- if @actor.skill_can_use?(skill.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- if !@sld
- x = 4 + index % 2 * (288 + 32)
- y = index / 2 * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(skill.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
- cost = @actor.calc_sp_cost(@actor, skill)
- self.contents.draw_text(x + 232, y, 48, 32, cost.to_s, 2)
- else
- x = 4 + index % 2 * 257
- y = index / 2 * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(skill.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.font.size = $fontsize2
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 200, 32, skill.name, 0)
- cost = @actor.calc_sp_cost(@actor, skill)
- self.contents.draw_text(x + 175, y, 50, 32, cost.to_s, 2)
- end
- end
- end
- #==============================================================================
- # ** Window_SkillStatus
- #------------------------------------------------------------------------------
- # This window displays the skill user's status on the skill screen.
- #==============================================================================
- class Window_SkillStatusHUD < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- # actor : actor
- #--------------------------------------------------------------------------
- def initialize(actor)
- super(0, 64, 520, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.size = $fontsize
- x = 6
- draw_actor_name(@actor, x, 0)
- x += 100
- draw_actor_state(@actor, x, 2)
- x += 70
- draw_bar(@actor, x + 63, 0, 75, 16, @actor.hp, @actor.maxhp, text_color(12))
- draw_actor_hp(@actor, x, -1, 140)
- x += 160
- draw_bar(@actor, x + 63, 0, 75, 16, @actor.sp, @actor.maxsp, text_color(13))
- draw_actor_sp(@actor, x, -1, 140)
- end
- end
- #==============================================================================
- # ** Window_ReverseSkill
- #==============================================================================
- class Window_Skill
- #--------------------------------------------------------------------------
- Window_BG = 'Background'
- #--------------------------------------------------------------------------
- def initialize(actor)#_index)
- @disposed = false
- #@actor_index = actor_index
- @actor = $game_party.actors[actor]
- #@actor = actor
- create_windows
- @started = 0
- end
- #--------------------------------------------------------------------------
- def create_windows
- @hud = Sprite.new
- @hud.bitmap = RPG::Cache.picture("Window_Skill/"+Window_BG)
- #@name_window = Window_ActorName.new(@actor)
- @skill_list = Window_SkillBattle.new(@actor)#Window_ReverseSkillList.new(@actor)
- @help_window = Window_Help.new(54,356,510,66)
- @help_window.opacity = 0
- #@help_window.x = 54
- #@help_window.y = @help_window.y + 356
- #@help_window.width = 510
- #@help_window.height = 66
- @skill_list.help_window = @help_window
- @status_window = Window_SkillStatusHUD.new(@actor)
- @status_window.opacity = 0
- @status_window.x = 58
- @status_window.y = @status_window.y - 18
- end
- #--------------------------------------------------------------------------
- def initialize_popup(style)
- img = RPG::Cache.picture("Window_ReverseSkill/BackgroundPopup")
- @popup = Window_Popup.new(img)
- @counting = [0,50]
- if style == :question
- @popup.set_main(["Do you really want to","reverse this skill?"])
- @popup.set_choice(0, "Yes")
- @popup.set_choice(1, "No")
- @popup.index = 1
- else
- @popup.set_main(["You reversed the skill into","a Clean Scroll and Magic Orb!"])
- @popup.set_choice(0, "OK")
- @popup.index = 0
- end
- update_popup
- end
- #--------------------------------------------------------------------------
- def update
- return if @disposed
- $game_player.prevent_movement_with_mouse = true
- $game_player.prevent_movement = true
- if @popup
- update_popup
- return
- end
- @skill_list.update
- @help_window.update
- @status_window.update
- @started += 1
- return if @started < 5
- update_input
- end
- #--------------------------------------------------------------------------
- def update_input
- if Keys.trigger?(:B) || Mouse.trigger?(1)
- $game_system.se_play($data_system.cancel_se)
- #$game_temp.freeze_save_call = true
- #self.dispose
- HUD.close_window
- elsif Keys.trigger?(:C) || Mouse.trigger?(0)
- # Get currently selected data on the skill window
- @skill = @skill_list.skill
- # If unable to use
- if @skill == nil or not @actor.skill_can_use?(@skill.id)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # If effect scope is ally
- if @skill.scope >= 3
- # Activate target window
- @skill_list.active = false
- #@target_window.x = (@skill_list.index + 1) % 2 * 304
- #@target_window.visible = true
- #@target_window.active = true
- # Set cursor position to effect scope (single / all)
- #if @skill.scope == 4 || @skill.scope == 6
- # @target_window.index = -1
- #elsif @skill.scope == 7
- # @target_window.index = @actor_index - 10
- #else
- # @target_window.index = 0
- #end
- HUD.start_select(:actors, [0, ["Window_Skill.new", :window],
- ["Window_Skill.new", :skill_use]])
- # If effect scope is other than ally
- else
- # If common event ID is valid
- if @skill.common_event_id > 0
- # Common event call reservation
- $game_temp.common_event_id = @skill.common_event_id
- # Play use skill SE
- $game_system.se_play(@skill.menu_se)
- # Use up SP
- @actor.sp -= @skill.sp_cost
- # Remake each window content
- @status_window.refresh
- @skill_list.refresh
- #@target_window.refresh
- # Switch to map screen
- $scene = Scene_Map.new
- return
- end
- end
- return
- #skill = @skill_list.skill
- #if skill.nil?
- # $game_system.se_play($data_system.buzzer_se)
- # return
- #end
- #$game_system.se_play($data_system.decision_se)
- #initialize_popup(:question)
- # If R button was pressed
- # If R button was pressed
- elsif Keys.trigger?(:R)
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se)
- # To next actor
- @actor_index += 1
- @actor_index %= $game_party.actors.size
- @actor = $game_party.actors[actor_index]
- # Switch to different skill screen
- @skill_list.refresh(@actor)
- return
- # If L button was pressed
- elsif Keys.trigger?(:L)
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se)
- # To previous actor
- @actor_index += $game_party.actors.size - 1
- @actor_index %= $game_party.actors.size
- @actor = $game_party.actors[actor_index]
- # Switch to different skill screen
- @skill_list.refresh(@actor)
- return
- end
- end
- #--------------------------------------------------------------------------
- def update_popup
- @popup.update
- if @popup.main != ["Do you really want to","reverse this skill?"]
- @counting[0] += 1
- if @counting[0] >= @counting[1]
- dispose_popup
- @started = 0
- return
- end
- end
- case @popup.decision
- when 0
- if @popup.main == ["Do you really want to","reverse this skill?"]
- $game_system.se_play(($data_system.decision_se))
- skill = @skill_list.skill
- @actor.forget_skill(skill.id)
- $game_party.gain_item(49, 1)
- $game_party.gain_item(50, 1)
- @skill_list.refresh
- dispose_popup
- initialize_popup(:reversed)
- else
- $game_system.se_play($data_system.decision_se)
- dispose_popup
- end
- @started = 0
- when 1, -1
- $game_system.se_play($data_system.cancel_se)
- dispose_popup
- @started = 0
- end
- end
- #--------------------------------------------------------------------------
- def dispose_popup
- @popup.dispose unless @popup.nil?
- @popup = nil
- end
- #--------------------------------------------------------------------------
- def dispose
- @hud.dispose
- #HUD.main.reset_tone
- #@name_window.dispose
- @skill_list.dispose
- @help_window.dispose
- @status_window.dispose
- dispose_popup
- $game_player.prevent_movement_with_mouse = false
- $game_player.prevent_movement = false
- @disposed = true
- end
- #--------------------------------------------------------------------------
- def disposed?
- return @disposed
- end
- end
Add Comment
Please, Sign In to add comment