s2client-api
s2client-api copied to clipboard
OnUnitIdle override not working
I am following the tutorial here but when I try to print a simple string after overriding OnUnitIdle nothing happens.
This is what I use:
virtual void OnUnitIdle(const Unit* unit) final { std::cout << "TEST" << std::endl......
.
Then I create a worker and let it do nothing, but there is no message in the console window.
I have find out that acquiring of observation is broken because the game sets flag "has_cloak" for some units, but set CloakState to CloakUnknown. sc2api considers this value as error and stops receiving observation.
So, naive solution is to update the convertion routine for CloakState in the sc2_proto_to_pods.cc file.
I'm not sure what the reason of this changes in protocol and don't know if it is a correct solution. But you can try to cherry pick the observation-fix branch from my fork
Cool, I will try it out.
The fix worked for OnUnitIdle, but now OnGameStop() don't get called
virtual void OnGameStop() final {
cout << "TEST " << endl;
Control()->SaveReplay("LastSave.SC2Replay");
}