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

Method start

bwapi/TestAIModule/Source/UseTechTest.cpp:28–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26 BWAssertF(userType!=UnitTypes::Unknown,{fail=true;return;});
27}
28void UseTechTest::start()
29{
30 if (fail) return;
31 running = true;
32
33 int userCount = Broodwar->self()->completedUnitCount(userType);
34 BWAssertF(userCount>=1,{Broodwar->printf("Error: Cannot find any owned units of type %s for tech type %s!",userType.c_str(),techType.c_str());fail=true;return;});
35 for (Unit u : Broodwar->self()->getUnits())
36 if (u->getType()==userType)
37 user = u;
38
39 startPosition = user->getPosition();
40 Broodwar->printf("Testing %s...",techType.c_str());
41 BWAssertF(user->getEnergy()>=techType.energyCost(),{Broodwar->printf("Error: Not enough energy!");fail=true;return;});
42
43 if (techType==TechTypes::Scanner_Sweep)
44 {
45 for (Unit u : Broodwar->getAllUnits())
46 if (u->getType()==UnitTypes::Zerg_Hatchery)
47 {
48 targetUnit = u;
49 targetPosition = u->getPosition();
50 }
51 BWAssertF(targetUnit!=NULL,{fail=true;return;});
52 BWAssertF(targetPosition!=Positions::None,{fail=true;return;});
53 BWAssertF(targetPosition!=Positions::Unknown,{fail=true;return;});
54 }
55 else if (techType==TechTypes::Stim_Packs)
56 {
57 //no target unit/position
58 }
59 else if (techType==TechTypes::Optical_Flare)
60 {
61 for (Unit u : Broodwar->getAllUnits())
62 if (u->getType()==UnitTypes::Terran_Firebat)
63 {
64 targetUnit = u;
65 }
66 BWAssertF(targetUnit!=NULL,{fail=true;return;});
67 }
68 else if (techType==TechTypes::Restoration)
69 {
70 for (Unit u : Broodwar->getAllUnits())
71 if (u->isBlind())
72 {
73 targetUnit = u;
74 }
75 BWAssertF(targetUnit!=NULL,{fail=true;return;});
76 }
77 else if (techType==TechTypes::Spider_Mines)
78 {
79 targetUnit = user;
80 targetPosition = user->getPosition();
81 isInPosition = true;
82 }
83 else if (techType==TechTypes::Defensive_Matrix)
84 {
85 for (Unit u : Broodwar->getAllUnits())

Callers

nothing calls this directly

Calls 15

logFunction · 0.85
completedUnitCountMethod · 0.80
printfMethod · 0.80
c_strMethod · 0.80
getEnergyMethod · 0.80
energyCostMethod · 0.80
isBlindMethod · 0.80
hasNukeMethod · 0.80
selfMethod · 0.45
getUnitsMethod · 0.45
getTypeMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected