plasmasickness.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. local PlasmaSickness = {}
  2. PlasmaSickness.name = 'PlasmaSickness'
  3. PlasmaSickness.code = 'plasmasickness'
  4. PlasmaSickness.text = 'This unit is slowed.'
  5. PlasmaSickness.hide = false
  6. PlasmaSickness.duration = 6
  7. function PlasmaSickness:activate()
  8. self.stacks = self.stacks or 1
  9. self.amount = self.owner.class.speed * .05 * self.stacks
  10. self.owner.haste = self.owner.haste - self.amount
  11. self.timer = self.duration
  12. self.depth = -10000
  13. if ctx.view then ctx.view:register(self) end
  14. end
  15. function PlasmaSickness:deactivate()
  16. self.owner.haste = self.owner.haste + self.amount
  17. if ctx.view then ctx.view:unregister(self) end
  18. end
  19. function PlasmaSickness:update()
  20. self.timer = timer.rot(self.timer, function()
  21. ctx.buffs:remove(self.owner, 'plasmasickness')
  22. end)
  23. end
  24. function PlasmaSickness:stack()
  25. self:deactivate()
  26. self.stacks = math.min(self.stacks + 1, 3)
  27. self:activate()
  28. end
  29. function PlasmaSickness:draw()
  30. local ox, oy = self.owner.drawX, self.owner.drawY - 120
  31. local dir = math.pi / 2
  32. for i = 1, self.stacks do
  33. local x1, y1 = ox + math.dx(10, dir), oy + math.dy(10, dir)
  34. local x2, y2 = x1 + math.dx(10, dir - .5), y1 + math.dy(10, dir - .5)
  35. local x3, y3 = x1 + math.dx(10, dir + .5), y1 + math.dy(10, dir + .5)
  36. love.graphics.setColor(0, 255, 255, 100 * self.owner.alpha)
  37. love.graphics.polygon('fill', x1, y1, x2, y2, x3, y3)
  38. love.graphics.setColor(0, 255, 255, 255 * self.owner.alpha)
  39. love.graphics.polygon('line', x1, y1, x2, y2, x3, y3)
  40. dir = dir + (2 * math.pi / 3)
  41. end
  42. end
  43. return PlasmaSickness