Thanks.. Almost was gonna pay but the potion tip worked and I got it working , only thing that would be nice is to have it show how much mana it is healing in purple or something.![]()
http://otland.net/threads/see-the-mana-from-mana-potions-in-purple-text.228013Thanks.. Almost was gonna pay but the potion tip worked and I got it working , only thing that would be nice is to have it show how much mana it is healing in purple or something.![]()
local config = {
-- first paladins spiritrune
[2299] = {health = {2000, 2500}, mana = {200, 400}, vocations = {3}, text = 'paladins', level = 250, emptyId = 2299},
-- first knights healthrune
[2307] = {health = {2250, 2850}, vocations = {4}, text = 'knights', level = 250, emptyId = 2307},
-- first mages manarune
[2283] = {mana = {2000, 2800}, vocations = {1, 2}, text = 'sorcerers and druids', level = 250, emptyId = 2283},
}
local antidote = Combat()
antidote:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
antidote:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
antidote:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
antidote:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
antidote:setParameter(COMBAT_PARAM_DISPEL, CONDITION_POISON)
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))
-- 1000 - 100 due to exact condition timing. -100 doesn't hurt us, and players don't have reminding ~50ms exhaustion.
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local potion = config[item.itemid]
if not potion then
return true
end
if itemEx.itemid ~= 1 or itemEx.type ~= THING_TYPE_PLAYER then
return true
end
if player:getCondition(CONDITION_EXHAUST_HEAL) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
return true
end
local target = Player(itemEx.uid)
if potion.antidote and not antidote:execute(target, Variant(itemEx.uid)) then
return false
end
if (potion.level and player:getLevel() < potion.level)
or (type(potion.vocations) == 'table' and not isInArray(potion.vocations, player:getVocation():getBase():getId()))
and not (player:getGroup():getId() >= 2) then
player:say(string.format('This custom rune can only be used by %s of level %d or higher.', potion.text, potion.level), TALKTYPE_MONSTER_SAY)
return true
end
if type(potion.health) == 'table' and not doTargetCombatHealth(0, target, COMBAT_HEALING, potion.health[1], potion.health[2], CONST_ME_MAGIC_RED) then
return false
end
if type(potion.mana) == 'table' and not doTargetCombatMana(0, target, potion.mana[1], potion.mana[2], CONST_ME_MAGIC_RED) then
return false
end
local cStorage = player:getStorageValue(Storage.Achievements.PotionAddict)
if cStorage < 100000 then
player:setStorageValue(Storage.Achievements.PotionAddict, math.max(1, cStorage) + 1)
elseif cStorage == 100000 then
player:addAchievement('Potion Addict')
player:setStorageValue(Storage.Achievements.PotionAddict, 100001)
end
player:addCondition(exhaust)
doCreatureSayWithRadius(target, 'Yeaah...', TALKTYPE_MONSTER_SAY, 2, 2, toPosition)
Item(item.uid):remove(1)
if fromPosition.x == CONTAINER_POSITION then
player:addItem(potion.emptyId, 1)
else
Game.createItem(potion.emptyId, 1, fromPosition)
end
return true
end
local config = {
-- first paladins spiritrune
[2299] = {health = {2000, 2500}, mana = {200, 400}, vocations = {3}, text = 'paladins', level = 250, emptyId = 2299},
-- first knights healthrune
[2307] = {health = {2250, 2850}, vocations = {4}, text = 'knights', level = 250, emptyId = 2307},
-- first mages manarune
[2283] = {mana = {2000, 2800}, vocations = {1, 2}, text = 'sorcerers and druids', level = 250, emptyId = 2283},
}
local antidote = Combat()
antidote:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
antidote:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
antidote:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
antidote:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
antidote:setParameter(COMBAT_PARAM_DISPEL, CONDITION_POISON)
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))
-- 1000 - 100 due to exact condition timing. -100 doesn't hurt us, and players don't have reminding ~50ms exhaustion.
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local potion = config[item.itemid]
if not potion then
return true
end
if itemEx.itemid ~= 1 or itemEx.type ~= THING_TYPE_PLAYER then
return true
end
if player:getCondition(CONDITION_EXHAUST_HEAL) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
return true
end
local target = Player(itemEx.uid)
if potion.antidote and not antidote:execute(target, Variant(itemEx.uid)) then
return false
end
if (potion.level and player:getLevel() < potion.level)
or (type(potion.vocations) == 'table' and not isInArray(potion.vocations, player:getVocation():getBase():getId()))
and not (player:getGroup():getId() >= 2) then
player:say(string.format('This custom rune can only be used by %s of level %d or higher.', potion.text, potion.level), TALKTYPE_MONSTER_SAY)
return true
end
if type(potion.health) == 'table' and not doTargetCombatHealth(0, target, COMBAT_HEALING, potion.health[1], potion.health[2], CONST_ME_MAGIC_RED) then
return false
end
if type(potion.mana) == 'table' then
local manas = math.floor(math.random((potion.mana[1]),(potion.mana[2])))
player:sendTextMessage(MESSAGE_EXPERIENCE, "You've gained "..manas.." mana.", player:getPosition(), "" .. manas .. "", TEXTCOLOR_PURPLE)
doSendMagicEffect(getPlayerPosition(player), CONST_ME_MAGIC_RED)
doPlayerAddMana(player, manas)
end
local cStorage = player:getStorageValue(Storage.Achievements.PotionAddict)
if cStorage < 100000 then
player:setStorageValue(Storage.Achievements.PotionAddict, math.max(1, cStorage) + 1)
elseif cStorage == 100000 then
player:addAchievement('Potion Addict')
player:setStorageValue(Storage.Achievements.PotionAddict, 100001)
end
player:addCondition(exhaust)
doCreatureSayWithRadius(target, 'Yeaah...', TALKTYPE_MONSTER_SAY, 2, 2, toPosition)
Item(item.uid):remove(1)
if fromPosition.x == CONTAINER_POSITION then
player:addItem(potion.emptyId, 1)
else
Game.createItem(potion.emptyId, 1, fromPosition)
end
return true
end
local config = {
-- first paladins spiritrune
[2299] = {health = {2000, 2500}, mana = {200, 400}, vocations = {3}, text = 'paladins', level = 250, emptyId = 2299},
-- first knights healthrune
[2307] = {health = {2250, 2850}, vocations = {4}, text = 'knights', level = 250, emptyId = 2307},
-- first mages manarune
[2283] = {mana = {2000, 2800}, vocations = {1, 2}, text = 'sorcerers and druids', level = 250, emptyId = 2283},
}
local antidote = Combat()
antidote:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
antidote:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
antidote:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
antidote:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
antidote:setParameter(COMBAT_PARAM_DISPEL, CONDITION_POISON)
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))
-- 1000 - 100 due to exact condition timing. -100 doesn't hurt us, and players don't have reminding ~50ms exhaustion.
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local potion = config[item.itemid]
if not potion then
return true
end
if itemEx.itemid ~= 1 or itemEx.type ~= THING_TYPE_PLAYER then
return true
end
if player:getCondition(CONDITION_EXHAUST_HEAL) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
return true
end
local target = Player(itemEx.uid)
if potion.antidote and not antidote:execute(target, Variant(itemEx.uid)) then
return false
end
if (potion.level and player:getLevel() < potion.level)
or (type(potion.vocations) == 'table' and not isInArray(potion.vocations, player:getVocation():getId()))
and not (player:getGroup():getId() >= 2) then
player:say(string.format('This custom rune can only be used by %s of level %d or higher.', potion.text, potion.level), TALKTYPE_MONSTER_SAY)
return true
end
if type(potion.health) == 'table' and not doTargetCombatHealth(0, target, COMBAT_HEALING, potion.health[1], potion.health[2], CONST_ME_MAGIC_RED) then
return false
end
if type(potion.mana) == 'table' then
local manas = math.floor(math.random((potion.mana[1]),(potion.mana[2])))
player:sendTextMessage(MESSAGE_EXPERIENCE, "You've gained "..manas.." mana.", player:getPosition(), "" .. manas .. "", TEXTCOLOR_PURPLE)
doSendMagicEffect(getPlayerPosition(player), CONST_ME_MAGIC_RED)
doPlayerAddMana(player, manas)
end
player:addCondition(exhaust)
doCreatureSayWithRadius(target, 'Yeaah...', TALKTYPE_MONSTER_SAY, 2, 2, toPosition)
Item(item.uid):remove(1)
if fromPosition.x == CONTAINER_POSITION then
player:addItem(potion.emptyId, 1)
else
Game.createItem(potion.emptyId, 1, fromPosition)
end
return true
end
<action itemid="2299" script="potion.lua"/>
<action itemid="2307" script="potion.lua"/>
<action itemid="2283" script="potion.lua"/>