From 4b50ea89723593b921f8cd39c232d7227236ec83 Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 26 Nov 2024 21:02:30 +0100 Subject: [PATCH] librange: try to use superwow for range detection --- libs/librange.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libs/librange.lua b/libs/librange.lua index e8a4f962..10ba9042 100644 --- a/libs/librange.lua +++ b/libs/librange.lua @@ -161,6 +161,19 @@ librange:SetScript("OnUpdate", function() if this.id <= numunits and librange.slot then local unit = units[this.id] if not UnitIsUnit("target", unit) then + -- try to read distance via superwow first + if superwow_active then + local x1, y1 = UnitPosition("player") + local x2, y2 = UnitPosition(unit) + -- only continue if we got position values + if (x1 and x1 > 0) and (x2 and x2 > 0) then + local distance = ((x2 - x1)^2 + (y2 - y1)^2)^.5 + unitdata[unit] = distance < 45 and 1 or 0 + this.id = this.id + 1 + return + end + end + -- suspend for various conditions if pfUI.loot and pfUI.loot:IsShown() then return nil end if LootFrame and LootFrame:IsShown() then return nil end