Skip to content

Commit

Permalink
System - Tracker Update per Daemonic
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteOne committed Apr 24, 2023
1 parent 1a60476 commit 1747f8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
27 changes: 14 additions & 13 deletions Libs/!LibDraw/LibDraw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ local function WorldToScreen (wX, wY, wZ)
-- br._G.print("K: "..tostring(k)..", V: "..tostring(v))
-- end
local sX, sY = br._G.WorldToScreen(wX, wY, wZ)
if not sX or sX == 0 then
return false, false
end
if sX and sY and br.unlocker ~= "WA" and br.unlocker ~= "LuaBox" then
return sX, -(WorldFrame:GetTop() - sY);
else
Expand Down Expand Up @@ -72,8 +75,6 @@ function LibDraw.SetWidth(w)
end

function LibDraw.Line(sx, sy, sz, ex, ey, ez)
if not WorldToScreen then return end

local sx, sy = WorldToScreen(sx, sy, sz)
local ex, ey = WorldToScreen(ex, ey, ez)

Expand Down Expand Up @@ -141,8 +142,7 @@ function LibDraw.Array(vectors, x, y, z, rotationX, rotationY, rotationZ)
end

function LibDraw.Draw2DLine(sx, sy, ex, ey)
if not WorldToScreen or not sx or not sy or not ex or not ey then return end
if sx == 0 or ex == 0 then return end
if not sx or not sy or not ex or not ey then return end

local L = tremove(LibDraw.lines) or false
if L == false then
Expand Down Expand Up @@ -190,11 +190,11 @@ local arrow = {
}

function LibDraw.Arrow(x, y, z, direction, multiplier)
if not multiplier then multiplier = 1 end
if not multiplier or multiplier == 0 then multiplier = 1 end
local sx, sy, sz, ex, ey, ez, sx, sy, ex, ey
for _, vector in ipairs(arrow) do
sx, sy, sz = x + vector[1]*multiplier, y + vector[2], z + vector[3]
ex, ey, ez = x + vector[4]*multiplier, y + vector[5], z + vector[6]
sx, sy, sz = x + vector[1]*multiplier, y + vector[2]*multiplier, z + vector[3]
ex, ey, ez = x + vector[4]*multiplier, y + vector[5]*multiplier, z + vector[6]

sx, sy, sz = LibDraw.rotateZ(x, y, z, sx, sy, sz, direction)
ex, ey, ez = LibDraw.rotateZ(x, y, z, ex, ey, ez, direction)
Expand All @@ -209,10 +209,11 @@ local full_circle = rad(365)
local small_circle_step = rad(15)

function LibDraw.Circle(x, y, z, size)
if not size or size == 0 then return end
local lx, ly, nx, ny, fx, fy = false, false, false, false, false, false
for v=0, full_circle, small_circle_step do
nx, ny = WorldToScreen( (x+cos(v)*size), (y+sin(v)*size), z )
if nx ~= 0 and ny ~= 0 then
if nx and ny then
LibDraw.Draw2DLine(lx, ly, nx, ny)
else
fx, fy = nx, ny
Expand All @@ -232,7 +233,7 @@ function LibDraw.GroundCircle(x, y, z, size)
fx, fy, fz = (x+cos(v)*size), (y+sin(v)*size), z
end
nx, ny = WorldToScreen( (fx+cos(v)*size), (fy+sin(v)*size), fz )
if nx ~= 0 and ny ~= 0 then
if nx and ny then
LibDraw.Draw2DLine(lx, ly, nx, ny)
end
lx, ly = nx, ny
Expand All @@ -246,7 +247,7 @@ function LibDraw.Arc(x, y, z, size, arc, rotation)
local as, ae = -half_arc, half_arc
for v = as, ae, ss do
nx, ny = WorldToScreen( (x+cos(rotation+rad(v))*size), (y+sin(rotation+rad(v))*size), z )
if nx ~= 0 and ny ~= 0 then
if nx and ny then
LibDraw.Draw2DLine(lx, ly, nx, ny)
else
fx, fy = nx, ny
Expand All @@ -264,7 +265,7 @@ function LibDraw.Texture(config, x, y, z, alphaA)
local left, right, top, bottom, scale = config.left, config.right, config.top, config.bottom, config.scale
local alpha = config.alpha or alphaA

if not WorldToScreen or not texture or not width or not height or not x or not y or not z then return end
if not texture or not width or not height or not x or not y or not z then return end
if not left or not right or not top or not bottom then
left = 0
right = 1
Expand All @@ -277,7 +278,7 @@ function LibDraw.Texture(config, x, y, z, alphaA)
end

local sx, sy = WorldToScreen(x, y, z)
if sx == 0 or sy == 0 then return end
if not sx or not sy then return end
local w = width * scale
local h = height * scale
sx = sx - w*0.5
Expand Down Expand Up @@ -308,7 +309,7 @@ function LibDraw.Text(text, font, x, y, z)

local sx, sy = WorldToScreen(x, y, z)

if sx ~= 0 and sy ~= 0 then
if sx and sy then

local F = tremove(LibDraw.fontstrings) or LibDraw.canvas:CreateFontString(nil, "BACKGROUND")

Expand Down
14 changes: 8 additions & 6 deletions System/engines/Tracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,30 @@ local function isInteracting(unit)
return interactTime > time
end

local lx, ly, lz
local function trackObject(object, isUnit, name, objectid, objectguid, interact)
if not br._G.ObjectExists(object) then return end
local xOb, yOb, zOb = br._G.ObjectPosition(object)
local pX, pY, pZ = br._G.ObjectPosition("player")
if zOb == nil then zOb = pZ end
if zOb == nil then return end
if interact == nil then
interact = true
end
-- local playerDistance = br._G.GetDistanceBetweenPositions(pX, pY, pZ, xOb, yOb, zOb)
local zDifference = math.floor(zOb - pZ)
if xOb ~= nil and (lx == nil or lx ~= xOb or ly ~= yOb or lz ~= zOb) then --and playerDistance < 200 then
if xOb ~= nil then --and playerDistance < 200 then
if math.abs(zDifference) > 50 then
LibDraw.SetColor(255, 0, 0, 100)
else
LibDraw.SetColor(0, 255, 0, 100)
end
LibDraw.Circle(xOb, yOb, zOb, 2)
local Cr = br._G.UnitCombatReach(object)
if not Cr or Cr == 0 then Cr = 1.5 end
LibDraw.Circle(xOb, yOb, zOb, Cr)
if isUnit then
LibDraw.Arrow(xOb, yOb, zOb, br._G.UnitFacing(object) + math.pi * 2)
LibDraw.Arrow(xOb, yOb, zOb, br._G.UnitFacing(object) + math.pi * 2, Cr / 2)
else
LibDraw.Arrow(xOb, yOb, zOb, br._G.UnitFacing("player") + math.pi * 2)
LibDraw.Arrow(xOb, yOb, zOb, br._G.UnitFacing("player") + math.pi * 2, Cr / 2)
end
-- if name == "" or name == "Unknown" then
-- name = isUnit and br._G.UnitName(object) or nil
Expand Down Expand Up @@ -73,7 +76,6 @@ local function trackObject(object, isUnit, name, objectid, objectguid, interact)
end
tracking = true
end
lx, ly, lz = xOb, yOb, zOb
end

_G.string.trim = function(string)
Expand Down

0 comments on commit 1747f8a

Please sign in to comment.