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

Method ScoutWithUnit

examples/common/bot_examples.cc:289–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289void MultiplayerBot::ScoutWithUnit(Unit unit, const ObservationInterface* observation) {
290 Units enemy_units = observation->GetUnits(Unit::Alliance::Enemy, IsAttackable());
291 if (!unit.orders.empty()) {
292 return;
293 }
294 Point2D target_pos;
295
296 if (FindEnemyPosition(unit.tag, target_pos)) {
297 if (Distance2D(unit.pos, target_pos) < 20 && enemy_units.empty()) {
298 if (TryFindRandomPathableLocation(unit.tag, target_pos)) {
299 Actions()->UnitCommand(unit, ABILITY_ID::SMART, target_pos);
300 return;
301 }
302 }
303 else if (!enemy_units.empty())
304 {
305 Actions()->UnitCommand(unit, ABILITY_ID::ATTACK, enemy_units.front());
306 return;
307 }
308 Actions()->UnitCommand(unit, ABILITY_ID::SMART, target_pos);
309 }
310 else {
311 if (TryFindRandomPathableLocation(unit.tag, target_pos)) {
312 Actions()->UnitCommand(unit, ABILITY_ID::SMART, target_pos);
313 }
314 }
315}
316
317//Try build structure given a location. This is used most of the time
318bool MultiplayerBot::TryBuildStructure(AbilityID ability_type_for_structure, UnitTypeID unit_type, Point2D location, bool isExpansion = false) {

Callers

nothing calls this directly

Calls 4

IsAttackableClass · 0.85
Distance2DFunction · 0.85
GetUnitsMethod · 0.80
UnitCommandMethod · 0.80

Tested by

no test coverage detected