• 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!

Solved Mana rune

Elaney

Member
Joined
Jan 1, 2009
Messages
1,561
Reaction score
12
Location
Sweden
Well the problem is i got a mana rune for mages atm (only giving mana the higher ur m lvl is). But i want a mana rune that is inf and gives btw 1-1.2k mana all the time or a mana rune that only 1 voc can use. Anyone out there who can help me?




Code:
-- Mana Rune - by Killavus. --
-- Feel free to edit! --
function onUse(cid, item, frompos, item2, topos)

	local level = getPlayerLevel(cid)
	local mlevel = getPlayerMagLevel(cid)
	
	-- Exhausted Settings --
	local exhausted_seconds = 1 -- How many seconds manarune will be unavailible to use. --
	local exhausted_storagevalue = 7000 -- Storage Value to store exhaust. It MUST be unused! --
	-- Exhausted Settings END --
	
	-- Mana Formula Settings --
	-- You can use "level" and "mlevel" --
	local mana_minimum = (level * 2.3) + (mlevel * 3) - 50
	local mana_maximum = (level * 3.3) + (mlevel * 3)
	-- Mana Formula Settings END --
	
	local mana_add = math.random(mana_minimum, mana_maximum)
	
		-- We check the charges. --
		if(item.type > 1) then
			-- Exhausted check. --
			if(os.time() > getPlayerStorageValue(cid, exhausted_storagevalue)) then
				-- Entity is player? --
				if(isPlayer(item2.uid) == 1) then
					doSendMagicEffect(frompos, CONST_ME_MAGIC_RED)
					doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
					doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
					doPlayerAddMana(item2.uid, mana_add)
					setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
				else
					doSendMagicEffect(frompos, CONST_ME_POFF)
					doPlayerSendCancel(cid, "You can use this rune only on players.")
				end
			else
				doSendMagicEffect(frompos, CONST_ME_POFF)
				doPlayerSendCancel(cid, "You are exhausted.")
			end
		else
			if(os.time() < getPlayerStorageValue(cid, exhausted_storagevalue)) then
				doSendMagicEffect(frompos, CONST_ME_POFF)
				doPlayerSendCancel(cid, "You are exhausted.")
			else
				if(isPlayer(item2.uid) == 1) then
					doSendMagicEffect(frompos, CONST_ME_MAGIC_RED)
					doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
					doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
					doPlayerAddMana(item2.uid, mana_add)
					setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
				else
					doSendMagicEffect(frompos, CONST_ME_POFF)
					doPlayerSendCancel(cid, "You can use this rune only on players.")
				end
			end
		end
						
	return 1
end
 
Last edited:
Well the problem is i got a mana rune for mages atm (only giving mana the higher ur m lvl is). But i want a mana rune that is inf and gives btw 1-1.2k mana all the time or a mana rune that only 1 voc can use. Anyone out there who can help me?
Code:
local ultimateMana = [COLOR="RED"]RUNE ID[/COLOR]

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local var = numberToVariant(cid)
	local level = getPlayerLevel(cid)
	local mag = getPlayerMagLevel(cid)

	[COLOR="RED"]local manamin = (level/2.5)+(mag*2)
	local manamax = (level/2)+(mag*2)[/COLOR]

	if itemEx.uid ~= cid or itemEx.itemid ~= 1 then
		return TRUE
	end

	if(item.itemid == ultimateMana) then
		if (getPlayerLevel(cid) < 150) and (getPlayerVocation(cid) ~= [COLOR="RED"]VOCATION_ID[/COLOR]) then
			doCreatureSay(cid, "This potion can only be consumed by players of level 150 or higher.", TALKTYPE_ORANGE_1)
			return TRUE
		end
		if(doTargetCombatMana(0, cid, manamin, manamax, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
			return FALSE
		end
		--doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
		doTransformItem(item.uid, ultimateMana)
	end
	return TRUE
end

something you can work with really, just change the stuff in red
min and max mana is the range for your mana healing and the vocation id is the ID of the vocation you want to use it, u can also remove the level requirement if u wish
 
Last edited:
Code:
local ultimateMana = [COLOR="RED"]RUNE ID[/COLOR]

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local var = numberToVariant(cid)
	local level = getPlayerLevel(cid)
	local mag = getPlayerMagLevel(cid)

	[COLOR="RED"]local manamin = (level/2.5)+(mag*2)
	local manamax = (level/2)+(mag*2)[/COLOR]

	if itemEx.uid ~= cid or itemEx.itemid ~= 1 then
		return TRUE
	end

	if(item.itemid == ultimateMana) then
		if (getPlayerLevel(cid) < 150) and (getPlayerVocation(cid) ~= [COLOR="RED"]VOCATION_ID[/COLOR]) then
			doCreatureSay(cid, "This potion can only be consumed by players of level 150 or higher.", TALKTYPE_ORANGE_1)
			return TRUE
		end
		if(doTargetCombatMana(0, cid, manamin, manamax, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
			return FALSE
		end
		--doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
		doTransformItem(item.uid, ultimateMana)
	end
	return TRUE
end

something you can work with really, just change the stuff in red
min and max mana is the range for your mana healing and the vocation id is the ID of the vocation you want to use it, u can also remove the level requirement if u wish


All works except the vocation id.
 
Well not if i use it in action. But as a spell it gives error.

if you are using it as a spell you probably don't need to check for the voc like that then i'd assume (never done like that) and just put in spells.xml the vocations that are allowed to cast that spell just as it does in the other spells
 
if you are using it as a spell you probably don't need to check for the voc like that then i'd assume (never done like that) and just put in spells.xml the vocations that are allowed to cast that spell just as it does in the other spells

well it dont work at all as a spell thats why i get an error ;p

and what i mean that the id is not working is that all vocation can still use the mana rune.
 
Last edited:
Using as a spell rune

in manarune.lua
Code:
function onGetFormulaValues(cid, level, maglevel)
	[COLOR="RED"]min = (level * 1 + maglevel * 4) * 2.08
	max = (level * 1 + maglevel * 4) * 2.7[/COLOR]
	return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
	return doTargetCombatMana(0, cid, min, max, CONST_ME_MAGIC_BLUE)
end

in spells.xml
Code:
	<rune name="Mana Rune" id="2273" allowfaruse="1" lvl="100" maglv="100" exhaustion="1000" aggressive="0" needtarget="1" blocktype="solid" script="manarune.lua">

	<vocation name="none"/>
</rune>
changing the values to your needs..


As an Action

in manarune.lua
Code:
local ultimateMana = RUNE ID

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local var = numberToVariant(cid)
	local level = getPlayerLevel(cid)
	local mag = getPlayerMagLevel(cid)

	local manamin = (level/2.5)+(mag*2)
	local manamax = (level/2)+(mag*2)

	if itemEx.uid ~= cid or itemEx.itemid ~= 1 then
		return TRUE
	end

	if(item.itemid == ultimateMana) then
		if (getPlayerLevel(cid) < 150) or (getPlayerVocation(cid) ~= VOCATION_ID) then
			doCreatureSay(cid, "This potion can only be consumed by players of level 150 or higher.", TALKTYPE_ORANGE_1)
			return TRUE
		end
		if(doTargetCombatMana(0, cid, manamin, manamax, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
			return FALSE
		end
		--doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
		doTransformItem(item.uid, ultimateMana)
	end
	return TRUE
end
**same as previous, just changed an AND to OR and it works, add more ors to limit vocations or if you need something specific i can do that too
 
Last edited:
Code:
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

Why using it when "combat" does not exist?
 
Back
Top