scope MoveUnits initializer init
globals
rect array Arena
endglobals
private function setupRects takes nothing returns nothing
set Arena[0] = gg_rct_ArenaLeft
set Arena[1] = gg_rct_ArenaRight
endfunction
private function HeroFilter takes nothing returns boolean
if IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then
return true
endif
return false
endfunction
private function GetTeam takes unit u returns integer
local player p
local integer i = 0
loop
set p = Player(i)
if GetOwningPlayer(u) == p then
set u = null
set p = null
return 0
endif
set i = i + 1
exitwhen i > 5
endloop
set p = null
set u = null
return 1
endfunction
private function HeroMover takes unit u, integer team returns nothing
local rect r = Arena[team]
call SetUnitX(u, GetRectCenterX(r))
call SetUnitY(u, GetRectCenterY(r))
set u = null
set r = null
endfunction
private function GetAllHeroes takes nothing returns nothing
local group g = CreateGroup()
local unit u
local integer team
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Filter(function HeroFilter))
loop
set u = FirstOfGroup(g)
call GroupRemoveUnit(g, u)
exitwhen u == null
set team = GetTeam(u)
call HeroMover(u, team)
endloop
call DestroyGroup(g)
set g = null
set u = null
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 60., true)
call TriggerAddAction(t, function GetAllHeroes)
set t = null
endfunction
endscope