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

[Req] Mana Drain

muphet

New Member
Joined
Apr 27, 2008
Messages
233
Reaction score
2
Hi. I need a scipt for mana drain spell.
1. script check actual target (monsters only) maxhealth
2. script multiple this local *0.05 (5%)
3. monster loss hp = percent of maxhp, caster get this variable of Mana (not health).

Can someone help?:p
 
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_RED)

function onCastSpell(cid, var)
	local pid = getCreatureTarget(cid)
	local drainAmount = getCreatureMaxHealth(pid) * 0.05
	
	if(isPlayer(pid)) then
		doPlayerSendCancel(cid, "You may not use this spell on players")
	else
		doCreatureAddHealth(pid, -drainAmount)
		doCreatureAddMana(cid, drainAmount)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BLUE)
	end
	return doCombat(cid, combat, var)
end
 
Last edited by a moderator:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_RED)

function onCastSpell(cid, var)
        local pid = getCreatureTarget(cid)
        local drainAmount = getCreatureMaxHealth(pid)
       
        if(isPlayer(pid)) then
                doPlayerSendCancel(cid, "You may not use this spell on players")
        else
                doCreatureAddHealth(pid, -drainAmount)
                doCreatureAddMana(cid, drainAmount[COLOR="Red"]*0.05[/COLOR])
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BLUE)
        end
        return doCombat(cid, combat, var)
end
??
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_RED)

function onCastSpell(cid, var)
        local pid = getCreatureTarget(cid)
        local drainAmount = getCreatureMaxHealth(pid)
       
        if(isPlayer(pid)) then
                doPlayerSendCancel(cid, "You may not use this spell on players")
        else
                doCreatureAddHealth(pid, -drainAmount)
                doCreatureAddMana(cid, drainAmount[COLOR="Red"]*0.05[/COLOR])
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BLUE)
        end
        return doCombat(cid, combat, var)
end
??

Would instantly kill the target.

Thanks for pointing out my mistake though, fixed and updated post.
 
Back
Top