scope SpiritForm
globals
private unit array morphed
private integer count = 0
endglobals
function SpiritFormRemove takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = LoadInteger(udg_Table, GetHandleId(t), 'indx')
if GetUnitTypeId( morphed[i] ) == 'E00R' or IsUnitDeadBJ( morphed[i] ) then
call UnitRemoveAbility( morphed[i], 'A036' )
call UnitRemoveAbility( morphed[i], 'A037' )
call RecTimer(t)
set morphed[i] = null
endif
set t = null
endfunction
function Trig_Spirit_Form_Conditions takes nothing returns boolean
local unit u
local timer t
local integer i
if GetSpellAbilityId() == 'A034' then
set u = GetTriggerUnit()
set t = GetFreeTimer()
set i = GetUnitAbilityLevel( u , 'A034' )
set morphed[count] = u
call SaveInteger(udg_Table, GetHandleId(t), 'indx', count)
if count >= 20 then
set count = 0
else
set count = count + 1
endif
call TimerStart( t , 0.25, true, function SpiritFormRemove )
set t = null
call UnitAddAbility( u, 'A036' )
call UnitAddAbility( u, 'A037' )
call SetUnitAbilityLevel( u , 'A037', i )
call UnitMakeAbilityPermanent(u, true, 'A036')
call UnitMakeAbilityPermanent(u, true, 'A037')
set u = null
endif
return false
endfunction
//===========================================================================
function InitTrig_Spirit_Form takes nothing returns nothing
set gg_trg_Spirit_Form = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spirit_Form, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spirit_Form, Condition( function Trig_Spirit_Form_Conditions ) )
endfunction
endscope