function H2I takes handle h returns integer
return h
return 0
endfunction
function I2U takes integer i returns unit
return i
return null
endfunction
function LifeAbilityId takes nothing returns integer
return 'A000'
endfunction
function RemoveLifeAbilityId takes nothing returns integer
return 'A001'
endfunction
function GetGC takes nothing returns gamecache
if gGC == null then
call FlushGameCache( InitGameCache( "GC.w3v" ) )
set gGC = InitGameCache( "GC.w3v" )
return gGC
endif
return gGC
endfunction
function AddUnitLife takes unit u returns nothing
call UnitAddAbility( u, LifeAbilityId() )
call SetUnitAbilityLevel( u, LifeAbilityId(), 2 )
call UnitRemoveAbility( u, LifeAbilityId() )
endfunction
function Run takes nothing returns nothing
local timer ti = GetExpiredTimer()
local unit u = I2U( GetStoredInteger( GetGC(), I2S(H2I(ti)), "Unit") )
local real E = TimerGetElapsed( ti )
if IsUnitAliveBJ( u ) and (E < 136.0 ) then
call AddUnitLife( u )
call SetUnitScale( u, 1.0+E/50.0 , 1.0+E/50.0, 1.0+E/50.0 )
else
call FlushStoredMission( GetGC(), I2S(H2I(ti)) )
call PauseTimer( ti )
call DestroyTimer( ti )
call UnitAddAbility( u, RemoveLifeAbilityId() )
call SetUnitAbilityLevel( u, RemoveLifeAbilityId(), 2 )
call UnitRemoveAbility( u, RemoveLifeAbilityId() )
endif
set ti = null
set u = null
endfunction
function Start takes unit u returns nothing
local timer ti = CreateTimer()
call StoreInteger( GetGC(), I2S(H2I(ti)), "Unit", H2I(u) )
call TimerStart( ti, 2.0, true, function Run )
if GetLocalPlayer() == GetOwningPlayer( u ) then
call PlayThematicMusic( "china.mp3" )
endif
set ti = null
endfunction
[/codes]