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

Method HasEnemyTarget

bwapi/BWScriptEmulator/AIControl.cpp:39–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39bool 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}

Callers

nothing calls this directly

Calls 9

getOrderTargetMethod · 0.80
isHallucinationMethod · 0.80
canIssueCommandMethod · 0.80
isInWeaponRangeMethod · 0.80
isEnemyMethod · 0.45
selfMethod · 0.45
getPlayerMethod · 0.45
getTypeMethod · 0.45
getLoadedUnitsMethod · 0.45

Tested by

no test coverage detected