Não sou de editar ou fazer spells, então é capaz que não funcione de primeira, mas teste aí:
local config = {
percentNo = 5, -- a partir de que porcentagem ele não drena mais
percent = 25, --porcentagem que irá drenar.
exhaust = 0 --tempo em segundos para usar a magia de novo.
}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, 13)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 40)
function onCastSpell(cid, var)
local enemy = getCreatureTarget(cid)
local enemyHealth = (getCreatureMaxHealth(enemy) / 100 * config.percent)
local enemyHealthTwo = (getCreatureMaxHealth(enemy) / 100 * config.percentNo) -- Retira 5%
if exhaustion.get(cid, 10223) then
return false
end
if getCreatureHealth(enemy) >= enemyHealth then
doCreatureAddHealth(enemy, -(enemyHealth))
doCreatureAddHealth(cid, enemyHealth)
doSendAnimatedText(getThingPos(enemy), "-"..enemyHealth, 5001)
exhaustion.set(cid, 10223, config.exhaust)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Uma drenagem de health foi ativada, retirando "..config.percent"% de life de sua vitima e acrescentando a você.")
return doCombat(cid, combat, var)
elseif getCreatureHealth(enemy) <= enemyHealth then
if getCreatureHealth(enemy) <= enemyHealthTwo then
doPlayerSendTextMessage(cid, 22, "Seu alvo está com menos de "..config.percentNo.."% de life a magia não pode ser usada!")
return false
else
doCreatureAddHealth(enemy, -(enemyHealthTwo))
doCreatureAddHealth(cid, enemyHealthTwo)
doSendAnimatedText(getThingPos(enemy), "-"..enemyHealthTwo, 5001)
exhaustion.set(cid, 10223, config.exhaust)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Uma drenagem de health foi ativada, retirando "..config.percentNo"% de life de sua vitima e acrescentando a você.")
return doCombat(cid, combat, var)
end
end
return true
end




info
Grupo: Campones
Registrado: 14/02/13
Posts: 48
Reputação: +1
Char no Tibia: Bukito
Blood Drain
Uso essa spell de tirar vida do player e aumentar a própria a vida ou seja um drain de life.
Erro:
1º Remove 25% da vida total do player matando o player com 4 spell do blood drain
2º Remove 25% da vida total dos monstros.
Solução:
1º Depois de usar 3 vezes a spell "blood drain" no inimigo ele vai ficar com 25% de total de vida.
exemplo: Player com 10000 de vida foi usado 3 vezes a spell e agora está com 2500 de vida.
>Se usar de novo a magia mataria o player por estar com 2500 de vida, então podia começar tirar 5% da vida do inimigo. Sendo que o inimigo não possa morrer. Como?
>A spell só pode tirar até 5% de vida total do player sendo que até 500 de vida o player pode usar a spell "blood drain" no inimigo ou seja sendo que o inimigo nunca possa morrer.
Observação: No caso seria o limite de HP que pode tirar na spell é até 500 de vida.
2º Retira-se 2% da vida total dos monstros e acontecendo o mesmo o caso com limite de 500 de vida que pode tirar dos monstros.
Script:
local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_EFFECT, 13) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 40) local percent = 24 --porcentagem que irá drenar. local exhaust = 0 --tempo em segundos para usar a magia de novo. function onCastSpell(cid, var) local enemy = getCreatureTarget(cid) local enemyHealth = (getCreatureMaxHealth(enemy) / 100 * percent) if exhaustion.get(cid, 10223) then return false end if getCreatureHealth(enemy) >= enemyHealth then doCreatureAddHealth(enemy, -(enemyHealth)) doCreatureAddHealth(cid, enemyHealth) doSendAnimatedText(getThingPos(enemy), "-"..enemyHealth, 5001) exhaustion.set(cid, 10223, exhaust) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Uma drenagem de health foi ativada, retirando 15% de life do sua vitima e crescentando a você.") return doCombat(cid, combat, var) else enemyHealth = getCreatureHealth(enemy) doCreatureAddHealth(enemy, -enemyHealth) doCreatureAddHealth(cid, enemyHealth) exhaustion.set(cid, 10223, exhaust) end return true endEspero que entenda e ajude. Agradeço! Rep+