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

About spells.xml functions

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
1,067
Solutions
5
Reaction score
63
Hi
so i tried to make(copy) spell that when u type "power down" your mana goes to zero so its like way to skills your magic level faster. But console gives me this warning
Untitled.png

Code:
    <instant name="power down" words="power down" aggressive="0" params="0" lvl="0" maglv="0" mana="0" soul="0" exhaustion="1" prem="0" enabled="1" function="Power Down"></instant>
this one script do not have lua so i dont rly know how function is working this way.
 
Solution
If u mean like this, console gives me warnings
Code:
function onCastSpell(creature, variant)
   local mana = 100
   if getCreatureMana(cid) =< mana then
   return creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
return TRUE
end
change (this means the player need to have 100% mana to cast the spell)
XML:
manapercent="100"
to
XML:
mana="1"
Then use this lua script
LUA:
function onCastSpell(creature, variant)
   local amount = creature:getMana()
   creature:addManaSpent(amount)
   creature:addMana(-amount)
   creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
   return true
end
This should remove all the mana the player have no matter what and also add it as manaspent for magic level training.
About the word...
in spells.xml "mana" means how much mana is needed to execute a spell.

And if there's no .lua script it is directly in sources like conjure.
 
in spells.xml "mana" means how much mana is needed to execute a spell.

And if there's no .lua script it is directly in sources like conjure.
so probably this script is made in source because there was no lua when i ripped it. Where can i find that source file?
 
Okay so how to remove that warning from console now?
First you have to change
XML:
function="Power Down"
to something like this
XML:
script="custom/power_down.lua"
Then you have to make a lua script inside the custom folder named power_down.lua
inside that file you make your spell and that error should be gone.
Since there is no "Power Down" function in the source, you can always add it to the source but i would have made a lua script instead.

The script could contain just some effect sent to the player position each time the spell is cast.

power_down.lua
LUA:
function onCastSpell(creature, variant)
   return creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end

Edit:
I assume you use tfs 1.x
 
Last edited:
First you have to change
XML:
function="Power Down"
to something like this
XML:
script="custom/power_down.lua"
Then you have to make a lua script inside the custom folder named power_down.lua
inside that file you make your spell and that error should be gone.
Since there is no "Power Down" function in the source, you can always add it to the source but i would have made a lua script instead.

The script could contain just some effect sent to the player position each time the spell is cast.

power_down.lua
LUA:
function onCastSpell(creature, variant)
   return creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end

Edit:
I assume you use tfs 1.x
Thanks it works but it have couple problems so first one. It let me to power down only then when i have full mana, but if my mana is not full i cant power down it should let me to power down all the time. And second problem is that, it sends"power down" message in default chat when i accomplice that command it should hide that message. How to make it?
Code:
    <instant name="power down" words="power down" aggressive="0" manapercent="100" params="0" lvl="0" maglv="0" mana="0" soul="0" exhaustion="1" prem="0" enabled="1" script="power_down.lua"></instant>
 
as I've said before it checks do you have so much mana.

Remove that part from spells.xml (mana) and it can be done by the script.
Something like this:
LUA:
if getCreatureMana(cid) =< 100 then
 
as I've said before it checks do you have so much mana.

Remove that part from spells.xml (mana) and it can be done by the script.
Something like this:
LUA:
if getCreatureMana(cid) =< 100 then
If u mean like this, console gives me warnings
Code:
function onCastSpell(creature, variant)
   local mana = 100
   if getCreatureMana(cid) =< mana then
   return creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
return TRUE
end
 
If u mean like this, console gives me warnings
Code:
function onCastSpell(creature, variant)
   local mana = 100
   if getCreatureMana(cid) =< mana then
   return creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
return TRUE
end
The xml code provided above will remove the required amount of mana so there is no need to check whether the player has enough in the script.
LUA:
function onCastSpell(creature, variant)
    return creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
 
If u mean like this, console gives me warnings
Code:
function onCastSpell(creature, variant)
   local mana = 100
   if getCreatureMana(cid) =< mana then
   return creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
return TRUE
end
change (this means the player need to have 100% mana to cast the spell)
XML:
manapercent="100"
to
XML:
mana="1"
Then use this lua script
LUA:
function onCastSpell(creature, variant)
   local amount = creature:getMana()
   creature:addManaSpent(amount)
   creature:addMana(-amount)
   creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
   return true
end
This should remove all the mana the player have no matter what and also add it as manaspent for magic level training.
About the word "Power Down" sent to the default chat is because its the spell word, just like Exura is sent to the default chat when players use that spell. so its not possible to make it disappear.

Edit:
I did not test the script
Make sure that the addManaSpent() dont remove mana, if that is the case then you can remove addMana()
 
Last edited:
Solution
change (this means the player need to have 100% mana to cast the spell)
XML:
manapercent="100"
to
XML:
mana="1"
Then use this lua script
LUA:
function onCastSpell(creature, variant)
   local amount = creature:getMana()
   creature:addManaSpent(amount)
   creature:addMana(-amount)
   creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
   return true
end
This should remove all the mana the player have no matter what and also add it as manaspent for magic level training.
About the word "Power Down" sent to the default chat is because its the spell word, just like Exura is sent to the default chat when players use that spell. so its not possible to make it disappear.

Edit:
I did not test the script
Make sure that the addManaSpent() dont remove mana, if that is the case then you can remove addMana()
Thanks it works and to hide message in default you have to make return true to return false. Everything is working perfect now, thanks.
 
Thanks it works and to hide message in default you have to make return true to return false. Everything is working perfect now, thanks.
Alright! Im not sure if the addMana() counts towards the magic level training aswell, i mean so the spell will give 2x mana spent instead of 1x as intended. You have to test it to make sure it works 100% as intended (im not so familiar in spells)
 
Back
Top