Page 1 of 1
logging playerlist including bots (half done but bugged)
Posted: 05 Aug 2010, 09:28
by knorke
I want to log all players in a game with their Allyteam, colors etc. to a textfile.
For human players that works already. For bots it does not.
code so far:
http://pastebin.org/448406
It logs some bots, but not all. Cant see a system to it though.
Compare the "Result:" with the real setup:
http://www.abload.de/img/clipboard02md2f.jpg
Ais called "ca_Drei" and "Vier" are missing.
Does not matter if CA's Lua AI "CAI" or Nullai its never quite correct.
I want the real name of the AIs not the ones of their hosters.
If someone can have a look at this that would be cool :)
I do not even know if .dll or Lua AI makes a difference?
Reason I need this is so that Bots can show up in game stats image thingies just like human players:
http://img13.abload.de/img/2v2icyrunkomplettp4ty.jpg
Re: logging playerlist including bots (half done but bugged)
Posted: 05 Aug 2010, 10:08
by zwzsg
GetPlayerInfo takes a playerID
GetAIInfo takes a teamID
Re: logging playerlist including bots (half done but bugged)
Posted: 05 Aug 2010, 16:35
by AF
Try looking at the shard stats widget
Re: logging playerlist including bots (half done but bugged)
Posted: 05 Aug 2010, 20:15
by knorke
zwzsg wrote:GetPlayerInfo takes a playerID
GetAIInfo takes a teamID
Oh. They can both take it up their .. for all I care!
Thanks, will be helpful.
But then this would be incorrect as well?
Code: Select all
for p = 0,31 do
local name,active,spec,teamID,allyTeamID,pingTime,cpuUsage = Spring_GetPlayerInfo(p)
if name == nil then
teamID, skirmishAIID, name, hostingPlayerID, shortName, version = Spring.GetAIInfo(p)
pingTime,cpuUsage = 100 end
end
Smoth copy&pasted that in lobby from one of his widgets.
It is done like this AdvPlayerlist as well:
http://sl.pastebin.com/JSsqUDxg
line 1813 and 1816
2000 lines for a playerlist Oo
AF wrote:Try looking at the shard stats widget
What file would I find this in, I downloaded Shard.0.29Spikey
game:SendToConsole("OHAI DER")
---
wtf.
Here is the latest version:
http://pastebin.org/449217
It tries to write to whateverfolderspringuses\replaylogs\[somename].txt
function get_playerlist_s () is the problem.
Its called at gamestart but you can retrigger it by typing
openlogfile
getplayerlist
into chat.
I want it to output something like:
[PlayerInfo]name=<[RoX]knorke> playerID=<1> allyTeamID=<0> teamID=<0> spectator=<true> playercolor_r=<248> playercolor_g=<6> playercolor_b=<223>
[PlayerInfo]name=<[Sin]Thogram> playerID=<2> allyTeamID=<0> teamID=<0> spectator=<false> playercolor_r=<248> playercolor_g=<6> playercolor_b=<223>
[PlayerInfo]name=<[SNTT]lfing> playerID=<3> allyTeamID=<0> teamID=<0> spectator=<true> playercolor_r=<248> playercolor_g=<6> playercolor_b=<223>
[PlayerInfo]name=<[CoX]jimjoe> playerID=<4> allyTeamID=<1> teamID=<1> spectator=<false> playercolor_r=<25> playercolor_g=<255> playercolor_b=<0>
But including AIplayers.
Maybe with botplayer=<yes> but I dont care for that.
Re: logging playerlist including bots (half done but bugged)
Posted: 05 Aug 2010, 22:24
by AF
The shard stats widget has its own thread in this forum
Re: logging playerlist including bots (half done but bugged)
Posted: 06 Aug 2010, 03:27
by knorke
AF: Was that the thing used for the AI kp tourney?
Did not find that thread again but still thanks.
Also many thanks to smoth and zwsg for their efforts.
Seperate loops for
Spring.GetAIInfo(i) and Spring.GetPlayerInfo (i)
solved it. I hope.
Re: logging playerlist including bots (half done but bugged)
Posted: 06 Aug 2010, 16:09
by slogic
For me shortName is empty since Spring 0.82RC in the following line:
Code: Select all
teamID, skirmishAIID, name, hostingPlayerID, shortName, version = Spring.GetAIInfo(p)
script.txt does contain ShortName keys. Strange.
Re: logging playerlist including bots (half done but bugged)
Posted: 06 Aug 2010, 16:28
by hoijui
slogic, version is not empty?
they will have default values/be empty if the AI is not local, cause shortName and version are not synced info.
Re: logging playerlist including bots (half done but bugged)
Posted: 06 Aug 2010, 17:31
by slogic
Ouch, my wrong. I fixed it. Number of items in return list of GetAIInfo() is reduced by one. Long ago i was surprised that practical result does not correspond what i've read in source code. May be that time source code was from upcoming 0.82.x.
Anyway, i can't tell what exactly was removed currently.