unitframes: add 40y-rangecheck

This commit is contained in:
shagu
2017-06-02 18:01:50 +02:00
parent 31012d4921
commit 0b3e9df0d9
11 changed files with 115 additions and 1 deletions
+43
View File
@@ -1,6 +1,7 @@
pfUI.api = { }
pfUI.api._G = getfenv(0)
local _G = getfenv(0)
-- [ strsplit ]
-- Splits a string using a delimiter.
-- 'delimiter' [string] characters that will be interpreted as delimiter
@@ -14,6 +15,48 @@ function pfUI.api.strsplit(delimiter, subject)
return unpack(fields)
end
-- [ UnitInRange ]
-- Returns whether a party/raid member is nearby. It uses spells with a distance of around 40 yards.
-- unit [string] A unit to query (string, unitID)
-- return: [bool] "1" if in range otherwise "nil"
local RangeCache = {}
function pfUI.api.UnitInRange(unit)
if not UnitExists(unit) or not UnitIsVisible(unit) then
return nil
end
if CheckInteractDistance(unit, 4) then
return 1
else if not pfUI.rangecheck or not pfUI.rangecheck.slot then
return nil
else
-- Extended Range Check
if not RangeCache[unit] or RangeCache[unit].time + pfUI.rangecheck.interval < GetTime() then
RangeCache[unit] = {}
RangeCache[unit].time = GetTime()
local noswitch = true
if not UnitIsUnit("target", unit) then
TargetUnit(unit)
noswitch = false
end
if IsActionInRange(pfUI.rangecheck.slot) == 1 then
RangeCache[unit].range = 1
else
RangeCache[unit].range = nil
end
if not noswitch then
TargetLastTarget()
end
end
return RangeCache[unit].range
end
end
end
-- [ strvertical ]
-- Creates vertical text using linebreaks. Multibyte char friendly.
-- 'str' [string] String to columnize.
+2
View File
@@ -77,6 +77,8 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", nil, "portraitalpha", "0.1")
pfUI:UpdateConfig("unitframes", nil, "portraittexture", "1")
pfUI:UpdateConfig("unitframes", nil, "layout", "default")
pfUI:UpdateConfig("unitframes", nil, "rangecheck", "0")
pfUI:UpdateConfig("unitframes", nil, "rangechecki", ".5")
-- pfUI:UpdateConfig("unitframes", nil, "buff_size", "20") -- TODO migrate, deprecated
-- pfUI:UpdateConfig("unitframes", nil, "debuff_size", "20") -- TODO migrate, deprecated
+1 -1
View File
@@ -170,7 +170,7 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick)
end
if this.config.faderange == "1" then
if CheckInteractDistance(this.label .. this.id, 4) or not UnitName(this.label .. this.id) then
if pfUI.api.UnitInRange(this.label .. this.id, 4) or not UnitName(this.label .. this.id) then
if this:GetAlpha() ~= 1 then
this:SetAlpha(1)
if this.config.portrait == "bar" then