在Game_Battler这一栏里
#--------------------------------------------------------------------------
# ● 定义状态变化变量
#--------------------------------------------------------------------------
def staterate
return $game_variables[2]
end
#--------------------------------------------------------------------------
# ● 计算状态变化
# obj : 技能、物品或攻击者
#--------------------------------------------------------------------------
def apply_state_changes(obj)
plus = obj.plus_state_set # 获取状态变化(+)
minus = obj.minus_state_set # 获取状态变化(-)
for i in plus # 状态变化(+)
next if state_resist?(i) # 判断状态是否无效
next if dead? # 判断是否无法战斗
next if i == 1 and @immortal # 判断是否为不死身
if state?(i) # 判断状态是否已存在
@remained_states.push(i) # 记录为变更状态
next
end
if obj.is_a?(RPG::Skill)
if obj.description[0,2] == "10"
$game_variables[2] = 10
elsif obj.description[0,2] == "20"
$game_variables[2] = 20
elsif obj.description[0,2] == "30"
$game_variables[2] = 30
elsif obj.description[0,2] == "40"
$game_variables[2] = 40
elsif obj.description[0,2] == "50"
$game_variables[2] = 50
elsif obj.description[0,2] == "60"
$game_variables[2] = 60
elsif obj.description[0,2] == "70"
$game_variables[2] = 70
else
$game_variables[2] = 100
end
else
$game_variables[2] = 100
end
if rand(100) < staterate * state_probability(i) / 100 # 计算状态机率
add_state(i) # 附加状态
@added_states.push(i) # 记录已附加状态
end
end
for i in minus # 状态变化(-)
next unless state?(i) # 判断状态是否已存在
remove_state(i) # 移除状态
@removed_states.push(i) # 记录以移除状态
end
for i in @added_states & @removed_states # 清除附加和移除状态
@added_states.delete(i)
@removed_states.delete(i)
end
end