function AddDMGEx takes boolean DMG, boolean newunit, unit u, integer value returns nothing
local integer i
local integer n
local integer a1
local integer a2
local integer a3
local integer a4
local integer p = GetPlayerId( GetOwningPlayer( u ) ) + 1
if newunit then
call UnitAddAbility(u, udg_Abilities2[14])
call UnitAddAbility(u, udg_Abilities2[15])
call UnitAddAbility(u, udg_Abilities2[16])
call UnitAddAbility(u, udg_Abilities2[17])
call UnitAddAbility(u, udg_Abilities2[18])
call UnitAddAbility(u, udg_Abilities2[19])
call UnitAddAbility(u, udg_Abilities2[20])
endif
if not DMG then
set a1 = udg_Abilities2[14]
set a2 = udg_Abilities2[15]
set a3 = udg_Abilities2[16]
set i = value
set n = i / 100 + 1
call SetUnitAbilityLevel( u, a3, n )
set i = i - ( i / 100 ) * 100
set n = i / 10 + 1
call SetUnitAbilityLevel( u, a2, n )
set i = i - ( i / 10 ) * 10
set n = i + 1
call SetUnitAbilityLevel( u, a1, n )
else
set a1 = udg_Abilities2[17]
set a2 = udg_Abilities2[18]
set a3 = udg_Abilities2[19]
set a4 = udg_Abilities2[20]
set i = value
set n = i / 1000 + 1
call SetUnitAbilityLevel( u, a4, n )
set i = i - ( i / 1000 ) * 1000
set n = i / 100 + 1
call SetUnitAbilityLevel( u, a3, n )
set i = i - ( i / 100 ) * 100
set n = i / 10 + 1
call SetUnitAbilityLevel( u, a2, n )
set i = i - ( i / 10 ) * 10
set n = i + 1
call SetUnitAbilityLevel( u, a1, n )
endif
endfunction