| 8 | Broodwar->setCommandOptimizationLevel(4); |
| 9 | } |
| 10 | void MicroTest::onFrame() |
| 11 | { |
| 12 | Position goal=Broodwar->getMousePosition()+Broodwar->getScreenPosition(); |
| 13 | std::map<Unit , int> targetAdjustedHP; |
| 14 | std::map<Unit , Unitset > targetsInRange; |
| 15 | std::map<Unit , Unitset > targetGetAttackers; |
| 16 | for (Unit e : Broodwar->enemy()->getUnits()) |
| 17 | { |
| 18 | targetAdjustedHP[e]=e->getHitPoints(); |
| 19 | for (Unit s : Broodwar->self()->getUnits()) |
| 20 | { |
| 21 | if (s->isInWeaponRange(e)) |
| 22 | { |
| 23 | targetAdjustedHP[e]-=5; |
| 24 | targetsInRange[s].insert(e); |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | for (Unit s : Broodwar->self()->getUnits()) |
| 29 | { |
| 30 | int minAdjHP=100000; |
| 31 | Unit localTarget = NULL; |
| 32 | for (Unit e : targetsInRange[s]) |
| 33 | { |
| 34 | if (localTarget == NULL || targetAdjustedHP[e]<minAdjHP) |
| 35 | { |
| 36 | localTarget = e; |
| 37 | minAdjHP = targetAdjustedHP[e]; |
| 38 | } |
| 39 | } |
| 40 | targetGetAttackers[localTarget].insert(s); |
| 41 | } |
| 42 | bool isAttackFrame = false; |
| 43 | int maxCoolDown = 0; |
| 44 | for (Unit s : Broodwar->self()->getUnits()) |
| 45 | { |
| 46 | isAttackFrame = isAttackFrame || s->isAttackFrame(); |
| 47 | if (s->getGroundWeaponCooldown() > maxCoolDown) |
| 48 | maxCoolDown = s->getGroundWeaponCooldown(); |
| 49 | } |
| 50 | if (lastIsAttackFrame && !isAttackFrame) |
| 51 | { |
| 52 | Broodwar->issueCommand(Broodwar->self()->getUnits(),UnitCommand::rightClick(NULL,goal)); |
| 53 | for (Unit s : Broodwar->self()->getUnits()) |
| 54 | { |
| 55 | Broodwar->drawLineMap(s->getPosition(), goal, Colors::Green); |
| 56 | } |
| 57 | } |
| 58 | else |
| 59 | { |
| 60 | if (maxCoolDown == 0) |
| 61 | { |
| 62 | for (std::pair<Unit, Unitset> p : targetGetAttackers) |
| 63 | { |
| 64 | Unit e = p.first; |
| 65 | for (Unit s : p.second) |
| 66 | { |
| 67 | if (Broodwar->getFrameCount() - s->getLastCommandFrame() > 4) |
nothing calls this directly
no test coverage detected