function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
// A unit enters the building
local unit roof = gg_unit_hfoo_0000
call FadeUnitVertexColorForPlayer( roof, 1, 1, 1, 1, 1, 1, 1, 0.40, 1.0, GetOwningPlayer( GetEnteringUnit() ) )
endfunction
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
set gg_trg_Untitled_Trigger_001 = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Untitled_Trigger_001, gg_rct_Region_000 )
call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
// A unit leaves the building
local unit roof = (.. get the roof somehow ..)
call FadeUnitVertexColorForPlayer( roof, 1, 1, 1, 0.40, 1, 1, 1, 1, 1.0, GetOwningPlayer( GetLeavingUnit() ) )
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
set gg_trg_Untitled_Trigger_001 = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Untitled_Trigger_001, gg_rct_Region_000 )
call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
// =======================================
// Fade unit vertex colors
function FadeUnitVertexColorForPlayer_Update takes nothing returns nothing
local timer t = GetExpiredTimer()
local real r = GetHandleReal(t, "r") + GetHandleReal(t, "dr")
local real g = GetHandleReal(t, "g") + GetHandleReal(t, "dg")
local real b = GetHandleReal(t, "b") + GetHandleReal(t, "db")
local real a = GetHandleReal(t, "a") + GetHandleReal(t, "da")
local integer step = GetHandleInt(t, "step") - 1
local unit u = GetHandleUnit(t, "u")
local player who = Player( GetHandleInt(t, "player") )
if ( who == GetLocalPlayer() ) then
call SetUnitVertexColor(u, R2I(r*255), R2I(g*255), R2I(b*255), R2I(a*255))
endif
if ( u == null or step <= 0 ) then
call FlushHandleLocals(t)
call DestroyTimer(t)
return
endif
call SetHandleReal(t, "r", r)
call SetHandleReal(t, "g", g)
call SetHandleReal(t, "b", b)
call SetHandleReal(t, "a", a)
call SetHandleInt(t, "step", step)
endfunction
function FadeUnitVertexColorForPlayer takes unit u, real r1, real g1, real b1, real a1, real r2, real g2, real b2, real a2, real time, player who returns nothing
local timer t
local real update = 0.05
if ( time <= 0 ) then
if ( who == GetLocalPlayer() ) then
call SetUnitVertexColor(u, R2I(r2*255), R2I(g2*255), R2I(b2*255), R2I(a2*255))
endif
return
endif
call SetUnitVertexColor(u, R2I(r1*255), R2I(g1*255), R2I(b1*255), R2I(a1*255))
set t = CreateTimer()
call SetHandleReal(t, "r", r1)
call SetHandleReal(t, "g", g1)
call SetHandleReal(t, "b", b1)
call SetHandleReal(t, "a", a1)
call SetHandleReal(t, "dr", update*(r2-r1)/time)
call SetHandleReal(t, "dg", update*(g2-g1)/time)
call SetHandleReal(t, "db", update*(b2-b1)/time)
call SetHandleReal(t, "da", update*(a2-a1)/time)
call SetHandleHandle(t, "u", u)
call SetHandleInt(t, "step", R2I(time/update + 0.99))
call SetHandleInt(t, "player", GetPlayerId(who))
call TimerStart(t, update, true, function FadeUnitVertexColorForPlayer_Update)
endfunction