DOT.lua 1.6 KB

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