LaihoE / demoparser

Counter-Strike 2 replay parser for Python and JavaScript
MIT License
277 stars 29 forks source link

Keeping track of player equipment #20

Closed Yesber closed 10 months ago

Yesber commented 12 months ago

Hey,

I would like to keep track of what equipment (weapons + nades + c4) each player has equipped. I've tried parsing the "item_equip" event but it doesn't tell me who equipped the item, it also doesn't tell me when someone drops an item. Do you know if there is a way to do this? I'm using node.

All the best,

LaihoE commented 12 months ago

When you say "equipped" do you mean what item the player currently has in its hand or what items are in its "inventory" or whatever you want to call it.

  1. "Currently in hand"

    let ticks = parseTicks("path_to_demo.dem", ["active_weapon_name"])

    Will give you these:

    {
    active_weapon_name: 'glock',
    name: 'player1',
    steamid: '765611111111111111',
    tick: 288
    },
  2. Or are you interested in something like this (Not implemented atm but should):

    let ticks = parseTicks("path_to_demo.dem", ["inventory"])
{
    inventory: ["C4", "AK", "glock", "kevlar"],
    name: 'player1',
    steamid: '765611111111111111',
    tick: 288
},
Yesber commented 12 months ago

I get the active_weapon_name and it's working well, 2. is what I had in mind. Primary, secondary, knife, nades and c4 is what I used to get from the csgo parser. Thanks!

LaihoE commented 12 months ago

Made some good progress on this. I think I got the others working fine, but knife would require some different logic. Would you like to share why you are interested in the knife? I assume everyone to always have a knife in their inventory (or are you interested in the knife type or something?)

Yesber commented 12 months ago

Nice, well done!

I'm not particularly interested in the knife, for my use case I would be fine assuming that everyone has one.

It is possible to make modes where you don't necessarily have a knife, and it could be fun to know the type.

LaihoE commented 11 months ago

Ok, so after very many unexpected turns it should be finally done in 0.8.0. You can use it with the "inventory" prop. The knife was also added.

Yesber commented 11 months ago

Nice! Thank you so much, it is working great overall!

The player loses their knife when they die but keeps the rest of their inventory, the behavior I would expect was that the player loses all of their inventory on death.

I'm also looking at a demo where a bomb drop has been missed, resulting in two players having the bomb in their inventory at the same time. I run parseTicks(demoPath, ["inventory"], [5452]) and the returned object has two players with a c4 in their inventory. The player who originally dropped the bomb loses it from his inventory later in the round, which could be a clue.

I'd send you the demo on discord but the link in the readme doesn't work 😊

G4ble commented 11 months ago

I am using python and I still get a DemoParser.Exception: UnknownPropName("inventory") using ticks = parser.parse_ticks(["inventory"])

LaihoE commented 11 months ago

@G4ble make sure you have the newest version. pip uninstall demoparser2 pip install demoparser2==0.8.1

G4ble commented 11 months ago

Thanks everything works now!

LaihoE commented 11 months ago

@Yesber Damn. Was able to reproduce the c4 problem on other demo. Not too sure what could be causing this as I don't do anything special like tracking bomb drops etc, the demo has something similar to player.inventory that I use. Looking into this atm.

Also yes values of dead players are known to be buggy and this happens with other props also. For example dead players might have odd coordinates. The problem is that it's not so clear which props are ok to trust when the player is dead. (This is part of the demo and not due to some odd parser logic). Sometimes you might also want to know a value from a dead player. The solution for now is to make sure "is_alive" is true. The parser could of course do this, but as said sometimes this is not what you want. I'm still thinking about what to do to this.

LaihoE commented 11 months ago

Does this only happen with the C4 or has there been problems with other equipment? The C4 could be handled differently if it truly is the only problem.

ypracapp commented 11 months ago

I've only seen it happen with the C4

ypracapp commented 11 months ago

I've only seen it happen with the C4

LaihoE commented 11 months ago

Could you check if this was fixed in 0.10.0?

Yesber commented 10 months ago

It seems to be fixed in 0.10.0 👍

LaihoE commented 10 months ago

Closing, feel free to re-open if more problems appear.