local function skill(cid)
local skills = {SKILL_CLUB,SKILL_SWORD,SKILL_AXE}
table.sort(skills, function(a,b) return getPlayerSkill(cid,a)>getPlayerSkill(cid,b) end)
return getPlayerSkill(cid,skills[1])
end
function onCastSpell(cid, var)
local skill, target = skill(cid),variantToNumber(var)
local formula = {skill*10,skill*5}
if target == 0 then
return doPlayerSendCancel(cid,"You need a target to cast this spell.")
end
if not (getCreatureHealth(cid) > formula[2]) then
return doPlayerSendCancel(cid,"You do not have enough hit points to cast this spell.")
end
doAreaCombatHealth(0, COMBAT_DEATHDAMAGE, getCreaturePosition(cid), 0, -formula[2], -formula[2], CONST_ME_MORTAREA)
doAreaCombatHealth(cid, COMBAT_DEATHDAMAGE, getCreaturePosition(target), 0, -formula[1], -formula[1], CONST_ME_MORTAREA)
return true
end