[*]Author: Mock
[*]Tested on: TFS 0.3.6
Like the first but better and without bugs. You can now set level multipiler
Add this tag on actions.xml and delete old potions tag:
Code:
<action itemid="7588" script="liquids/potions charges.lua" allowfaruse="1"/>
<action itemid="7589" script="liquids/potions charges.lua" allowfaruse="1"/>
<action itemid="7590" script="liquids/potions charges.lua" allowfaruse="1"/>
<action itemid="7591" script="liquids/potions charges.lua" allowfaruse="1"/>
<action itemid="8472" script="liquids/potions charges.lua" allowfaruse="1"/>
<action itemid="8473" script="liquids/potions charges.lua" allowfaruse="1"/>
<action itemid="7618" script="liquids/potions charges.lua" allowfaruse="1"/>
<action itemid="7620" script="liquids/potions charges.lua" allowfaruse="1"/>
Lua:
-- Script by Mock (the bear)
local storage = {
[1] = {17073,function(hmax,hmin,cid,multipiler) doCreatureAddHealth(cid, math.random(hmin+multipiler,hmax+multipiler)) end},
[2] = {17074,function(hmax,hmin,cid,multipiler) doCreatureAddMana(cid, math.random(hmin+multipiler,hmax+multipiler)) end},
[3] = {17075,function(hmax,hmin,cid,multipiler) doCreatureAddHealth(cid, math.random(hmin[1]+multipiler,hmax[1]+multipiler)) doCreatureAddMana(cid, math.random(hmin[2]+multipiler,hmax[2]+multipiler)) end},
}
local potions = {
-- smalll
--ITEMID level type max min empyt vocation exhaust delay level increase heal
[7620] = {lvl=0,tipo=2,hmax=101,hmin=100,vasio=7636,vocs={0,1,2,3,4,5,6,7,8,9,10,11,12},exaust=1,lvladd=0},
[7618] = {lvl=0,tipo=1,hmax=100,hmin=50,vasio=7636,vocs={0,1,2,3,4,5,6,7,8,9,10,11,12},exaust=1,lvladd=0}, -- HP
---strong
[7589] = {lvl=50,tipo=2,hmax=190,hmin=110,vasio=7634,vocs={1,2,3,5,6,7,11,10,9},exaust=1,lvladd=0},
[7588] = {lvl=50,tipo=1,hmax=400,hmin=200,vasio=7634,vocs={3,4,7,8,12,11},exaust=1,lvladd=0}, -- HP
-- great
[7591] = {lvl=80,tipo=1,hmax=800,hmin=600,vasio=7635,vocs={4,8,12},exaust=1,lvladd=0}, -- hP
[7590] = {lvl=80,tipo=2,hmax=800,hmin=600,vasio=7635,vocs={1,2,5,6,10,9},exaust=1,lvladd=0}, -- MP
[8472] = {lvl=80,tipo=3,hmax={400,190},hmin={200,110},vasio=7635,vocs={3,7,11},exaust=1,lvladd=0},
--- ultimate
[8473] = {lvl=130,tipo=1,hmax=1000,hmin=800,vasio=7635,vocs={4,8,0,0,12},exaust=1,lvladd=0},
--My custom mana potion
[2363] = {lvl=130,tipo=2,hmax=2000,hmin=1000,vasio=7635,vocs={4,8,0,0,12},exaust=1,lvladd=0.5},
config={
startCharges=5, -- If potion has no one charge it change
}
}
--- Script by Mock (the bear)
local function getItemDName(uid)
return getItemAttribute(uid,'name')
end
local function setItemName(uid,name)
return doItemSetAttribute(uid,'name',name)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isPlayer(itemEx.uid) == false or potions[item.itemid] == nil or isCreature(itemEx.uid) == false then
return FALSE
elseif tonumber(getPlayerStorageValue(itemEx.uid, storage[potions[item.itemid].tipo][1])) and tonumber(getPlayerStorageValue(itemEx.uid, storage[potions[item.itemid].tipo][1])) > tonumber(os.clock()*100) then
doPlayerSendDefaultCancel(itemEx.uid, RETURNVALUE_YOUAREEXHAUSTED)
return TRUE
elseif getPlayerLevel(itemEx.uid) < potions[item.itemid].lvl or not isInArray(potions[item.itemid].vocs,getPlayerVocation(itemEx.uid)) then
doCreatureSay(itemEx.uid, "Only required vocation and level "..potions[item.itemid].lvl.." or above may drink this fluid.", TALKTYPE_ORANGE_1)
return TRUE
end
setPlayerStorageValue(itemEx.uid, storage[potions[item.itemid].tipo][1], (os.clock()+potions[item.itemid].exaust)*100)
local multipiler = (potions[item.itemid].lvladd or 0)*getPlayerLevel(itemEx.uid)
storage[potions[item.itemid].tipo][2](potions[item.itemid].hmax,potions[item.itemid].hmin,itemEx.uid,multipiler)
local cnt =(getItemName(item.uid) or ''):match('(%d+)')
cnt = (tonumber(cnt) or potions.config.startCharges)
if cnt and cnt > 1 then
setItemName(item.uid, getItemNameById(item.itemid).." x "..cnt-1)
else
doTransformItem(item.uid,potions[item.itemid].vasio)
end
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
return TRUE --- Script by Mock (the bear)
end
And enjoy ;D
dont forget to config.
18:09 You see a mana potion x 4.
It weighs 1.80 oz.
Last edited: