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

Action Manarune that heals % of maxmana

Limos

Senator
Premium User
Joined
Jun 7, 2010
Messages
10,013
Solutions
8
Reaction score
3,056
Location
Netherlands
Manarune that heals % of maxmana and hprune that heals % of maxhealth

I made this script for someone in support and I decided to share it incase other people would want it too.

Tested with TFS 0.3.6pl1 8.54

Actions.xml
XML:
<action itemid="XXXX" event="script" value="other/rune.lua"/>


Mana rune (heals % of maxmana).
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000) -- time in seconds x1000
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
        local manamax = getPlayerMaxMana(cid)
        local min = 3 -- this means 3% minimum healing
        local max = 5 -- this means 5% maximum healing
        local mana_add = math.random((manamax * (min/100)), (manamax * (max/100)))  
 
	if(hasCondition(cid, CONDITION_EXHAUST)) then
        	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are exhausted")
                return true
	end
    	doPlayerAddMana(cid, mana_add)
    	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    	doSendAnimatedText(getPlayerPosition(cid),"+"..mana_add.."", TEXTCOLOR_LIGHTBLUE)
	doAddCondition(cid, exhaust)
    	return true
end

Hp rune (heals % hp of maxhealth).
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000) -- time in seconds x1000
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
        local hpmax = getCreatureMaxHealth(cid)
        local min = 3 -- this means 3% minimum healing
        local max = 5 -- this means 5% maximum healing
        local hp_add = math.random((hpmax * (min/100)), (hpmax * (max/100)))  
 
	if(hasCondition(cid, CONDITION_EXHAUST)) then
        	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are exhausted")
                return true
	end
    	doCreatureAddHealth(cid, hp_add)
    	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    	doSendAnimatedText(getPlayerPosition(cid),"+"..hp_add.."", TEXTCOLOR_GREEN) 
	doAddCondition(cid, exhaust)
    	return true
end

Hp and mana.
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000) -- time in seconds x1000
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
        local hpmax, manamax = getCreatureMaxHealth(cid), getPlayerMaxMana(cid)
        local minhp, maxhp = 3, 5 -- this means 3% minimum hp healing and 5% maximum hp healing 
        local minmana, maxmana = 3, 5 -- this means 3% minimum mana healing and 5% maximum mana healing 
        local hp_add, mana_add = math.random((hpmax * (minhp/100)), (hpmax * (maxhp/100))), math.random((manamax * (minmana/100)), (manamax * (maxmana/100)))   
 
	if(hasCondition(cid, CONDITION_EXHAUST)) then
        	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are exhausted")
                return true
	end
	doCreatureAddHealth(cid, hp_add)
    	doPlayerAddMana(cid, mana_add)
    	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    	doSendAnimatedText(getPlayerPosition(cid),"+"..hp_add.."", TEXTCOLOR_GREEN)
	doAddCondition(cid, exhaust)
    	return true
end

Rune for certain vocations (mana rune for sorcerers and druids as example).
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000) -- time in seconds x1000
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
        local manamax = getPlayerMaxMana(cid)
        local min = 3 -- this means 3% minimum healing
        local max = 5 -- this means 5% maximum healing
        local mana_add = math.random((manamax * (min/100)), (manamax * (max/100)))
 
	if(hasCondition(cid, CONDITION_EXHAUST)) then
        	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are exhausted")
                return true
	end

        if(isSorcerer(cid) or isDruid(cid))then 
    		doPlayerAddMana(cid, mana_add)
    		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    		doSendAnimatedText(getPlayerPosition(cid),"+"..mana_add.."", TEXTCOLOR_LIGHTBLUE)
		doAddCondition(cid, exhaust)
	else
 		doPlayerSendTextMessage(cid,22,"This is only for sorcerers and druids.")
	end
    	return true
end

Runes for TFS 0.2 client 9.1+

Tested with TFS 0.2.14 9.6

actions.xml
XML:
<action itemid="XXXX" script="other/manarune.lua"/>

Mana rune (heals % of maxmana).
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000) -- time in seconds x1000
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
        local manamax = getPlayerMaxMana(cid)
        local min = 3 -- this means 3% minimum healing
        local max = 5 -- this means 5% maximum healing
        local mana_add = math.random((manamax * (min/100)), (manamax * (max/100)))
 
	if(getCreatureCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE) then
        	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are exhausted")
                return true
	end
	doPlayerAddMana(cid, mana_add)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) 
	doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "+"..math.floor(mana_add).." mana", getCreaturePosition(cid), mana_add, TEXTCOLOR_TEAL)
	doAddCondition(cid, exhaust)
	return true
end

Hp rune (heals % hp of maxhealth).
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000) -- time in seconds x1000
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
        local hpmax = getCreatureMaxHealth(cid)
        local min = 3 -- this means 3% minimum healing
        local max = 5 -- this means 5% maximum healing
        local hp_add = math.random((hpmax * (min/100)), (hpmax * (max/100)))  
 
	if(getCreatureCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE) then
        	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are exhausted")
                return true
	end
    	doCreatureAddHealth(cid, hp_add)
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) 
	doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "+"..math.floor(hp_add).." health", getCreaturePosition(cid), hp_add, TEXTCOLOR_GREEN)
	doAddCondition(cid, exhaust)
	return true
end

Hp and mana.
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000) -- time in seconds x1000
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
        local hpmax, manamax = getCreatureMaxHealth(cid), getPlayerMaxMana(cid)
        local minhp, maxhp = 3, 5 -- this means 3% minimum hp healing and 5% maximum hp healing 
        local minmana, maxmana = 3, 5 -- this means 3% minimum mana healing and 5% maximum mana healing 
        local hp_add, mana_add = math.random((hpmax * (minhp/100)), (hpmax * (maxhp/100))), math.random((manamax * (minmana/100)), (manamax * (maxmana/100)))   
 
	if(getCreatureCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE) then
        	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are exhausted")
                return true
	end
    	doCreatureAddHealth(cid, hp_add)
    	doPlayerAddMana(cid, mana_add)
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) 
	doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "+"..math.floor(hp_add).." health and +"..math.floor(mana_add).." mana", getCreaturePosition(cid), hp_add, TEXTCOLOR_GREEN)
	doAddCondition(cid, exhaust)
	return true
end

NOTE: If both functions for animated text don't work on your server, you can use this one instead.
Lua:
doCreatureSay(cid, "+"..math.floor(mana_add).."", TALKTYPE_ORANGE_1)

If you still have problems, errors or anything else that makes it not work, report it in this thread.
 
Last edited:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local manamax = getPlayerMaxMana(cid)
    local mana_add = (manamax * 0.07) 
    local storage = 1000
    local time = 1
 
    if exhaustion.check(cid, storage) then    
        doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_POFF)     
        return doPlayerSendCancel(cid, "You are exhausted")
    end
    if(getPlayerVocation(cid) == 5) or (getPlayerVocation(cid) == 6) or (getPlayerVocation(cid) == 7) or (getPlayerVocation(cid) == 8)then
    doPlayerAddMana(cid, mana_add)
    doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
    exhaustion.set(cid, storage, time)
    doSendAnimatedText(getPlayerPosition(cid),""..mana_add.."", TEXTCOLOR_LIGHTBLUE)
 else
 	doPlayerSendTextMessage(cid,22,"This is only for Master Sorcerers, Elder druids, Royal paladins and Elite knights.")
end
    return TRUE
end
 
I don´t understand how to use it



function onUse(cid, item, fromPosition, itemEx, toPosition)
local manamax = getPlayerMaxMana(cid)
local mana_add = (manamax * 0.07)
local storage = 1000
local time = 1

if exhaustion.check(cid, storage) then
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_POFF)
return doPlayerSendCancel(cid, "You are exhausted")
end
if(getPlayerVocation(cid) == 1) or (getPlayerVocation(cid) == 5) or (getPlayerVocation(cid) == 2) or

(getPlayerVocation(cid) == 6)then
doPlayerAddMana(cid, 1150 mana_add) << how to use << add mana its says mana_add can you make it easier ?
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
exhaustion.set(cid, storage, time)
doSendAnimatedText(getPlayerPosition(cid),""..DON MR BITCHES.."", TEXTCOLOR_LIGHTBLUE)
else
doPlayerSendTextMessage(cid,22,"This is only for sorcerers and druids.")
end
return TRUE
end
 
I used mana_add as a local here, like you can see at the top of the script. This script gives a % of someones maxmana. If you want to change the % you have to change the 0.07 in local mana_add = (manamax * 0.07). Now it's 7%, if you want it for example 20% just make it like this: local mana_add = (manamax * 0.20). If you don't want it to heal a % of your maxmana you can delete the mana_add in doPlayerAddMana and write a number instead. Btw the mana_add I wrote in the doSendAnimatedText is a link to the local, so it shows how much you heal. If you want it to have a text, you should remove ".. ..", so that you only have it like this: "text".
 
Last edited:
Awesome manarune script, really advanced!
I especially love this part doSendAnimatedText(getPlayerPosition(cid),""..mana_add.."", TEXTCOLOR_LIGHTBLUE)

Repped!
 
Thnx, it's actually pretty basic, but since someone requested it, I thought it maybe would also be usefull for some other people :p
 
Last edited:
can u add the scripts for 9.54 version this one wont work says attempt to get 'exhaustion' a nil value
 
Back
Top