#--------------------------------------------------------------------------
# ● 使用方法:在职业上备注以下内容
# <exp>
# 升级到等级 lv 所需要的总经验值公式
# </exp>
# 可以使用的参数:
# lv: 等级
# basis:基础值
# extra:修正值
# acc_a:增加度 a
# acc_b:增加度 b
#
# 例(默认公式):
# <exp>
# basis*((lv-1)**(0.9+acc_a/250))*
# lv*(lv+1)/(6+lv**2/50/acc_b)+
# (lv-1)*extra
# </exp>
#
# 注意事项:请尽量保证 lv 为 1 时,所需经验不要大于 0
#--------------------------------------------------------------------------
class RPG::Class < RPG::BaseItem
include Math
#--------------------------------------------------------------------------
# ● 达到指定等级需要累积的经验值
#--------------------------------------------------------------------------
original_formula = instance_method(:exp_for_level)
define_method :exp_for_level do |level|
@exp_formula ||=
if @note =~ /<exp>\s*(.+)\s*<\/exp>/mi
basis, extra, acc_a, acc_b = @exp_params.map(&:to_f)
eval("->(lv){lv=lv.to_f;(#{$1}).round}")
else
original_formula.bind(self)
end
@exp_formula.(level)
end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 等级最小值
#--------------------------------------------------------------------------
def min_level; 1; end
def min_level?; @level <= min_level; end
#--------------------------------------------------------------------------
# ● 经验值变化
#--------------------------------------------------------------------------
def change_exp(exp, show)
@exp[@class_id] = [exp, 0].max
last_level = @level
last_skills = skills
level_up while !max_level? && self.exp >= next_level_exp
level_down while !min_level? && self.exp < current_level_exp
display_level_up(skills - last_skills) if show && @level > last_level
refresh
end
end