Control.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Control = Buff:New()
  2. --初始化Buff,通过传入一些自定义参数控制成长相关的数值
  3. function Control:SetData(...)
  4. self.ctrlType = ...
  5. self.cover = true --控制效果可被覆盖
  6. -- 刷新排序等级
  7. self.sort = 4
  8. end
  9. --初始化后调用一次
  10. function Control:OnStart()
  11. if self.ctrlType == 1 then --眩晕
  12. self.target.ctrl_dizzy = true
  13. elseif self.ctrlType == 2 then --沉默
  14. self.target.ctrl_slient = true
  15. elseif self.ctrlType == 3 then --嘲讽(包括沉默)
  16. self.target.lockTarget = self.caster
  17. self.target.ctrl_slient = true
  18. elseif self.ctrlType == 4 then --禁疗
  19. self.target.ctrl_noheal = true
  20. elseif self.ctrlType == 5 then --致盲
  21. self.target.ctrl_blind = true
  22. elseif self.ctrlType == 7 then --麻痹
  23. self.target.ctrl_palsy = true
  24. end
  25. self.target.ctrltimes = self.target.ctrltimes + 1
  26. end
  27. --间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
  28. function Control:OnTrigger()
  29. return true
  30. end
  31. --效果结束时调用一次
  32. function Control:OnEnd()
  33. if self.ctrlType == 1 then --眩晕
  34. self.target.ctrl_dizzy = false
  35. elseif self.ctrlType == 2 then --沉默
  36. self.target.ctrl_slient = false
  37. elseif self.ctrlType == 3 then --嘲讽(包括沉默)
  38. self.target.lockTarget = nil
  39. self.target.ctrl_slient = false
  40. elseif self.ctrlType == 4 then --禁疗
  41. self.target.ctrl_noheal = false
  42. elseif self.ctrlType == 5 then --致盲
  43. self.target.ctrl_blind = false
  44. elseif self.ctrlType == 7 then --麻痹
  45. self.target.ctrl_palsy = false
  46. end
  47. end
  48. --只有当cover字段为true时触发,返回true则被新效果覆盖
  49. function Control:OnCover(newBuff)
  50. return newBuff.ctrlType == self.ctrlType
  51. end
  52. -- 比较buff
  53. function Control:OnCompare(buff)
  54. return self.ctrlType == buff.ctrlType
  55. end
  56. return Control