i recomend
spells.xml
PHP:<instant name="Mana" words="waste" lvl="100" manapercent="100" aggressive="0" selftarget="1" exhaustion="1000" needlearn="0" event="script" value="mana.lua"/>
mana.lua
PHP:local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ASSASSIN) setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, -0, 0.0, -0) local area = createCombatArea(AREA_SQUARE1X1) setCombatArea(combat, area) function onCastSpell(cid, var) return doCombat(cid, combat, var) end
not really. but i dont got notepad ++ on my office computer.
doPlayerAddSpentMana(cid, (playermana * getConfigInfo('rateMagic')))
-- Simple "Mana Waste" spell (or well.. spell simulation) by Guitar Freak (yay).
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)
function onCastSpell(cid, var)
local playermana = getPlayerMana(cid) -- Checks player mana.
if playermana > 0 then -- Checks if player has at least 1 mana or more. If he does:
doPlayerAddSpentMana(cid, (playermana * getConfigInfo('rateMagic'))) -- It adds the current amount of mana the player has to the "mana spent" of the player.
doCreatureAddMana(cid, - playermana) -- Simultaneously it removes all the player current mana to 0. So with these 2 functions you wouldnt be really "spending" the mana like a normal spell, but you'd be simulating the event and it would work the same.
doCombat(cid, combat, var)
else -- Otherwise,
doPlayerSendCancel(cid, "You dont have any mana.") -- If the player has 0 mana, it sends this cancel message and does nothing.
end
end
-- Flaws Im aware of:
-- 1. (FIXED) It adds battle lock because the mana is taken like if a monster were hitting you (If you know how to fix this, feel free to post it!).
-- 2. (FIXED) Its not really a "spell" itself so I think you cant put animations/effects to it, but its a working simulation at least (FIXED, forgot to add a local for position so I could send the magic effect).
-- 3. (FIXED) It just added the mana spent of 1x, now it depends on the server magic rate.
You forgot something really important.
The Script doesn't check how high the mana rate is, so if the server has a mana rate of 60x (just an example), he'll just gain 1x using this script
replace your line with this, then it's fine.
Code:doPlayerAddSpentMana(cid, (playermana * getConfigInfo('rateMagic')))
kind regards, Evil Hero
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
function onCastSpell(cid, var)
local playerMana = getPlayerMana(cid)
local inFight = hasCondition(cid, CONDITION_INFIGHT)
if playerMana > 0 then
doPlayerAddSpentMana(cid, getPlayerMana(cid) * getConfigInfo('rateMagic'))
doCreatureAddMana(cid, -playerMana)
doCombat(cid, combat, var)
if not inFight then
doRemoveCondition(cid, CONDITION_INFIGHT)
end
else
doPlayerSendCancel(cid, "You dont have any mana.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
end
In your script posted on the first page, The locals are above the function and its trying to get the value of cid but cant because there above the function.
I think now we've got rid of INFIGHT condition after usage, also optimized the scriptCode:local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE) setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0) function onCastSpell(cid, var) local playerMana = getPlayerMana(cid) local inFight = hasCondition(cid, CONDITION_INFIGHT) if playerMana > 0 then doPlayerAddSpentMana(cid, getPlayerMana(cid) * getConfigInfo('rateMagic')) doCreatureAddMana(cid, -playerMana) doCombat(cid, combat, var) if not inFight then doRemoveCondition(cid, CONDITION_INFIGHT) end else doPlayerSendCancel(cid, "You dont have any mana.") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) end end
Well, I just saw a thread by a person requesting this spell, and I havent seen threads here with things like a spell that you use that wastes all your mana at any time, to mana train whenever the player feels like, and not only when the mana is a certain amount (or full) like most servers's manawaste spells.
So, as Im learning lua and Im still not too great at it, I decided Id give it a shot to see if I could make it or something similar.
I ended up on the "similar"
This means that what I made is a "simulation" of the spell, it isnt really a spell spell, but it works exactly like one and the "mana waste" part works perfectly.
I also added comment lines on the script to explain each part for anyone who is learning too. Here it is.
In spells.xml add this:
Lua:<instant name="Mana Waste" words="manawaste" lvl="1" mana="0" aggressive="0" selftarget="1" exhaustion="1000" needlearn="0" event="script" value="manawaste.lua"/>
Now into scripts make manawaste.lua and add this:
Lua:-- Simple "Mana Waste" spell by Guitar Freak (yay). local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0) function onCastSpell(cid, var) local playermana = getPlayerMana(cid) -- Checks player mana. local position = getPlayerPosition(cid) -- Checks player position. if playermana > 0 then -- Checks if player has at least 1 mana or more. If he does: doPlayerAddSpentMana(cid, (playermana * getConfigInfo('rateMagic'))) -- It adds the current amount of mana the player has to the "mana spent" of the player. doCreatureAddMana(cid, - playermana) -- Simultaneously it removes all the player current mana to 0. So with these 2 functions you wouldnt be really "spending" the mana like a normal spell, but you'd be simulating the event and it would work the same. doCombat(cid, combat, var) else -- Otherwise, doPlayerSendCancel(cid, "You dont have any mana.") -- If the player has 0 mana, it sends this cancel message and does nothing. end end -- Flaws Im aware of: -- 1. It adds battle lock because the mana is taken like if a monster were hitting you (If you know how to fix this, feel free to post it!).
I know its a bit silly But is one of the first scripts I make from scratch (the other ones are even sillier, lol).
Also, if anyone with better experience can take the time to fix the "flaws" I added at the end of the file, feel free to post here your corrections. Or if you find another flaw too.
Or if you have a spell spell for this matter feel free to post it
PS: Tested + working on TFS 0.3+
Have fun.
Not bad but....ppl won't need a mana rune that way Lolz they will use this spell to add mana and......suxyz :wub: