Talk:API TargetByName

Store a target as a variable by name, then call it back up using this -- if there's any *dead* units within range that share the name of the unit you mean to target, it will ALWAYS target the dead unit, lol. This is such an oversight on Blizzard's part, imo. Basically, a dead mob does not have "corpse" or anything like it in it's actual name string to distinguish it from other mobs of the same type that are still living. Not only that, but for whatever reason, it will always target the dead unit if it is in range using this command.
 * This works just like /tar Unit, which is to say it attempts to target Unit. The problems arrive when there is more than one unit named Unit, or if there is none.  In the case of multiple Units, it targets the nearest, which is the cause of your "always the dead thing" problem.  If Unit does not exist, the client does some sort of string matching.  It seems to rank units first by initial characters matched, but I haven't really tested this.  In any case, the client targets a visible unit, usually nearby, that has at least its first letter in common with Unit.  If there is no visible unit with even the first name in common, an error is generated, the English localization of which is "Uknknown Unit."