本帖最后由 taroxd 于 2014-11-23 07:40 编辑
morningboo 发表于 2014-11-22 21:25
本人水平较低,根据大大说的,自己想了下,貌似得从伤害结算入手,配合一个公式中可以使用公共事件的脚本 ...
用一个新的类来保存状态的信息,包括“a1, a2, a3”,“还有几回合结束”等等
并且,在每回合结算时,更新一次“状态”信息和角色信息。
这种事情不建议在公共事件完成,建议纯脚本+技能公式。
不想打开 RM 参考默认脚本了,就给你个思路吧:
class MyState def initialze @users = [] end def add_user(user, turn) @users.push [user, turn] end # how much hp to change def value @users.inject(0) {|a, (user, _)| a + user.atk * (rand * 0.05 + 0.15) } end # should be invoked every turn def update @users.delete_if {|pair| (pair[1] -= 1) <= 0 } end # define state-like methods such as :priority, :restriction if necessary end class Game_BattlerBase # when initialize # @my_state = MyState.new # when turn starts # @my_state.update # self.hp -= @my_statue.value.to_i # override methods such as :states if necessary # should be invoked in the formula def add_my_state(user, turn) @my_state.add_user user, turn end end
class MyState
def initialze
@users = []
end
def add_user(user, turn)
@users.push [user, turn]
end
# how much hp to change
def value
@users.inject(0) {|a, (user, _)| a + user.atk * (rand * 0.05 + 0.15) }
end
# should be invoked every turn
def update
@users.delete_if {|pair| (pair[1] -= 1) <= 0 }
end
# define state-like methods such as :priority, :restriction if necessary
end
class Game_BattlerBase
# when initialize
# @my_state = MyState.new
# when turn starts
# @my_state.update
# self.hp -= @my_statue.value.to_i
# override methods such as :states if necessary
# should be invoked in the formula
def add_my_state(user, turn)
@my_state.add_user user, turn
end
end
|