#### ER_WEAPON_RESTRICTION # Weapon
#### ER_ARMOR_RESTRICTION # Armor
### Condition array.
# << [Condition, Value, Reverse], ... >>
# Each index of the array corresponds to Weapon/Armor ID.
# If add 'true' at the end of the array, all conditions become indispensable.
# (If did not added 'true', one of the conditions only has to consist.)
# If "Reverse" is true, condition "more than" changes into "below".
# (It is possible to omit "Reverse".)
# **** Conditon list (X is "Value") ****
# 0 : Level - more than X
# 1 : Max HP - more than X
# 2 : Max SP - more than X
# 3 : Str(Strength) - more than X
# 4 : Dex(Dexterity) - more than X
# 5 : Agi(Agility) - more than X
# 6 : Int(Intelligence) - more than X
# 10001..19999 : Switch ID "'Condition' - 10000" is true
# 20001..29999 : Variable ID "'Condition' - 20000" - more than X
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["EquipmentRestriction"] = true
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 装備可能判定
# item : アイテム
#--------------------------------------------------------------------------
alias equippable_KGC_EquipmentRestriction? equippable?
def equippable?(item)
if (result = equippable_KGC_EquipmentRestriction?(item))
conditions = nil
# 条件取得
if item.is_a?(RPG::Weapon)
conditions = KGC::ER_WEAPON_RESTRICTION[item.id]
elsif item.is_a?(RPG::Armor)
conditions = KGC::ER_ARMOR_RESTRICTION[item.id]
end
# 条件判定
if conditions != nil
return pass_equipment_restriction?(item, conditions)
end
end
return result
end
#--------------------------------------------------------------------------
# ● 装備条件通過判定
#--------------------------------------------------------------------------
def pass_equipment_restriction?(item, conditions)
if conditions[-1, 1] == true
all = conditions.pop
else
all = false
end
# 条件判定
conditions.each { |condition|
result = true
case condition[0]
when 0 # レベル
result = self.level >= condition[1]
when 1 # MAXHP
result = self.maxhp >= condition[1]
when 2 # MAXSP
result = self.maxsp >= condition[1]
when 3 # 腕力
result = self.str >= condition[1]
when 4 # 器用さ
result = self.dex >= condition[1]
when 5 # 素早さ
result = self.agi >= condition[1]
when 6 # 魔力
result = self.int >= condition[1]
when 10001..19999 # スイッチ
result = $game_switches[condition[0] - 10000]
when 20001..29999 # 変数
result = $game_variables[condition[0] - 20000] >= condition[1]
end
# 反転
if condition[2]
result = !result
end
if all
# 条件が成り立たない場合は false
unless result
return false
end
else
# 条件が成り立つ場合は true
if result
return true
end
end
}
return all
end
end
#### ER_WEAPON_RESTRICTION # Weapon
#### ER_ARMOR_RESTRICTION # Armor
### Condition array.
# << [Condition, Value, Reverse], ... >>
# Each index of the array corresponds to Weapon/Armor ID.
# If add 'true' at the end of the array, all conditions become indispensable.
# (If did not added 'true', one of the conditions only has to consist.)
# If "Reverse" is true, condition "more than" changes into "below".
# (It is possible to omit "Reverse".)
# **** Conditon list (X is "Value") ****
# 0 : Level - more than X
# 1 : Max HP - more than X
# 2 : Max SP - more than X
# 3 : Str(Strength) - more than X
# 4 : Dex(Dexterity) - more than X
# 5 : Agi(Agility) - more than X
# 6 : Int(Intelligence) - more than X
# 10001..19999 : Switch ID "'Condition' - 10000" is true
# 20001..29999 : Variable ID "'Condition' - 20000" - more than X
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["EquipmentRestriction"] = true
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 装備可能判定
# item : アイテム
#--------------------------------------------------------------------------
alias equippable_KGC_EquipmentRestriction? equippable?
def equippable?(item)
if (result = equippable_KGC_EquipmentRestriction?(item))
conditions = nil
# 条件取得
if item.is_a?(RPG::Weapon)
conditions = KGC::ER_WEAPON_RESTRICTION[item.id]
elsif item.is_a?(RPG::Armor)
conditions = KGC::ER_ARMOR_RESTRICTION[item.id]
end
# 条件判定
if conditions != nil
return pass_equipment_restriction?(item, conditions)
end
end
return result
end
#--------------------------------------------------------------------------
# ● 装備条件通過判定
#--------------------------------------------------------------------------
def pass_equipment_restriction?(item, conditions)
if conditions[-1, 1] == true
all = conditions.pop
else
all = false
end
# 条件判定
conditions.each { |condition|
result = true
case condition[0]
when 0 # レベル
result = self.level >= condition[1]
when 1 # MAXHP
result = self.maxhp >= condition[1]
when 2 # MAXSP
result = self.maxsp >= condition[1]
when 3 # 腕力
result = self.str >= condition[1]
when 4 # 器用さ
result = self.dex >= condition[1]
when 5 # 素早さ
result = self.agi >= condition[1]
when 6 # 魔力
result = self.int >= condition[1]
when 10001..19999 # スイッチ
result = $game_switches[condition[0] - 10000]
when 20001..29999 # 変数
result = $game_variables[condition[0] - 20000] >= condition[1]
end
# 反転
if condition[2]
result = !result
end
if all
# 条件が成り立たない場合は false
unless result
return false
end
else
# 条件が成り立つ場合は true
if result
return true
end
end
}
return all
end
end