Hello ^_^
I have made spell which is working perfectly but is way to wirte it shorten??
NOTE: This is drain life spell
Thanks for help :thumbup:
I have made spell which is working perfectly but is way to wirte it shorten??
Lua:
local formulaDrainHealth = {
min = 50 * 2 + 400 * 3,
max = 40 * 2.5 + 500 * 3.5
}
function onCastSpell(cid, var)
local drain = math.random(formulaDrainHealth.min, formulaDrainHealth.max)
local target = getCreatureTarget(cid)
local percent = 70
if(getCreatureHealth(target) == 0) then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
elseif(getCreatureHealth(target) < drain) then
doSendAnimatedText(getCreaturePosition(target), ''.. getCreatureHealth(target) ..'', TEXTCOLOR_RED)
doCreatureAddHealth(cid, getCreatureHealth(target) * percent / 100)
doCreatureAddHealth(target, - getCreatureHealth(target))
doSendDistanceShoot(getCreaturePosition(target), getCreaturePosition(cid), 30)
elseif(getCreatureHealth(target) > 0) then
doSendAnimatedText(getCreaturePosition(target), ''.. drain ..'', TEXTCOLOR_RED)
doCreatureAddHealth(cid, drain * (percent / 100))
doCreatureAddHealth(target, - drain)
doSendDistanceShoot(getCreaturePosition(target), getCreaturePosition(cid), 30)
end
return true
end
NOTE: This is drain life spell
Thanks for help :thumbup: