121 lines
5.5 KiB
Lua
121 lines
5.5 KiB
Lua
--EVERY FRAME (Throttled)
|
|
function()
|
|
if aura_env.lastscan < GetTime() then
|
|
if UnitExists("focus") then
|
|
if UnitInParty("focus") then
|
|
--Get MapID for both
|
|
local myMapID = C_Map.GetBestMapForUnit("player")
|
|
local focusMapID = C_Map.GetBestMapForUnit("focus")
|
|
|
|
--Get Coordinates for both within same map
|
|
local pX, pY, fX, fY = 0, 0, 0, 0
|
|
if myMapID == focusMapID then
|
|
pX, pY = aura_env.round(C_Map.GetPlayerMapPosition(myMapID, "player").x, 4) * 10000, aura_env.round(C_Map.GetPlayerMapPosition(myMapID, "player").y, 4) * 10000
|
|
fX, fY = aura_env.round(C_Map.GetPlayerMapPosition(myMapID, "focus").x, 4) * 10000, aura_env.round(C_Map.GetPlayerMapPosition(myMapID, "focus").y, 4) * 10000
|
|
end
|
|
|
|
if pX > 0 and pY > 0 and fX > 0 and fY > 0 then
|
|
--Get player direction facing and convert to angle
|
|
local playerFace = GetPlayerFacing() or 0
|
|
local playerA = math.floor(playerFace * 100)
|
|
playerA = aura_env.range(playerA, 0, 630, 360) - 1
|
|
playerA = - playerA
|
|
playerA = math.floor(playerA)
|
|
playerA = playerA - 90
|
|
if playerA < 0 then playerA = playerA + 360 end
|
|
|
|
--Get relative Coordinates
|
|
local X = fX - pX
|
|
local Y = fY - pY
|
|
local hyp = math.sqrt((X ^ 2) + (Y ^ 2))
|
|
local a = math.atan2(Y, X)
|
|
a = a - math.rad(playerA)
|
|
local Y2, X2 = hyp * math.cos(a), hyp * math.sin(a)
|
|
local zoomout, zoomin = 100, 50
|
|
if (math.abs((X2 * aura_env.zoom)) > zoomout or math.abs((Y2 * aura_env.zoom)) > zoomout) and aura_env.zoom > 0.3 then
|
|
aura_env.zoom = aura_env.zoom - 0.2
|
|
elseif (math.abs((X2 * aura_env.zoom)) > zoomout or math.abs((Y2 * aura_env.zoom)) > zoomout) and aura_env.zoom <= 0.3 and aura_env.zoom > 0.1 then
|
|
aura_env.zoom = aura_env.zoom - 0.05
|
|
elseif (math.abs((X2 * aura_env.zoom)) > zoomout or math.abs((Y2 * aura_env.zoom)) > zoomout) and aura_env.zoom <= 0.1 and aura_env.zoom > 0.0005 then
|
|
aura_env.zoom = aura_env.zoom - 0.0005
|
|
elseif (math.abs((X2 * aura_env.zoom)) > zoomout or math.abs((Y2 * aura_env.zoom)) > zoomout) and aura_env.zoom < 0.001 then
|
|
aura_env.zoom = 1
|
|
end
|
|
if (math.abs((X2 * aura_env.zoom)) < zoomin and math.abs((Y2 * aura_env.zoom)) < zoomin) and aura_env.zoom < 50 then
|
|
aura_env.zoom = aura_env.zoom + 0.2
|
|
end
|
|
aura_env.region.text:SetText("Zoom: " .. aura_env.zoom .. "\nDistance: " .. aura_env.round(hyp, 0))
|
|
aura_env.region.playerTexture:SetPoint("CENTER", aura_env.region, "CENTER", 0, 0)
|
|
aura_env.region.focusTexture:SetPoint("CENTER", aura_env.region, "CENTER", X2 * aura_env.zoom, Y2 * aura_env.zoom)
|
|
|
|
--Get class to color
|
|
local pclass, fclass = select(3, UnitClass("player")), select(3, UnitClass("focus"))
|
|
aura_env.region.playerTexture:SetVertexColor(aura_env.classColor(pclass))
|
|
aura_env.region.focusTexture:SetVertexColor(aura_env.classColor(fclass))
|
|
return true
|
|
else
|
|
print("Focus not in map!")
|
|
end
|
|
aura_env.lastscan = GetTime() + aura_env.throttle / 1000
|
|
else print("Focus not in party!"); aura_env.region.playerTexture:Hide(); aura_env.region.focusTexture:Hide(); aura_env.lastscan = GetTime() + 5 end
|
|
else print("No focus found!"); aura_env.region.playerTexture:Hide(); aura_env.region.focusTexture:Hide(); aura_env.lastscan = GetTime() + 5 end
|
|
end
|
|
end
|
|
|
|
--INIT
|
|
aura_env.throttle = 250
|
|
aura_env.lastscan = 0
|
|
aura_env.zoom = 1
|
|
aura_env.range = function(val, min, max, max2)
|
|
val = 1 - (((max - val) / (max - min)) * max2)
|
|
return val
|
|
end
|
|
aura_env.round = function(var, n)
|
|
if (n) then
|
|
var = math.floor((var * 10^n) + 0.5) / (10^n)
|
|
else
|
|
var = math.floor(var+0.5)
|
|
end
|
|
return var
|
|
end
|
|
aura_env.classColor = function(class)
|
|
if class == 1 then return 0.78, 0.61, 0.43, 0.75 elseif
|
|
class == 2 then return 0.96, 0.55, 0.73, 0.75 elseif
|
|
class == 3 then return 0.67, 0.83, 0.45, 0.75 elseif
|
|
class == 4 then return 1, 0.96, 0.41, 0.75 elseif
|
|
class == 5 then return 1, 1, 1, 0.75 elseif
|
|
class == 6 then return 0.77, 0.12, 0.23, 0.75 elseif
|
|
class == 7 then return 0, 0.44, 0.87, 0.75 elseif
|
|
class == 8 then return 0.25, 0.78, 0.92, 0.75 elseif
|
|
class == 9 then return 0.53, 0.53, 0.93, 0.75 elseif
|
|
class == 10 then return 0, 1, 0.59, 0.75 elseif
|
|
class == 11 then return 1, 0.49, 0.04, 0.75 elseif
|
|
class == 12 then return 0.64, 0.19, 0.79, 0.75 else
|
|
return 1, 1, 1, 1 end
|
|
end
|
|
|
|
if not aura_env.region.playerTexture then
|
|
local playerTexture = aura_env.region:CreateTexture(nil, "OVERLAY")
|
|
aura_env.region.playerTexture = playerTexture
|
|
end
|
|
aura_env.region.playerTexture:SetTexture("Interface\\Addons\\WeakAuras\\PowerAurasMedia\\Auras\\Aura72")
|
|
aura_env.region.playerTexture:SetHeight(16)
|
|
aura_env.region.playerTexture:SetWidth(16)
|
|
aura_env.region.playerTexture:Show()
|
|
if not aura_env.region.focusTexture then
|
|
local focusTexture = aura_env.region:CreateTexture(nil, "OVERLAY")
|
|
aura_env.region.focusTexture = focusTexture
|
|
end
|
|
aura_env.region.focusTexture:SetTexture("Interface\\Addons\\WeakAuras\\PowerAurasMedia\\Auras\\Aura72")
|
|
aura_env.region.focusTexture:SetHeight(16)
|
|
aura_env.region.focusTexture:SetWidth(16)
|
|
aura_env.region.focusTexture:Show()
|
|
if not aura_env.region.text then
|
|
local text = aura_env.region:CreateFontString(nil, aura_env.region)
|
|
aura_env.region.text = text
|
|
end
|
|
aura_env.region.text:ClearAllPoints()
|
|
aura_env.region.text:SetPoint("CENTER", aura_env.region, "CENTER", 0, 500)
|
|
aura_env.region.text:SetFont("Interface\\AddOns\\SharedMedia_MyMedia\\font\\FiraCode-Medium.ttf", 16, "OUTLINE")
|
|
aura_env.region.text:SetJustifyH("CENTER")
|
|
aura_env.region.text:Show() |