#============================================================================== # ** ExEquip_SwordAndShield (AEROGP) #------------------------------------------------------------------------------ # This script changes the rules of "two swords style" so that an actor is # still allowed to equip a shield, even in the weapon slot. #============================================================================== $imported = {} if $imported == nil $imported["ExEquip_SwordAndShield"] = true module EXEQP_SWRDSHLD #------------------------------------------------------------------------------ # *** CUSTOMIZATION SECTION *** #------------------------------------------------------------------------------ # Actor exception array. # Actors whose ID is specified here will NOT follow the rules defined # by this script. (Use [] for none) EXCEPTION = [] #------------------------------------------------------------------------------ # !!! IT IS NOT ADVISED TO EDIT BEYOND THIS PORTION OF THE SCRIPT !!! #------------------------------------------------------------------------------ #-------------------------------------------------------------------------- # * Get Armor ID of Shield #-------------------------------------------------------------------------- def self.shield_kind if $imported["EquipmentOverhaul"] type = YEM::EQUIP::TYPE_LIST[0] return YEM::EQUIP::TYPE_RULES[type][1] end return 0 end end #------------------------------------------------------------------------------ # ** Game_Actor #------------------------------------------------------------------------------ class Game_Actor < Game_Battler alias _exeswsh_initialize initialize unless $@ alias _exeswsh_weapons weapons unless $@ alias _exeswsh_armors armors unless $@ #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :equip_class # equip class #-------------------------------------------------------------------------- # * Object Initialization (Definition Added) # actor_id : actor ID #-------------------------------------------------------------------------- def initialize(actor_id) _exeswsh_initialize(actor_id) @equip_class = [RPG::Weapon, two_swords_style ? RPG::Weapon : RPG::Armor] end #-------------------------------------------------------------------------- # * Get Weapon Object Array (Redefined) #-------------------------------------------------------------------------- def weapons if @equip_class == nil _exeswsh_weapons else result = [] if @equip_class[0] == RPG::Weapon result.push($data_weapons[@weapon_id]) end if @equip_class[1] == RPG::Weapon result.push($data_weapons[@armor1_id]) end return result end end #-------------------------------------------------------------------------- # * Get Armor Object Array (Redefined) #-------------------------------------------------------------------------- def armors if @equip_class == nil _exeswsh_armors else result = [] if @equip_class[0] == RPG::Armor result.push($data_armors[@weapon_id]) end if @equip_class[1] == RPG::Armor result.push($data_armors[@armor1_id]) end result.push($data_armors[@armor2_id]) result.push($data_armors[@armor3_id]) result.push($data_armors[@armor4_id]) return result end end #-------------------------------------------------------------------------- # * Get Left-Hand Object (For Equip Screen) #-------------------------------------------------------------------------- def left_hand if @equip_class == nil return [$data_weapons[@weapon_id]] elsif @equip_class[0] == RPG::Weapon return [$data_weapons[@weapon_id]] elsif @equip_class[0] == RPG::Armor return [$data_armors[@weapon_id]] end return [nil] end #-------------------------------------------------------------------------- # * Get Right-Hand Object (For Equip Screen) #-------------------------------------------------------------------------- def right_hand if @equip_class == nil if two_swords_style return [$data_weapons[@armor1_id]] else return [$data_armors[@armor1_id]] end elsif @equip_class[1] == RPG::Weapon return [$data_weapons[@armor1_id]] elsif @equip_class[1] == RPG::Armor return [$data_armors[@armor1_id]] end return [nil] end #-------------------------------------------------------------------------- # * Get Body Armor Object Array (For Equip Screen) #-------------------------------------------------------------------------- def body_armors result = [] result.push($data_armors[@armor2_id]) result.push($data_armors[@armor3_id]) result.push($data_armors[@armor4_id]) return result end #-------------------------------------------------------------------------- # * Get Equipped Item Object Array (Redefined) #-------------------------------------------------------------------------- def equips return left_hand + right_hand + body_armors end #-------------------------------------------------------------------------- # * Determine if Shield can still be equipped #-------------------------------------------------------------------------- def sword_and_shield? return (not EXEQP_SWRDSHLD::EXCEPTION.include?(id)) end #-------------------------------------------------------------------------- # * Change Equipment (designate object) (Definition Added) # equip_type : Equip region (0..4) # item : Weapon or armor (nil is used to unequip) # test : Test flag (for battle test or temporary equipment) #-------------------------------------------------------------------------- def change_equip(equip_type, item, test = false) last_item = equips[equip_type] unless test return if $game_party.item_number(item) == 0 if item != nil $game_party.gain_item(last_item, 1) $game_party.lose_item(item, 1) end item_id = item == nil ? 0 : item.id case equip_type when 0 # Weapon @weapon_id = item_id if two_swords_style and item_id != 0 @equip_class[0] = item.class unless shield_legal? # If shield is not allowed change_equip(1, nil, test) # Unequip from other hand end end unless two_hands_legal? # If two hands is not allowed change_equip(1, nil, test) # Unequip from other hand end when 1 # Weapon / Shield @armor1_id = item_id if two_swords_style and item_id != 0 @equip_class[1] = item.class unless shield_legal? # If shield is not allowed change_equip(0, nil, test) # Unequip from other hand end end unless two_hands_legal? # If two hands is not allowed change_equip(0, nil, test) # Unequip from other hand end when 2 # Head @armor2_id = item_id when 3 # Body @armor3_id = item_id when 4 # Accessory @armor4_id = item_id end end #-------------------------------------------------------------------------- # * Discard Equipment (Redefined) # item : Weapon or armor to be discarded. # Used when the "Include Equipment" option is enabled. #-------------------------------------------------------------------------- def discard_equip(item) if @weapon_id == item.id and @equip_class[0] == item.class @weapon_id = 0 @equip_class[0] = nil elsif @armor1_id == item.id and @equip_class[1] == item.class @armor1_id = 0 @equip_class[1] = nil elsif item.is_a?(RPG::Armor) if @armor2_id == item.id @armor2_id = 0 elsif @armor3_id == item.id @armor3_id = 0 elsif @armor4_id == item.id @armor4_id = 0 end end end #-------------------------------------------------------------------------- # * Determine if Shield is Usable #-------------------------------------------------------------------------- def shield_legal? return true if @weapon_id == 0 or @armor1_id == 0 return @equip_class.include?(RPG::Weapon) end #-------------------------------------------------------------------------- # * Determine if Equippable # item : item #-------------------------------------------------------------------------- def equippable?(item) if item.is_a?(RPG::Weapon) return self.class.weapon_set.include?(item.id) elsif item.is_a?(RPG::Armor) if item.kind == EXEQP_SWRDSHLD::shield_kind and two_swords_style return false unless sword_and_shield? end return self.class.armor_set.include?(item.id) end return false end end #------------------------------------------------------------------------------ # ** Window_EquipItem #------------------------------------------------------------------------------ class Window_EquipItem < Window_Item #-------------------------------------------------------------------------- # * Whether to include item in list (Redefined) # item : item #-------------------------------------------------------------------------- def include?(item) return true if item == nil if @equip_type == 0 if item.is_a?(RPG::Armor) return false if item.kind != EXEQP_SWRDSHLD::shield_kind return false unless @actor.two_swords_style return false unless @actor.sword_and_shield? end else return false unless item.is_a?(RPG::Armor) return false unless item.kind == @equip_type - 1 end return @actor.equippable?(item) end end #------------------------------------------------------------------------------ # ** Scene_Equip #------------------------------------------------------------------------------ class Scene_Equip < Scene_Base #-------------------------------------------------------------------------- # * Update Status Window (Redefined) # Clone doesn't duplicate the equip_class array, so it must be cloned # individually and then reapplied after equip changes have been made. #-------------------------------------------------------------------------- def update_status_window if @equip_window.active @status_window.set_new_parameters(nil, nil, nil, nil) elsif @item_window.active temp_class = @actor.equip_class.clone temp_actor = @actor.clone temp_actor.change_equip(@equip_window.index, @item_window.item, true) new_atk = temp_actor.atk new_def = temp_actor.def new_spi = temp_actor.spi new_agi = temp_actor.agi @actor.equip_class = temp_class @status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi) end @status_window.update end end #------------------------------------------------------------------------------ # ** Yanfly Engine Zealous - Equipment Overhaul (Redefined) #------------------------------------------------------------------------------ if $imported["EquipmentOverhaul"] #------------------------------------------------------------------------------ # ** Window_Equip_Item #------------------------------------------------------------------------------ class Window_Equip_Item < Window_Selectable #-------------------------------------------------------------------------- # * Refresh (Redefined) #-------------------------------------------------------------------------- def refresh(type, debug = false) debug = false unless $TEST @data = []; @type = type if @type == :weapon equips = $game_party.equip_weapons if @actor.two_swords_style and @actor.sword_and_shield? equips += $game_party.equip_armours(EXEQP_SWRDSHLD::shield_kind) end equips = $data_weapons if debug else equips = $game_party.equip_armours(@type) equips = $data_armors if debug end @data += [nil] if YEM::EQUIP::TYPE_RULES[@type][2] for item in equips @data.push(item) if include?(item) end @data += [nil] if YEM::EQUIP::TYPE_RULES[@type][2] and @data.size > 8 @item_max = @data.size create_contents for i in 0..(@item_max-1); draw_item(i); end end #-------------------------------------------------------------------------- # * Whether or not to include in item list (Redefined) # item : item #-------------------------------------------------------------------------- def include?(item) return false if item == nil case @type when :weapon if item.is_a?(RPG::Armor) return false if item.kind != EXEQP_SWRDSHLD::shield_kind return false unless @actor.two_swords_style return false unless @actor.sword_and_shield? end else kind = YEM::EQUIP::TYPE_RULES[@type][1] return false unless item.kind == kind end return class_equippable?(item) end end #------------------------------------------------------------------------------ # ** Scene_Equip #------------------------------------------------------------------------------ class Scene_Equip < Scene_Base #-------------------------------------------------------------------------- # * Optimize Equipment (Redefined) #-------------------------------------------------------------------------- def perform_optimize Sound.play_equip last_hp = @actor.maxhp last_mp = @actor.maxmp types = [:weapon] + @actor.equip_type slot = -1 for type in types if slot == 1 and @actor.two_swords_style and not @actor.sword_and_shield? type = :weapon end slot += 1 next unless YEM::EQUIP::TYPE_RULES[type][3] item = optimal_equip(slot, type) next if item == nil @actor.change_equip(slot, item) end @status_window.refresh(@equip_window.index) @equip_window.refresh @stat_window.refresh @actor.hp += @actor.maxhp - last_hp @actor.mp += @actor.maxmp - last_mp end end end # Equipment Overhaul