class Game_BattlerBase
#--------------------------------------------------------------------------
# ● 判定武器类型是否屏蔽
#--------------------------------------------------------------------------
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
cet=Chd114::Equip::Type[cetid].push(etid)
equipcan=0
for i in cet
if i<0
equipcan+=1 if equip_wtype_ok?(-i) && !weapon_type_cover?(-i)
else
equipcan+=1 if equip_atype_ok?(i) && !armor_type_cover?(i)
end
end
return true if equipcan==cet.size
return false
end
end
class Game_Actor
#--------------------------------------------------------------------------
# ● 实例变量
#--------------------------------------------------------------------------
attr_writer :cover_weapon # 屏蔽武器类型
attr_writer :cover_armor # 屏蔽防具类型
#--------------------------------------------------------------------------
# ○ 屏蔽装备类型取得
#--------------------------------------------------------------------------
def cover_weapon
@cover_weapon = [] if @cover_weapon == nil
return @cover_weapon
end
def cover_armor
@cover_armor = [] if @cover_armor == nil
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
cetid = item.is_a?(RPG::Weapon)? -item.id : item.id
cet=Chd114::Equip::Etype[cetid].push(item.etype_id)
return if item && !cet.include?(slot_id)
end
@equips[slot_id].object = item
refresh
end
#--------------------------------------------------------------------------
# ● 卸下无法装备的物品
# item_gain : 卸下的装备是否保留
#--------------------------------------------------------------------------
def release_unequippable_items(item_gain = true)
@equips.each_with_index do |item, i|
if item.object!=nil
cetid = item.is_a?(RPG::Weapon)? -item.object.id : item.object.id
cet=Chd114::Equip::Etype[cetid].push(item.object.etype_id)
if !equippable?(item.object) || !cet.include?(equip_slots[i])
trade_item_with_party(nil, item.object) if item_gain
item.object = nil
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
cetid = item.is_a?(RPG::Weapon)? -item.id : item.id
cet=Chd114::Equip::Etype[cetid].push(item.etype_id)
return false if !cet.include?(@actor.equip_slots[@slot_id])
return @actor.equippable?(item)
end
end