class Game_Actor
#--------------------------------------------------------------------------
# ● 将装备类型变换为装备栏 ID 的列表
#--------------------------------------------------------------------------
alias FreeDualWield_slot_list slot_list
def slot_list(etype_id)
result = []
equip_slots.each_with_index {|e, i|
result.push(i) if etype_id == 0 && dual_wield? && i == 1 || e == etype_id
}
result
end
#--------------------------------------------------------------------------
# ● 获取装备栏的数组
#--------------------------------------------------------------------------
alias FreeDualWield_equip_slots equip_slots
def equip_slots
return [0,1,2,3,4]
end
#--------------------------------------------------------------------------
# ● 更换装备
# slot_id : 装备栏 ID
# item : 武器/护甲(为 nil 时装备解除)
#--------------------------------------------------------------------------
alias FreeDualWield_change_equip change_equip
def change_equip(slot_id, item)
return unless trade_item_with_party(item, equips[slot_id])
if !dual_wield_toka?(slot_id, item)
return if item && equip_slots[slot_id] != item.etype_id
end
@equips[slot_id].object = item
refresh
end
#--------------------------------------------------------------------------
# ● 卸下无法装备的物品
# item_gain : 卸下的装备是否保留
#--------------------------------------------------------------------------
alias FreeDualWield_release_unequippable_items release_unequippable_items
def release_unequippable_items(item_gain = true)
@equips.each_with_index do |item, i|
if !equippable?(item.object)
trade_item_with_party(nil, item.object) if item_gain
item.object = nil
elsif dual_wield? && i == 1
if feature_seal_shield?(@equips[0].object) || feature_seal_shield?(item.object)
trade_item_with_party(nil, item.object) if item_gain
item.object = nil
end
elsif item.object.etype_id != equip_slots[i]
trade_item_with_party(nil, item.object) if item_gain
item.object = nil
end
end
end
#--------------------------------------------------------------------------
# ● 是否为双手武器
#--------------------------------------------------------------------------
def feature_seal_shield?(item)
return false unless item && item.etype_id == 0
feature = item.features.select {|ft| ft.code == 54 }
feature_set = feature.inject([]) {|r, ft| r |= [ft.data_id] }
return feature_set.include?(1)
end
#--------------------------------------------------------------------------
# ● 是否为【双持】且【装备槽为副手】且【装备为单手武器】
#--------------------------------------------------------------------------
def dual_wield_toka?(slot_id, item)
return dual_wield? && slot_id == 1 && !feature_seal_shield?(item)
end
end
class Window_EquipItem
alias FreeDualWield_include? include?
def include?(item)
return true if item == nil
return false unless item.is_a?(RPG::EquipItem)
return false if @slot_id < 0
return false unless @actor.equippable?(item)
return true if @actor.dual_wield_toka?(@slot_id, item)
return false if item.etype_id != @actor.equip_slots[@slot_id]
return true
end
end