Bots are handled quite differently in the engine so it makes sense that the Lua interface reflects this. It might take a lot of effort to modify the engine and such change could break backward compatibility. It's probably easier to poison your callouts:
Code: Select all
local AIs = {}
do
local teamList = Spring.GetTeamList()
for _, teamID in pairs(teamList) do
local _, playerID, _, isAI, _, allyTeamID = Spring.GetTeamInfo(teamID)
if isAI then
local aiID, aiName, aiHost = Spring.GetAIInfo(teamID)
local data = {
name = aiName,
teamID = teamID,
allyTeamID = allyTeamID,
playerID = aiHost,
}
local luaAI = Spring.GetTeamLuaAI(teamID)
if luaAI ~= "" then
data.luaAI = luaAI
data.country = "AI" -- Anguilla, British overseas territory
data.rank = 0
else
data.country = select(8, Spring.GetPlayerInfo(playerID))
data.rank = select(9, Spring.GetPlayerInfo(playerID))
end
AIs[-aiID] = data
end
end
end
local origGPI = Spring.GetPlayerInfo
Spring.GetPlayerInfo = function(playerID)
local aiData = AIs[playerID]
if not aiData then
return origGPI(playerID)
end
local active, ping, cpu = true, 0, 0
if not aiData.luaAI then
active = select(2, origGPI(aiData.playerID))
ping = select(6, origGPI(aiData.playerID))
cpu = select(7, origGPI(aiData.playerID))
end
return aiData.name, active, false, aiData.teamID, aiData.allyTeamID, ping, cpu, aiData.country, aiData.rank, {} -- 104.0
-- return aiData.name, active, false, aiData.teamID, aiData.allyTeamID, ping, cpu, aiData.country, aiData.rank, true, {} -- develop
end
local origGPL = Spring.GetPlayerList
Spring.GetPlayerList = function (teamID, active)
local ret = origGPL(teamID, active)
for aiID, aiData in pairs(AIs) do
if (not teamID or aiData.teamID == teamID)
and (not active or select(2, origGPI(aiData.playerID)))
then
ret[#ret + 1] = aiID
end
end
return ret
end