#===============================================================================
# ■ 【简易坑爹系列】武器、装备及状态限制技能脚本
#-------------------------------------------------------------------------------
# 使用方法:
# 1. 插入Game_Actor之后,Main之前的任意位置。
# 1. 在下面设置需要被视为武器种类的属性名称。
# 2. 在属性列表内增加相对应的属性
# 3. 利用武器属性来设置种类,每个武器只能归类到一个种类。
# 4. 利用技能属性来设置发动技能需要的武器种类,可以设置多个,但只需满足其中
# 一个便可发动。
# 5. 没有设定条件的技能在任何武器或没有武器的情况下皆可发动。
# 6. 上面所述皆可运用在装备及状态
#===============================================================================
module WLS
#-----------------------------------------------------------------------------
# 名称列在此的属性会被视为武器种类处理。
# 被视为武器种类的属性将不会对伤害造成任何影响。
#-----------------------------------------------------------------------------
TYPES = ["剑", "刀", "杖"]
#-----------------------------------------------------------------------------
unless defined?(ACTOR)
ACTOR = ::Game_Actor
WEAPON = ::RPG::Weapon
SKILL = ::RPG::Skill
ITEM = ::RPG::Item
ARMOR = ::RPG::Armor
ENEMY = ::RPG::Enemy
CLASS = ::RPG::Class
STATE = ::RPG::State
end
module_function
def elementSetClass(claz, prefix = '')
copy_const(::Class.new(claz){
define_method(prefix.to_s + 'element_set') do
set = super.clone
temp = ::WLS::TYPES.map{|t|$data_system.elements.index(t)}
set.delete_if{|e|temp.include?(e)}
return set
end
})
end
def elementRanksClass(claz)
copy_const(::Class.new(claz) {
def element_ranks
ranks = super.clone
::WLS::TYPES.each do |t|
ranks[$data_system.elements.index(t)] = 3
end
return ranks
end
})
end
def copy_const(claz)
claz.superclass.constants.each do |c|
claz.const_set(c, claz.superclass.const_get(c))
end
return claz
end
def define_type(claz, var)
claz.const_set(:VAR, var)
claz.class_eval do
def type
temp = WLS::TYPES.map{|t|$data_system.elements.index(t)}
return instance_variable_get(self.class::VAR).find{|e|temp.include?(e)}
end
end
end
end
Game_Actor = Class.new(WLS::ACTOR) do
def skill_can_use?(skill)
orig = super(skill)
skill = skill.is_a?(RPG::Skill) ? skill : $data_skills[skill]
types = [$data_weapons[self.weapon_id].type]
types |= [@armor1_id, @armor2_id, @armor3_id, @armor4_id].map{|i|$data_armors[i].type}
types |= @states.map{|s|$data_states[s].type}
return ((skill.required_types.empty? or skill.required_types.any?{|t|types.include?(t)}) and orig)
end
end
module RPG
Weapon = ::WLS.elementSetClass(::WLS::WEAPON)
Skill = ::WLS.elementSetClass(::WLS::SKILL)
Item = ::WLS.elementSetClass(::WLS::ITEM)
Armor = ::WLS.elementSetClass(::WLS::ARMOR, :guard_)
State = ::WLS.elementSetClass(::WLS::STATE, :guard_)
Class = ::WLS.elementRanksClass(::WLS::CLASS)
Enemy = ::WLS.elementRanksClass(::WLS::ENEMY)
::WLS.define_type(Weapon, :@element_set)
::WLS.define_type(Armor, :@guard_element_set)
::WLS.define_type(State, :@guard_element_set)
class Skill
def required_types
temp = WLS::TYPES.map{|t|$data_system.elements.index(t)}
return @element_set.find_all{|e|temp.include?(e)}
end
end
end