infusion.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. local Infusion = extend(Spell)
  2. local g = love.graphics
  3. function Infusion:activate()
  4. local unit, ability = self:getUnit(), self:getAbility()
  5. self.x = unit.x
  6. self.y = unit.y
  7. self.team = unit.team
  8. self.timer = ability.duration
  9. ctx.event:emit('view.register', {object = self})
  10. end
  11. function Infusion:deactivate()
  12. ctx.event:emit('view.unregister', {object = self})
  13. end
  14. function Infusion:update()
  15. local unit, ability = self:getUnit(), self:getAbility()
  16. if not unit then ctx.spells:remove(self) end
  17. self.timer = timer.rot(self.timer, function()
  18. ctx.spells:remove(self)
  19. end)
  20. table.each(ctx.target:inRange(self, ability.range, 'ally', 'unit'), function(ally)
  21. ally:heal(ally.maxHealth * ability.maxHealthHeal / ability.duration * ls.tickrate, unit)
  22. if ability:hasUpgrade('distortion') then
  23. ally.buffs:add('distortionhaste', {timer = ls.tickrate, haste = ability.upgrades.distortion.haste})
  24. end
  25. if ability:hasUpgrade('resilience') then
  26. ally.buffs:add('resilience', {timer = ls.tickrate})
  27. end
  28. end)
  29. if ability:hasUpgrade('distortion') then
  30. table.each(ctx.target:inRange(self, ability.range, 'enemy', 'unit'), function(enemy)
  31. enemy.buffs:add('distortionslow', {timer = ls.tickrate, slow = ability.upgrades.distortion.slow})
  32. end)
  33. end
  34. end
  35. function Infusion:draw()
  36. local ability = self:getAbility()
  37. g.setColor(self:getUnit().team == ctx.player.team and {0, 255, 0} or {255, 0 , 0})
  38. g.circle('line', self.x, self.y, ability.range)
  39. end
  40. return Infusion