battleaxe.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. local BattleAxe = {}
  2. BattleAxe.name = 'BattleAxe'
  3. BattleAxe.code = 'battleaxe'
  4. BattleAxe.text = 'Rawr!'
  5. BattleAxe.type = 'weapon'
  6. BattleAxe.damage = 45
  7. BattleAxe.cooldown = 1.1
  8. function BattleAxe:activate(owner)
  9. self.timer = 0
  10. end
  11. function BattleAxe:update(owner)
  12. self.timer = timer.rot(self.timer)
  13. end
  14. function BattleAxe:canFire(owner)
  15. return self.timer == 0
  16. end
  17. function BattleAxe:fire(owner)
  18. ctx.spells:activate(owner.id, data.spell.battleaxe)
  19. self.timer = self.cooldown
  20. end
  21. BattleAxe.reload = f.empty
  22. function BattleAxe:crosshair()
  23. local g, p, b, x, y = love.graphics, ctx.players:get(ctx.id), data.spell.battleaxe, ctx.view:frameMouseX(), ctx.view:frameMouseY()
  24. local v = ctx.view
  25. local t = (self.timer / self.cooldown)
  26. local o = (t ^ 2 * ((1 + 1.6) * t - 1.6)) * (b.radius + 10)
  27. if math.distance(x, y, (p.x - v.x) * v.scale, (p.y - v.y) * v.scale) < b.distance * v.scale then
  28. x, y = p.x + math.dx(b.distance, p.angle) - v.x, p.y + math.dy(b.distance, p.angle) - v.y
  29. x, y = x * v.scale, y * v.scale
  30. end
  31. g.setColor(255, 255, 255, 255 * (1 - p.cloak / 2))
  32. g.setLineWidth(2)
  33. for i = 1, 4 do
  34. local ang = p.angle - math.pi / 4 + (i * math.pi / 2)
  35. local x1, y1 = x + math.dx(b.radius / 2 - 4 - o, ang), y + math.dy(b.radius / 2 - 4 - o, ang)
  36. local x2, y2 = x + math.dx(b.radius / 2 + 4 - o, ang), y + math.dy(b.radius / 2 + 4 - o, ang)
  37. g.line(x1, y1, x2, y2)
  38. end
  39. g.setLineWidth(1)
  40. end
  41. return BattleAxe