Despite the post being very old, I'll leave some ideas.
Only Computer enemies with a running AI will intelligently (vaguely...) select targets to attack. Otherwise they will just attack whatever is nearest.
This makes sense, but I don't totally agree. There are a series of interferences to identify a priority, disregarding the approximation.
The "Stats-Priority" field doesn't really interfere in almost anything (I believe), only in very detailed micro-combat issues, maybe it only works for breaking values within countless variants that predate this poor O.E. specification, in the end from the accounts this function is almost useless, after all, in fact all units tend to attack closer objects, but despite that, there are significant priorities, capable of making an attacker stop attacking a unit and quickly change target.
No it does not, the linked topic is offtopic. Priority goes like this: Highest to Lowest... 1. Hero (it has an on/off switch) 2. Lowest Armor 3. Closer Unit 4. Fortified armor
What puffdragon claims, i believe, is the closest to what is actually available.
Heroes are "constant" targets of the AI, this is indisputable. But of course there are factors that go beyond approximation, even if they are not commonly occurring or so noticeable. In many cases, even if they are on the same line of aproximation, I have noticed some melee units are prioritized over some types long ranged units. Units with Fortified armor are always repelled by the AI, becoming the last targets (but for siege attackers I think maybe they are the main targets). Divine units also tend to be the last target (i think), everything seems to vary according to the type of attacker also, the attack source appears to have preferred target types.. some higher lvl Creeps try to attack low HP units first, others prefer lighter armor units or they seek to prioritize units that have the type of armor in which their attack is the most brutal.