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

Method TryBuildSCV

examples/common/bot_examples.cc:2097–2131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2095}
2096
2097bool TerranMultiplayerBot::TryBuildSCV() {
2098 const ObservationInterface* observation = Observation();
2099 Units bases = observation->GetUnits(Unit::Alliance::Self, IsTownHall());
2100
2101 for (const auto& base : bases) {
2102 if (base.unit_type == UNIT_TYPEID::TERRAN_ORBITALCOMMAND && base.energy > 50) {
2103 Tag mineral;
2104 if (FindNearestMineralPatch(base.pos, mineral)) {
2105 Actions()->UnitCommand(base.tag, ABILITY_ID::EFFECT_CALLDOWNMULE, mineral);
2106 }
2107 }
2108 }
2109
2110 if (observation->GetFoodWorkers() >= max_worker_count_) {
2111 return false;
2112 }
2113
2114 if (observation->GetFoodUsed() >= observation->GetFoodCap()) {
2115 return false;
2116 }
2117
2118 if (observation->GetFoodWorkers() > GetExpectedWorkers(UNIT_TYPEID::TERRAN_REFINERY)) {
2119 return false;
2120 }
2121
2122 for (const auto& base : bases) {
2123 //if there is a base with less than ideal workers
2124 if (base.assigned_harvesters < base.ideal_harvesters && base.build_progress == 1) {
2125 if (observation->GetMinerals() >= 50) {
2126 return TryBuildUnit(ABILITY_ID::TRAIN_SCV, base.unit_type);
2127 }
2128 }
2129 }
2130 return false;
2131}
2132
2133bool TerranMultiplayerBot::TryBuildSupplyDepot() {
2134 const ObservationInterface* observation = Observation();

Callers

nothing calls this directly

Calls 9

ObservationClass · 0.85
IsTownHallClass · 0.85
CountUnitTypeFunction · 0.85
GetUnitsMethod · 0.80
UnitCommandMethod · 0.80
GetFoodWorkersMethod · 0.80
GetFoodUsedMethod · 0.80
GetFoodCapMethod · 0.80
GetMineralsMethod · 0.80

Tested by

no test coverage detected