ability.lua 641 B

1234567891011121314151617181920212223242526272829
  1. Ability = class()
  2. function Ability:init()
  3. self.timer = 0
  4. end
  5. function Ability:createSpell(code, vars)
  6. if not vars then code, vars = self.code, code end
  7. ctx.spells:add(data.spell[self.unit.class.code][code], table.merge(vars, {ability = self}, true))
  8. end
  9. function Ability:getUnitDirection()
  10. return (self.unit.animation.flipped and -1 or 1)
  11. end
  12. function Ability:canUse()
  13. return self.timer == 0
  14. end
  15. function Ability:rot()
  16. self.timer = self.timer - math.min(self.timer, ls.tickrate * self.unit.haste)
  17. if self.timer <= 0 then
  18. f.exe(self.ready, self)
  19. end
  20. end
  21. function Ability:used()
  22. self.timer = self.cooldown or 0
  23. end