Quantcast
WoWInterface - View Single Post - A more efficient 'enemies in range'?
View Single Post
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