kotiq / wt-tools

War Thunder resource extraction tools
27 stars 3 forks source link

Parse server replay files #2

Open TaLajans opened 2 years ago

TaLajans commented 2 years ago

Hello,

would it be possible to improve wrpl parser to parse server replay files from https://warthunder.com/en/tournament/replay/ to get key server data and ignore all other information that could change during next update?


Right now wrpl_unpacker_2.py can parse only local replay files and it exports map json, final result json and file called wrplu.bin.

Server replays looks like this wrplu.bin, but some times it can be split into N number of files like in this example https://warthunder.com/en/tournament/replay/type/157247827975305385 image

Problem

This mission end window is displayed only once in a game right after you leave a match or it ended.

init

From this window you can get a lot of information about each of the vehicle you used in this match.

time crit groundkills hits

kotiq commented 2 years ago

@TaLajans This will require in-depth knowledge of the game protocol, which I don't have right now. I saw a similar project for WOT created by evido.

TaLajans commented 2 years ago

I saw that WOT parser from evido too. I do hope that in near future you or someone else could get that knowledge of the game protocol and share it with everyone so we could have a similar tool for WT.

Keksilton commented 2 years ago

Server replays do not include useful information in the same format, so right now it's not possible. You can check out Replay reader over on https://keksilton.github.io/WtTools.Web/ It's still limited to local replays and basic data, but it might be more convenient, I guess.

TaLajans commented 2 years ago

Thank you for this replay reader @Keksilton, but as of now it only gives nice scoreboard visualization, but you already could extract it using this wrpl_unpacker_ng.py.

It looks like a file as you call wrplu.bin is a bit more like server replays, but as @kotiq mention you would need in-depth knowledge of game protocol to parse it.

prandleman commented 2 years ago

@TaLajans

I've been working on a clog parser that can get you

It was designed as a real-time parser to get details such as level binary, mission blk, team information etc. I haven't directly looked for information on point capture, but since it HUD messages are output to the log one might be able to see who the point capture award (is there an award for one capture or only multiple, not sure) had been awarded to. I'm not sure if which point was captured is important to you, but I'm sure the icon changes on the web map so yeah..

Only issue I see is that the replay file would have to be played back to get the information to appear in the clog. If participants sent them or they were uploaded to server the parse would be almost instant with timestamps for all the events. If you were curious the main way to tell if player has spawned or died is not by the web map json request api (cause that's a bit funky with how it's state machine works and the valid keys for indicators and state) but buy watching the camera controller output log.

kotiq commented 2 years ago

@prandleman Processing the binary log in real time can lead to a gaming advantage, which formally violates the user agreement. For this reason, I did not finish building the state machine for events from the log. I would not like ordinary users to be banned. I hope the parser from thundertac hasn't gone too far yet.

TaLajans commented 2 years ago

@prandleman, as I understand you would need to launch server or player replay via game to generate this clog?

While I would like to start with something small like spawn, death, kill and mission outcome (win/lose). To have timestamps would be great if available, and you are not getting any award for capping first base only from second one and onwards.

I'm curious on how optimize it would be run. You are not allowed to run multiple instances of the game and because of this it could be the biggest bottleneck. Some fights take 10 - 30 minutes to finish. So if I would get 10 replays or more it could take few hours just to replay them. Is there a way to run WT in background like headless process to generate clog?

The ideal solution would be as @kotiq has some the scripts that just takes file as parameter and parses it. Does any part from clog and server replay binary matches that could be used?

prandleman commented 2 years ago

@TaLajans Yeah the reason I haven't put my parser up is that I has the xor key hard coded into the file and can be used to get an advantage with one line from the log (with a bit of work I might add). I think it's application is best with CDK power users that accept the risk and the real-time nature of it is just doing regex searches which could be liken to parsing the clog and doing a ctrl+f find lol.

Let's revisit this idea but I will need some time to hunt for my original work on parsing the damage log given by the webapi, but you should know the timestamps would be spotty. Maybe if the wrpl parsed files have a start time (I can't recall atm), but yeah I wanna stay away from the clog parser idea. Here is an example of what I can do with the webapi (red is regex caught, grey is missed) this version is not the best iteration and doesn't have any sort of timestamp.

If you wanna discuss more talk to me in discord cause I don't want to have a chain of messages in the issue section: bit.ly/ttaccord look for the discord server creator

image

these all come from public webapi ("http://localhost:8111/hudmsg?lastEvt=0&lastDmg=")

prandleman commented 2 years ago

@kotiq Nice connect there. I forgot I switched to my school account on github. Yeah, I contemplated it for a long time. Being very new to programming and software development I am still getting use to the lack of knowledge from the end user. So hard to get them to open a text file and jot in some data.. And yeah, the real-part was mostly to understand xor and debug mission editor trigger logic as well as 3d model / fm cdk errors, but then I realized I could do automate more for the end user, but obviously with some risk.

I'll remove all that cause I do worry about the end user. I haven't published any of the code that does this AFAIK, but Gaijin would know I was getting the player name somehow if they ever tried it lol.

With my current knowledge, the only thing that I'd be losing is the player name and which team they were on (which is kind of big, but AFAIK thundertac isn't used on a full team scale just 1v1 dogfights, so assigning the teams wouldn't be too much of a hassle. The wt root directory, current level.bin and anything else I needed can be acquired without parsing the clog. I guess I will revisit the idea of using the wrpl files post match.

On that, the only thing that I found that could be really used to cheat would be the FMW lines.

TaLajans commented 2 years ago

If there is someone who would do such parser let me know. I'm willing to pay/donate up to 1k euro for such work.

nilshellerhoff commented 2 years ago

Hey @TaLajans , I have spent some time analyzing server replay files, you can see the efforts over at https://github.com/nilshellerhoff/warthunder-replay-parser. I'm not very experienced in anything binary though, but essentially you can see which vehicles have been involved in a battle. Also there is some stuff for automatically downloading replay files and getting vehicle info from the wiki.

PS: A lot of stuff is missing, I have e.g. not been able to get teams info (which player was on which team) or any information about battle progress. This was more about getting some matchmaker stats