Need a workaround for bots and GetPlayerList()

Need a workaround for bots and GetPlayerList()

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Need a workaround for bots and GetPlayerList()

Post by Forboding Angel »

Code: Select all

Spring.Echo("[Default Mex Layout] Map size is: " .. mapx + mapz)
local players = Spring.GetPlayerList()
local count = 0
for i = 1, #players do
    local playerID = players[i]
    if not select(3, Spring.GetPlayerInfo(playerID)) then
        count = count + 1
    end
end
Spring.SetGameRulesParam("peopleCount", count)

teamIDCount = Spring.GetGameRulesParam("peopleCount")

Spring.Echo("[Default Mex Layout] Number of teamIDs in this match: " .. teamIDCount)
This only counts human players. I need it to count bots as well. I only need a count of allyteams that are in the game. This is important because it defines how many metal spots are placed in a game. I have some mitigating logic that does some rounding up so that the impact from, say a 3v3bots will output enough spots deemed for a 2v2, but I would like to not be hamstrung in this fashion.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Need a workaround for bots and GetPlayerList()

Post by Silentwings »

https://github.com/Balanced-Annihilatio ... ds.lua#L76 can be easily modified to count all different types of player/team/AI.
Post Reply

Return to “Game Development”