Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # ■ ACE Equipment System [RMXP]
- # ■ Author: Bigace360
- # ■ Version: 1.15
- # ■ Date: August 17, 2012
- # ■ Blog: http://bigaceworld.wordpress.com/
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # VERSION HISTORY #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # 08.17.2012 (v1.00) - Initial Release
- # 08.26.2012 (v1.11) - Improved Coding
- # - Added layout image
- # 01.23.2013 (v1.12) - Improved Coding
- # 05.12.2013 (v1.14) - Improved Coding
- # - Fiexed issue with the item window
- # 05.21.2013 (v1.15) - Compatibility with Scene_MenuBase to reduce lines and
- # increase compatibility with other ACMS scripts
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # INTRODUCTION #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # This script essentially redefines the way the equipment system works while
- # keeping the core without rewriting too much. This script changes the
- # equipment scene with a different layout and more efficient methods. Also adds
- # a command window that allows the player to choose from four diffenet
- # methods: Manual, Optimize, Optimize All, & Unequip All.
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # FEATURES #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # ● Manual - Equip and unequip equipment one at a time.
- # ● Optimize & Optimize all - Chooses the best equipment for the player
- # automatically
- # ● Unequip All - removes all equipment from the player
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # INSTRUCTIONS #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below Scene_Debug, and Warrior_Engine, but above Main.
- # Considering the special nature of this script, it is highly recommended that
- # you place this script above all non-core scripts, but below Warrior Engine,
- # Scene_Base, and ACE Scene_Menu. Remember to save.
- #
- # Scroll down and edit the module as you see fitting for your game.
- #
- #-------------------------------------------------------------------------------
- #
- # You can add custom layouts now, place your layout image within the Picture
- # folder. If you also have my ACE Menu Engine then place it in the Menu folder.
- #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # SECTIONS #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # ■ Modules
- # ** ACE Module
- #
- # ■ Game_Objects
- # ** Game_Temp
- # ** Game_Actor
- #
- # ■ Windows
- # ** Window_Base
- # ** Window_Selectable
- # ** Window_MenuHelp
- # ** Window_Item
- # ** Window_EquipLeft
- # ** Window_EquipRight
- # ** Window_EquipItem
- # ** Window_EquipActor
- # ** Window_Command_Base
- # ** Window_EquipCommand
- #
- # ■ Scenes
- # ** Scene_Item
- # ** Scene_Equip
- # ** Scene_Battle
- #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- #
- # Credits/Thanks:
- # - Bigace360, for the script.
- #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # Script Conflicts and Compatability #
- #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
- # Compatibility
- # Requires the script 'Scene_Base' v1.5 or higher
- # Requires the script 'Scene_MenuBase' v1.00 or higher
- #
- # ● Alias methods
- # class Game_Temp
- # def initialize
- #
- # class Window_Base
- # def initialize(*args)
- #
- # ● Overwrite methods
- # class Window_EquipLeft
- # Has been completely overwritten. Expect no functionality with any scripts
- # that will also replace Window_EquipLeft.
- #
- # class Window_EquipRight
- # Has been completely overwritten. Expect no functionality with any scripts
- # that will also replace Window_EquipRight.
- #
- # class Window_EquipItem
- # Has been completely overwritten. Expect no functionality with any scripts
- # that will also replace Window_EquipItem.
- #
- # class Scene_Equip
- # Has been completely overwritten. Expect no functionality with any scripts
- # that will also replace Scene_Equip.
- #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Module ACE::CORE
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- module ACE
- module CORE
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ◆ Section I. General Menu Settings ◆
- # -------------------------------------------------------------------------
- # This changes the way Menus appear in your game. You can change their
- # alignment, and the location of the help window, Note that any non-ACE
- # System scripts may not conform to these Menu styles.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- EQUIP_CONFIG ={
- # :equip_win => [Opacity, Window Border?]. (Opacity Limit: 0~255)
- :equip_win => [200, false],
- # :background - Background images
- :background => 'back04',
- # :menu_index - If :menu_access is true, then this value determines where
- # in the menu command window it is inserted.
- :menu_index => 2,
- # :layout - Image filename for window layout, must be in the Menu folder
- :layout => '',
- }
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ◆ Section II. Main Settings ◆
- # -------------------------------------------------------------------------
- # This section adjusts the commands that appear in the command window used
- # for the status screen. Rearrange the commands, add new ones, remove them
- # as you see fit.
- #
- # -------------------------------------------------------------------------
- # :command Description
- # -------------------------------------------------------------------------
- # :manual Activates the manual equip window.
- # :optimize Optimizes one equipment slot for the actor.
- # :optimize_all Optimizes all equipment slots for the actor.
- # :remove_all Clears all equipment from the actor.
- # :aptitude Enter aptitude attuning menu.
- #
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # This array arranges the order of which the commands appear in the Equip
- # Command window in the Equip Scene.
- EQUIP_COMMAND =[ # Do not remove this.
- [:manual, 'Equip'],
- [:optimize, 'Optimize'],
- [:optimize_all, 'Optimize-All'],
- [:remove_all, 'Clear'],
- ] # Do not remove this.
- # This hash allows you change the name of the command and its description.
- EQUIP_DESCRIPTIONS ={ # Do not remove this.
- # :command => 'DESCRIPTION'
- :manual => 'Allows you to manually add and remove your player\'s equipment',
- :optimize => 'Chooses the best equipment for a selected slot',
- :optimize_all => 'Chooses the best equipment for all the slots but accessories',
- :remove_all => 'Removes all equipment at once',
- } # Do not remove this.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ◆ Section III. Optimize Settings ◆
- # -------------------------------------------------------------------------
- # This sections allows you to customize how the system automatically adds
- # equipment to your player.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- WEIGHT ={
- :weapon =>{
- :atk => 1.0,
- :pdef => 0.0,
- :mdef => 0.0,
- :str => 0.0,
- :dex => 0.0,
- :agi => 0.0,
- :int => 0.0,
- },
- :armor =>{
- :eva => 0.0,
- :pdef => 0.75,
- :mdef => 0.25,
- :str => 0.0,
- :dex => 0.0,
- :agi => 0.0,
- :int => 0.0,
- },
- }
- # It ignores optimizations for accessories
- NO_ACCESSORY_OPTIMIZATION = false
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ◆ Section IV. Misc Window Settings ◆
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # This section adjusts the minor visuals that you see inside of the newly
- # organized Equip Scene. Adjust the settings as you see fit.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # This sets the un-equipment text in the slot window.
- UNEQUIP_ICON = '049-Skill06'
- # This sets the no-equipment text in the slot window.
- NOEQUIP_ICON = '049-Skill06'
- # The following determines the vocabulary used for the remade equip scene.
- # Adjust it accordingly to set the way text is displayed.
- VOCAB ={ # Do not remove this.
- :arrow => '→',
- :stat_up => '↑', # '▲' '↑' '»' '+' '>'
- :stat_down => '↓', # '▼' '↓' '«' '-' '>'
- :noequip => '<No Equipment>',
- :unequip => '<Unequip>',
- :amount => ':%2d',
- :eva => 'EVA',
- } # Do not remove this.
- # These are the stats shown inside of the equip scene menu and they order
- # they'll appear in. If a stat applied by a script doesn't exist, it'll be
- # ignored and the next command will be shifted up by one.
- # Legal Stats:
- # :atk, :pdef, :mdef, :str, :dex, :agi, :int, :eva
- SHOWN_STATS = [:atk, :pdef, :mdef, :str, :dex, :agi, :int, :eva]
- end
- #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
- # * BEGIN [ DON'T TOUCH THIS SECTION ]
- #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
- #
- # ▼ Warning
- # Editting anything past this point may potentially result in causing
- # computer damage, incontinence, explosion of user's head, coma, death,
- # and/or halitosis so edit at your own risk.
- #
- #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # ■ MESSAGE
- # ---------------------------------------------------------------------------
- # Setting module for the ACE::MESSAGE
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- module MESSAGE
- #--------------------------------------------------------------------------
- # * required
- # This method checks for the existance of the basic module and other
- # ACMS scripts required for this script to work, don't edit this
- #--------------------------------------------------------------------------
- def self.required(name, req, version, type = nil)
- if !$ace_script[:scene_menu_base]
- msg = "The script '%s' requires the script\n"
- msg += "'scene_MenuBase' v%s or higher above it to work properly\n"
- msg += "Go to http://bigaceworld.wordpress.com/ to download this script."
- print(sprintf(msg, self.script_name(name), version))
- exit
- else
- self.required_script(name, req, version, type)
- end
- end
- #--------------------------------------------------------------------------
- # * script_name
- # Get the script name base on the imported value, don't edit this
- #--------------------------------------------------------------------------
- def self.script_name(name, ext = "ACMS")
- name = name.to_s.gsub("_", " ").upcase.split
- name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
- name.join(" ")
- end
- end
- end
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # ▼ Import to Global Hash ▼ #
- ($ace_script ||= {})[:ace_equip_menu] = 1.15
- ACE::MESSAGE.required_script(:ace_equip_menu, :scene_base, 1.5, :above)
- ACE::MESSAGE.required_script(:ace_equip_menu, :scene_menu_base, 1.00, :above)
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Game_Temp
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Game_Temp
- attr_accessor(:scene_equip_index, :scene_equip_oy)
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Game_Actor
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Game_Actor < Game_Battler
- def equip_slots
- return [0, 1, 2, 3, 4]
- end
- def slot_name
- [
- $data_system.words.weapon,
- $data_system.words.armor1, $data_system.words.armor2,
- $data_system.words.armor3, $data_system.words.armor4,
- ]
- end
- def equip_change_ok?(slot_id)
- return true
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_Base
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_Base < Window
- alias :init_equip_ace :initialize unless $@
- def initialize(*args, &block)
- init_equip_ace(*args, &block)
- equip_opacity? if $scene.is_a?(Scene_Equip)
- end
- def equip_opacity?
- equipment = ACE::CORE::EQUIP_CONFIG[:equip_win]
- self.back_opacity = equipment[0]
- self.opacity = equipment[0] if equipment[1]
- end
- def draw_new_parameter(actor, x, y, stats)
- stats.each do |type|
- case type
- when :atk, :pdef, :mdef, :str, :dex, :agi, :int
- vocab = eval("$data_system.words.#{type}")
- value = eval("actor.#{type}.group")
- when :eva
- vocab = ACE::CORE::VOCAB[:eva]
- value = sprintf("%d%%", [actor.eva, 100].min)
- else next
- end
- contents.font.color = system_color
- contents.draw_text(x, y, 120, 24, vocab)
- contents.font.color = normal_color
- contents.draw_text(x + 80, y, 36, 24, value, 2)
- y += 20
- end
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_EquipCommand
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_EquipCommand < Window_CommandBase
- def initialize
- super(create_command_list)
- end
- def create_command_list
- vocab = []; data = []
- EQUIP_COMMAND.each do |command|
- case command[0]
- when :manual, :optimize, :optimize_all, :remove_all
- else next
- end
- data << command[0]; vocab << command[1]
- end
- return vocab, data
- end
- def visible_line_number
- return [[self.height, 3].min, 1].max
- end
- def cursor_pagedown
- return if Input.repeat?(Input::R)
- super
- end
- def cursor_pageup
- return if Input.repeat?(Input::L)
- super
- end
- def description
- return EQUIP_DESCRIPTIONS[method]
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_EquipLeft
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_EquipLeft < Window_Base
- include ACE::CORE
- def initialize(x, y)
- super(x, y, 272, fitting_height(8))
- self.contents = Bitmap.new(width - 32, height - 32)
- @actor = nil
- end
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- def refresh
- contents.clear
- stats = SHOWN_STATS
- contents.font.color = normal_color
- draw_parameter(0, stats)
- draw_right_arrow(120, 20)
- draw_new_parameter(@actor, 4, 0, stats)
- end
- def draw_right_arrow(x, y)
- contents.font.color = system_color
- 8.times {|i| contents.draw_text(x, y * i, 40, 20, VOCAB[:arrow], 1)}
- end
- def draw_parameter(y, stats)
- stats.each do |type|
- case type
- when :atk, :pdef, :mdef, :str, :dex, :agi, :int, :eva
- else next
- end
- new_value = eval("@new_#{type.to_s}")
- contents.draw_text(200, y, 36, 24, new_value.to_s, 2)
- y += 20
- end
- end
- def set_new_parameters(new_atk = nil, new_pdef = nil, new_mdef = nil,
- new_str = nil, new_dex = nil, new_agi = nil, new_int = nil, new_eva = nil)
- return unless @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
- @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
- refresh
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_EquipRight
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_EquipRight < Window_Selectable
- include ACE::CORE
- attr_reader :item_window
- def initialize(x, y)
- super(x, y, 368, fitting_height(8))
- self.contents = Bitmap.new(width - 32, height - 32)
- @actor = nil
- refresh
- deactivate
- end
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- def item_max
- @item_max = @actor ? @actor.equip_slots.size : 0
- end
- def item
- @actor ? @actor.equips[index] : nil
- end
- def slot_name(index)
- @actor ? @actor.slot_name[index] : ''
- end
- def enable?(index)
- @actor ? @actor.equip_change_ok?(index) : false
- end
- def refresh
- super
- end
- def draw_item(index)
- return unless @actor
- rect = item_rect_for_text(index)
- contents.font.color = system_color
- contents.font.color.alpha = enable?(index) ? 255 : translucent_alpha
- contents.draw_text(rect.x, rect.y, 92, line_height, slot_name(index))
- item = @actor.equips[index]
- dx = rect.x + 100
- dw = contents.width - dx - 24
- if item.nil?
- draw_nothing_equip(dx, rect.y, false, dw)
- else
- draw_item_name(item, dx, rect.y, enable?(index), dw)
- end
- end
- def draw_nothing_equip(dx, dy, enabled, dw)
- contents.font.color = normal_color
- contents.font.color.alpha = enabled ? 255 : translucent_alpha
- draw_icon(NOEQUIP_ICON, dx, dy, enabled)
- contents.draw_text(dx + 24, dy, dw - 24, line_height, VOCAB[:noequip])
- end
- def item_window=(item_window)
- @item_window = item_window
- update
- end
- def update
- super
- @item_window.slot_id = index if @item_window
- end
- def update_help
- @help_window.set_text(item.nil? ? VOCAB[:noequip] : item.description)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_EquipItem
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_EquipItem < Window_Item
- include ACE::CORE
- def initialize(x, y, width)
- super(x, y, width, fitting_height(8))
- @actor = nil
- @slot_id = 0
- @column_max = 1
- deactivate
- unselect
- end
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- self.oy = 0
- end
- def slot_id=(slot_id)
- return if @slot_id == slot_id
- @slot_id = slot_id
- refresh
- self.oy = 0
- end
- def include?(item)
- return true if item.nil?
- if @slot_id == 0
- return false unless item.is_a?(RPG::Weapon)
- else
- return false unless item.is_a?(RPG::Armor)
- return false if item.kind != @actor.equip_slots[@slot_id - 1]
- end
- return @actor.equippable?(item)
- end
- def enable?(item)
- return true
- end
- def draw_item(index)
- item = @data[index]
- rect = item_rect(index)
- return draw_remove_equip(rect) if item.nil?
- number = $game_party.item_number(item)
- dw = contents.width - rect.x - 24
- draw_item_name(item, rect.x, rect.y, enable?(item), dw)
- contents.draw_text(rect, sprintf(VOCAB[:amount], number), 2)
- end
- def draw_remove_equip(rect)
- draw_icon(UNEQUIP_ICON, rect.x, rect.y + 4)
- rect.x += 26; rect.width -= 24
- contents.font.color.alpha = 128
- contents.draw_text(rect, VOCAB[:unequip])
- end
- def update_help
- @help_window.set_text(item.nil? ? VOCAB[:unequip] : item.description)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Scene_Equip
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Scene_Equip < Scene_MenuBase
- def initialize(actor_index = 0)
- @actor_index = actor_index
- end
- def equip_type_max; return @actor.equip_slots.size; end
- def create_menu_layout
- super
- return if EQUIP_CONFIG[:layout].empty?
- @back.bitmap = RPG::Cache.menu("Background/#{EQUIP_CONFIG[:layout]}")
- end
- def start
- super
- @actor = $game_party.actors[@actor_index]
- create_help_window
- create_status_window
- create_command_window
- create_slot_window
- create_item_windows
- relocate_windows if $ace_script[:ace_main_menu]
- end
- def create_status_window
- @status_window = Window_EquipLeft.new(368, 192)
- @actor_window = Window_StatusActor.new(160, 64)
- @status_window.actor = @actor
- @actor_window.actor = @actor
- end
- def create_command_window
- @command_window = Window_EquipCommand.new
- @command_window.help_window = @help_window
- @command_window.y = @help_window.height
- @command_window.oy = @equip_oy if !@equip_oy.nil?
- @command_window.activate.select(0)
- end
- def create_slot_window
- @equip_window = Window_EquipRight.new(0, 192)
- @equip_window.help_window = @help_window
- @equip_window.actor = @actor
- @equip_window.select(0)
- end
- def create_item_windows
- @item_windows = []
- equip_type_max.times do |i|
- @item_windows[i] = Window_EquipItem.new(0, 192, 368)
- @item_windows[i].help_window = @help_window
- @item_windows[i].actor = @actor
- @item_windows[i].slot_id = i
- @item_windows[i].hide
- end
- end
- def relocate_windows
- relocate_help
- relocate_command if Menu.main_menu_right
- end
- def relocate_help
- case Menu.main_menu_align
- when 0
- @help_window.y = 0
- @command_window.y = @help_window.height
- @status_window.y = @command_window.y + @command_window.height
- when 1
- @command_window.y = 0
- @help_window.y = @actor_window.height
- @status_window.y = @help_window.y + @help_window.height
- else
- @command_window.y = 0
- @status_window.y = @actor_window.height
- @help_window.y = @status_window.y + @status_window.height
- end
- @status_window.y = @equip_window.y
- @actor_window.y = @command_window.y
- end
- def relocate_command
- @actor_window.x = 0
- @command_window.x = 480
- end
- def background_image
- EQUIP_CONFIG[:background]
- end
- def update
- super
- update_item_windows
- update_status_window
- if @command_window.active; update_command_selection
- elsif @equip_window.active; update_equip_selection
- elsif @item_window.active; update_item_selection
- end
- end
- def update_item_windows
- equip_type_max.times do |i|
- @item_windows[i].visible = (@equip_window.index == i)
- end
- @item_window = @item_windows[@equip_window.index]
- end
- def update_status_window
- item1 = @equip_window.item
- @status_window.set_new_parameters if @equip_window.active
- return unless @item_window.active
- item2 = @item_window.item
- @actor.equip(@equip_window.index, item2.nil? ? 0 : item2.id)
- new_atk, new_pdef, new_mdef = @actor.atk, @actor.pdef, @actor.mdef
- new_str, new_dex, new_agi = @actor.str, @actor.dex, @actor.agi
- new_int, new_eva = @actor.int, @actor.eva
- @actor.equip(@equip_window.index, item1.nil? ? 0 : item1.id)
- @status_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str,
- new_dex, new_agi, new_int, new_eva)
- end
- def update_command_selection
- equip_type_max.times {|i| @item_windows[i].hide}
- update_command if Input.trigger?(Input::C)
- cancel_command if Input.trigger?(Input::B)
- actors_command if Input.trigger?(Input::R) || Input.trigger?(Input::L)
- end
- def cancel_command
- Sound.play_se(:cancel)
- if $ace_script[:ace_main_menu] && !$ace_script[:ace_status_menu]
- return unless $game_temp.menu_command_index.has_key?(:equip)
- $scene = Scene_Menu.new($game_temp.menu_command_index[:equip])
- elsif $ace_script[:ace_status_menu] && $game_temp.status_index
- $scene = Scene_Status(@actor_index)
- else
- $scene = Scene_Menu.new(EQUIP_CONFIG[:menu_index])
- end
- end
- def cancel_equiped
- Sound.play_se(:cancel)
- @equip_window.deactivate
- @command_window.activate
- end
- def update_command
- Sound.play_se(:decision)
- @command_window.deactivate
- case @command_window.method
- when :manual, :optimize then @equip_window.activate.select(0)
- when :optimize_all then optimize_all
- when :remove_all then remove_all
- end
- end
- def update_equip_selection
- @equip_window.show
- equip_type_max.times {|i| @item_windows[i].hide}
- cancel_equiped if Input.trigger?(Input::B)
- select_equiped if Input.trigger?(Input::C)
- actors_command if Input.trigger?(Input::R) || Input.trigger?(Input::L)
- end
- def select_equiped
- Sound.play_se(:decision)
- case @command_window.method
- when :manual then equip_manual
- when :optimize then equip_optimize
- end
- end
- def equip_manual
- if @actor.equip_fix?(@equip_window.index)
- Sound.play_se(:buzzer)
- else
- Sound.play_se(:decision)
- @equip_window.deactivate
- @item_window.activate.select(0)
- end
- end
- def equip_optimize
- @equip_window.deactivate
- update_optimize
- end
- def update_optimize
- cancel_optimize if Input.trigger?(Input::B)
- select_optimize if Input.trigger?(Input::C)
- end
- def cancel_optimize
- Sound.play_se(:cancel)
- @equip_window.deactivate
- @command_window.activate
- end
- def select_optimize
- Sound.play_se(:decision)
- optimize(@equip_window.index)
- item_refresh_windows
- @equip_window.activate
- end
- def optimize_all
- Sound.play_se(:decision)
- optimize_equipments
- item_command_active
- end
- def remove_all
- Sound.play_se(:decision)
- clear_equipments
- item_command_active
- end
- def item_refresh_windows
- @equip_window.refresh
- @status_window.refresh
- end
- def item_command_active
- item_refresh_windows
- @command_window.activate
- end
- def clear_equipments
- equip_type_max.times do |slot|
- @actor.equip(slot, 0) if @actor.equip_change_ok?(slot)
- end
- end
- def optimize_equipments
- equip_type_max.times do |slot|
- optimize(slot) if @actor.equip_change_ok?(slot)
- end
- end
- def optimize(slot)
- if slot == 0
- object = $data_weapons[@actor.weapon_id]
- optimal = object.id
- max = 0.00
- @actor.weapon_id != 0 ? max = calc_weapon_stats(object) : optimal = 0
- @actor.equip(0, 0)
- flag = false; zero_flag = true
- $data_weapons.each do |weapon|
- next flag = true if !flag
- evaluation = 0.00
- evaluation = calc_weapon_stats(weapon)
- zero_flag = false if evaluation > 0
- next unless @actor.equippable?(weapon) && evaluation > max &&
- $game_party.weapon_number(weapon.id) > 0
- max = evaluation
- optimal = weapon.id
- end
- optimal = 0 if zero_flag
- @actor.equip(0, optimal)
- elsif slot >= 1
- not_equipped = false
- case slot
- when 1
- not_equipped = true if @actor.armor1_id == 0
- not_equipped = true unless object = $data_armors[@actor.armor1_id]
- when 2
- not_equipped = true if @actor.armor2_id == 0
- not_equipped = true unless object = $data_armors[@actor.armor2_id]
- when 3
- not_equipped = true if @actor.armor3_id == 0
- not_equipped = true unless object = $data_armors[@actor.armor3_id]
- else
- return if NO_ACCESSORY_OPTIMIZATION
- not_equipped = true if @actor.armor4_id == 0
- not_equipped = true unless object = $data_armors[@actor.armor4_id]
- end
- optimal = object.id
- current = 0.00
- not_equipped = false ? current = calc_armor_stats(object) : optimal = 0
- @actor.equip(slot, 0)
- flag = false; zero_flag = true
- $data_armors.each do |armor|
- next flag = true if !flag
- next if armor.kind != slot-1
- evaluation = 0.00
- evaluation = calc_armor_stats(armor)
- zero_flag = false if evaluation > 0
- next unless @actor.equippable?(armor) &&
- $game_party.armor_number(armor.id) > 0 && evaluation > current
- current = evaluation
- optimal = armor.id
- end
- optimal = 0 if zero_flag
- @actor.equip(slot, optimal)
- end
- end
- def calc_weapon_stats(object)
- current = 0.00
- current += object.atk * WEIGHT[:weapon][:atk]
- current += object.pdef * WEIGHT[:weapon][:pdef]
- current += object.mdef * WEIGHT[:weapon][:mdef]
- current += object.str_plus * WEIGHT[:weapon][:str]
- current += object.dex_plus * WEIGHT[:weapon][:dex]
- current += object.agi_plus * WEIGHT[:weapon][:agi]
- current += object.int_plus * WEIGHT[:weapon][:int]
- return current
- end
- def calc_armor_stats(object)
- current = 0.00
- current += object.eva * WEIGHT[:armor][:eva]
- current += object.pdef * WEIGHT[:armor][:pdef]
- current += object.mdef * WEIGHT[:armor][:mdef]
- current += object.str_plus * WEIGHT[:armor][:str]
- current += object.dex_plus * WEIGHT[:armor][:dex]
- current += object.agi_plus * WEIGHT[:armor][:agi]
- current += object.int_plus * WEIGHT[:armor][:int]
- return current
- end
- def update_item_selection
- @equip_window.hide
- cancel_item if Input.trigger?(Input::B)
- select_item if Input.trigger?(Input::C)
- end
- def cancel_item
- Sound.play_se(:cancel)
- @equip_window.activate
- @item_window.deactivate.unselect
- end
- def select_item
- Sound.play_se(:equip)
- item = @item_window.item
- @actor.equip(@equip_window.index, item.nil? ? 0 : item.id)
- @item_window.deactivate.unselect
- @equip_window.activate.refresh
- @item_windows.each {|x| x.refresh}
- end
- def actors_command
- Sound.play_se(:cursor)
- @actor_index += Input.trigger?(Input::L) ? -1 : 1
- @actor_index %= $game_party.actors.size
- $scene = Scene_Equip.new(@actor_index)
- end
- end
Add Comment
Please, Sign In to add comment