-
Sergeant Major
Target lowest health enemy
I am looking to create an addon or a macro, that will target the lowest health enemy within range, and then bind it to tab.
I am planning on using the following API call: UnitHealth(unit)
Now what I am missing, and what I am asking is if I can create an array of the players within range, check their health, and return the player with the lowest health.
Any suggestion/ideas/help?
-
OwnedCore News Correspondent
You are going to want to use UnitInRange() function like so:
inRange = UnitInRange("unit") or UnitInRange("name")
For a raid entry, you could do something like on the following page which will show you how to use the function: GetRaidRosterInfo - World of Warcraft Programming: A Guide and Reference for Creating WoW Addons
I am not 100% on the syntax for WoW, but the principle behind it (using some of the things on that page) would be something like:
Code:
var rosterInRange[] = null;
for( i = 1; i < GetNumGroupMembers(); i++) {
if( UnitInRange(GetRaidRosterInfo(i).name ) {
// Unit is in range, add them to an array for parsing afterwards
rosterInRange.Add(GetRaidRosterInfo[i]);
}
}
You can either choose to call some sort of GetPlayerInfo() if it exists by the name given by GetRaidRosterInfo[i].name and get their health value and assign it to an array key'd by the raidID for later. So you could actually just flat out compare the values of health, sort the array from highest to lowest, and then prioritize a spell that way. Because the key would be the raid members ID, it would already know which one to target.
-
Post Thanks / Like - 2 Thanks
Nov17,
Parog (2 members gave Thanks to Veritable for this useful post)
-
Active Member
-
Sergeant Major
Originally Posted by
Owneth
if you mean protected calls, isn't that what LUA unlockers are for?