• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Potion

kamilcioo

Veteran OT User
Joined
Jul 25, 2008
Messages
979
Solutions
1
Reaction score
291
I want to make health potion which will give hp depend on your level and magic and only for knight and elite knight.
 
LUA:
local hpMin = 2500
local hpMax = 10000
local HPmultiLvl = 6.0
local HPmultiMaglvl = 1.0
local HPplus = 1000
local hpValues = {0.8, 1.2} -- random range
local reqLevel = 250

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
setConditionParam(exhaust, CONDITION_PARAM_SUBID, EXHAUST_HEALING)	

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(hasCondition(cid, CONDITION_EXHAUST, EXHAUST_HEALING)) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return true
	end

	if(getPlayerLevel(cid) < reqLevel or not isInArray({4,8}, getPlayerVocation(cid))) and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not use this potion.")
		return true
	end
	
	local health = getPlayerLevel(cid) * HPmultiLvl + getPlayerMagLevel(cid) * HPmultiMaglvl + HPplus
	if(not doCreatureAddHealth(itemEx.uid, math.ceil(math.min(hpMax, math.max(hpMin, math.random(health * hpValues[1], health * hpValues[2])))))) then
		return false
	end

	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	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

	doAddCondition(cid, exhaust)
	return true
end
 
Tyy rep ++. Can someone make it for mana and how to make this pot work with exana mort? I mean no exhausted for both in same time.
 
Last edited:
Moved vocations param from script to config.
Mana version (no exhaust with healing spells):
LUA:
local mpMin = 2500
local mpMax = 10000
local MPmultiLvl = 6.0
local MPmultiMaglvl = 1.0
local MPplus = 1000
local mpValues = {0.8, 1.2} -- random range
local reqLevel = 250
local reqVocations = {4, 8} -- knight (4) or  elite knight (8)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerLevel(cid) < reqLevel or not isInArray(reqVocations, getPlayerVocation(cid))) and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not use this potion.")
		return true
	end
	
	local mana = getPlayerLevel(cid) * MPmultiLvl + getPlayerMagLevel(cid) * MPmultiMaglvl + MPplus
	if(not doCreatureAddMana(itemEx.uid, math.ceil(math.min(mpMax, math.max(mpMin, math.random(mana * mpValues[1], mana * mpValues[2])))))) then
		return false
	end

	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	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
	return true
end
Health version without exhaust:
LUA:
local hpMin = 2500
local hpMax = 10000
local HPmultiLvl = 6.0
local HPmultiMaglvl = 1.0
local HPplus = 1000
local hpValues = {0.8, 1.2} -- random range
local reqLevel = 250
local reqVocations = {4, 8} -- knight (4) or  elite knight (8)

function onUse(cid, item, fromPosition, itemEx, toPosition) 
	if(getPlayerLevel(cid) < reqLevel or not isInArray(reqVocations, getPlayerVocation(cid))) and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not use this potion.")
		return true
	end
 
	local health = getPlayerLevel(cid) * HPmultiLvl + getPlayerMagLevel(cid) * HPmultiMaglvl + HPplus
	if(not doCreatureAddHealth(itemEx.uid, math.ceil(math.min(hpMax, math.max(hpMin, math.random(health * hpValues[1], health * hpValues[2])))))) then
		return false
	end
 
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	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
	return true
end
Health and mana in one script (no exhaust):
LUA:
local mpMin = 2500
local mpMax = 10000
local MPmultiLvl = 6.0
local MPmultiMaglvl = 1.0
local MPplus = 1000
local mpValues = {0.8, 1.2} -- random range

local hpMin = 2500
local hpMax = 10000
local HPmultiLvl = 6.0
local HPmultiMaglvl = 1.0
local HPplus = 1000
local hpValues = {0.8, 1.2} -- random range

local reqLevel = 250
local reqVocations = {4, 8} -- knight (4) or  elite knight (8)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerLevel(cid) < reqLevel or not isInArray(reqVocations, getPlayerVocation(cid))) and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not use this potion.")
		return true
	end
	
	local mana = getPlayerLevel(cid) * MPmultiLvl + getPlayerMagLevel(cid) * MPmultiMaglvl + MPplus
	if(not doCreatureAddMana(itemEx.uid, math.ceil(math.min(mpMax, math.max(mpMin, math.random(mana * mpValues[1], mana * mpValues[2])))))) then
		return false
	end
 
	local health = getPlayerLevel(cid) * HPmultiLvl + getPlayerMagLevel(cid) * HPmultiMaglvl + HPplus
	if(not doCreatureAddHealth(itemEx.uid, math.ceil(math.min(hpMax, math.max(hpMin, math.random(health * hpValues[1], health * hpValues[2])))))) then
		return false
	end

	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	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
	return true
end
 
Back
Top