class RPG::UsableItem::Damage MAX_DMG_RATE = 1 # 最大攻击增幅 BERSERKER_CLASS_ID = 1 # 狂战士职业id alias eval_for_berserker eval def eval(a, b, v) if a.actor? && a.class.id == BERSERKER_CLASS_ID rate = 1 + MAX_DMG_RATE * (1 - (a.hp - 1) / a.mhp.to_f) f = @formula.gsub("a.atk", "(a.atk * #{rate})") yield_formula(f){ eval_for_berserker(a, b, v) } else eval_for_berserker(a, b, v) end end def yield_formula(formula) original_formula = @formula @formula = formula result = yield @formula = original_formula result end end
class RPG::UsableItem::Damage
MAX_DMG_RATE = 1 # 最大攻击增幅
BERSERKER_CLASS_ID = 1 # 狂战士职业id
alias eval_for_berserker eval
def eval(a, b, v)
if a.actor? && a.class.id == BERSERKER_CLASS_ID
rate = 1 + MAX_DMG_RATE * (1 - (a.hp - 1) / a.mhp.to_f)
f = @formula.gsub("a.atk", "(a.atk * #{rate})")
yield_formula(f){ eval_for_berserker(a, b, v) }
else
eval_for_berserker(a, b, v)
end
end
def yield_formula(formula)
original_formula = @formula
@formula = formula
result = yield
@formula = original_formula
result
end
end
插入 ▼ 插件脚本 之下、 Main 之上 |