MCPcopy Create free account
hub / github.com/bwapi/bwapi / issueCommand

Method issueCommand

bwapi/BWAPIClient/Source/UnitImpl.cpp:21–63  ·  view source on GitHub ↗

--------------------------------------------- ISSUE COMMAND ----------------------------------------------

Source from the content-addressed store, hash-verified

19 }
20 //--------------------------------------------- ISSUE COMMAND ----------------------------------------------
21 bool UnitImpl::issueCommand(UnitCommand command)
22 {
23 if ( !canIssueCommand(command) )
24 return false;
25
26 command.unit = this;
27
28 // If using train or morph on a hatchery, automatically switch selection to larva
29 // (assuming canIssueCommand ensures that there is a larva)
30 if ( (command.type == UnitCommandTypes::Train ||
31 command.type == UnitCommandTypes::Morph) &&
32 getType().producesLarva() && command.getUnitType().whatBuilds().first == UnitTypes::Zerg_Larva )
33 {
34 Unitset larvae( this->getLarva() );
35 for (Unit larva : larvae)
36 {
37 if ( !larva->isConstructing() && larva->isCompleted() && larva->canCommand() )
38 {
39 command.unit = larva;
40 break;
41 }
42 }
43 if ( command.unit == this )
44 return false;
45 }
46
47 BWAPIC::UnitCommand c;
48 c.type = command.type;
49#pragma warning(suppress: 6011)
50 c.unitIndex = command.unit->getID();
51 if ( command.target )
52 c.targetIndex = command.target->getID();
53 else
54 c.targetIndex = -1;
55 c.x = command.x;
56 c.y = command.y;
57 c.extra = command.extra;
58 Command{ command }.execute();
59 static_cast<GameImpl*>(BroodwarPtr)->addUnitCommand(c);
60 lastCommandFrame = Broodwar->getFrameCount();
61 lastCommand = command;
62 return true;
63 }
64}

Callers

nothing calls this directly

Calls 12

getLarvaMethod · 0.95
canIssueCommandFunction · 0.85
producesLarvaMethod · 0.80
whatBuildsMethod · 0.80
getUnitTypeMethod · 0.80
isConstructingMethod · 0.80
isCompletedMethod · 0.80
canCommandMethod · 0.80
addUnitCommandMethod · 0.80
getIDMethod · 0.45
executeMethod · 0.45
getFrameCountMethod · 0.45

Tested by

no test coverage detected