function RacePickTimerExp takes nothing returns nothing
local integer i=0
local race r
loop // set standard races choosen in game lobby
if (not g_racePicked[i]) and (DetectHumanSlot(i) or DetectCompSlot(i)) then
set r=GetPlayerRace(Player(i))
set g_racePicked[i]=true //added 22-10-2017 to fix bug reported by StoPCampinGn00b
if r==RACE_HUMAN then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "HUMAN detected for player " + I2S(i+1))
call MeleeStartingUnitsHuman(Player(i), GetStartLocationLoc(GetPlayerStartLocation(Player(i))), true, true, true)
if DetectCompSlot(i) then
call StartMeleeAI(Player(i), "human.ai")
endif
elseif r==RACE_ORC then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "ORC detected for player " + I2S(i+1))
call MeleeStartingUnitsOrc(Player(i), GetStartLocationLoc(GetPlayerStartLocation(Player(i))), true, true, true)
if DetectCompSlot(i) then
call StartMeleeAI(Player(i), "orc.ai")
endif
elseif r==RACE_UNDEAD then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "UNDEAD detected for player " + I2S(i+1))
call MeleeStartingUnitsUndead(Player(i), GetStartLocationLoc(GetPlayerStartLocation(Player(i))), true, true, true)
if DetectCompSlot(i) then
call StartMeleeAI(Player(i), "undead.ai")
endif
elseif r==RACE_NIGHTELF then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "NIGHTELF detected for player " + I2S(i+1))
call MeleeStartingUnitsNightElf(Player(i), GetStartLocationLoc(GetPlayerStartLocation(Player(i))), true, true, true)
if DetectCompSlot(i) then
call StartMeleeAI(Player(i), "elf.ai")
endif
else
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "UNRECOGNIZED race detected for player " + I2S(i+1))
endif
endif
set i = i + 1
exitwhen i == bj_MAX_PLAYERS
endloop
call PauseAllUnitsBJ(false)
call DestroyTimerDialog(bj_lastCreatedTimerDialog)
call MultiboardMinimize(udg_Mb, true)
call MultiboardDisplay(udg_Mb, false)
call DestroyMultiboard(udg_Mb)
call InitHeroLimitSystem() // init *now* because if "random hero" flag was set 1st hero will be spawned
// by this function (RacePickTimerExp) for standard races
endfunction