查看: 1684|回复: 1

[已经过期] 关于护盾跟施法者属性挂钩的脚本改造

[复制链接]
梦石
0
星屑
75
在线时间
345 小时
注册时间
2011-10-13
回帖
380
发表于 2016-10-4 16:01:53 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
寻找到一个护盾技能,但是好像只能施加固定数值的护盾,求问如何将护盾值改造成跟施法者属性挂钩
  1. module RPG
  2.   class UsableItem
  3.     def jiadunvalue
  4.       note.split(/[\r\n]+/).each { |line|
  5.         case line
  6.         when /<加盾:(\d+)>/i
  7.           return $1.to_i
  8.         end
  9.       }
  10.       return 0
  11.     end
  12.   end
  13. end
  14. class Game_Battler
  15.   def make_damage_value(user, item)
  16.     value = item.damage.eval(user, self, $game_variables)
  17.     value *= item_element_rate(user, item)
  18.     value *= pdr if item.physical?
  19.     value *= mdr if item.magical?
  20.     value *= rec if item.damage.recover?
  21.     value = apply_critical(value) if @result.critical
  22.     value = apply_variance(value, item.damage.variance)
  23.     value = apply_guard(value)
  24.     @dun = 0 if @dun.nil?
  25.     if item.damage.to_hp?
  26.       a = [value,@dun].min
  27.       value -= a
  28.       @dun -= a
  29.     end
  30.     @result.make_damage(value.to_i, item)
  31.   end
  32.   alias item_apply_dunval_zabing item_apply
  33.   def item_apply(user, item)
  34.     item_apply_dunval_zabing(user, item)
  35.     @dun += item.jiadunvalue
  36.   end
  37. end
复制代码

点评

问得好,@dun = 0 if @dun.nil?可以改成@dun||=0 ,然后后面就盾的数值就读取角色的属性来操作就好了。  发表于 2016-10-4 16:27
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部