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 281 forks source link

[Help] ~Build Placement , Invalid Path #256

Closed thehatb0y closed 6 years ago

thehatb0y commented 6 years ago

Hello guys, I'm trying to make a fuction wich place buildings at specific location, but somehow my function are not working properly, so i need some hand to figure out.

This code should count how many Depos are, and return a position where to build the next depo forming a kind of matrix.

    Point2D DepoLocation() {
   if (CountUnitType(UNIT_TYPEID::TERRAN_SUPPLYDEPOT) > 1) {
                if(CountUnitType(UNIT_TYPEID::TERRAN_SUPPLYDEPOT) > 1 && CountUnitType(UNIT_TYPEID::TERRAN_SUPPLYDEPOT) <= 8){
                    Point2D Location;
                    Location.x = 14.0+CountUnitType(UNIT_TYPEID::TERRAN_SUPPLYDEPOT)*2;
                    Location.y = 120.0;
                    return Location;
                }
                if (CountUnitType(UNIT_TYPEID::TERRAN_SUPPLYDEPOT) > 8 && CountUnitType(UNIT_TYPEID::TERRAN_SUPPLYDEPOT) <= 14) {
                    Point2D Location;
                    Location.x = (CountUnitType(UNIT_TYPEID::TERRAN_SUPPLYDEPOT) *2);
                    Location.y = 116.0;
                    return Location;
                }
                if (CountUnitType(UNIT_TYPEID::TERRAN_SUPPLYDEPOT) > 14) {
                    Point2D Location;
                    Location.x = 14.0 - (CountUnitType(UNIT_TYPEID::TERRAN_SUPPLYDEPOT) *2);
                    Location.y = 112.0;
                    return Location;
                }
            }
    }

Here's a SS of what is happening. Some times, SVC can't figure out a valid path to build but the coordinates are 100% accurate, but if i manually low and up my depos some how SVC find the correct way and build the next depo, but if i didn't low/up the depo it just stucks and stop to build depos. So what's wrong here?

invalid_path

thehatb0y commented 6 years ago

The problem was solved using Point3D instead of Point2D. =) Hope that's help somebody.