TeamInitPlayerSlots

Parameters
teamCount integer
comment

Assign all players to a team (force) in a "pseudo-random" fashion.

note

Players aren't assigned to teams randomly, but in a round-robin way. This means if teamCount == 2 with 4 players:

  • player 0 -> team 0
  • player 1 -> team 1
  • player 2 -> team 0
  • player 3 -> team 1
  • etc.
note

This function is called in the scope of config by InitGenericPlayerSlots etc. to set up the map based on chosen default game type.

return type
nothing
Source code
function TeamInitPlayerSlots takes integer teamCount returns nothing
    local integer index
    local player  indexPlayer
    local integer team

    call SetTeams(teamCount)

    call CheckInitPlayerSlotAvailability()
    set index = 0
    set team = 0
    loop
        if (bj_slotControlUsed[index]) then
            set indexPlayer = Player(index)
            call SetPlayerTeam( indexPlayer, team )
            set team = team + 1
            if (team >= teamCount) then
                set team = 0
            endif
        endif

        set index = index + 1
        exitwhen index == bj_MAX_PLAYERS
    endloop
endfunction
Source
Blizzard.j
wc3modding.com
TeamInitPlayerSlots