shiverarmor.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. local ShiverArmor = extend(Buff)
  2. ShiverArmor.tags = {}
  3. function ShiverArmor:prehurt(amount, source, kind)
  4. if source and kind and table.has(kind, 'attack') then
  5. local damage = self:getDamage()
  6. local stunChance = self:getStunChance()
  7. source:hurt(damage, self.player)
  8. if source.buffs and love.math.random() < stunChance then
  9. source.buffs:add('crystallize', {timer = self.stunDuration})
  10. end
  11. end
  12. end
  13. function ShiverArmor:update()
  14. if love.math.random() < .2 and not ctx.player.dead then
  15. ctx.particles:emit('kujuattack', self.player.x, self.player.y + self.player.height / 2 + love.math.randomNormal(15), 1)
  16. end
  17. end
  18. function ShiverArmor:die()
  19. if data.unit.kuju.upgrades.frostnova.level > 0 then
  20. local targets = ctx.target:inRange(ctx.player, 180, 'enemy', 'unit')
  21. table.each(targets, function(target)
  22. local damage = self:getDamage()
  23. local stunChance = self:getStunChance()
  24. target:hurt(damage, self.player)
  25. ctx.particles:emit('frozenorb', target.x, target.y, 1)
  26. if target.buffs and love.math.random() < stunChance then
  27. target.buffs:add('crystallize', {timer = self.stunDuration})
  28. end
  29. end)
  30. end
  31. end
  32. function ShiverArmor:getDamage()
  33. local ability = data.ability.kuju.shiverarmor
  34. local level = data.unit.kuju.upgrades.shiverarmor.level
  35. local spirit = Unit.getStat('kuju', 'spirit')
  36. return ability.runeDamage + 15 * level + ability.spiritRatio * spirit
  37. end
  38. function ShiverArmor:getStunChance()
  39. local ability = data.ability.kuju.shiverarmor
  40. local level = data.unit.kuju.upgrades.crystallize.level
  41. return level > 0 and (ability.runeStunChance + .05 + .15 * level) or 0
  42. end
  43. return ShiverArmor