Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onUse(player, item, fromPosition, target, toPosition, isHotkey)
- -------------------------------------------
- -- Config
- -------------------------------------------
- local exhaustStorage = 2017 -- This storage is used for the cooldown.
- local config = {
- ["manaRune"] = {
- itemId = 2275, --Set the item id here.
- effect = CONST_ME_HOLYDAMAGE, -- Set the effect here
- cooldown = 1, -- Set the exhaust time here. (1 = 1 second)
- allowedVocs = {1, 2, 5, 6},
- formulas = {
- -- Set the min and max values here.
- min = player:getLevel() * (1.4) + player:getMagicLevel() * (1.6) + 400,
- max = player:getLevel() * (1.4) + player:getMagicLevel() * (1.6) + 750,
- },
- },
- ["healthRune"] = {
- itemId = 2297,
- effect = CONST_ME_HOLYDAMAGE,
- cooldown = 1,
- allowedVocs = {4, 8} ,
- formulas = {
- min = math.ceil(player:getLevel() * (1.4) + player:getMagicLevel() * (1.65) + 450),
- max = math.ceil(player:getLevel() * (1.4) + player:getMagicLevel() * (1.65) + 750),
- },
- },
- ["paladinRune"] = {
- itemId = 2300,
- effect = CONST_ME_HOLYDAMAGE,
- cooldown = 1,
- allowedVocs = {3, 7},
- formulas = {
- min = player:getLevel() * (1.4) + player:getMagicLevel() * (1.5) + 400,
- max = player:getLevel() * (1.4) + player:getMagicLevel() * (1.5) + 750,
- },
- },
- }
- -------------------------------------------
- -- Script
- -------------------------------------------
- if player:getExhaustion(exhaustStorage) > 0 then
- player:getPosition():sendMagicEffect(CONST_ME_POFF)
- player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You are exhausted." )
- return true
- end
- local rune
- for k,v in pairs(config) do
- if item:getId() == v.itemId then
- rune = k
- end
- end
- if rune == nil then
- print("Rune ID not found in confg")
- return true
- end
- local settings = config[rune]
- local amount = math.random(settings.formulas.min, settings.formulas.max)
- local playerVoc = player:getVocation():getId()
- if rune == "manaRune" then
- if table.contains(settings.allowedVocs, playerVoc) then
- player:say('+'..amount.."mp", TALKTYPE_MONSTER_SAY)
- player:addMana(amount)
- player:getPosition():sendMagicEffect(settings.effect)
- else
- player:getPosition():sendMagicEffect(CONST_ME_POFF)
- player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You cannot use this rune." )
- return true
- end
- elseif rune == "healthRune" then
- if table.contains(settings.allowedVocs, playerVoc) then
- player:say('+'..amount.."hp", TALKTYPE_MONSTER_SAY)
- player:addMana(amount)
- player:getPosition():sendMagicEffect(settings.effect)
- else
- player:getPosition():sendMagicEffect(CONST_ME_POFF)
- player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You cannot use this rune." )
- return true
- end
- elseif rune == "paladinRune" then
- if table.contains(settings.allowedVocs, playerVoc) then
- player:say('+'..amount.."mp", TALKTYPE_MONSTER_SAY)
- player:say('+'..amount.."hp", TALKTYPE_MONSTER_SAY)
- player:addMana(amount)
- player:addHealth(amount)
- player:getPosition():sendMagicEffect(settings.effect)
- else
- player:getPosition():sendMagicEffect(CONST_ME_POFF)
- player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You cannot use this rune." )
- return true
- end
- end
- player:setExhaustion(exhaustStorage, settings.cooldown)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement