Can anyone add distance effect in this spell?
local function suck(cid, target)
if isCreature(cid) then
if isCreature(target) then
local formula = math.random(getPlayerLevel(cid), getPlayerLevel(cid) * 10)
doCreatureAddHealth(cid, formula)
doCreatureAddHealth(target, -formula)
doSendAnimatedText(getThingPos(cid), "+"..formula, COLOR_GREEN)
doSendAnimatedText(getThingPos(target), "-"..formula, COLOR_RED)
doSendMagicEffect(getThingPos(cid), 12)
doSendMagicEffect(getThingPos(target), 45)
return true
end
end
return true
end
function onCastSpell(cid)
local config = {
arrounds = 3, -- Vezes que a magia vai atacar
exaust = 5, -- tempo de exaust -> 1 = 1s
level = 50,
mana = 4500, -- Mana que vai gastar
time = 1000, -- tempo para executar a magia novamente (arrounds) -> 1 = 1s
t = getCreatureTarget(cid), --- Não mexa.
}
if config.t <= 0 then
doPlayerSendCancel(cid, "You need a target.")
return false
end
if getCreatureMana(cid) < config.mana then
doPlayerSendCancel(cid, "You need "..config.mana.." of mana to cast this spell.")
return false
end
if getPlayerLevel(cid) < config.level then
doPlayerSendCancel(cid, "You need level "..config.level.." to cast this spell.")
return false
end
if exhaustion.get(cid, 21511) then
doPlayerSendCancel(cid, "You need wait "..exhaustion.get(cid, 21511).." seconds.")
return false
end
exhaustion.set(cid, 21511, config.exaust)
doCreatureAddMana(cid, - config.mana)
doCreatureSay(cid, "BLOOD SUCK", TALKTYPE_MONSTER)
for a = 1, config.arrounds do
addEvent(suck, config.time * a, cid, config.t)
end
return false
end
local function suck(cid, target)
if isCreature(cid) then
if isCreature(target) then
local formula = math.random(getPlayerLevel(cid), getPlayerLevel(cid) * 10)
doCreatureAddHealth(cid, formula)
doCreatureAddHealth(target, -formula)
doSendAnimatedText(getThingPos(cid), "+"..formula, COLOR_GREEN)
doSendAnimatedText(getThingPos(target), "-"..formula, COLOR_RED)
doSendMagicEffect(getThingPos(cid), 12)
doSendMagicEffect(getThingPos(target), 45)
return true
end
end
return true
end
function onCastSpell(cid)
local config = {
arrounds = 3, -- Vezes que a magia vai atacar
exaust = 5, -- tempo de exaust -> 1 = 1s
level = 50,
mana = 4500, -- Mana que vai gastar
time = 1000, -- tempo para executar a magia novamente (arrounds) -> 1 = 1s
t = getCreatureTarget(cid), --- Não mexa.
}
if config.t <= 0 then
doPlayerSendCancel(cid, "You need a target.")
return false
end
if getCreatureMana(cid) < config.mana then
doPlayerSendCancel(cid, "You need "..config.mana.." of mana to cast this spell.")
return false
end
if getPlayerLevel(cid) < config.level then
doPlayerSendCancel(cid, "You need level "..config.level.." to cast this spell.")
return false
end
if exhaustion.get(cid, 21511) then
doPlayerSendCancel(cid, "You need wait "..exhaustion.get(cid, 21511).." seconds.")
return false
end
exhaustion.set(cid, 21511, config.exaust)
doCreatureAddMana(cid, - config.mana)
doCreatureSay(cid, "BLOOD SUCK", TALKTYPE_MONSTER)
for a = 1, config.arrounds do
addEvent(suck, config.time * a, cid, config.t)
end
return false
end