DOT.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. DOT = Buff:New()
  2. --初始化Buff,通过传入一些自定义参数控制成长相关的数值
  3. function DOT:SetData(...)
  4. self.interval,
  5. self.damageType, --1 燃烧 2 中毒 3 流血 4 点燃 5 洪荒烈火 6 业火
  6. self.damagePro, --1 物理 2 魔法 (真实伤害时 为伤害值)
  7. self.damageFactor = ... --伤害系数
  8. self.isRealDamage = false
  9. self.isBeInfect = false --是否是被传染的buff
  10. --if self.damageType == 2 then
  11. -- self.cover = true
  12. -- self.layer = 1
  13. --else
  14. -- self.cover = false
  15. -- self.layer = nil
  16. --end
  17. self.isDeBuff = true
  18. -- 刷新排序等级
  19. self.sort = 2
  20. -- if self.damageType == 3 then -- 流血buff在行动之后刷新
  21. -- self.sort = 3
  22. -- end
  23. if self.damageType==5 or self.damageType==6 then
  24. local limit = self.caster:GetRoleData(RoleDataName.Attack) * 2
  25. if self.damagePro > limit then
  26. self.damagePro = limit
  27. end
  28. end
  29. self.damagePro=BattleUtil.ErrorCorrection(self.damagePro)
  30. self.damagePro=math.floor(self.damagePro)
  31. end
  32. --初始化后调用一次
  33. function DOT:OnStart()
  34. -- if self.caster.isTeam then
  35. -- self.isRealDamage = true
  36. -- end
  37. end
  38. --间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
  39. function DOT:OnTrigger()
  40. if self.isRealDamage then
  41. BattleUtil.ApplyDamage(nil, self.caster, self.target, self.damagePro, nil, nil,self.damageType,nil)
  42. else
  43. BattleUtil.CalDamage(nil, self.caster, self.target, self.damagePro, self.damageFactor, 0, self.damageType)
  44. end
  45. return true
  46. end
  47. --效果结束时调用一次
  48. function DOT:OnEnd()
  49. if self.isBeInfect then
  50. self.isBeInfect = false
  51. self.target.isBeInfect = false
  52. end
  53. end
  54. --只有当cover字段为true时触发,返回true则被新效果覆盖
  55. function DOT:OnCover(newBuff)
  56. --if self.damageType == 2 then
  57. -- newBuff.layer = self.layer + 1
  58. -- newBuff.damageFactor =
  59. --end
  60. return true
  61. end
  62. -- 比较buff
  63. function DOT:OnCompare(buff)
  64. return buff.damageType == self.damageType
  65. end
  66. return DOT