local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 5)
function onGetFormulaValues(player, level, magicLevel)
local min = (level / 5) + (magicLevel * 1.4) + 8
local max = (level / 5) + (magicLevel * 2.2) + 14
return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onCastSpell(creature, variant)
local target = variant:getNumber()
if not target then
creature:sendCancelMessage("You have to target a creature.")
return false
end
local target = Creature(target)
if not target then
creature:sendCancelMessage("You have to target a creature.")
return false
end
if target:isPlayer() and target:getGuid() ~= creature:getGuid() and not creature:getGroup():getAccess() then
creature:sendCancelMessage("You cannot cast this spell on this target.")
return false
end
local level = creature:getLevel()
local magicLevel = creature:getMagicLevel()
local damage = math.floor((level + magicLevel) * 0.9)
target:addHealth(-damage, false, "spell", false)
creature:addHealth(damage * 0.9, false, "spell", false)
creature:getPosition():sendMagicEffect(5)
return true
end