function ID takes unit u,real dam,integer b,real dur returns nothing
local boolean isunit = false
local integer thua = R2I(dam)
local integer tram
local integer chuc
local integer dvi
local integer a
local integer id = GetUnitTypeId(u)
local real countdur = 0
debug call BJDebugMsg(I2S(5 / 0))
//loop
if GetUnitAbilityLevel(u,'AInv') <= 0 then
set isunit = true
call UnitAddAbility(u,'AInv')
endif
set tram = ( thua / 100 )
set thua = ( thua - ( tram * 100 ) )
set chuc = ( thua / 10 )
set thua = ( thua - ( chuc * 10 ) )
set dvi = thua
// -------- + Damage ----------
loop
exitwhen (IsUnitPaused(u) == false and GetUnitState(u,UNIT_STATE_LIFE) > 0 )
call TriggerSleepAction(0.5)
endloop
set a = 1
loop
exitwhen a > tram
call UnitAddItemByIdSwapped( 'I00G',u )
set a = a + 1
endloop
set a = 1
loop
exitwhen a > chuc
call UnitAddItemByIdSwapped( 'I00H',u )
set a = a + 1
endloop
set a = 1
loop
exitwhen a > dvi
call UnitAddItemByIdSwapped( 'I00E',u )
set a = a + 1
endloop
if dur == 0 and b == 0 then
if isunit == true then
call UnitRemoveAbility(u,'AInv')
endif
return
endif
// -------- - Damage ----------
loop
exitwhen countdur > dur
call TriggerSleepAction( 0.5)
// if GetUnitTypeId(u) != id then
// exitwhen false
// endif
set countdur = countdur + 0.5
endloop
// exitwhen true
//endloop
if b != 0 then
loop
exitwhen GetUnitAbilityLevel(u,b) <= 0
call TriggerSleepAction(1)
endloop
endif
loop
exitwhen ( GetUnitState(u,UNIT_STATE_LIFE) > 0 )
call TriggerSleepAction( 1.00 )
endloop
loop
exitwhen IsUnitPaused(u) == false
call TriggerSleepAction(1)
endloop
set a = 1
loop
exitwhen a > tram
call UnitAddItemByIdSwapped( 'I00F',u )
set a = a + 1
endloop
set a = 1
loop
exitwhen a > chuc
call UnitAddItemByIdSwapped( 'I00I',u )
set a = a + 1
endloop
set a = 1
loop
exitwhen a > dvi
call UnitAddItemByIdSwapped( 'I00D',u )
set a = a + 1
endloop
if isunit == true then
call UnitRemoveAbility(u,'AInv')
endif
endfunction