function addon:OnUpdate()
if not self.tUnits then return end
local counter = 0
for k, v in pairs(self.tUnits) do
local tFacing = v:GetFacing()
if not tFacing then return end
local tPos = v:GetPosition()
if not tPos then return end
--t2:FindChild("Pos"):SetText(("y: %s x: %s z: %s"):format(tPos.y, tPos.x, tPos.z)) -- debug
local rot = math.atan(tFacing.x/tFacing.z)
local rotPlus = rot+math.rad(60) -- offset
local rotNeg = rot+math.rad(-60) -- offset
tFacing.x = tFacing.x*-1 -- because else it is an inverted flipped coordinate system
if not self.markers[1] or not self.markers[1][1] then self:SetupMarks() end -- check if at least 1 is set up or not
for nCounterCounter = 1, 3 do -- 3 safe areas per mob
for i = 1, #self.markers[counter+nCounterCounter] do
if (nCounterCounter%3) == 1 then
local tPlusEndPoint = { x = tPos.x+nLineLength*math.sin(rotPlus), y = tPos.y, z = tPos.z+nLineLength*math.cos(rotPlus)}
local vV1 = Vector3.New(tPos.x, tPos.y, tPos.z)
local vV2 = Vector3.New(tPlusEndPoint.x, tPlusEndPoint.y, tPlusEndPoint.z)
local vVector = Vector3.InterpolateLinear(vV1, vV2, (1/#self.markers[counter+nCounterCounter]) * i)
self.markers[counter+nCounterCounter][i]:SetWorldLocation(vVector)
self.markers[counter+nCounterCounter][i]:Show(true)
elseif (nCounterCounter%3) == 2 then
local tNegEndPoint = { x = tPos.x+nLineLength*math.sin(rotNeg), y = tPos.y, z = tPos.z+nLineLength*math.cos(rotNeg)}
local vV1 = Vector3.New(tPos.x, tPos.y, tPos.z)
local vV2 = Vector3.New(tNegEndPoint.x, tNegEndPoint.y, tNegEndPoint.z)
local vVector = Vector3.InterpolateLinear(vV1, vV2, (1/#self.markers[counter+nCounterCounter]) * i)
self.markers[counter+nCounterCounter][i]:SetWorldLocation(vVector)
self.markers[counter+nCounterCounter][i]:Show(true)
elseif (nCounterCounter%3) == 0 then
local tHeadEndPoint = { x = tPos.x+nLineLength*math.sin(rot+math.rad(180)), y = tPos.y, z = tPos.z+nLineLength*math.cos(rot+math.rad(180))}
local vV1 = Vector3.New(tPos.x, tPos.y, tPos.z)
local vV2 = Vector3.New(tHeadEndPoint.x, tHeadEndPoint.y, tHeadEndPoint.z)
local vVector = Vector3.InterpolateLinear(vV1, vV2, (1/#self.markers[counter+nCounterCounter]) * i)
self.markers[counter+nCounterCounter][i]:SetWorldLocation(vVector)
self.markers[counter+nCounterCounter][i]:Show(true)
self.markers[counter+nCounterCounter][i]:SetBGColor(tColor.yellow)
end
end
end
counter = counter + 3
end
end
Comments
0 B
|0 👍
/0 👎