Automatic Targeting is the part of the Tactical AI that chooses the targets for regular attacks when there are targets in range but the player has not explicitly specified a target. It governs the target choice for the weapons of all units and buildings carrying out one of these commands:
- Stop (also known as "idling")
- Hold Position
- Attack Move
- Follow Ally
It does not concern units carrying out one of these commands:
- Attack Target
- Any spell or ability
Once a target is chosen, it will remain the target until it ceases being a valid target (e.g., dies, becomes invisible, or goes up a ramp), leaves the weapon range or a higher-priority target enters the weapon range.
A unit (or building) considers all valid targets within the Scan Range of its weapons. The criteria for selection are, from most to least important:
- Which targets are threats to me?
- Which targets have the highest Attack Target Priority (ATP) values?
- Which targets allow me to use my primary weapon?
- Which target is the closest?
The four following sections elaborate on each of the criteria. The later criteria are only taken into account if there are multiple best targets for each of the previous criteria.
There are two possible reasons for a target to be considered a threat:
- They have a weapon that can return fire, i.e., the attacker is a legal target for the weapon.
- The unit type is one that has the "Always a Threat to Attackers" flag set:
2. Attack Target Priority
Every unit and building type has a fixed Attack Target Priority (ATP) value. Higher values make a target more attractive. With only few exceptions, all units and defensive buildings share an ATP of 20, while all other buildings share an ATP of 11. A comprehensive listing is given below.
3. Multiple Weapons
In case of equal threat and ATP value criteria, these units will prefer to use their primary weapon over their secondary weapon. With the exception of the Battlecruiser, all these units' primary weapons are their anti-air weapons.
4. Closest Target
Once reaching this step, most units and buildings simply choose the target closest to themselves amongst the remaining candidates. The exceptions are as follows.
The following units pick the target candidate which requires the least amount of turning to fire at:
This method of target choice gives the units a more slow and inert feeling. For the Melee units the impact on gameplay is minimal, while Thors and Battlecruisers may behave differently from what one would expect.
Distance from Target
The Colossus is the only unit that picks the target candidate closest to its previous target. This, too, is likely done to give it a less agile and more vulnerable feeling. Depending on the situation, this method of target choice can be an advantage (automatically keeping focus on the ranks of Hydralisks or Marines where Colossuses inflict most damage) or a disadvantage (not switching to Zerglings nibbling at the Colossus's feet).
- Void Rays target Marines over Marauders, because they consider Marines threats but Marauders not.
- Void Rays target Overlords, Roaches and Drones all exactly the same, as none of them are considered threats and they all have an ATP value of 20. The sole criterion is which target is closest.
- Queens target Oracles over Phoenixes, because they don't consider Phoenixes threats (their weapon can't shoot ground units) and Oracles are flagged to always be threats (even if their weapon is disabled).
- Zerglings target filled Bunkers over Supply Depots, because they consider filled Bunkers threats and Supply Depots not.
- If the Bunkers were empty, they would not be considered threats but would still be targeted first as their ATP value (19) is higher than that of Supply Depots (11).
- Zerglings target Marines over empty Bunkers, because they consider Marines threats but empty Bunkers not.
- Mutalisks target Marines over Missile Turrets, because both are threats, but Marines have a higher ATP value (20 vs. 19).
- Thors and Queens target Mutalisks over Zerglings, because both are considered threats with an ATP value of 20, but Mutalisks allow them to use their primary (anti-air) weapons.
- Thors and Queens target Roaches over Overlords if the Roaches are in range of their secondary (anti-ground) weapons, because they consider Roaches a threat but Overlords not.
- Thors and Queens target Overlords hovering directly over Roaches if they are not in range of their secondary (anti-ground) weapons but in range of their primary (anti-air) weapons.
- Corollary: Attack moving Thors or Queens towards Roaches sitting under an Overlord will cause them to stop approaching once the Overlord gets into range and attack the Overlord.
- Workers (including MULEs) have a "Default Acquire Level" of defensive. It is raised to offensive (the default for all other units and buildings) only when they are attack moving. The following rules apply:
- Units with a defensive acquire level do not automatically acquire targets for their weapons.
- Units with a defensive acquire level are not classified as threats by other units.
- An exception to the above rule applies when an SCV or a MULE repairs a threatening target: the repairing unit inherits the target's threat and ATP value, making it the preferred target if it is closer than the threatening target.
- Ghosts and Lurkers can toggle the automatic target acquisition of their weapons on and off using a button on their command card. This option is intended to help keep them undetected.
- When a unit or building is attacking a target with the highest priority while carrying out an explicit "attack target" command, issuing a "stop" command will not cause the attacking to stop nor the target to switch. One particular use case for this behavior can be found in cannon rushing: a certain enemy building can be prioritized while still immediately responding to nearing units.
- The "Always a Threat to Attackers" flag was likely introduced to alleviate the frustration of juicy targets such as spellcasters and units with special attacks only being targeted very late in fights. However, in some situations the effects of the flag can be unintuitive. For example, air-to-ground units may prioritize closer ground-to-ground units (Disruptors, Lurkers, Swarm Hosts) over potentially more dangerous ground-to-air units and buildings (Hydralisks, Spore Crawlers, Stalkers, Photon Cannons).
- AI players treat workers (including MULEs) as if they had an ATP value of 10, which gives them a lower priority than buildings. This feature is called "Override Target Priority" and is likely meant as a favor to human opponents.
- printf. "printf's cannon rush guide: Mechanics 3 - tips and tricks (@3:11)". YouTube. Retrieved 31 Aug 2018.