staticgrenade.lua 974 B

12345678910111213141516171819202122232425262728293031323334353637
  1. local StaticGrenade = {}
  2. ----------------
  3. -- Meta
  4. ----------------
  5. StaticGrenade.name = 'Static Grenade'
  6. StaticGrenade.code = 'staticgrenade'
  7. StaticGrenade.text = 'This unit is slowed and disarmed.'
  8. StaticGrenade.hide = false
  9. ----------------
  10. -- Data
  11. ----------------
  12. StaticGrenade.disarmDuration = 1.75
  13. StaticGrenade.slowDuration = 1.25
  14. function StaticGrenade:activate()
  15. local stacks, buff = 0, ctx.buffs:get(self.owner, 'plasmasickness')
  16. stacks = buff and buff.stacks or 0
  17. self.owner.disarm = math.max(self.owner.disarm, self.disarmDuration)
  18. self.slowAmount = self.owner.class.speed * (.2 + (.2 * stacks))
  19. self.owner.haste = self.owner.haste - self.slowAmount
  20. self.timer = self.slowDuration
  21. end
  22. function StaticGrenade:deactivate()
  23. self.owner.haste = self.owner.haste + self.slowAmount
  24. end
  25. function StaticGrenade:update()
  26. self.timer = timer.rot(self.timer, function()
  27. ctx.buffs:remove(self.owner, 'staticgrenade')
  28. end)
  29. end
  30. return StaticGrenade