Sprint.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --[[
  2. Script Name : Spells/Commoner/Sprint.lua
  3. Script Purpose : Sprint
  4. Script Author : theFoof
  5. Script Date : 2014.3.9
  6. Script Note :
  7. --]]
  8. function cast(Caster, Target, Speed, is_tick)
  9. local has_moved = SprinterHasMoved(Caster, is_tick)
  10. if not has_moved and GetTempVariable(Caster, "sprint_bonus_active") == "true" then
  11. return
  12. end
  13. local power_left = GetPower(Caster)
  14. local total_power = GetMaxPower(Caster)
  15. if power_left - (total_power * .1) < 0 then
  16. if GetTempVariable(Caster, "sprint_bonus_active") == "true" then
  17. RemoveSpellBonus()
  18. SetTempVariable(Caster, "sprint_bonus_active", nil)
  19. end
  20. else
  21. if is_tick == true then
  22. local total_power = GetMaxPower(Caster)
  23. ModifyPower(Caster, (-1 *(total_power * .1)))
  24. end
  25. if GetTempVariable(Caster, "sprint_bonus_active") ~= "true" then
  26. AddSpellBonus(Caster, 609, Speed)
  27. end
  28. SetTempVariable(Caster, "sprint_bonus_active", "true")
  29. SetTempVariable(Caster, "sprint_bonus_x", GetX(Caster) .. "")
  30. SetTempVariable(Caster, "sprint_bonus_y", GetY(Caster) .. "")
  31. SetTempVariable(Caster, "sprint_bonus_z", GetZ(Caster) .. "")
  32. end
  33. end
  34. function SprinterHasMoved(Caster, is_tick)
  35. if is_tick ~= true then
  36. return true
  37. end
  38. local ret = false
  39. if GetTempVariable(Caster, "sprint_bonus_x") ~= GetX(Caster) .. "" then
  40. ret = true
  41. elseif GetTempVariable(Caster, "sprint_bonus_y") ~= GetY(Caster) .. "" then
  42. ret = true
  43. elseif GetTempVariable(Caster, "sprint_bonus_z") ~= GetZ(Caster) .. "" then
  44. ret = true
  45. end
  46. return ret
  47. end
  48. function tick(Caster, Target, Speed)
  49. cast(Caster, Target, Speed, true)
  50. end
  51. function remove(Caster)
  52. RemoveSpellBonus()
  53. SetTempVariable(Caster, "sprint_bonus_active", nil)
  54. SetTempVariable(Caster, "sprint_bonus_x", nil)
  55. SetTempVariable(Caster, "sprint_bonus_y", nil)
  56. SetTempVariable(Caster, "sprint_bonus_z", nil)
  57. end