9
3

Sprint.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. ModifyPower(Caster, -1 * (total_power * .1))
  23. end
  24. if GetTempVariable(Caster, "sprint_bonus_active") ~= "true" then
  25. AddSpellBonus(Caster, 609, Speed)
  26. end
  27. SetTempVariable(Caster, "sprint_bonus_active", "true")
  28. SetTempVariable(Caster, "sprint_bonus_x", GetX(Caster) .. "")
  29. SetTempVariable(Caster, "sprint_bonus_y", GetY(Caster) .. "")
  30. SetTempVariable(Caster, "sprint_bonus_z", GetZ(Caster) .. "")
  31. end
  32. end
  33. function SprinterHasMoved(Caster, is_tick)
  34. if is_tick ~= true then
  35. return true
  36. end
  37. local ret = false
  38. if GetTempVariable(Caster, "sprint_bonus_x") ~= GetX(Caster) .. "" then
  39. ret = true
  40. elseif GetTempVariable(Caster, "sprint_bonus_y") ~= GetY(Caster) .. "" then
  41. ret = true
  42. elseif GetTempVariable(Caster, "sprint_bonus_z") ~= GetZ(Caster) .. "" then
  43. ret = true
  44. end
  45. return ret
  46. end
  47. function tick(Caster, Target, Speed)
  48. cast(Caster, Target, Speed, true)
  49. end
  50. function remove(Caster)
  51. RemoveSpellBonus()
  52. SetTempVariable(Caster, "sprint_bonus_active", nil)
  53. SetTempVariable(Caster, "sprint_bonus_x", nil)
  54. SetTempVariable(Caster, "sprint_bonus_y", nil)
  55. SetTempVariable(Caster, "sprint_bonus_z", nil)
  56. end