summon.lua 829 B

12345678910111213141516171819202122232425262728293031323334
  1. local summon = lib.object.create():include(lib.ability)
  2. function summon:getCost()
  3. return #util.filter(app.context.objects, 'isMinion')
  4. end
  5. function summon:canCast(owner)
  6. local muju = app.context.objects.muju
  7. return owner == muju and self:canPayJuju()
  8. end
  9. function summon:cast(owner, x, y)
  10. if not self:canCast(owner) then return false end
  11. self:payJuju()
  12. local distance = owner.config.radius + app.minions.bruju.config.radius
  13. local angle = util.angle(owner.position.x, owner.position.y, x, y)
  14. local minion = app.context:addObject(app.minions.bruju.object, {
  15. position = {
  16. x = owner.position.x + util.dx(distance, angle),
  17. y = owner.position.y + util.dy(distance, angle) / 2
  18. }
  19. })
  20. minion:command(x, y)
  21. self.lastCast = lib.tick.index
  22. owner.animation:set('summon')
  23. end
  24. return summon