local percentHealthMin = 10 --eg. You will hit for 10% of your max health at the minimum
local percentHealthMax = 20 --eg. You will hit for 20% of your max health at the maximum
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
function onCastSpell(cid, var)
local min = getCreatureMaxHealth(cid) / (100/percentHealthMin)
local max = getCreatureMaxHealth(cid) / (100/percentHealthMax)
if doCombat(cid, combat, var) then
return doTargetCombatHealth(cid, variantToNumber(var), COMBAT_DEATHDAMAGE, -min, -max, CONST_ME_MORTAREA)
end
return false
end