/*
* Calculate spell resistance
*/
call DisableTrigger(Trigger(targetId_p).parent.trigger)
set life = GetWidgetLife(u)
set scale = GetUnitState(u, UNIT_STATE_MAX_LIFE)
call SetWidgetLife(u, scale)
call UnitDamageTarget(u, u, -scale/2, false, false, null, DAMAGE_TYPE_UNIVERSAL, null)
set scale = 2*(scale - GetWidgetLife(u))/scale
if (scale > 1) then
set damageOriginal = -damageOriginal*scale
else
set damageOriginal = -damageOriginal
endif
call SetWidgetLife(u, life)
call EnableTrigger(Trigger(targetId_p).parent.trigger)
set damage_p = damageOriginal