ggtracker / sc2reader

Extracts gameplay information from Starcraft II replay files
http://pypi.python.org/pypi/sc2reader
MIT License
145 stars 144 forks source link

not showing event for queuing ordered units #117

Closed demienYu closed 2 years ago

demienYu commented 4 years ago

If i order just one unit at a time (say, Marine in a Barrack) i have two events: 1) BasicCommandEvent event.ability.id = 5088, event.ability.name = TrainMarine when i order marine 2) UnitBornEvent event.name = "Unit born Marine" when marine production is done

But when I order multiple marines in a queue i just get one BasicCommandEvent "TrainMarine" and then multiple UnitBornEvents, when every marine is done.

Is it possible to catch "train" event when i order every unit in a queue?

dsjoerg commented 4 years ago

That is so weird, I would have thought you would get multiple TrainMarine events. I suggest you look at the raw event stream, either using sc2reader or https://github.com/Blizzard/s2protocol.

If the raw event stream doesn't have multiple TrainMarine events, then there isn't anything that can be done about it without hacking the StarCraft2 client itself.

dsjoerg commented 4 years ago

It seems especially weird to me because the replay contains all the information necessary to replay the game. So somewhere in there is the information about how many marines the player is attempting to train.

demienYu commented 4 years ago

What do you mean by the "raw event stream"? How can i access it using sc2reader? I access events through replay.events list.

demienYu commented 4 years ago

I've just parsed game events using s2protocol and i actually see queuing marines. But s2protocol events format is something really hard to comprehend. sc2reader is much usable. {"m_cmdFlags": 256, "m_abil": {"m_abilLink": 159, "m_abilCmdIndex": 0, "m_abilCmdData": None}, "m_data": {"None": None}, "m_sequence": 19, "m_otherUnit": None, "m_unitGroup": None, "_event": "NNet.Game.SCmdEvent", "_eventid": 27, "_gameloop": 2264, "_userid": {"m_userId": 0}, "_bits": 112}, {"m_state": 1, "m_sequence": 20, "_event": "NNet.Game.SCommandManagerStateEvent", "_eventid": 103, "_gameloop": 2267, "_userid": {"m_userId": 0}, "_bits": 56}, {"m_state": 1, "m_sequence": 21, "_event": "NNet.Game.SCommandManagerStateEvent", "_eventid": 103, "_gameloop": 2271, "_userid": {"m_userId": 0}, "_bits": 56}, {"m_state": 1, "m_sequence": 22, "_event": "NNet.Game.SCommandManagerStateEvent", "_eventid": 103, "_gameloop": 2275, "_userid": {"m_userId": 0}, "_bits": 56}, {"m_state": 1, "m_sequence": 23, "_event": "NNet.Game.SCommandManagerStateEvent", "_eventid": 103, "_gameloop": 2280, "_userid": {"m_userId": 0}, "_bits": 56}, {"m_state": 1, "m_sequence": 24, "_event": "NNet.Game.SCommandManagerStateEvent", "_eventid": 103, "_gameloop": 2282, "_userid": {"m_userId": 0}, "_bits": 56}, So in my opinion it would be great to fix this in sc2reader

StoicLoofah commented 4 years ago

That's a great suggestion! Admittedly, sc2reader is very much in maintenance mode, so if either your or someone else in the community wants to submit a pull request for it, I will happily take a look, but I personally am unlikely to take a stab at this

danfulton commented 2 years ago

I know this is a zombie thread, but running into this at the moment, so I thought I'd chime in if anyone has any hints for me.

I think this generally affects any Train event, even if it is not immediate... e.g. if I select a Command Center, train an SCV, wait five seconds and train another SCV without changing selection, then I do see a TrainSCV BasicCommandEvent for the first SCV, but nothing for the second. I noticed something similar with Zerg Morph events, but in that case you DO see all the larva->egg morphs at the same time, so you can imply what the egg is for based on the last Morph event you saw.

Before I found this issue, I was thinking along same lines as @dsjoerg ... the info MUST be in the replay, so somehow it is not getting extracted properly somewhere along the line.

All the binary parsing is a little obscure to me, but if I can figure anything out I'll make a PR.

danfulton commented 2 years ago

Ah, I was a bit confused by the CommandManagerStateEvent that @demienYu was catching, but it looks like it just means "repeat the last CommandEvent received."

{'m_state': 1, 'm_sequence': 33, '_event': 'NNet.Game.SCommandManagerStateEvent', '_eventid': 103, '_gameloop': 1031, '_userid': {'m_userId': 0}, '_bits': 56}

I'm making a class to catch these and will make a PR shortly.