fear.lua 860 B

123456789101112131415161718192021222324252627282930313233
  1. local Fear = extend(Ability)
  2. ----------------
  3. -- Stats
  4. ----------------
  5. Fear.cooldown = 12
  6. Fear.duration = 1.75
  7. ----------------
  8. -- Behavior
  9. ----------------
  10. function Fear:activate()
  11. self.unit.animation:on('event', function(event)
  12. if event.data.name == 'fear' then
  13. local target = ctx.target:closest(self.unit, 'enemy', 'unit')
  14. if target and math.abs(self.unit.x - target.x) <= self.unit.range + self.unit.width / 2 + target.width / 2 then
  15. target.buffs:add('fear', {timer = self.duration, target = self.unit})
  16. ctx.sound:play(data.media.sounds.spuju.fear, function(sound) sound:setVolume(.5) end)
  17. end
  18. end
  19. end)
  20. end
  21. function Fear:use()
  22. if self.unit.target and isa(self.unit.target, Unit) then
  23. self.unit.animation:set('fear')
  24. self.unit.casting = true
  25. self.timer = self.cooldown
  26. end
  27. end
  28. return Fear