function onCastSpell(cid, var)
local level = getPlayerLevel(cid)
local mg = getPlayerMagLevel(cid)
local min = -(level *0.28 + mg * 2.34 * 1.0)
local max = -(level * 0.34 + mg * 2.34 * 1.0)
if isCreature(getCreatureTarget(cid)) then
local creaturePos = getCreaturePosition(getCreatureTarget(cid))
creaturePos.stackpos = 255
addEvent(function() if getCreatureTarget(cid) ~= nil then doTargetCombatHealth(cid,getThingfromPos(creaturePos).uid, 1, min, max, 17) doSendDistanceShoot(getCreaturePosition(cid), creaturePos, 31) doSendMagicEffect(creaturePos, 17) return TRUE end end, 17)
return TRUE
else
local n = 6
for i = 1, n do
local newPos = getPositionByDirection(getCreaturePosition(cid), getCreatureLookDirection(cid), i)
newPos.stackpos = 255
if not isWalkable(newPos, false, true, true) or isCreature(getThingfromPos(newPos).uid) or i == n then
doSendDistanceShoot(getCreaturePosition(cid), newPos, 31)
addEvent(function() if isCreature(getThingfromPos(newPos).uid) then
doTargetCombatHealth(cid,getThingfromPos(newPos).uid, 1, min, max, 17)
doSendMagicEffect(newPos, 17) return TRUE else
doSendMagicEffect(newPos, 17) end end, 140)
break
end
end
end
end