local config = {
removeOnUse = "no",
usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
splashable = "no",
realAnimation = "no", -- make text effect visible only for players in range 1x1
healthMultiplier = 15,
manaMultiplier = 15
}
config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)
local POTIONS = {
[8704] = {empty = 7636, splash = 2, health = {50, 100}, storage = 49990}, -- small health potion
[7618] = {empty = 7636, splash = 2, health = {0.6,0.8,1.2}, storage = 49989}, -- health potion
[7588] = {empty = 7634, splash = 2, health = {2.1,2,2.5}, level = 50, storage = 49988}, -- strong health potion
[7591] = {empty = 7635, splash = 2, health = {4,7,10}, level = 80, storage = 49987}, -- great health potion
[8473] = {empty = 7635, splash = 2, health = 7, level = 130, storage = 49986}, -- ultimate health potion
[7620] = {empty = 7636, splash = 7, mana = {1.5,1.1,0.5}, storage = 49985}, -- mana potion
[7589] = {empty = 7634, splash = 7, mana = {3.5,2,1}, level = 50, storage = 49984}, -- strong mana potion
[7590] = {empty = 7635, splash = 7, mana = {8,6,2.5}, level = 80, storage = 49983}, -- great mana potion
[8472] = {empty = 7635, splash = 3, health = 3, mana = 3, level = 80, storage = 49982} -- great spirit potion
}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = POTIONS[item.itemid]
if(not potion) then
return false
end
if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
if(not config.splashable) then
return false
end
if(toPosition.x == CONTAINER_POSITION) then
toPosition = getThingPos(item.uid)
end
doDecayItem(doCreateItem(2016, potion.splash, toPosition))
doTransformItem(item.uid, potion.empty)
return true
end
if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if potion.level and getPlayerLevel(cid) < potion.level and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) then
doCreatureSay(itemEx.uid, "You Need " .. potion.level .. " level for use this fluid.", TALKTYPE_ORANGE_1)
return true
end
local health = potion.health
local mana = potion.mana
if getPlayerStorageValue(cid, potion.storage) > 1 then
-- MAGOS
if getPlayerVocation(cid) == 1 and getPlayerVocation(cid) == 5 and getPlayerVocation(cid) == 9 and getPlayerVocation(cid) == 2 and getPlayerVocation(cid) == 6 and getPlayerVocation(cid) == 10 then
if health and not doCreatureAddHealth(itemEx.uid, getPlayerLevel(cid) * health[1]) then
return false
end
if mana and not doPlayerAddMana(itemEx.uid, getPlayerLevel(cid) * mana[1]) then
return false
end
end
-- PALLY
if getPlayerVocation(cid) == 3 and getPlayerVocation(cid) == 7 and getPlayerVocation(cid) == 11 then
if health and not doCreatureAddHealth(itemEx.uid, getPlayerLevel(cid) * health[2]) then
return false
end
if mana and not doPlayerAddMana(itemEx.uid, getPlayerLevel(cid) * mana[2]) then
return false
end
end
-- KINA
if getPlayerVocation(cid) == 4 and getPlayerVocation(cid) == 8 and getPlayerVocation(cid) == 12 then
if health and not doCreatureAddHealth(itemEx.uid, getPlayerLevel(cid) * health[3]) then
return false
end
if mana and not doPlayerAddMana(itemEx.uid, getPlayerLevel(cid) * mana[3]) then
return false
end
end
setPlayerStorageValue(cid, potion.storage, getPlayerStorageValue(cid, potion.storage)-1)
doPlayerSendTextMessage(cid, 19, "Haz usado una potion de "..getPlayerStorageValue(cid, potion.storage).." charges.")
else
doPlayerSendTextMessage(cid, 19, "Se te han acabado las cargas, compra mas diciendo: !charges |type|,|amount|.")
return false
end
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
if(not realAnimation) then
doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
else
for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
if(isPlayer(tid)) then
doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
end
end
end
doAddCondition(cid, exhaust)
return true
end