#===================================================# * Class New_Scene_Equip Begins#===================================================# This class performs equipment screen processing.#===================================================class New_Scene_Equip #-------------------------------------------------------------------------- # * Object Initialization # actor_index : actor index # equip_index : equipment index #-------------------------------------------------------------------------- def initialize(actor_index = 0, equip_index = 0) @actor_index = actor_index @equip_index = equip_index end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # Get actor @actor = $game_party.actors[@actor_index] # Make windows @help_window = Window_Help.new @left_window = New_Window_EquipLeft.new(@actor) @right_window = New_Window_EquipRight.new(@actor) @item_windows = [] (0..4).each {|i| @item_windows.push(New_Window_EquipItem.new(@actor, i))} @spriteset = Spriteset_Map.new # Associate help window @right_window.help_window = @help_window @item_windows.each {|win| win.help_window = @help_window} # Set menu opacity @help_window.opacity = Juan_Configuration::Menu_Opacity @left_window.opacity = Juan_Configuration::Menu_Opacity @right_window.opacity = Juan_Configuration::Menu_Opacity @item_windows.each_index {|i| @item_windows.opacity = Juan_Configuration::Menu_Opacity } # Set cursor position @right_window.index = @equip_index refresh # Execute transition Graphics.transition # Main loop loop { # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end } # Prepare for transition Graphics.freeze # Dispose of windows @help_window.dispose @left_window.dispose @right_window.dispose @item_windows.each {|win| win.dispose} @spriteset.dispose end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh # Set item windows to visible @item_windows.each_index {|i| @item_windows.visible = (@right_window.index == i) } # Get currently equipped item item1 = @right_window.item # Set current item window to @item_window case @right_window.index when 0 # @item_window = @item_window1 newmode = 0 when 1 # @item_window = @item_window3 newmode = 1 when 2 # @item_window = @item_window4 newmode = 1 when 3 # @item_window = @item_window4 newmode = 1 when 4 # @item_window = @item_window5 newmode = 1 end if newmode != @left_window.mode @left_window.mode = newmode @left_window.refresh end if @right_window.active @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil, '', '') end @item_window = @item_windows[@right_window.index] # If right window is active if @right_window.active # Erase parameters for after equipment change# @left_window.set_new_parameters(nil, nil, nil) @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil, '', '') end # If item window is active if @item_window.active item2 = @item_window.item last_hp = @actor.hp last_sp = @actor.sp old_atk = @actor.atk old_pdef = @actor.pdef old_mdef = @actor.mdef old_str = @actor.str old_dex = @actor.dex old_agi = @actor.agi old_int = @actor.int old_eva = @actor.eva @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id) new_atk = @actor.atk new_pdef = @actor.pdef new_mdef = @actor.mdef new_str = @actor.str new_dex = @actor.dex new_agi = @actor.agi new_int = @actor.int new_eva = @actor.eva @left_window.changes = [0, 0, 0, 0, 0, 0, 0, 0] if new_atk > old_atk @left_window.changes[0] = 1 end if new_atk < old_atk @left_window.changes[0] = -1 end if new_pdef > old_pdef @left_window.changes[1] = 1 end if new_pdef < old_pdef @left_window.changes[1] = -1 end if new_mdef > old_mdef @left_window.changes[2] = 1 end if new_mdef < old_mdef @left_window.changes[2] = -1 end if new_str > old_str @left_window.changes[3] = 1 end if new_str < old_str @left_window.changes[3] = -1 end if new_dex > old_dex @left_window.changes[4] = 1 end if new_dex < old_dex @left_window.changes[4] = -1 end if new_agi > old_agi @left_window.changes[5] = 1 end if new_agi < old_agi @left_window.changes[5] = -1 end if new_int > old_int @left_window.changes[6] = 1 end if new_int < old_int @left_window.changes[6] = -1 end if new_eva > old_eva @left_window.changes[7] = 1 end if new_eva < old_eva @left_window.changes[7] = -1 end elem_text = make_elem_text(item2) stat_text = make_stat_text(item2) @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id) @actor.hp = last_hp @actor.sp = last_sp @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, elem_text, stat_text) end end# --------------------------------def make_elem_text(item) text = '' flag = false if item.is_a?(RPG::Weapon) for i in item.element_set if flag text += ',' end text += $data_system.elements flag = true end end if item.is_a?(RPG::Armor) for i in item.guard_element_set if flag text += ',' end text += $data_system.elements flag = true end end return text end# --------------------------------def make_stat_text(item) text = '' flag = false if item.is_a?(RPG::Weapon) for i in item.plus_state_set if flag text += ',' end text += $data_states.name flag = true end end if item.is_a?(RPG::Armor) for i in item.guard_state_set if flag text += ', ' end text += $data_states.name flag = true end end return text end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update windows @left_window.update @right_window.update @item_window.update @spriteset.update refresh # If right window is active: call update_right if @right_window.active update_right # If item window is active: call update_item elsif @item_window.active update_item end end #-------------------------------------------------------------------------- # * Frame Update (when right window is active) #-------------------------------------------------------------------------- def update_right # If B button was pressed if Input.trigger?(Input:: # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to menu screen $scene = Scene_Menu.new(2) # If C button was pressed elsif Input.trigger?(Input::C) # If equipment is fixed if @actor.equip_fix?(@right_window.index) # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Activate item window @right_window.active = false @item_window.active = true @item_window.index = 0 # If R button was pressed elsif Input.trigger?(Input::R) # Play cursor SE $game_system.se_play($data_system.cursor_se) # To next actor @actor_index += 1 @actor_index %= $game_party.actors.size # Switch to different equipment screen $scene = New_Scene_Equip.new(@actor_index, @right_window.index) # If L button was pressed elsif Input.trigger?(Input::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 # Switch to different equipment screen $scene = New_Scene_Equip.new(@actor_index, @right_window.index) end end #-------------------------------------------------------------------------- # * Frame Update (when item window is active) #-------------------------------------------------------------------------- def update_item # If B button was pressed if Input.trigger?(Input:: # Play cancel SE $game_system.se_play($data_system.cancel_se) # Activate right window @right_window.active = true @item_window.active = false @item_window.index = -1 # If C button was pressed elsif Input.trigger?(Input::C) # Play equip SE $game_system.se_play($data_system.equip_se) # Get currently selected data on the item window item = @item_window.item # Change equipment @actor.equip(@right_window.index, item == nil ? 0 : item.id) # Activate right window @right_window.active = true @item_window.active = false @item_window.index = -1 # Remake right window and item window contents @right_window.refresh @item_window.refresh end endend#===================================================# * Class New_Scene_Equip Ends#===================================================#==============================================================================# ** Window_EquipLeft#------------------------------------------------------------------------------# This window displays actor parameter changes on the equipment screen.#==============================================================================class New_Window_EquipLeft < Window_Base # -------------------------------- attr_accessor :mode attr_accessor :changes # -------------------------------- #-------------------------------------------------------------------------- # * Object Initialization # actor : actor #-------------------------------------------------------------------------- def initialize(actor) super(0, 64, 272, 416) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = Juan_Configuration::Menu_Opacity self.z += Juan_Configuration::Menu_Z_Opacity @actor = actor @mode = 0 @changes = [0, 0, 0, 0, 0, 0, 0, 0] @elem_text = '' @stat_text = '' refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear draw_actor_name(@actor, 4, 0) draw_actor_level(@actor, 180, 0) (0..6).each {|i| draw_actor_parameter(@actor, 4, 32 + 32 * i, i)} if @mode == 0 self.contents.font.color = up_color self.contents.draw_text(4, 256, 200, 32, 'Elemental Attack:') self.contents.draw_text(4, 320, 200, 32, 'Status Attack:') elsif @mode == 1 self.contents.font.color = up_color self.contents.draw_text(4, 256, 200, 32, 'Elemental Defense:') self.contents.draw_text(4, 320, 200, 32, 'Status Defense:') end if @new_atk != nil self.contents.font.color = system_color self.contents.draw_text(160, 32, 40, 32, '»»', 1) if @changes[0] == 0 self.contents.font.color = normal_color elsif @changes[0] == -1 self.contents.font.color = down_color else self.contents.font.color = up_color end self.contents.draw_text(200, 32, 36, 32, @new_atk.to_s, 2) end if @new_pdef != nil self.contents.font.color = system_color self.contents.draw_text(160, 64, 40, 32, '»»', 1) if @changes[1] == 0 self.contents.font.color = normal_color elsif @changes[1] == -1 self.contents.font.color = down_color else self.contents.font.color = up_color end self.contents.draw_text(200, 64, 36, 32, @new_pdef.to_s, 2) end if @new_mdef != nil self.contents.font.color = system_color self.contents.draw_text(160, 96, 40, 32, '»»', 1) if @changes[2] == 0 self.contents.font.color = normal_color elsif @changes[2] == -1 self.contents.font.color = down_color else self.contents.font.color = up_color end self.contents.draw_text(200, 96, 36, 32, @new_mdef.to_s, 2) end if @new_str != nil self.contents.font.color = system_color self.contents.draw_text(160, 128, 40, 32, '»»', 1) if @changes[3] == 0 self.contents.font.color = normal_color elsif @changes[3] == -1 self.contents.font.color = down_color else self.contents.font.color = up_color end self.contents.draw_text(200, 128, 36, 32, @new_str.to_s, 2) end if @new_dex != nil self.contents.font.color = system_color self.contents.draw_text(160, 160, 40, 32, '»»', 1) if @changes[4] == 0 self.contents.font.color = normal_color elsif @changes[4] == -1 self.contents.font.color = down_color else self.contents.font.color = up_color end self.contents.draw_text(200, 160, 36, 32, @new_dex.to_s, 2) end if @new_agi != nil self.contents.font.color = system_color self.contents.draw_text(160, 192, 40, 32, '»»', 1) if @changes[5] == 0 self.contents.font.color = normal_color elsif @changes[5] == -1 self.contents.font.color = down_color else self.contents.font.color = up_color end self.contents.draw_text(200, 192, 36, 32, @new_agi.to_s, 2) end if @new_int != nil self.contents.font.color = system_color self.contents.draw_text(160, 224, 40, 32, '»»', 1) if @changes[6] == 0 self.contents.font.color = normal_color elsif @changes[6] == -1 self.contents.font.color = down_color else self.contents.font.color = up_color end self.contents.draw_text(200, 224, 36, 32, @new_int.to_s, 2) end end #-------------------------------------------------------------------------- # * Set parameters after changing equipment # new_atk : attack power after changing equipment # new_pdef : physical defense after changing equipment # new_mdef : magic defense after changing equipment #-------------------------------------------------------------------------- def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, elem_text, stat_text) flag = false if new_atk != @new_atk || new_pdef != @new_pdef || new_mdef != @new_mdef flag = true elsif new_str != @new_str || new_dex != @new_dex || new_agi != @new_agi flag = true elsif new_eva != @new_eva || elem_text != @elem_text || stat_text != @stat_text flag = true end @new_atk = new_atk @new_pdef = new_pdef @new_mdef = new_mdef @new_str = new_str @new_dex = new_dex @new_agi = new_agi @new_int = new_int @new_eva = new_eva @elem_text = elem_text @stat_text = stat_text if flag refresh end endend#==============================================================================# ** Window_EquipRight#------------------------------------------------------------------------------# This window displays items the actor is currently equipped with on the# equipment screen.#==============================================================================class New_Window_EquipRight < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization # actor : actor #-------------------------------------------------------------------------- def initialize(actor) super(272, 64, 368, 192) self.contents = Bitmap.new(width - 32, height - 32) @actor = actor refresh self.index = 0 end #-------------------------------------------------------------------------- # * Item Acquisition #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear @data = [] @data.push($data_weapons[@actor.weapon_id]) @data.push($data_armors[@actor.armor1_id]) @data.push($data_armors[@actor.armor2_id]) @data.push($data_armors[@actor.armor3_id]) @data.push($data_armors[@actor.armor4_id]) @item_max = @data.size self.contents.font.color = system_color self.contents.draw_text(4, 0, 92, 32, $data_system.words.weapon) self.contents.draw_text(4, 32, 92, 32, $data_system.words.armor1) self.contents.draw_text(4, 32, 92, 32, $data_system.words.armor2) self.contents.draw_text(4, 64, 92, 32, $data_system.words.armor3) self.contents.draw_text(5, 96, 92, 32, $data_system.words.armor4) @data.each_index {|i| draw_item_name(@data, 92, 32 * i)} end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? '' : self.item.description) endend#==============================================================================# ** Window_EquipItem#------------------------------------------------------------------------------# This window displays choices when opting to change equipment on the# equipment screen.#==============================================================================class New_Window_EquipItem < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization # actor : actor # equip_type : equip region (0-3) #-------------------------------------------------------------------------- def initialize(actor, equip_type) super(272, 256, 368, 224) @actor = actor @equip_type = equip_type @column_max = 1#2 refresh self.active = false self.index = -1 self.opacity = Juan_Configuration::Menu_Opacity self.z += Juan_Configuration::Menu_Z_Opacity end #-------------------------------------------------------------------------- # * Item Acquisition #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # Add equippable weapons if @equip_type == 0 weapon_set = $data_classes[@actor.class_id].weapon_set (1...$data_weapons.size).each {|i| if $game_party.weapon_number(i) > 0 && weapon_set.include?(i) @data.push($data_weapons) end } end # Add equippable armor if @equip_type != 0 armor_set = $data_classes[@actor.class_id].armor_set (1...$data_armors.size).each {|i| if $game_party.armor_number(i) > 0 && armor_set.include?(i) if $data_armors.kind == @equip_type-1 @data.push($data_armors) end end } end # Add blank page @data.push(nil) # Make a bit map and draw all items @item_max = @data.size self.contents = Bitmap.new(width - 32, row_max * 32) (0...@item_max-1).each {|i| draw_item(i)} s = @data.size-1 self.contents.draw_text(4, s*32, 100, 32, '[Unequip]') end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] # x = 4 + index % 2 * (288 + 32) # y = index / 2 * 32 x = 4 y = index * 32 case item when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.font.color = normal_color self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 288, y, 16, 32, ':', 1) self.contents.draw_text(x + 304, y, 24, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? '' : self.item.description) endend