| 60 | initialScarabCount = unit->getScarabCount(); |
| 61 | } |
| 62 | void 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) |
nothing calls this directly
no test coverage detected