• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Help - Potions

hustlamike

Shit happens.
Joined
Dec 23, 2007
Messages
134
Reaction score
0
Ok so i got my potions so u can use them and use a spell at the same time also the vial dissapears to save cap the only thing i cant get to happen is i want to make it so people can use potions on other people lol i hope someone can help me here's my scripts i using tfs 0.2 latest patch.


Fluids.Lua
-- TODO: Rewrite this script using fluidtypes from LIQUIDS doc-file,
-- and correct itemid's to recieve the liquids.

local drunk = createConditionObject(CONDITION_DRUNK)
setConditionParam(drunk, CONDITION_PARAM_TICKS, 60000)

local poison = createConditionObject(CONDITION_POISON)
addDamageCondition(poison, 2, 6000, -5)
addDamageCondition(poison, 3, 6000, -4)
addDamageCondition(poison, 5, 6000, -3)
addDamageCondition(poison, 10, 6000, -2)
addDamageCondition(poison, 20, 6000, -1)

local fluidType = {3, 4, 5, 7, 10, 11, 13, 15, 19}
local fluidMessage = {"Aah...", "Urgh!", "Mmmh.", "Aaaah...", "Aaaah...", "Urgh!", "Urgh!", "Aah...", "Urgh!"}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if itemEx.itemid == 1 then
if item.type == 0 then
doPlayerSendCancel(cid, "It is empty.")
elseif itemEx.uid == cid then
doChangeTypeItem(item.uid, 0)
if item.type == 3 or item.type == 15 then
doTargetCombatCondition(0, cid, drunk, CONST_ME_NONE)
elseif item.type == 4 then
doTargetCombatCondition(0, cid, poison, CONST_ME_NONE)
elseif item.type == 7 then
doPlayerAddMana(cid, math.random(50, 150))
doSendMagicEffect(fromPosition, CONST_ME_MAGIC_BLUE)
elseif item.type == 10 then
doCreatureAddHealth(cid, 60)
doSendMagicEffect(fromPosition, CONST_ME_MAGIC_BLUE)
end
for i = 0, table.maxn(fluidType) do
if item.type == fluidType then
doCreatureSay(cid, fluidMessage, TALKTYPE_ORANGE_1)
return TRUE
end
end
doCreatureSay(cid, "Gulp.", TALKTYPE_ORANGE_1)
else
local splash = doCreateItem(2025, item.type, toPosition)
doChangeTypeItem(item.uid, 0)
doDecayItem(splash)
end
elseif (itemEx.itemid >= 490 and itemEx.itemid <= 493) or (itemEx.itemid >= 4608 and itemEx.itemid <= 4625) or (itemEx.itemid >= 618 and itemEx.itemid <= 629) or itemEx.itemid == 1771 then
doChangeTypeItem(item.uid, 9)
elseif itemEx.itemid == 103 then
doChangeTypeItem(item.uid, 19)
elseif (itemEx.itemid >= 598 and itemEx.itemid < 712) or itemEx.itemid == 1509 then
doChangeTypeItem(item.uid, 26)
elseif (itemEx.itemid >= 351 and itemEx.itemid <= 355) then
doChangeTypeItem(item.uid, 19)
elseif (itemEx.itemid >= 602 and itemEx.itemid <= 605) then
doChangeTypeItem(item.uid, 28)
elseif itemEx.itemid == 1772 then
doChangeTypeItem(item.uid, 3)
elseif itemEx.itemid == 1773 then
doChangeTypeItem(item.uid, 15)
elseif item.type == 0 then
doPlayerSendCancel(cid, "It is empty.")
else
if toPosition.x == CONTAINER_POSITION then
toPosition = getCreaturePosition(cid)
end
splash = doCreateItem(2025, item.type, toPosition)
doChangeTypeItem(item.uid, 0)
doDecayItem(splash)
end
return TRUE
end




Potions.Lua
local ultimateHealthPot = 8473
local greatHealthPot = 7591
local greatManaPot = 7590
local greatSpiritPot = 8472
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local smallHealthPot = 8704
local antidotePot = 8474
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636

local antidote = createCombatObject()
setCombatParam(antidote, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(antidote, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(antidote, COMBAT_PARAM_TARGETCASTERORTOPMOST, TRUE)
setCombatParam(antidote, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(antidote, COMBAT_PARAM_DISPEL, CONDITION_POISON)

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(itemEx.uid ~= cid or itemEx.itemid ~= 1) then
return TRUE
end

if(item.itemid == antidotePot) then
if(doCombat(cid, antidote, numberToVariant(cid)) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
elseif(item.itemid == smallHealthPot) then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 50, 100, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
elseif(item.itemid == healthPot) then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 100, 200, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
elseif(item.itemid == manaPot) then
if(doTargetCombatMana(0, cid, 100, 200, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
elseif(item.itemid == strongHealthPot) then
if(not(isKnight(cid) or isPaladin(cid)) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by paladins and knights of level 50 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 380, 430, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
elseif(item.itemid == strongManaPot) then
if(not(isSorcerer(cid) or isDruid(cid) or isPaladin(cid)) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by sorcerers, druids and paladins of level 50 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatMana(0, cid, 110, 190, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
elseif(item.itemid == greatSpiritPot) then
if(not(isPaladin(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by paladins of level 80 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 250, 300, CONST_ME_MAGIC_BLUE) == LUA_ERROR or doTargetCombatMana(0, cid, 100, 200, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
elseif(item.itemid == greatHealthPot) then
if(not(isKnight(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by knights of level 80 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 730, 830, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
elseif(item.itemid == greatManaPot) then
if(not(isSorcerer(cid) or isDruid(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by sorcerers and druids of level 80 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatMana(0, cid, 250, 300, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
elseif(item.itemid == ultimateHealthPot) then
if(not(isKnight(cid)) or (getPlayerLevel(cid) < 130)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by knights of level 130 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 900, 1000, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
end
return TRUE
end
 
The thing is these scripts check lvl and voc of "user", character that is used with. I think it can be simply fixed by taking the actual user by getting his uid with getThingFromPos(fromPosition), then u have to check if it's player ;P it should works then like real tibia (I am not sure if you don't have to add stackpos 253 to this function, you can try if doesn't work). Then you have to check this player level/voc by changing isKnight(cid) for isKnight(name of variable you use).
 
Back
Top