rend.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. local Rend = extend(Buff)
  2. Rend.tags = {'crit'}
  3. Rend.runeChance = 0
  4. Rend.runePerStack = 0
  5. function Rend:preattack(target, amount)
  6. local level = self.unit:upgradeLevel('rend')
  7. local chances = {.08, .15, .21, .26, .30}
  8. local chance = self.runeChance + chances[level]
  9. local deathwishLevel = self.unit:upgradeLevel('deathwish')
  10. if deathwishLevel > 0 and target.health / target.maxHealth < .2 + .1 * deathwishLevel then
  11. chance = chance * 2
  12. end
  13. if love.math.random() < chance then
  14. local furyLevel = self.unit:upgradeLevel('fury')
  15. if furyLevel > 0 then
  16. local buff = self.unit.buffs:get('fury')
  17. local amount = self.runePerStack + ({.1, .12, .15})[furyLevel]
  18. if buff then buff.maxStacks = 2 + furyLevel end
  19. buff = self.unit.buffs:add('fury', {timer = 5})
  20. buff.frenzy = buff.stack and amount * buff.stacks or amount
  21. end
  22. local x, y = self.unit:attackParticlePosition(target)
  23. ctx.particles:emit('crit', x, y, 10)
  24. ctx.sound:play(data.media.sounds.xuju.crit)
  25. return amount * 2
  26. end
  27. return amount
  28. end
  29. function Rend:bonuses()
  30. local bonuses = {}
  31. if self.runeChance > 0 then
  32. table.insert(bonuses, {'Runes', math.round(self.runeChance * 100) .. '%', 'crit chance'})
  33. end
  34. return bonuses
  35. end
  36. return Rend