Blizzard / s2client-api

StarCraft II Client - C++ library supported on Windows, Linux and Mac designed for building scripted bots and research using the SC2API.
MIT License
1.66k stars 282 forks source link

A error of sc2::ClientEvents::OnUnitCreated() . #299

Open DotaIsMind opened 5 years ago

DotaIsMind commented 5 years ago

I hope use sc2::ClientEvents::OnUnitCreated() to record the number of units and the GameLoop when the units was created in a replay, but there was an error in recording the number of workers(probe, drone and SCV), with more recorded results than actual results. On December 28, 2018, this error disappeared, my program ended up recording the same results as in the replay, I thought it was fixed, but now it appears again. Does anyone else have the same problem as me?How did you solve it?

DotaIsMind commented 5 years ago

This issue has the same problem. #242

Archiatrus commented 5 years ago

The problem is that units get "created" whenever the unit model gets created. So whenever a worker leaves a refinery. But also a unit leaving a medivac for example. Interesting that this was changed for a while. Anyway, I assume that the unit tag stays with a unit. So you could have something like std::map<unit_type_id_type, std::set<unit_tag_type>> unitTypeCounter. Then you insert every unit in the set for it's type and at the end of the game you can query the size of the relevant unit type set. Of course if you are only interested in workers you can drop the map part and only use one set were you insert if it is a worker.

DotaIsMind commented 5 years ago

Thanks for your help.