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

Method update

bwapi/TestAIModule/Source/FollowTest.cpp:41–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 started=false;
40}
41void FollowTest::update()
42{
43 if (running == false) return;
44 if (fail)
45 {
46 running = false;
47 return;
48 }
49 int thisFrame = Broodwar->getFrameCount();
50 BWAssert(thisFrame==nextFrame);
51 nextFrame++;
52 Broodwar->setScreenPosition(unit->getPosition() - Position(320,240));
53
54 if (unit->getDistance(target)>32*15 && started==false)
55 {
56 BWAssertF(unit->follow(target),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;});
57 BWAssertF(unit->getOrder()==Orders::Follow,{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;});
58 BWAssertF(unit->getTarget()==target,{fail=true;return;});
59 started=true;
60 startFrame=Broodwar->getFrameCount();
61 }
62
63 if (started)
64 {
65 if (thisFrame<startFrame+50)
66 {
67 BWAssertF(unit->getOrder()==Orders::Follow,{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;});
68 BWAssertF(unit->getTarget()==target || unit->getOrderTarget()==target,{fail=true;return;});
69 }
70 else if (thisFrame==startFrame+50)
71 {
72 BWAssertF(unit->stop(),{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;});
73 BWAssertF(unit->isIdle()==true,{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;});
74 }
75 else if (thisFrame<startFrame+100)
76 {
77 }
78 else if (thisFrame<startFrame+200)
79 {
80 BWAssertF(unit->isIdle()==true,{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;});
81 BWAssertF(unit->isMoving()==false || unit->isBraking(),{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;});
82 running = false;
83 }
84 else if (thisFrame==startFrame+200)
85 {
86 running = false;
87 }
88 }
89}
90
91void FollowTest::stop()
92{

Callers

nothing calls this directly

Calls 15

printfMethod · 0.80
c_strMethod · 0.80
getLastErrorMethod · 0.80
getOrderTargetMethod · 0.80
isIdleMethod · 0.80
isMovingMethod · 0.80
isBrakingMethod · 0.80
PositionClass · 0.50
getFrameCountMethod · 0.45
setScreenPositionMethod · 0.45
getPositionMethod · 0.45
getDistanceMethod · 0.45

Tested by

no test coverage detected