MCPcopy Create free account
hub / github.com/Blizzard/s2client-api / GetPosition

Method GetPosition

examples/common/bot_examples.cc:3220–3243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3218}
3219
3220bool MarineMicroBot::GetPosition(UNIT_TYPEID unit_type, Unit::Alliance alliace, Point2D& position) {
3221 const ObservationInterface* observation = Observation();
3222 Units units = observation->GetUnits(alliace);
3223
3224 if (units.empty()) {
3225 return false;
3226 }
3227
3228 position = Point2D(0.0f, 0.0f);
3229 unsigned int count = 0;
3230
3231 for (const auto& u : units) {
3232 if (u.unit_type == unit_type) {
3233 position.x += u.pos.x;
3234 position.y += u.pos.y;
3235 ++count;
3236 }
3237 }
3238
3239 position.x /= count;
3240 position.y /= count;
3241
3242 return true;
3243}
3244
3245bool MarineMicroBot::GetNearestZergling(const Point2D& from) {
3246 const ObservationInterface* observation = Observation();

Callers

nothing calls this directly

Calls 3

ObservationClass · 0.85
Point2DClass · 0.85
GetUnitsMethod · 0.80

Tested by

no test coverage detected