[/i][/i][/i][/i][i][i][i][i][i][i]class Game_BattlerBase
[/i][/i][/i][/i][/i][/i][i][i][i][i][i][i] #--------------------------------------------------------------------------
# ● 判定武器类型是否屏蔽
#--------------------------------------------------------------------------
def weapon_type_cover?(stype_id)
cover_weapon.include?(stype_id)
end
#--------------------------------------------------------------------------
# ● 判定防具类型是否屏蔽
#--------------------------------------------------------------------------
def armor_type_cover?(stype_id)
cover_armor.include?(stype_id)
end
#--------------------------------------------------------------------------
# ● 获取可用武器类型时除去屏蔽(删除)武器类型
#--------------------------------------------------------------------------
def add_weapon_types
features_set(FEATURE_EQUIP_WTYPE).delete_if &method(:weapon_type_cover?)
end
#--------------------------------------------------------------------------
# ● 获取可用防具类型时除去屏蔽(删除)防具类型
#--------------------------------------------------------------------------
def add_armor_types
features_set(FEATURE_EQUIP_ATYPE).delete_if &method(:armor_type_cover?)
end
#--------------------------------------------------------------------------
# ● 判定物品是否可以装备
#--------------------------------------------------------------------------
def equippable?(item)
return false if item.is_a?(RPG::Item)
return false unless item.is_a?(RPG::EquipItem)
return false if equip_type_sealed?(item.etype_id)
etid = item.is_a?(RPG::Weapon)? -item.wtype_id : item.atype_id
cetid = item.is_a?(RPG::Weapon)? -item.id : item.id
equipcan=0
cen=[]
@equips.each_with_index do |item, i|
if item.object!=nil
cen.push(item.object.is_a?(RPG::Weapon)? -item.object.id : item.object.id)
end
end
return false if Equip::Number[cetid]<=cen.select{|x|x==cetid}.size
for i in cen
return false if Equip::SameTime[cetid].include?(i)
return false if Equip::SameTime[i].include?(cetid)
end
for i in item.types
if i<0
return false if !(equip_wtype_ok?(-i) && !weapon_type_cover?(-i))
else
return false if !(equip_atype_ok?(i) && !armor_type_cover?(i))
end
end
return true
end
end
class Game_Actor
#--------------------------------------------------------------------------
# ● 实例变量
#--------------------------------------------------------------------------
attr_writer :cover_weapon # 屏蔽武器类型
attr_writer :cover_armor # 屏蔽防具类型
#--------------------------------------------------------------------------
# ○ 屏蔽装备类型取得
#--------------------------------------------------------------------------
def cover_weapon
@cover_weapon||=[]
return @cover_weapon
end
def cover_armor
@cover_armor||=[]
return @cover_armor
end
#--------------------------------------------------------------------------
# ● 更换装备
# slot_id : 装备栏 ID
# item : 武器/护甲(为 nil 时装备解除)
#--------------------------------------------------------------------------
def change_equip(slot_id, item)
return unless trade_item_with_party(item, equips[slot_id])
if item!=nil
if equips[slot_id]!=nil
return if item && !item.etypes.include?(equip_slots[slot_id]) && !equips[slot_id].etypes.include?(item.etype_id)
else
return if item && !item.etypes.include?(equip_slots[slot_id])
end
end
@equips[slot_id].object = item
refresh
end
#--------------------------------------------------------------------------
# ● 装备上最强装备
#--------------------------------------------------------------------------
def optimize_equipments
clear_equipments
equip_slots.size.times do |i|
next if !equip_change_ok?(i)
items = $game_party.equip_items.select do |item|
item.etypes.include?(equip_slots[i]) &&
equippable?(item) && item.performance >= 0
end
change_equip(i, items.max_by {|item| item.performance })
end
end
#--------------------------------------------------------------------------
# ● 卸下无法装备的物品
# item_gain : 卸下的装备是否保留
#--------------------------------------------------------------------------
def release_unequippable_items(item_gain = true)
loop do
last_equips = equips.dup
return if equips == last_equips
end
@equips.each_with_index do |item, i|
if item.object!=nil
if equip_slots[i]!=nil
if !equippable?(item.object) || (!item.etypes.include?(equip_slots[i]) && !equip_slots[i].etypes.include?(item))
trade_item_with_party(nil, item.object) if item_gain
item.object = nil
end
else
if !equippable?(item.object) || !item.etypes.include?(equip_slots[i])
trade_item_with_party(nil, item.object) if item_gain
item.object = nil
end
end
end
end
end
end
class Window_EquipItem < Window_ItemList
#--------------------------------------------------------------------------
# ● 查询使用列表中是否含有此物品
#--------------------------------------------------------------------------
def include?(item)
return true if item == nil
return false unless item.is_a?(RPG::EquipItem)
return false if @slot_id < 0
return false if !item.etypes.include?(@actor.equip_slots[@slot_id])
return @actor.equippable?(item)
end
end