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

OnUnitIdle override not working #301

Open marcus1337 opened 5 years ago

marcus1337 commented 5 years ago

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.

piroxiljin commented 5 years ago

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

marcus1337 commented 5 years ago

Cool, I will try it out.

marcus1337 commented 5 years ago

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

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