function Exit_Region_Actions takes nothing returns nothing
local region r = GetTriggeringRegion()
local integer id = GetHandleId(r)
local unit u = GetTriggerUnit()
call SetUnitX(u, LoadReal(udg_RectHT, id, 0) + LoadReal(udg_RectHT, id, 2) - GetUnitX(u))
call SetUnitY(u, LoadReal(udg_RectHT, id, 1) + LoadReal(udg_RectHT, id, 3) - GetUnitY(u))
if GetLocalPlayer() == GetOwningPlayer(u) then
call SetCameraPosition(GetUnitX(u), GetUnitY(u))
endif
set r = null
set u = null
endfunction
function InitRegion takes rect rec returns nothing
local region r = CreateRegion()
local integer id = GetHandleId(r)
call SaveReal(udg_RectHT, id, 0, GetRectMinX(rec))
call SaveReal(udg_RectHT, id, 1, GetRectMinY(rec))
call SaveReal(udg_RectHT, id, 2, GetRectMaxX(rec))
call SaveReal(udg_RectHT, id, 3, GetRectMaxY(rec))
call RegionAddRect(r, rec)
call TriggerRegisterLeaveRegion(udg_ExitRect, r, null)
set r = null
endfunction
function InitTrig_Exit_Region takes nothing returns nothing
set udg_RectHT = InitHashtable()
set udg_ExitRect = CreateTrigger()
call TriggerAddAction(udg_ExitRect, function Exit_Region_Actions )
call InitRegion(gg_rct_ExitRect1)
call InitRegion(gg_rct_ExitRect2)
call InitRegion(gg_rct_ExitRect3)
call InitRegion(gg_rct_ExitRect4)
endfunction