• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Spell [0.3+] Waste all your mana AT ANY TIME (for mana training!).

I will take a look when im home at my own computer. Will post an working version then ;)
 
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

Huh? :huh: Read 3rd post of this thread.

I already stated that with "manapercent", it uses 100% of the mana when the player reaches 100%, not at any time, like mine.

Mine is just an alternative for the usual "manawaste" spell that most servers use only with the manapercent = 100 thing.

If you have a way to fix the 1st flaw of my spell, good post it.
If you want to optimize my script by shortening it or making it more configurable somehow but still having the same functionality, good post it.

But why would you "recommend" a totally different one (which was also already posted by Gangster) on this thread, whose title is so clear? > "At any time"

Im just saying, because I dont quite get it ;)

@Elaney:
Will be looking forward to it :thumbup:
 
Last edited:
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 :p

replace your line with this, then it's fine.
Code:
doPlayerAddSpentMana(cid, (playermana * getConfigInfo('rateMagic')))


kind regards, Evil Hero
 
Sorry for the double post but here is the complete fixed one, optimized it also a bit ^^

Lua:
-- 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.

kind regards, Evil Hero
 
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 :p

replace your line with this, then it's fine.
Code:
doPlayerAddSpentMana(cid, (playermana * getConfigInfo('rateMagic')))


kind regards, Evil Hero

Big thanks Evil Hero! I wasnt even aware it was needed at all :thumbup:

Btw I saw you wrote (FIXED) on the first flaw on the optimized script on the other post, did you test it? Cause I think Ive done the "aggressive, false" thing before and didnt work out..

But still +Repped as a thanks for noticing that other bug and optimizing :) And ty Fragdonut :p
 
doCreatureAddMana
this function
gives pz lock
you must edit it for
another (hint: watch party spell 'heal')
but change hp to mana ;d
 
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.
 
Code:
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
I think now we've got rid of INFIGHT condition after usage, also optimized the script :)
 
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.

So true!

My mistake, like a month ago I was going through all my scripts getting the "configs" out of the scripts because Colandus told me it was useless to keep them inside since they'd get redefined every time the script loaded, so it is truly useless, but I forgot to keep inside those that call for cid (duh :p), etc, it always happens to me lol thanks for the reminder ;)

Code:
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
I think now we've got rid of INFIGHT condition after usage, also optimized the script :)

Hey there Hermes, by the look of it I would think too it gets rid of the infight condition, have you tested it out to make sure?

Thanks anyway both of you!

EDIT: Nvm, I did test it and it works! I will edit the first post with it.

However, does anyone know how does the "getConfigInfo('rateMagic')" thing really work? Or what is the formula for "rateMagic"?

Because now that Im testing this, with the getConfigInfo it is spending a lot more mana than it should, but when I remove it, it takes the real thing.

Anyway edited first post with all optimizations, it should work properly now, thanks Hermes!
 
Last edited:
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 :p 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:
 
Code:
doPlayerAddMana(cid, - playermana, FALSE)
(for compat, also should work on 0.2 and 0.3, and you should remove combat and doCombat)
 
Back
Top