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

Method update

bwapi/TestAIModule/Source/AttackUnitTest.cpp:62–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 initialScarabCount = unit->getScarabCount();
61}
62void AttackUnitTest::update()
63{
64 if (running == false) return;
65 if (fail)
66 {
67 running = false;
68 return;
69 }
70 int thisFrame = Broodwar->getFrameCount();
71 BWAssert(thisFrame==nextFrame);
72 nextFrame++;
73 if (unit->exists())
74 {
75 Broodwar->setScreenPosition(unit->getPosition() - Position(320,240));
76 }
77 else
78 {
79 Broodwar->setScreenPosition(target->getPosition() - Position(320,240));
80 }
81
82 if (reachedDamagePointFrame==-1 &&
83 thisFrame>startFrame+100 &&
84 startingAttackFrame!=-1 &&
85 (target->getHitPoints()+target->getShields()<startingHPS-50 || (unit->getType().groundWeapon()==WeaponTypes::None &&
86 unit->getType().airWeapon()==WeaponTypes::None &&
87 unit->getType()!=UnitTypes::Protoss_Carrier &&
88 unit->getType()!=UnitTypes::Protoss_Reaver)))
89 reachedDamagePointFrame = thisFrame;
90 if (reachedDamagePointFrame==-1 && unit->exists()==false)
91 {
92 FAILTEST(unitType==UnitTypes::Zerg_Scourge || unitType==UnitTypes::Zerg_Infested_Terran);
93 running = false;
94 return;
95 }
96 if (reachedDamagePointFrame==-1)
97 {
98 FAILTEST(unit->getOrder()==Orders::AttackUnit);
99 FAILTEST(unit->getTarget()==target || unit->getOrderTarget()==target);
100 if ((unit->exists()==false || unit->isStartingAttack() || unit->getScarabCount()<initialScarabCount || (int)unit->getLoadedUnits().size()<unit->getInterceptorCount()) && startingAttackFrame==-1)
101 {
102 startingAttackFrame=thisFrame;
103 }
104 if (thisFrame>startFrame+2000)
105 {
106 BWAssertF(false,{log("Unit failed to attack target");fail=true;return;});
107 }
108 }
109 else
110 {
111 if (unit->getType().groundWeapon()!=WeaponTypes::None ||
112 unit->getType().airWeapon()!=WeaponTypes::None ||
113 unit->getType()==UnitTypes::Protoss_Carrier ||
114 unit->getType()==UnitTypes::Protoss_Reaver)
115 {
116 FAILTEST(target->getHitPoints()+target->getShields()<startingHPS);
117 }
118
119 if (stopped==false)

Callers

nothing calls this directly

Calls 15

logFunction · 0.85
getHitPointsMethod · 0.80
getShieldsMethod · 0.80
groundWeaponMethod · 0.80
airWeaponMethod · 0.80
getOrderTargetMethod · 0.80
isStartingAttackMethod · 0.80
getScarabCountMethod · 0.80
getInterceptorCountMethod · 0.80
isIdleMethod · 0.80
PositionClass · 0.50
getFrameCountMethod · 0.45

Tested by

no test coverage detected