s2client-api icon indicating copy to clipboard operation
s2client-api copied to clipboard

OnUnitIdle override not working

Open marcus1337 opened this issue 5 years ago • 3 comments

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.

marcus1337 avatar May 01 '19 13:05 marcus1337

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

piroxiljin avatar May 13 '19 19:05 piroxiljin

Cool, I will try it out.

marcus1337 avatar May 13 '19 21:05 marcus1337

The fix worked for OnUnitIdle, but now OnGameStop() don't get called

    virtual void OnGameStop() final {
        cout << "TEST " << endl;
        Control()->SaveReplay("LastSave.SC2Replay");
    }

marcus1337 avatar May 20 '19 10:05 marcus1337