bloodlust.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. local Bloodlust = {}
  2. ----------------
  3. -- Meta
  4. ----------------
  5. Bloodlust.name = 'Bloodlust'
  6. Bloodlust.code = 'bloodlust'
  7. Bloodlust.text = 'This Brute is gaining health because he killed someone.'
  8. Bloodlust.hide = false
  9. ----------------
  10. -- Data
  11. ----------------
  12. Bloodlust.heal = 15
  13. Bloodlust.rate = .25
  14. Bloodlust.duration = 6
  15. function Bloodlust:activate()
  16. self.timer = Bloodlust.duration
  17. self.healTimer = 0
  18. self.depth = 4
  19. if ctx.view then ctx.view:register(self) end
  20. end
  21. function Bloodlust:deactivate()
  22. if ctx.view then ctx.view:unregister(self) end
  23. end
  24. function Bloodlust:update()
  25. self.healTimer = self.healTimer - 1
  26. if self.healTimer <= 0 then
  27. self.owner:heal({amount = self.heal * self.rate})
  28. self.healTimer = math.round(Bloodlust.rate / tickRate)
  29. self.timer = self.timer - self.rate
  30. if self.timer <= 0 then ctx.buffs:remove(self.owner, self.code) end
  31. end
  32. end
  33. function Bloodlust:draw()
  34. love.graphics.setColor(128, 0, 0, 128)
  35. local x, y, s = self.owner.drawX, self.owner.drawY, self.owner.drawScale
  36. love.graphics.circle('fill', x, y, self.owner.radius * s * (1 + math.sin((self.timer + self.healTimer) * 50) / 4))
  37. end
  38. function Bloodlust:stack()
  39. self.timer = self.duration
  40. end
  41. return Bloodlust