Generated Maps:Manually Placing Player Starts
Return to Generated Maps - Home
Apart from the default functions described in the official documentation and generated map template, you can also place players completely manually.
To take teams into account, setup the team mapping table to know which player belongs to which team. The following is an example of placing team members on the same row next to each other, with one row per team. Critically, note how playerIndex works differently from playerID!
teamMappingTable = CreateTeamMappingTable() for teamNum = 1, #teamMappingTable do for i = 1, #teamMappingTable[teamNum].players do -- IMPORTANT: playerIndex counts from 0, but playerID counts from 1. If you omit the "-1" here, the map will crash. terrainLayoutResult[teamNum][i].playerIndex = teamMappingTable[teamNum].players[i].playerID - 1 end end
For example, with the following setup in the game lobby:
The code above results in this start:
If you do not care about teams when placing players, a simpler way is to use worldPlayerCount directly. In the following example, we place all players on the first row next to each other.
-- IMPORTANT: Start this loop from 0, not 1! for i = 0, worldPlayerCount - 1 do terrainLayoutResult[i + 1].playerIndex = i end
When placing players manually without using the default helper functions, the game does not automatically add starting resources at player locations, so it is generally recommended to place one of the tt_player_start terrain types at the same coordinates:
-- ... some logic to determine row,col for player starts ... terrainLayoutResult[row][col].playerIndex = i terrainLayoutResult[row][col].terrainType = tt_player_start_classic_plains