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

Weird spell Problem

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
989
Solutions
5
Reaction score
54
Hello,
i have really weird magic level train spell problem, basically i have spell that drops all your mana down to zero
<instant name="ki train" words="ki train" aggressive="0" mana="1" params="0" lvl="1" maglv="0" soul="0" exhaustion="1000" prem="0" enabled="1" script="power_down.lua"></instant>
so example if you have 4k mana and you type ki train it goes to 0 so you train you magic level like this
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
and now i noticed that my haste trains my magic level multiple times faster and it doesnt make sense at all, why
<instant name="haste" words="haste" selftarget="1" aggressive="0" lvl="10" maglv="10" mana="300" soul="0" exhaustion="1000" prem="1" enabled="1" script="speed up.lua"></instant>
so as you can see it requires 300 mana to cast so that 300mana goes to magic level train and now if you do ki train with like 10k mana it increase like nothing but that 10k mana should train you magic level like x30 times faster because you drain your mana to train your magic level. My mind is blown i dont know what to do.
TFS 1.2
 
Yes it fixed this problem but i cant flood ki train now until i dont get 100% mana

Have you removed that code you posted from your spell aswell? manapercent="100" will consume all your mana no matter how much you have if I'm not mistaken.

edit: nvm you are right
 
Last edited:
<instant name="ki train" words="ki train" aggressive="0" mana="0" params="0" lvl="1" maglv="0" soul="0" exhaustion="1000" prem="0" enabled="1" script="power_down.lua"></instant>

mana="1" means how much mana you need to use the spell.
manapercent="100" means that the character needs 100% mana to be able to cast the spell.

the amount of mana required to cast the spell is in spells.lua. and you have
mana="1"
Then what happends with the spell is in the spellscript. It feels like it should work the way you have it already..

So for example a player have 200 mana. He cast the spell and it cost 1, so he has 199 left.

what if you do this

Code:
function onCastSpell(creature, variant)
   local amount = creature:getMana()
   amount = amount - 1
   creature:addMana(-amount)
   creature:addManaSpent(amount)
   creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
   return true
end

I cant really try the code on my server cause I removed experience and skill advancing.
 
<instant name="ki train" words="ki train" aggressive="0" mana="0" params="0" lvl="1" maglv="0" soul="0" exhaustion="1000" prem="0" enabled="1" script="power_down.lua"></instant>

mana="1" means how much mana you need to use the spell.
manapercent="100" means that the character needs 100% mana to be able to cast the spell.

the amount of mana required to cast the spell is in spells.lua. and you have
mana="1"
Then what happends with the spell is in the spellscript. It feels like it should work the way you have it already..

So for example a player have 200 mana. He cast the spell and it cost 1, so he has 199 left.

what if you do this

Code:
function onCastSpell(creature, variant)
   local amount = creature:getMana()
   amount = amount - 1
   creature:addMana(-amount)
   creature:addManaSpent(amount)
   creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
   return true
end

I cant really try the code on my server cause I removed experience and skill advancing.
Hmm no it doesnt work because i had 8k mana and i did ki train so i gained like 3magic level so i did haste, which takes 1500mana i gained 9magic level so it doesnt work and doesnt make sense how 8k gave only 3magic level and 1,5k gave 9magic level
 
Change "creature:addManaSpent(-amount)" to "creature:addManaSpent(-amount * configManager.getNumber(configKeys.RATE_MAGIC)).
 
Oh, my bad. Just remove the minus sign from that code (the value has to be positive).
Okay it looks like it works "KINDA" i dont know. Im using now this spell.xml
<instant name="ki train" words="ki train" aggressive="0" mana="1" params="0" lvl="1" maglv="0" soul="0" exhaustion="1000" prem="0" enabled="1" script="power_down.lua"></instant>
so mana="1" with one ki train i gained from 1 to 9 i think ,but then if i change mana=1" to manapercent="100" i gained from 1 to around 30. So something is not right
 
Mana to cast should be zero. Because it's the script that tell the server how much mana you should spend and not the spell configuration.
 
Mana to cast should be zero. Because it's the script that tell the server how much mana you should spend and not the spell configuration.
Still something is not right it doesnt have full mana potential manapercent="100" gives magic level to 34 (which use full mana too train magic level), and mana="0" gives only 13, so it just shows that it use like 35% of mana too train magic level
 
But you want players to be able to cast the spell no matter how much mana they have.
It should cost 0 or 1 to cast. Inside the script you calculate how much mana the user have, saves that number and removes all mana. The saved number is then multiplied with the mlevel rate you have on the server and adds that new value to addmanadpent to the player.
So 100% Mana will give a lot more to mlvl than 5%.
 
But you want players to be able to cast the spell no matter how much mana they have.
It should cost 0 or 1 to cast. Inside the script you calculate how much mana the user have, saves that number and removes all mana. The saved number is then multiplied with the mlevel rate you have on the server and adds that new value to addmanadpent to the player.
So 100% Mana will give a lot more to mlvl than 5%.
Yes you are right but it doesnt explain why manaprecent gives 34magic level and mana="0 or 1" gives just 13. Because manaprecent gives all 100% mana and mana="0 or 1" gives all 100% so it doesnt make sense.
 
Hmm. Wait. It does make sense.
With manapercent 100 it takes all your mana and multiply it with your mlvl rate, before entering the script. Inside the script you have 0 mana, so nothing happends.

So 100%manayourRate to get in the script. Which is 13 I guess? Inside it's 0yourRate which makes result 0 anyway.

Edit: don't listen to me. I'm over thinking this..
 
Hmm. Wait. It does make sense.
With manapercent 100 it takes all your mana and multiply it with your mlvl rate, before entering the script. Inside the script you have 0 mana, so nothing happends.

So 100%manayourRate to get in the script. Which is 13 I guess? Inside it's 0yourRate which makes result 0 anyway.

Edit: don't listen to me. I'm over thinking this..
Yes with 100% manaprecent it multiplis it with my mlvl rate at this point everything is fine, so with mana 0 it do nothing it doesnt multiply so it means multiplier have no point to exist at this point? So even if i change magic level rate to 999 it will always stays with a default rate? Im so confused.
 
Back
Top