local res = {
{101, COMBAT_FIREDAMAGE}, {102, COMBAT_EARTHDAMAGE}, {103, COMBAT_ENERGYDAMAGE}, {104, COMBAT_ICEDAMAGE}, {105, COMBAT_HOLYDAMAGE}, {106, COMBAT_DEATHDAMAGE}, {107, COMBAT_PHYSICALDAMAGE}, {108, COMBAT_PHYSICALDAMAGE},
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if creature:isPlayer() then
if primaryType == COMBAT_HEALING then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
for i = 1, 8 do
if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
if primaryType == res[i][2] or i == 8 then
primaryDamage = (primaryDamage - (primaryDamage * (creature:getStorageValue(5) / 100)))
end
if secondaryType == res[i][2] or i == 8 then
secondaryDamage = (secondaryDamage - (secondaryDamage * (creature:getStorageValue(5) / 100)))
end
end
end
if primaryDamage == 0 and secondaryDamage == 0 and creature:isPlayer() then
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end