1 QuestHelper_File
["radar.lua"] = "Development Version"
2 QuestHelper_Loadtime
["radar.lua"] = GetTime()
17 local texparent
= CreateFrame("Frame")
21 QH_OnUpdate(function()
22 if not QuestHelper_Pref
.radar
then
24 for _
, v
in ipairs(widgets
) do
34 if not rc
then rc
= LibStub("LibRangeCheck-2.0") end
36 if tick
<= GetTime() then
38 if tick
< GetTime() then
42 local targ
= UnitGUID("target")
43 if targ
~= anchor
or UnitIsDead("target") then
44 for _
, v
in pairs(map
) do QuestHelper
:ReleaseTable(v
) end
46 for _
, v
in ipairs(widgets
) do
53 local minRange
, maxRange
= rc
:GetRange('target')
56 if not maxRange
then maxRange
= 120 end
58 minRange
= math
.max(0, minRange
- 1)
59 maxRange
= maxRange
+ 1
61 local mnr
, mxr
= minRange
* minRange
, maxRange
* maxRange
62 local px
, py
= QuestHelper
.routing_ax
, QuestHelper
.routing_ay
65 local newmap
= QuestHelper
:CreateTable("radar")
66 for x
, d
in pairs(map
) do
67 if not newmap
[x
- grid
] then newmap
[x
- grid
] = QuestHelper
:CreateTable("radar") end
68 if not newmap
[x
] then newmap
[x
] = QuestHelper
:CreateTable("radar") end
69 if not newmap
[x
+ grid
] then newmap
[x
+ grid
] = QuestHelper
:CreateTable("radar") end
71 for y
, v
in pairs(d
) do
72 newmap
[x
- grid
][y
- grid
] = (newmap
[x
- grid
][y
- grid
] or 0) + v
73 newmap
[x
- grid
][y
] = (newmap
[x
- grid
][y
] or 0) + v
* 2
74 newmap
[x
- grid
][y
+ grid
] = (newmap
[x
- grid
][y
+ grid
] or 0) + v
75 newmap
[x
][y
- grid
] = (newmap
[x
][y
- grid
] or 0) + v
* 2
76 newmap
[x
][y
] = (newmap
[x
][y
] or 0) + v
* 4
77 newmap
[x
][y
+ grid
] = (newmap
[x
][y
+ grid
] or 0) + v
* 2
78 newmap
[x
+ grid
][y
- grid
] = (newmap
[x
+ grid
][y
- grid
] or 0) + v
79 newmap
[x
+ grid
][y
] = (newmap
[x
+ grid
][y
] or 0) + v
* 2
80 newmap
[x
+ grid
][y
+ grid
] = (newmap
[x
+ grid
][y
+ grid
] or 0) + v
83 QuestHelper
:ReleaseTable(d
)
85 QuestHelper
:ReleaseTable(map
)
91 local newmap
= QuestHelper
:CreateTable("radar")
92 for x
, d
in pairs(map
) do
93 local newk
= QuestHelper
:CreateTable("radar")
94 local something
= false
97 for y
, v
in pairs(d
) do
100 --print(dx + dy, mnr, mxr)
101 if dx
+ dy
>= mnr
and dx
+ dy
<= mxr
then
103 highest
= max(highest
, v
)
111 QuestHelper
:ReleaseTable(d
)
113 QuestHelper
:ReleaseTable(map
)
118 highest
= 1 / highest
-- I don't know if mult is faster in lua or not, but it often is
119 for x
, d
in pairs(map
) do
120 for y
, v
in pairs(d
) do
127 -- probably a more efficient way to do this
128 px
, py
= math
.floor(px
/ grid
+ 0.5) * grid
, math
.floor(py
/ grid
+ 0.5) * grid
129 for dx
= 0, maxRange
, grid
do
130 for dy
= 0, maxRange
, grid
do
131 local ofs
= dx
* dx
+ dy
* dy
132 if ofs
>= mnr
and ofs
<= mxr
then
133 if not map
[px
+ dx
] then map
[px
+ dx
] = QuestHelper
:CreateTable("radar") end
134 if not map
[px
- dx
] then map
[px
- dx
] = QuestHelper
:CreateTable("radar") end
135 map
[px
+ dx
][py
+ dy
] = (map
[px
+ dx
][py
+ dy
] or 0) + 0.001
137 map
[px
- dx
][py
+ dy
] = (map
[px
- dx
][py
+ dy
] or 0) + 0.001
139 map
[px
- dx
][py
- dy
] = (map
[px
- dx
][py
- dy
] or 0) + 0.001
143 map
[px
+ dx
][py
- dy
] = (map
[px
+ dx
][py
- dy
] or 0) + 0.001
151 for x
, d
in pairs(map
) do
152 for y
, v
in pairs(d
) do
154 local widg
= widgets
[widgetofs
]
156 widg
= {texparent
:CreateTexture()}
157 table.insert(widgets
, widg
)
158 widg
[1]:SetWidth(lwidth
)
159 widg
[1]:SetHeight(lheight
)
161 widgetofs
= widgetofs
+ 1
163 widg
[1]:SetTexture(0, 1, 0, math
.min(1, v
* 1.2))
171 for rem
= widgetofs
, #widgets
do
172 widgets
[rem
][1]:Hide()
173 widgets
[rem
][3] = nil
178 -- here we replace the widgets
180 local rotatey
= (GetCVar("rotateMinimap") == "0") and 0 or GetPlayerFacing()
181 rotatey
= rotatey
* 180 / 3.14159
183 local mapdiam
= QuestHelper
.Astrolabe
:GetMapDiameter()
184 local minimap
= QuestHelper
.Astrolabe
:GetMinimapObject()
185 local mapwid
, maphei
= minimap
:GetWidth(), minimap
:GetHeight()
187 local xds
, yds
= mapwid
/ mapdiam
, maphei
/ mapdiam
189 local nwidth
, nheight
= xds
* grid
, yds
* grid
190 if nwidth
~= lwidth
or nheight
~= lheight
then
191 for _
, widg
in pairs(widgets
) do
192 widg
[1]:SetWidth(nwidth
)
193 widg
[1]:SetHeight(nheight
)
196 lwidth
, lheight
= nwidth
, nheight
198 local xdx
, xdy
, ydx
, ydy
= cos(rotatey
), -sin(rotatey
), -sin(rotatey
), -cos(rotatey
) -- this will be wrong, but I'll figure it out
199 xdx
, ydx
= xdx
* xds
, ydx
* xds
200 xdy
, ydy
= xdy
* yds
, ydy
* yds
202 local px
, py
= QuestHelper
.routing_ax
, QuestHelper
.routing_ay
204 for _
, v
in pairs(widgets
) do
205 if not v
[3] then break end
207 local dx
, dy
= v
[2] - px
, v
[3] - py
209 v
[1]:SetPoint("CENTER", Minimap
, "CENTER", dx
* xdx
+ dy
* ydx
, dx
* xdy
+ dy
* ydy
)
210 --print("placing", dx * xdx + dy * ydx, dx * xdy + dy * ydy)
216 if ( minimapRotationEnabled
) then
217 minimapRotationOffset
= -Astrolabe
.GetFacing()