SentientCookie

Celestial Arc ability lua

Jan 24th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. require "/scripts/util.lua"
  2. require "/items/active/weapons/weapon.lua"
  3.  
  4. CelestialArc = WeaponAbility:new()
  5.  
  6. function CelestialArc:init()
  7. self.cooldownTimer = self.cooldownTime
  8. end
  9.  
  10. function CelestialArc:update(dt, fireMode, shiftHeld)
  11. WeaponAbility.update(self, dt, fireMode, shiftHeld)
  12.  
  13. self.cooldownTimer = math.max(0, self.cooldownTimer - dt)
  14.  
  15. if self.weapon.currentAbility == nil and self.fireMode == "alt" and self.cooldownTimer == 0 and status.overConsumeResource("energy", self.energyUsage) then
  16. self:setState(self.windup)
  17. end
  18. end
  19.  
  20. function CelestialArc:windup()
  21. self.weapon:setStance(self.stances.windup)
  22. self.weapon:updateAim()
  23.  
  24. util.wait(self.stances.windup.duration)
  25.  
  26. self:setState(self.fire)
  27. end
  28.  
  29. function CelestialArc:fire()
  30. self.weapon:setStance(self.stances.fire)
  31. self.weapon:updateAim()
  32.  
  33. local position = vec2.add(mcontroller.position(), {self.projectileOffset[1] * mcontroller.facingDirection(), self.projectileOffset[2]})
  34. local params = {
  35. powerMultiplier = activeItem.ownerPowerMultiplier(),
  36. power = self:damageAmount()
  37. }
  38. world.spawnProjectile(self.projectileType, position, activeItem.ownerEntityId(), self:aimVector(), false, params)
  39.  
  40. animator.playSound(self:slashSound())
  41.  
  42. util.wait(self.stances.fire.duration)
  43. self.cooldownTimer = self.cooldownTime
  44. end
  45.  
  46. function CelestialArc:slashSound()
  47. return self.weapon.elementalType.."TravelSlash"
  48. end
  49.  
  50. function CelestialArc:aimVector()
  51. return {mcontroller.facingDirection(), 0}
  52. end
  53.  
  54. function CelestialArc:damageAmount()
  55. return self.baseDamage * config.getParameter("damageLevelMultiplier")
  56. end
  57.  
  58. function CelestialArc:uninit()
  59. end
Advertisement
Add Comment
Please, Sign In to add comment