| 37 | } |
| 38 | |
| 39 | bool UnitWrap::HasEnemyTarget() |
| 40 | { |
| 41 | // Get the target |
| 42 | BWAPI::Unit pTarg = pUnit->getOrderTarget(); |
| 43 | if ( !pTarg ) |
| 44 | return false; |
| 45 | |
| 46 | // Ignore if not an enemy |
| 47 | if ( !Broodwar->self()->isEnemy(pTarg->getPlayer()) ) |
| 48 | return false; |
| 49 | |
| 50 | // Ignore if damaged hallucination |
| 51 | if ( pTarg->isHallucination() && (HP+Shields)(pTarg) != (MaxHP+MaxShields)(pTarg) ) |
| 52 | return false; |
| 53 | |
| 54 | // Ignore if it can be attacked and out of weapon range |
| 55 | if ( pUnit->canIssueCommand( UnitCommand::attack(pUnit, pTarg)) ) |
| 56 | return pUnit->isInWeaponRange(pTarg); |
| 57 | |
| 58 | // Ignore if it's an unloaded bunker |
| 59 | return pTarg->getType() == UnitTypes::Terran_Bunker && !pTarg->getLoadedUnits().empty(); |
| 60 | } |
nothing calls this directly
no test coverage detected