frostbite.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. local Frostbite = extend(Ability)
  2. Frostbite.cooldown = 20
  3. Frostbite.runeDamage = 0
  4. Frostbite.runeSize = 0
  5. ----------------
  6. -- Behavior
  7. ----------------
  8. function Frostbite:activate()
  9. self.timer = love.math.random() * self.cooldown
  10. self.unit.animation:on('event', function(event)
  11. if event.data.name == 'frostbite' then
  12. local target = ctx.target:closest(self.unit, 'enemy', 'unit')
  13. if target and math.abs(self.unit.x - target.x) <= self.unit.range + self.unit.width / 2 + target.width / 2 then
  14. self:createSpell({x = target.x})
  15. self.timer = self.cooldown
  16. end
  17. end
  18. end)
  19. end
  20. function Frostbite:use(target)
  21. if self.unit.target and isa(self.unit.target, Unit) then
  22. self.unit.animation:set('frostbite')
  23. self.unit.casting = true
  24. end
  25. end
  26. function Frostbite:bonuses()
  27. local bonuses = {}
  28. if self.runeDamage > 0 then
  29. table.insert(bonuses, {'Runes', math.round(self.runeDamage), 'damage'})
  30. end
  31. if self.runeSize > 0 then
  32. table.insert(bonuses, {'Runes', math.round(self.runeSize * 100) .. '%', 'size'})
  33. end
  34. return bonuses
  35. end
  36. return Frostbite