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

Method update

bwapi/TestAIModule/Source/RightClickTest.cpp:54–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 nextFrame = Broodwar->getFrameCount();
53}
54void RightClickTest::update()
55{
56 if (running == false) return;
57 if (fail)
58 {
59 running = false;
60 return;
61 }
62 int thisFrame = Broodwar->getFrameCount();
63 BWAssert(thisFrame==nextFrame);
64 nextFrame++;
65 Broodwar->setScreenPosition(unit->getPosition() - Position(320,240));
66
67 if (thisFrame < startFrame + 200)
68 {
69 BWAssertF(unit->isMoving(),{fail=true;return;});
70 BWAssertF(unit->getTargetPosition()==targetPosition,{fail=true;return;});
71 }
72 else if (thisFrame == startFrame + 200)
73 {
74 unit->rightClick(enemyUnit);
75 BWAssertF(unit->getOrder()==Orders::AttackUnit,{fail=true;return;});
76 BWAssertF(unit->getTarget() == enemyUnit || unit->getOrderTarget() == enemyUnit,{fail=true;return;});
77 }
78 else if (thisFrame < startFrame + 400)
79 {
80 BWAssertF(unit->getOrder()==Orders::AttackUnit,{fail=true;return;});
81 BWAssertF(unit->getTarget() == enemyUnit || unit->getOrderTarget() == enemyUnit,{fail=true;return;});
82 }
83 else if (thisFrame == startFrame + 400)
84 {
85 unit->rightClick(friendUnit);
86 BWAssertF(unit->getOrder()==Orders::Follow,{fail=true;return;});
87 BWAssertF(unit->getTarget() == friendUnit || unit->getOrderTarget() == friendUnit,{fail=true;return;});
88 }
89 else if (thisFrame < startFrame + 600)
90 {
91 BWAssertF(unit->getOrder()==Orders::Follow,{fail=true;return;});
92 BWAssertF(unit->getTarget() == friendUnit || unit->getOrderTarget() == friendUnit,{fail=true;return;});
93 }
94 else if (thisFrame == startFrame + 600)
95 {
96 unit->stop();
97 }
98 else if (thisFrame < startFrame + 650)
99 {
100 }
101 else
102 {
103 running = false;
104 }
105}
106
107void RightClickTest::stop()
108{

Callers

nothing calls this directly

Calls 11

isMovingMethod · 0.80
getOrderTargetMethod · 0.80
PositionClass · 0.50
getFrameCountMethod · 0.45
setScreenPositionMethod · 0.45
getPositionMethod · 0.45
getTargetPositionMethod · 0.45
rightClickMethod · 0.45
getOrderMethod · 0.45
getTargetMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected