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
39 local targ
= UnitGUID("target")
40 if targ
~= anchor
then
41 for _
, v
in pairs(map
) do QuestHelper
:ReleaseTable(v
) end
43 for _
, v
in ipairs(widgets
) do
50 local minRange
, maxRange
= rc
:GetRange('target')
53 if not maxRange
then maxRange
= 100 end
55 minRange
= math
.max(0, minRange
- 1)
56 maxRange
= maxRange
+ 1
58 local mnr
, mxr
= minRange
* minRange
, maxRange
* maxRange
59 local px
, py
= QuestHelper
.routing_ax
, QuestHelper
.routing_ay
62 local newmap
= QuestHelper
:CreateTable("radar")
63 for x
, d
in pairs(map
) do
64 if not newmap
[x
- grid
] then newmap
[x
- grid
] = QuestHelper
:CreateTable("radar") end
65 if not newmap
[x
] then newmap
[x
] = QuestHelper
:CreateTable("radar") end
66 if not newmap
[x
+ grid
] then newmap
[x
+ grid
] = QuestHelper
:CreateTable("radar") end
68 for y
, v
in pairs(d
) do
69 newmap
[x
- grid
][y
- grid
] = (newmap
[x
- grid
][y
- grid
] or 0) + v
70 newmap
[x
- grid
][y
] = (newmap
[x
- grid
][y
] or 0) + v
* 2
71 newmap
[x
- grid
][y
+ grid
] = (newmap
[x
- grid
][y
+ grid
] or 0) + v
72 newmap
[x
][y
- grid
] = (newmap
[x
][y
- grid
] or 0) + v
* 2
73 newmap
[x
][y
] = (newmap
[x
][y
] or 0) + v
* 4
74 newmap
[x
][y
+ grid
] = (newmap
[x
][y
+ grid
] or 0) + v
* 2
75 newmap
[x
+ grid
][y
- grid
] = (newmap
[x
+ grid
][y
- grid
] or 0) + v
76 newmap
[x
+ grid
][y
] = (newmap
[x
+ grid
][y
] or 0) + v
* 2
77 newmap
[x
+ grid
][y
+ grid
] = (newmap
[x
+ grid
][y
+ grid
] or 0) + v
80 QuestHelper
:ReleaseTable(d
)
82 QuestHelper
:ReleaseTable(map
)
88 local newmap
= QuestHelper
:CreateTable("radar")
89 for x
, d
in pairs(map
) do
90 local newk
= QuestHelper
:CreateTable("radar")
91 local something
= false
94 for y
, v
in pairs(d
) do
97 --print(dx + dy, mnr, mxr)
98 if dx
+ dy
>= mnr
and dx
+ dy
<= mxr
then
100 highest
= max(highest
, v
)
108 QuestHelper
:ReleaseTable(d
)
110 QuestHelper
:ReleaseTable(map
)
115 highest
= 1 / highest
-- I don't know if mult is faster in lua or not, but it often is
116 for x
, d
in pairs(map
) do
117 for y
, v
in pairs(d
) do
124 -- probably a more efficient way to do this
125 px
, py
= math
.floor(px
/ grid
+ 0.5) * grid
, math
.floor(py
/ grid
+ 0.5) * grid
126 for dx
= 0, maxRange
, grid
do
127 for dy
= 0, maxRange
, grid
do
128 local ofs
= dx
* dx
+ dy
* dy
129 if ofs
>= mnr
and ofs
<= mxr
then
130 if not map
[px
+ dx
] then map
[px
+ dx
] = QuestHelper
:CreateTable("radar") end
131 if not map
[px
- dx
] then map
[px
- dx
] = QuestHelper
:CreateTable("radar") end
132 map
[px
+ dx
][py
+ dy
] = (map
[px
+ dx
][py
+ dy
] or 0) + 0.01
134 map
[px
- dx
][py
+ dy
] = (map
[px
- dx
][py
+ dy
] or 0) + 0.01
136 map
[px
- dx
][py
- dy
] = (map
[px
- dx
][py
- dy
] or 0) + 0.01
140 map
[px
+ dx
][py
- dy
] = (map
[px
+ dx
][py
- dy
] or 0) + 0.01
148 for x
, d
in pairs(map
) do
149 for y
, v
in pairs(d
) do
151 local widg
= widgets
[widgetofs
]
153 widg
= {texparent
:CreateTexture()}
154 table.insert(widgets
, widg
)
155 widg
[1]:SetWidth(lwidth
)
156 widg
[1]:SetHeight(lheight
)
158 widgetofs
= widgetofs
+ 1
160 widg
[1]:SetTexture(0, 1, 0, math
.min(1, v
* 1.2))
168 for rem
= widgetofs
, #widgets
do
169 widgets
[rem
][1]:Hide()
170 widgets
[rem
][3] = nil
175 -- here we replace the widgets
177 local rotatey
= (GetCVar("rotateMinimap") == "0") and 0 or GetPlayerFacing()
178 rotatey
= rotatey
* 180 / 3.14159
180 local mapdiam
= QuestHelper
.Astrolabe
:GetMapDiameter()
181 local minimap
= QuestHelper
.Astrolabe
:GetMinimapObject()
182 local mapwid
, maphei
= minimap
:GetWidth(), minimap
:GetHeight()
184 local xds
, yds
= mapwid
/ mapdiam
, maphei
/ mapdiam
186 local nwidth
, nheight
= xds
* grid
, yds
* grid
187 if nwidth
~= lwidth
or nheight
~= lheight
then
188 for _
, widg
in pairs(widgets
) do
189 widg
[1]:SetWidth(nwidth
)
190 widg
[1]:SetHeight(nheight
)
193 lwidth
, lheight
= nwidth
, nheight
195 local xdx
, xdy
, ydx
, ydy
= cos(rotatey
), -sin(rotatey
), -sin(rotatey
), -cos(rotatey
) -- this will be wrong, but I'll figure it out
196 xdx
, ydx
= xdx
* xds
, ydx
* xds
197 xdy
, ydy
= xdy
* yds
, ydy
* yds
199 local px
, py
= QuestHelper
.routing_ax
, QuestHelper
.routing_ay
201 for _
, v
in pairs(widgets
) do
202 if not v
[3] then break end
204 local dx
, dy
= v
[2] - px
, v
[3] - py
206 v
[1]:SetPoint("CENTER", Minimap
, "CENTER", dx
* xdx
+ dy
* ydx
, dx
* xdy
+ dy
* ydy
)
207 --print("placing", dx * xdx + dy * ydx, dx * xdy + dy * ydy)
213 if ( minimapRotationEnabled
) then
214 minimapRotationOffset
= -Astrolabe
.GetFacing()