Thread Tools Display Modes
Prev Previous Post   Next Post Next
10-28-20, 08:15 PM   #1
thatrickguy
A Murloc Raider
Join Date: Sep 2020
Posts: 5
A more efficient 'enemies in range'?

So this is what I have right now for seeing if there are 3+ enemies in combat and within range of whirlwind. Is there a more elegant solution? Broken out into multiple ifs just for debugging purposes.

Code:
function are3EnemiesInRange()
   local inRange = 0
   local id
   for i = 1, 40 do
      id = "nameplate" .. i
      --local message = ""
       if UnitExists(id) then
         --message = id .. " "
         if UnitAffectingCombat(id) then
           -- message = message .. "in combat "
            if UnitIsEnemy("player",id) then
              -- message = message .. "is hostile "
               if IsItemInRange(63427, id) == true then
                 -- message = message .. "in range"
                  inRange = inRange + 1
               end
            end
         end
      end
      -- if (message ~= "") then
      --    print (message)
      -- end 
      if (inRange > 2 ) then
         break
      end
   end
   
   return (inRange > 2)
end
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » A more efficient 'enemies in range'?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off