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

Lua [8.60] Manarune.lua

Abbeh

New Member
Joined
Nov 22, 2012
Messages
98
Reaction score
1
Location
Sweden, Gothenburg
Good evening,

This is how the manarune looks like at the moment...

Code:
<action itemid="2270" event="script" value="other/manarune.lua"/>
- in actions.xml

This is the manarune.lua...

Code:
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 = 20 -- this means 3% minimum healing
local max = 30 -- 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) 
		return doPlayerSendCancel(cid, "You are exhausted")
	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

And it doesn't work. Anyone that has a solution?
 
thought i would give you mine "fully working" using it at the moment

Go to server/data/spells/spells.xml

add this line near UH RUNE

Lua:
<rune name="Mana Rune" id="2270" allowfaruse="1" charges="1" lvl="50" maglv="4" exhaustion="1100" aggressive="0" needtarget="1" blocktype="solid" event="script" value="manarune.lua"/>
	<vocation id="1"/>
	<vocation id="2"/>

Then go to Server/data/spells/healing

Make a new LUA script and add this and save as "manarune"

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 49)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
function onGetFormulaValues(cid, level, maglevel)
	local min = (getCreatureMaxMana(cid) / 100) * 15
	local max = (getCreatureMaxMana(cid) / 100) * 25
	return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

 
function onCastSpell(cid, var)	
	return doCombat(cid, combat, var)
end

That should work fine.

If this helps REP++ Me!
 
Can you tell me why it doesn't work? It's my script and I tested it on TFS 0.3.6pl1 8.54 and 0.4 8.6. If it doesn't work on other versions, I will add others that will work on those versions to the thread. What are the errors you get? or how does it not work?
Btw also tell which server you are using.
 
Last edited:
well thats my manarune script so i didnt test yours i just thought you needed a new script working, but i guess i can take a look tomorrow at your script, but you can take mine now if your ergent :D




Update : Im using 0.4_SVN latest Rev
 
Last edited:
Tell me whats wrong with it, if it really doesn't work on your version, then I should know whats wrong so I can add alternative versions to the thread.
 
I'm not getting any kind of errors. The only thing that doesn't work is when I use it, nothing else pops up. It says "you cannot use this object".

*Using the last spell rune.*

*You cannot use this object.*
 
Well tbh there is no need to use "Actions" as a manarune just use "Spells" the way its ment to be used, in the way for it to work i've never added a manarune through actions befor so, i know that through spells works 100% as im using it right now so :D
 
After experimenting with the different files, i solved it. Thank you very much, Smokiee Jo!

- - - Updated - - -

Well tbh there is no need to use "Actions" as a manarune just use "Spells" the way its ment to be used, in the way for it to work i've never added a manarune through actions befor so, i know that through spells works 100% as im using it right now so :D

Yeah I removed

Code:
<action itemid="2270" event="script" value="other/manarune.lua"/>
from the actions.xml and it's still working.

I love you man, no homo
 
Well tbh there is no need to use "Actions" as a manarune just use "Spells" the way its ment to be used, in the way for it to work i've never added a manarune through actions befor so, i know that through spells works 100% as im using it right now so :D

The reason for using them as actions is that they work the same way as potions, they don't exhaust other runes.


@down
use
XML:
 [/ XML]
 
Last edited:
LUA CODE

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 49)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
function onGetFormulaValues(cid, level, maglevel)
	local min = (getCreatureMaxMana(cid) / 100) * 20
	local max = (getCreatureMaxMana(cid) / 100) * 25
	return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

 
function onCastSpell(cid, var)	
	return doCombat(cid, combat, var)
end



XML CODE
Lua:
<rune name="Mana Rune" id="2270" allowfaruse="1" charges="1" lvl="50" maglv="4" exhaustion="1100" aggressive="0" needtarget="1" blocktype="solid" event="script" value="manarune.lua"/>
	<vocation id="1"/>
	<vocation id="2"/>
 
The reason for using them as actions is that they work the same way as potions, they don't exhaust other runes.

Btw, that server you are using doesn't even have a map named other.
XML:
<action itemid="2270" event="script" value="other/manarune.lua"/>
But I will add this to the thread, to inform people that it's an example and they shouldn't copy past it if you don't have a map named other.
I also see now it's based on 9.6, so this would mean the animated text probable doesn't work.

@down
use
XML:
 [/ XML][/QUOTE]

Then why is a lot of objects printed like that?

[code=xml]	<action fromid="2362" toid="2363" event="script" value="other/food.lua"/>
	<action fromid="2666" toid="2691" event="script" value="other/food.lua"/>
	<action fromid="2695" toid="2696" event="script" value="other/food.lua"/>
	<action fromid="2787" toid="2796" event="script" value="other/food.lua"/>
	<action itemid="5097" event="script" value="other/food.lua"/>
	<action itemid="6125" event="script" value="other/food.lua"/>
	<action itemid="6278" event="script" value="other/food.lua"/>
	<action itemid="6279" event="script" value="other/food.lua"/>
	<action itemid="6394" event="script" value="other/food.lua"/>
	<action itemid="6501" event="script" value="other/food.lua"/>
	<action fromid="6541" toid="6545" event="script" value="other/food.lua"/>
	<action itemid="6569" event="script" value="other/food.lua"/>
	<action itemid="6574" event="script" value="other/food.lua"/>
	<action itemid="7158" event="script" value="other/food.lua"/>
	<action itemid="7159" event="script" value="other/food.lua"/>
	<action fromid="7372" toid="7377" event="script" value="other/food.lua"/>
	<action itemid="7909" event="script" value="other/food.lua"/>
	<action fromid="8838" toid="8845" event="script" value="other/food.lua"/>
	<action itemid="8847" event="script" value="other/food.lua"/>

Same goes for "Music, Instruments", "Teleports (Stairs, ladders)", "Construction Kits" - These are located in actions.xml.

- - - Updated - - -

But yes, I had to make a new directory called "Healing" to make the manarune work.
 
My apologies, I confused it with an other link. However, it did gave errors, the exhaust that is used in your server is the exhaust from the 9.6 server. Also like I thought the animated text didn't work since it is based on the 9.6 server.
This will be the correct one to use.
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 = 20 -- this means 20% minimum healing
local max = 30 -- this means 30% 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) 
		return doPlayerSendCancel(cid, "You are exhausted")
	end
    	doPlayerAddMana(cid, mana_add)
    	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
	doAddCondition(cid, exhaust)
    	return true
end
I realize now that you probable didn't understand what I was asking you. Since the script should normaly work on 8.6 servers, I asked you what happens to find out what the problem was. I assume you thought the script itself didn't work and I asked you why.
Not all scripts work on every server. Most scripts give errors if some code parts don't work on your server. I made a screen to show you what I mean with errors:

Zwv5pi.png


Here you see the errors I was talking about with the exhaust and the animated text. If you help people by giving the errors or explaining what happens when you use it, it helps people to solve your problem more easy.
Now I had to download the server to find it out myself.

I do advice you to use an action, this way it will work the same as potions. The reason why potions is in actions is that the exhaust isn't the same as runes/spells. Else when you use them, you have to wait before you can use the mana rune.



@down
You can do all that in this script too :p
Lua:
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000) -- time in seconds x1000
This works the same way as the time in the exhaustion from the spells.xml line.
 
Last edited:
But as spells you can just change

Lua:
<rune name="Mana Rune" id="2270" allowfaruse="1" charges="1" lvl="50" maglv="4" exhaustion="1100" aggressive="0" needtarget="1" blocktype="solid" event="script" value="manarune.lua"/>


Code:
Exhaustion="1100"

To what ever you want it to be on how fast you want the manarune to work.
 
Back
Top