Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  2. -------------------------------------------
  3. -- Config
  4. -------------------------------------------
  5. local exhaustStorage = 2017 -- This storage is used for the cooldown.
  6. local config = {
  7. ["manaRune"] = {
  8. itemId = 2275, --Set the item id here.
  9. effect = CONST_ME_HOLYDAMAGE, -- Set the effect here
  10. cooldown = 1, -- Set the exhaust time here. (1 = 1 second)
  11. allowedVocs = {1, 2, 5, 6},
  12. formulas = {
  13. -- Set the min and max values here.
  14. min = player:getLevel() * (1.4) + player:getMagicLevel() * (1.6) + 400,
  15. max = player:getLevel() * (1.4) + player:getMagicLevel() * (1.6) + 750,
  16. },
  17. },
  18. ["healthRune"] = {
  19. itemId = 2297,
  20. effect = CONST_ME_HOLYDAMAGE,
  21. cooldown = 1,
  22. allowedVocs = {4, 8} ,
  23. formulas = {
  24. min = math.ceil(player:getLevel() * (1.4) + player:getMagicLevel() * (1.65) + 450),
  25. max = math.ceil(player:getLevel() * (1.4) + player:getMagicLevel() * (1.65) + 750),
  26. },
  27. },
  28. ["paladinRune"] = {
  29. itemId = 2300,
  30. effect = CONST_ME_HOLYDAMAGE,
  31. cooldown = 1,
  32. allowedVocs = {3, 7},
  33. formulas = {
  34. min = player:getLevel() * (1.4) + player:getMagicLevel() * (1.5) + 400,
  35. max = player:getLevel() * (1.4) + player:getMagicLevel() * (1.5) + 750,
  36. },
  37. },
  38. }
  39.  
  40. -------------------------------------------
  41. -- Script
  42. -------------------------------------------
  43. if player:getExhaustion(exhaustStorage) > 0 then
  44. player:getPosition():sendMagicEffect(CONST_ME_POFF)
  45. player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You are exhausted." )
  46. return true
  47. end
  48.  
  49. local rune
  50. for k,v in pairs(config) do
  51. if item:getId() == v.itemId then
  52. rune = k
  53. end
  54. end
  55.  
  56. if rune == nil then
  57. print("Rune ID not found in confg")
  58. return true
  59. end
  60.  
  61.  
  62. local settings = config[rune]
  63. local amount = math.random(settings.formulas.min, settings.formulas.max)
  64. local playerVoc = player:getVocation():getId()
  65.  
  66. if rune == "manaRune" then
  67. if table.contains(settings.allowedVocs, playerVoc) then
  68. player:say('+'..amount.."mp", TALKTYPE_MONSTER_SAY)
  69. player:addMana(amount)
  70. player:getPosition():sendMagicEffect(settings.effect)
  71. else
  72. player:getPosition():sendMagicEffect(CONST_ME_POFF)
  73. player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You cannot use this rune." )
  74. return true
  75. end
  76.  
  77. elseif rune == "healthRune" then
  78. if table.contains(settings.allowedVocs, playerVoc) then
  79. player:say('+'..amount.."hp", TALKTYPE_MONSTER_SAY)
  80. player:addMana(amount)
  81. player:getPosition():sendMagicEffect(settings.effect)
  82. else
  83. player:getPosition():sendMagicEffect(CONST_ME_POFF)
  84. player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You cannot use this rune." )
  85. return true
  86. end
  87.  
  88. elseif rune == "paladinRune" then
  89. if table.contains(settings.allowedVocs, playerVoc) then
  90. player:say('+'..amount.."mp", TALKTYPE_MONSTER_SAY)
  91. player:say('+'..amount.."hp", TALKTYPE_MONSTER_SAY)
  92. player:addMana(amount)
  93. player:addHealth(amount)
  94. player:getPosition():sendMagicEffect(settings.effect)
  95. else
  96. player:getPosition():sendMagicEffect(CONST_ME_POFF)
  97. player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You cannot use this rune." )
  98. return true
  99. end
  100. end
  101.  
  102. player:setExhaustion(exhaustStorage, settings.cooldown)
  103. return true
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement