elementrix
New Member
- Joined
- Feb 28, 2017
- Messages
- 20
- Reaction score
- 0
I would like to know if its possible to add in this script, so when you use a potion it shows how much it heals?
TFS 0.3.6
TFS 0.3.6
Lua:
local POTIONS = {
[7591] = {vocations = {4, 8}, vocStr = "knights", -- great health potion
minhp = "level * 2.2 + maglv * 3.3",
maxhp = "level * 2.75 + maglv * 4.4"},
[7590] = {vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids", -- great mana potion
minmana = "level * 1.4 + maglv * 3",
maxmana = "level * 1.5 + maglv * 4"},
[8472] = {vocations = {3, 7}, vocStr = "paladins", -- great spirit potion
minhp = "level * 1.3 + maglv * 2.5",
maxhp = "level * 1.6 + maglv * 3.5",
minmana = "level * 1.1 + maglv * 2.2",
maxmana = "level * 1.5 + maglv * 2.8"}
}
--[[local exhaust_mana = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust_mana, CONDITION_PARAM_TICKS, 1400)
setConditionParam(exhaust_mana, CONDITION_PARAM_SUBID, EXHAUST_HEALING)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, EXHAUST_HEALING)]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
local k = POTIONS[item.itemid]
if not k then
return false
elseif not isPlayer(itemEx.uid) then
return true
--[[elseif hasCondition(cid, CONDITION_EXHAUST, EXHAUST_HEALING) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true]]
end
if k.vocations and not isInArray(k.vocations, getPlayerVocation(cid)) and
not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)
then
doCreatureSay(itemEx.uid, "Only " .. k.vocStr .. " may drink this fluid.", TALKTYPE_ORANGE_1, false, cid)
return true
end
k,level, maglv = k,getPlayerLevel(cid), getPlayerMagLevel(cid)
if k.minhp then
doCreatureAddHealth(itemEx.uid, math.random(loadstring("return "..k.minhp..","..k.maxhp)()))
end
if k.minmana then
doCreatureAddMana(itemEx.uid, math.random(loadstring("return "..k.minmana..","..k.maxmana)()))
end
doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
doCreatureSay(itemEx.uid, "Mmmmh...", TALKTYPE_ORANGE_1, false, cid)
--doAddCondition(cid, k.minmana and exhaust_mana or exhaust)
k,level,maglv=nil,nil,nil
return true
end