Closed LaihoE closed 1 year ago
Do you happen to have an example of this? Mostly interested in what type of events you are parsing.
I'm trying to get the information of all players when a kill happens. My code looks roughly like this:
parser = DemoParser(demo_path)
death_event = parser.parse_events('player_death')
deaths = pd.DataFrame(death_event)
# get a list of ticks when a death occurred
all_death_ticks = deaths['tick'].tolist()
ticks_df = parser.parse_ticks(['X', 'Y', 'Z'], ticks=all_death_ticks)
ticks_df.to_csv(output_path, index=False)
This gives the information of the players but also the information the observers of the game. For instance, if I use this game not only I get the ten players, but also three observers: Linaaa, @shevcsgo, zw1nc3k.
Right now my solution is to have a metadata file with the player names in it and filter anything not in that list, but it's not ideal.
Thanks for the issue, this definitely needs to be fixed. The problem is actually in the parse_ticks and not exactly in the parse_events. I've been working on a bigger refactor and so ill fix it after. Here are 2 "glue" solutions in the meanwhile.
https://github.com/LaihoE/Python-demoparser/issues/7 Look at this issue we discussed team_num var it should work for filtering the players.
ticks_df = parser.parse_ticks(['X', 'Y', 'Z', 'team_num'], ticks=all_death_ticks)
ticks_df = ticks_df[ticks_df["team_num"].isin([2, 3])]
If you are only interested in the player and the victim you can do this (it will add columns like: player_X and victim_X):
parser = DemoParser(file)
df = pd.DataFrame(parser.parse_events('player_death', props=['X', 'Y', 'Z']))
df.to_csv(output_path, index=False)
Thanks for your solutions. The first solution you provided actually does what I need. Made the code much simpler and cleaner.
S2 version will have some checks in place to combat this. Unfortunately not adding anything extra for this s1 version.
This would be a useful feature to have. Currently the only reliable way of doing this for my use case is to manually filter spectators out of the final result.