Weird spell Problem

henkas

Active Member
Joined
Jul 8, 2015
Messages
653
Reaction score
30
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
 

BahamutxD

Jack of all trades, master of none
Joined
Jun 8, 2009
Messages
569
Reaction score
180
Location
Spain
Hmm, try with manapercent="100" instead of mana="1" on spells.xml? Just an idea, haven't tested myself.
 
OP
henkas

henkas

Active Member
Joined
Jul 8, 2015
Messages
653
Reaction score
30
Hmm, try with manapercent="100" instead of mana="1" on spells.xml? Just an idea, haven't tested myself.
Yes it fixed this problem but i cant flood ki train now until i dont get 100% mana
 

BahamutxD

Jack of all trades, master of none
Joined
Jun 8, 2009
Messages
569
Reaction score
180
Location
Spain
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:

Nemphis

Excellent OT User
Joined
Jun 22, 2009
Messages
325
Reaction score
114
Location
Sweden
<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.
 
OP
henkas

henkas

Active Member
Joined
Jul 8, 2015
Messages
653
Reaction score
30
<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
 

Itutorial

Advanced OT User
Joined
Dec 23, 2014
Messages
1,442
Reaction score
317
You have to add multipliers it’s not automatic.
 
OP
henkas

henkas

Active Member
Joined
Jul 8, 2015
Messages
653
Reaction score
30
You have to add multipliers it’s not automatic.
You mean?
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC)?
if yes i dont even imagine what should i do with it
 

Dnomyar

Well-Known Member
Joined
May 20, 2009
Messages
55
Reaction score
22
Location
Brazil
Change "creature:addManaSpent(-amount)" to "creature:addManaSpent(-amount * configManager.getNumber(configKeys.RATE_MAGIC)).
 
OP
henkas

henkas

Active Member
Joined
Jul 8, 2015
Messages
653
Reaction score
30
Change "creature:addManaSpent(-amount)" to "creature:addManaSpent(-amount * configManager.getNumber(configKeys.RATE_MAGIC)).
lul what gained from 0 to 255 magic level :D :D :D
 

Dnomyar

Well-Known Member
Joined
May 20, 2009
Messages
55
Reaction score
22
Location
Brazil
Oh, my bad. Just remove the minus sign from that code (the value has to be positive).
 
OP
henkas

henkas

Active Member
Joined
Jul 8, 2015
Messages
653
Reaction score
30
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
 

Nemphis

Excellent OT User
Joined
Jun 22, 2009
Messages
325
Reaction score
114
Location
Sweden
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.
 
OP
henkas

henkas

Active Member
Joined
Jul 8, 2015
Messages
653
Reaction score
30
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
 

Nemphis

Excellent OT User
Joined
Jun 22, 2009
Messages
325
Reaction score
114
Location
Sweden
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%.
 
OP
henkas

henkas

Active Member
Joined
Jul 8, 2015
Messages
653
Reaction score
30
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.
 

Nemphis

Excellent OT User
Joined
Jun 22, 2009
Messages
325
Reaction score
114
Location
Sweden
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..
 
OP
henkas

henkas

Active Member
Joined
Jul 8, 2015
Messages
653
Reaction score
30
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.
 

Nemphis

Excellent OT User
Joined
Jun 22, 2009
Messages
325
Reaction score
114
Location
Sweden
Try 0 mana and change to this
creature:addManaSpent(amount*999orwhateveryouhave)
 
Top