Square789 / tf2_dem_py

TF2 demo parser for python, glued together using C.
MIT License
9 stars 0 forks source link

how hard would it be to extract a timestamped log of kills in the match? #8

Closed davidhaas6 closed 1 year ago

Square789 commented 1 year ago

Let me preface this by saying that the project is horrible, has no defined standards, has been developed while i had no idea what i was doing, still crashes on 2% of demos and is not seeing much of a future. But it would of course be possible. Kills are game events, precisely ones with the id 23. I stole that id from here and god knows where they got it from. Game events are hardcoded to only be read when they are death events (ignore that other one, that should be player_shoot and it never appears in tf2 demos. (Yes, adding a field to the ParserState that would allow the configuration of events that are to be extracted would be way more awesome)). However, no data aside from their type and data is included as this is a toy project. It would be possible to modify the GameEvent struct to hold the tick at time of its reading as well; how they should end up coming out of the python conversion layer then: no clue, really. Nesting everything twice like {"type": 23, "type_name": "player_death", "tick": 1234, "data": {"userid": 42, ...}} might work out well... something to keep here i guess.

You want a solution. https://github.com/demostf/parser is a significantly more mature project. I do not remember much about when i tried compiling it 2 years ago, but it should be less painful to figure out its api and either build a small python wrapper for it or - as i remember it dumping json to stdout - reading that via subprocess and smoothly working with that. Hopefully rust is not too horrible to compile and get working in your case.

davidhaas6 commented 1 year ago

Thanks! I'll go ahead and use Parser