only1yzerman@0
|
1
|
only1yzerman@0
|
2 -------- SINGLE OBJECT IN GLOBAL NAMESPACE
|
only1yzerman@0
|
3
|
only1yzerman@0
|
4 Bloodhound2 = {};
|
only1yzerman@0
|
5
|
only1yzerman@0
|
6
|
only1yzerman@0
|
7 -------- CREATE OUR INVISIBLE FRAME TO RECEIVE EVENTS AND UPDATES
|
only1yzerman@0
|
8
|
only1yzerman@0
|
9 local frame = CreateFrame("Frame", nil, UIParent);
|
only1yzerman@0
|
10 Bloodhound2.Frame = frame;
|
only1yzerman@0
|
11
|
only1yzerman@0
|
12
|
only1yzerman@0
|
13 -------- DEFINE AND REGISTER EVENT HANDLERS
|
only1yzerman@0
|
14
|
only1yzerman@0
|
15 local events = {};
|
only1yzerman@0
|
16
|
only1yzerman@0
|
17 function events:MINIMAP_UPDATE_TRACKING(...)
|
only1yzerman@0
|
18 if player and player.Z then
|
only1yzerman@0
|
19 Bloodhound2.UpdateMinimap();
|
only1yzerman@0
|
20 end
|
only1yzerman@0
|
21 end
|
only1yzerman@0
|
22
|
only1yzerman@0
|
23 frame:SetScript("OnEvent",
|
only1yzerman@0
|
24 function(self, event, ...)
|
only1yzerman@0
|
25 events[event](self, ...);
|
only1yzerman@0
|
26 end);
|
only1yzerman@0
|
27
|
only1yzerman@0
|
28 local k, v;
|
only1yzerman@0
|
29
|
only1yzerman@0
|
30 for k, v in pairs(events) do
|
only1yzerman@0
|
31 frame:RegisterEvent(k);
|
only1yzerman@0
|
32 end
|
only1yzerman@0
|
33
|
only1yzerman@0
|
34
|
only1yzerman@0
|
35
|
only1yzerman@0
|
36
|
only1yzerman@0
|
37
|
only1yzerman@0
|
38
|
only1yzerman@0
|
39 ----------------------------------------------------------------------------------------------------
|
only1yzerman@0
|
40 -------- STORES A POINTER TO THE MINIMAP LOCALLY SO IT CAN BE CHANGED BY A RE-PARENTING FUNCTION
|
only1yzerman@0
|
41 -------- - Added by Zasurus(www.curseforge.com/profiles/Zasurus/) for MiniHugeHUD
|
only1yzerman@0
|
42 ----------------------------------------------------------------------------------------------------
|
only1yzerman@0
|
43 local Minimap = _G.Minimap;
|
only1yzerman@0
|
44 Minimap.MinimapName = "Minimap";
|
only1yzerman@0
|
45 ----------------------------------------------------------------------------------------------------
|
only1yzerman@0
|
46
|
only1yzerman@0
|
47
|
only1yzerman@0
|
48
|
only1yzerman@0
|
49
|
only1yzerman@0
|
50
|
only1yzerman@0
|
51
|
only1yzerman@0
|
52 -------- WORK AROUND WOW BUG THAT CAUSES GetPlayerMapPosition TO RETURN 0,0
|
only1yzerman@0
|
53
|
only1yzerman@0
|
54 WorldMapFrame:Show()
|
only1yzerman@0
|
55 WorldMapFrame:Hide()
|
only1yzerman@0
|
56
|
only1yzerman@0
|
57
|
only1yzerman@0
|
58 -------- HOOK INTO PER-FRAME UPDATE HANDLER
|
only1yzerman@0
|
59
|
only1yzerman@0
|
60 local player = {}; -- player position
|
only1yzerman@0
|
61 local totalElapsed = 0.0; -- time elapsed since last update
|
only1yzerman@0
|
62 local updatePeriod = 0.1; -- sec. interval for each minimap update
|
only1yzerman@0
|
63 local cpuThrottle = 0.05; -- throttle to 5% usage while moving
|
only1yzerman@0
|
64 local minUpdatePeriod = 0.04; -- sec. don't update more often than this
|
only1yzerman@0
|
65 local lastzoom = 0; -- previous minimap zoom level
|
only1yzerman@0
|
66 local updateTotalTime = 0; -- time spent updating minimap
|
only1yzerman@0
|
67 local updateCount = 0; -- number of times minimap updated
|
only1yzerman@0
|
68
|
only1yzerman@0
|
69 ----------------------------------------------------------------------------------------------------
|
only1yzerman@0
|
70 -------- MOVED OnUpdate Script into seperate function so it could be called by re-parent function
|
only1yzerman@0
|
71 -------- - Added by Zasurus(www.curseforge.com/profiles/Zasurus/) for MiniHugeHUD
|
only1yzerman@0
|
72 ----------------------------------------------------------------------------------------------------
|
only1yzerman@0
|
73 frame:SetScript("OnUpdate", function(self, elapsed) Bloodhound2.OnUpdateScript(self, elapsed) end);
|
only1yzerman@0
|
74 function Bloodhound2.OnUpdateScript(self, elapsed)
|
only1yzerman@0
|
75 totalElapsed = totalElapsed + elapsed; -- measure total elapsed time
|
only1yzerman@0
|
76
|
only1yzerman@0
|
77 if (totalElapsed >= updatePeriod) then -- if enough time has passed
|
only1yzerman@0
|
78 totalElapsed = mod(totalElapsed, updatePeriod);
|
only1yzerman@0
|
79 local isInInstance, instanceType = IsInInstance()
|
only1yzerman@0
|
80
|
only1yzerman@0
|
81 if isInInstance ~= nil then
|
only1yzerman@0
|
82 Bloodhound2.DrawArrow(0, 0, 0, 0)
|
only1yzerman@0
|
83 return
|
only1yzerman@0
|
84 end
|
only1yzerman@0
|
85
|
only1yzerman@0
|
86 local cmap = GetCurrentMapContinent();
|
only1yzerman@0
|
87 local zmap = GetCurrentMapZone();
|
only1yzerman@0
|
88 SetMapToCurrentZone();
|
only1yzerman@0
|
89 local c = GetCurrentMapContinent(); -- get current player position
|
only1yzerman@0
|
90 local z = GetCurrentMapZone();
|
only1yzerman@0
|
91 local x, y = GetPlayerMapPosition("player");
|
only1yzerman@0
|
92 local f = GetPlayerFacing();
|
only1yzerman@0
|
93 local m = Minimap:GetZoom();
|
only1yzerman@0
|
94 SetMapZoom(cmap, zmap);
|
only1yzerman@0
|
95
|
only1yzerman@0
|
96 if (c ~= player.C and c ~= 0) then -- reload continent data if continent has changed
|
only1yzerman@0
|
97 Bloodhound2.HerbNodes, Bloodhound2.ContinentHerbs = Bloodhound2.ReloadNodes(Bloodhound2.HerbDatabase[c], Bloodhound2.ZoneDatum[c]);
|
only1yzerman@0
|
98 Bloodhound2.OreNodes, Bloodhound2.ContinentOre = Bloodhound2.ReloadNodes(Bloodhound2.OreDatabase[c], Bloodhound2.ZoneDatum[c]);
|
only1yzerman@0
|
99 end
|
only1yzerman@0
|
100
|
only1yzerman@0
|
101 if (c ~= player.C or z ~= player.Z or x ~= player.X or y ~= player.Y or f ~= player.F or m ~= lastzoom) then
|
only1yzerman@0
|
102 player.C = c;
|
only1yzerman@0
|
103 player.Z = z;
|
only1yzerman@0
|
104 player.X = x;
|
only1yzerman@0
|
105 player.Y = y;
|
only1yzerman@0
|
106 player.F = f;
|
only1yzerman@0
|
107 lastzoom = m;
|
only1yzerman@0
|
108 local t0 = GetTime();
|
only1yzerman@0
|
109 Bloodhound2.UpdateMinimap(); -- player has moved or minimap scale has changed
|
only1yzerman@0
|
110 local t1 = GetTime() - t0;
|
only1yzerman@0
|
111
|
only1yzerman@0
|
112 -- calculate and throttle CPU usage to 5%
|
only1yzerman@0
|
113 updateTotalTime = updateTotalTime + t1
|
only1yzerman@0
|
114
|
only1yzerman@0
|
115 if updateCount > 10 then
|
only1yzerman@0
|
116 local avgTime = updateTotalTime / updateCount
|
only1yzerman@0
|
117 updatePeriod = avgTime / cpuThrottle
|
only1yzerman@0
|
118 Print(updateCount);
|
only1yzerman@0
|
119
|
only1yzerman@0
|
120 if updatePeriod < minUpdatePeriod then
|
only1yzerman@0
|
121 updatePeriod = minUpdatePeriod
|
only1yzerman@0
|
122 end
|
only1yzerman@0
|
123
|
only1yzerman@0
|
124 if updateCount >= 100 then
|
only1yzerman@0
|
125 updateTotalTime = updateTotalTime / 2
|
only1yzerman@0
|
126 updateCount = updateCount / 2
|
only1yzerman@0
|
127 end
|
only1yzerman@0
|
128 end
|
only1yzerman@0
|
129 end
|
only1yzerman@0
|
130 end
|
only1yzerman@0
|
131 end
|
only1yzerman@0
|
132
|
only1yzerman@0
|
133 function Bloodhound2.UpdateMinimap()
|
only1yzerman@0
|
134 local facing = 0
|
only1yzerman@0
|
135
|
only1yzerman@0
|
136 if GetCVar("rotateMinimap") ~= "0" then
|
only1yzerman@0
|
137 facing = GetPlayerFacing() * 57.2957795;
|
only1yzerman@0
|
138 end
|
only1yzerman@0
|
139
|
only1yzerman@0
|
140 local cf = cos(facing);
|
only1yzerman@0
|
141 local sf = sin(facing);
|
only1yzerman@0
|
142 local gx, gy = Bloodhound2.CalculateForce(cf, sf);
|
only1yzerman@0
|
143 Bloodhound2.DrawArrow(gx, gy, cf, sf);
|
only1yzerman@0
|
144 end
|
only1yzerman@0
|
145
|
only1yzerman@0
|
146
|
only1yzerman@0
|
147 -------- DATABASE LOADING
|
only1yzerman@0
|
148
|
only1yzerman@0
|
149 Bloodhound2.HerbNodes = {};
|
only1yzerman@0
|
150 Bloodhound2.OreNodes = {};
|
only1yzerman@0
|
151 Bloodhound2.ContinentHerbs = {};
|
only1yzerman@0
|
152 Bloodhound2.ContinentOre = {};
|
only1yzerman@0
|
153
|
only1yzerman@0
|
154 function Bloodhound2.ReloadNodes(database, zoneDatum)
|
only1yzerman@0
|
155
|
only1yzerman@0
|
156 if (database == nil) then return {}; end
|
only1yzerman@0
|
157
|
only1yzerman@0
|
158 local nodes = {};
|
only1yzerman@0
|
159 local db = {};
|
only1yzerman@0
|
160
|
only1yzerman@0
|
161 local zoneNode, positions;
|
only1yzerman@0
|
162 for zoneNode, positions in pairs(database) do
|
only1yzerman@0
|
163 local _, _, zone, node = string.find(zoneNode, "Z(%d+)N(%d+)");
|
only1yzerman@0
|
164 local z = tonumber(zone);
|
only1yzerman@0
|
165 local datum = zoneDatum[z];
|
only1yzerman@0
|
166 local n = tonumber(node);
|
only1yzerman@0
|
167 db[n] = true;
|
only1yzerman@0
|
168 local pxy = 0
|
only1yzerman@0
|
169
|
only1yzerman@0
|
170 for _,pos in ipairs(positions) do
|
only1yzerman@0
|
171 local xy = pos + pxy
|
only1yzerman@0
|
172 pxy = xy
|
only1yzerman@0
|
173 local x = floor(xy / 1000);
|
only1yzerman@0
|
174 local y = xy - 1000 * x;
|
only1yzerman@0
|
175 x, y = Bloodhound2.ZoneDatum.LocalToGlobal(x / 1000.0, y / 1000.0, datum);
|
only1yzerman@0
|
176 tinsert(nodes, {Z = z, N = n, X = x, Y = y, TimeStamp = time() - 60 - 3600 * math.random() });
|
only1yzerman@0
|
177 end
|
only1yzerman@0
|
178 end
|
only1yzerman@0
|
179
|
only1yzerman@0
|
180 return nodes, db;
|
only1yzerman@0
|
181 end
|
only1yzerman@0
|
182
|
only1yzerman@0
|
183
|
only1yzerman@0
|
184 -------- UTILITY FUNCTIONS
|
only1yzerman@0
|
185
|
only1yzerman@0
|
186 function Print(message)
|
only1yzerman@0
|
187 DEFAULT_CHAT_FRAME:AddMessage(message);
|
only1yzerman@0
|
188 end
|
only1yzerman@0
|
189
|
only1yzerman@0
|
190
|
only1yzerman@0
|
191
|
only1yzerman@0
|
192 -------- ARROW LOADING AND DISPLAY
|
only1yzerman@0
|
193
|
only1yzerman@0
|
194 local function GetArrowTexture()
|
only1yzerman@0
|
195
|
only1yzerman@0
|
196 local tex = Bloodhound2.GravityTexture
|
only1yzerman@0
|
197
|
only1yzerman@0
|
198 if not ( tex ) then
|
only1yzerman@1
|
199 tex = Minimap:CreateTexture("Bloodhound2_Arrow", "OVERLAY");
|
only1yzerman@0
|
200 tex:SetTexture("Interface\\AddOns\\Bloodhound2\\MinimapArrow");
|
only1yzerman@0
|
201 Bloodhound2.GravityTexture = tex
|
only1yzerman@0
|
202 end
|
only1yzerman@0
|
203
|
only1yzerman@0
|
204 return tex
|
only1yzerman@0
|
205 end
|
only1yzerman@0
|
206
|
only1yzerman@0
|
207 function Bloodhound2.DrawArrow(grx, gry, cf, sf)
|
only1yzerman@0
|
208
|
only1yzerman@0
|
209 local gravityX = grx * cf - gry * sf;
|
only1yzerman@0
|
210 local gravityY = gry * cf + grx * sf;
|
only1yzerman@0
|
211 local gravityTexture = GetArrowTexture()
|
only1yzerman@0
|
212
|
only1yzerman@0
|
213 if (gravityX == 0 and gravityY == 0) then
|
only1yzerman@0
|
214 gravityTexture:Hide();
|
only1yzerman@0
|
215 return;
|
only1yzerman@0
|
216 end
|
only1yzerman@0
|
217
|
only1yzerman@0
|
218 local gravityScale = sqrt(gravityX * gravityX + gravityY * gravityY)
|
only1yzerman@0
|
219 gravityX = gravityX / gravityScale
|
only1yzerman@0
|
220 gravityY = gravityY / gravityScale
|
only1yzerman@0
|
221
|
only1yzerman@0
|
222 -- determine rotated and scaled texture coordinates
|
only1yzerman@0
|
223 local gy = (gravityX + gravityY) / 2.82843
|
only1yzerman@0
|
224 local gx = (gravityX - gravityY) / 2.82843
|
only1yzerman@0
|
225
|
only1yzerman@0
|
226 gravityTexture:SetTexCoord(
|
only1yzerman@0
|
227 0.5 - gx, 0.5 + gy,
|
only1yzerman@0
|
228 0.5 + gy, 0.5 + gx,
|
only1yzerman@0
|
229 0.5 - gy, 0.5 - gx,
|
only1yzerman@0
|
230 0.5 + gx, 0.5 - gy);
|
only1yzerman@0
|
231
|
only1yzerman@0
|
232 gravityTexture:SetPoint("CENTER", Minimap, "CENTER", 40 * gravityX, -40 * gravityY)
|
only1yzerman@0
|
233 gravityTexture:Show()
|
only1yzerman@0
|
234 end
|
only1yzerman@0
|
235
|
only1yzerman@0
|
236
|
only1yzerman@0
|
237 -------- "RUBY" MANAGEMENT (REUSE RUBIES AND ONLY CREATE NEW ONES WHEN NEEDED)
|
only1yzerman@0
|
238
|
only1yzerman@0
|
239 local circles = {};
|
only1yzerman@0
|
240 local nextCircle = 1;
|
only1yzerman@0
|
241 local circleScale = 1;
|
only1yzerman@0
|
242
|
only1yzerman@0
|
243 function Bloodhound2.ResetCircles()
|
only1yzerman@0
|
244 nextCircle = 1;
|
only1yzerman@0
|
245 circleScale = Minimap:GetHeight() * 0.015 / (7 - Minimap:GetZoom());
|
only1yzerman@0
|
246 end
|
only1yzerman@0
|
247
|
only1yzerman@0
|
248 function Bloodhound2.SetCircle(dx, dy, alpha)
|
only1yzerman@0
|
249 local circle;
|
only1yzerman@0
|
250 if (#circles < nextCircle) then
|
only1yzerman@1
|
251 circle = Minimap:CreateTexture("Bloodhound_Circle", "ARTWORK", nil, -7);
|
only1yzerman@0
|
252 circles[nextCircle] = circle;
|
only1yzerman@0
|
253 circle:SetTexture("Interface\\AddOns\\Bloodhound2\\Circle");
|
only1yzerman@0
|
254 circle:SetWidth(12);
|
only1yzerman@0
|
255 circle:SetHeight(12);
|
only1yzerman@0
|
256 circle:SetAlpha(1);
|
only1yzerman@0
|
257 else
|
only1yzerman@0
|
258 circle = circles[nextCircle];
|
only1yzerman@0
|
259 end
|
only1yzerman@0
|
260
|
only1yzerman@0
|
261 nextCircle = nextCircle + 1;
|
only1yzerman@0
|
262 circle:SetPoint("CENTER", Minimap, "CENTER", dx * circleScale, -dy * circleScale);
|
only1yzerman@0
|
263 circle:SetAlpha(alpha);
|
only1yzerman@0
|
264 circle:Show();
|
only1yzerman@0
|
265 end
|
only1yzerman@0
|
266
|
only1yzerman@0
|
267 function Bloodhound2.HideExtraCircles()
|
only1yzerman@0
|
268 for i=nextCircle,#circles,1 do
|
only1yzerman@0
|
269 circles[i]:Hide();
|
only1yzerman@0
|
270 end
|
only1yzerman@0
|
271 end
|
only1yzerman@0
|
272
|
only1yzerman@0
|
273
|
only1yzerman@0
|
274
|
only1yzerman@0
|
275 -------- MAIN FUNCTION FOR CALCULATING RECOMMENDED DIRECTION OF TRAVEL
|
only1yzerman@0
|
276
|
only1yzerman@0
|
277 function Bloodhound2.CalculateForce(cf, sf)
|
only1yzerman@0
|
278
|
only1yzerman@0
|
279 local c = player.C; -- get player position
|
only1yzerman@0
|
280 local z = player.Z;
|
only1yzerman@0
|
281 local x = player.X;
|
only1yzerman@0
|
282 local y = player.Y;
|
only1yzerman@0
|
283
|
only1yzerman@0
|
284 if c == 0 or z == 0 then return 0,0 end -- don't draw arrow if using world coordinates
|
only1yzerman@0
|
285 if not Bloodhound2.ZoneDatum then return 0,0 end
|
only1yzerman@0
|
286
|
only1yzerman@0
|
287 local datum = Bloodhound2.ZoneDatum[c][z]; -- get scale and offset for current zone map
|
only1yzerman@0
|
288 if datum == nil then return 0,0 end
|
only1yzerman@0
|
289
|
only1yzerman@0
|
290 local gx, gy = Bloodhound2.ZoneDatum.LocalToGlobal(x, y, datum); -- convert player position to world coordinates
|
only1yzerman@0
|
291 local now = time(); -- value to use for time-stamping visited nodes
|
only1yzerman@0
|
292 local fx = 0; -- cumulative force, X-component
|
only1yzerman@0
|
293 local fy = 0; -- cumulative force, Y-component
|
only1yzerman@0
|
294 local multiZone = true; -- whether to include more than the current zone
|
only1yzerman@0
|
295 local inspectionRadius = 60;
|
only1yzerman@0
|
296
|
only1yzerman@0
|
297 if Settings then
|
only1yzerman@0
|
298 if Settings.MultiZoneMode==0 then
|
only1yzerman@0
|
299 multiZone = IsFlying();
|
only1yzerman@0
|
300 elseif Settings.MultiZoneMode==1 then
|
only1yzerman@0
|
301 multiZone = true;
|
only1yzerman@0
|
302 else
|
only1yzerman@0
|
303 multiZone = false;
|
only1yzerman@0
|
304 end
|
only1yzerman@0
|
305
|
only1yzerman@0
|
306 if Settings.InspectionRadius then
|
only1yzerman@0
|
307 inspectionRadius = Settings.InspectionRadius;
|
only1yzerman@0
|
308 end
|
only1yzerman@0
|
309 end
|
only1yzerman@0
|
310
|
only1yzerman@0
|
311 local settingsFilter = {}; -- which node types to ignore
|
only1yzerman@0
|
312 local nodes = {}; -- which nodes to track
|
only1yzerman@0
|
313
|
only1yzerman@0
|
314 for i=1,GetNumTrackingTypes(),1 do
|
only1yzerman@0
|
315 local name, _, active, _ = GetTrackingInfo(i);
|
only1yzerman@0
|
316 if (active == 1) then
|
only1yzerman@0
|
317 if (name == L["Find Herbs"]) then
|
only1yzerman@0
|
318 for k,v in pairs(Settings.HerbFilter) do settingsFilter[k] = v end
|
only1yzerman@0
|
319 for k,v in pairs(Bloodhound2.HerbNodes) do tinsert(nodes, v) end
|
only1yzerman@0
|
320 elseif (name == L["Find Minerals"]) then
|
only1yzerman@0
|
321 for k,v in pairs(Settings.OreFilter) do settingsFilter[k] = v end
|
only1yzerman@0
|
322 for k,v in pairs(Bloodhound2.OreNodes) do tinsert(nodes, v) end
|
only1yzerman@0
|
323 end
|
only1yzerman@0
|
324 end
|
only1yzerman@0
|
325 end
|
only1yzerman@0
|
326
|
only1yzerman@0
|
327 local avoidZones = {}; -- which zones to avoid
|
only1yzerman@0
|
328
|
only1yzerman@0
|
329 if multiZone then
|
only1yzerman@0
|
330 local cmc = GetCurrentMapContinent()
|
only1yzerman@0
|
331
|
only1yzerman@0
|
332 if not Settings.ZoneFilter[cmc] then
|
only1yzerman@0
|
333 Settings.ZoneFilter[cmc] = {}
|
only1yzerman@0
|
334 end
|
only1yzerman@0
|
335
|
only1yzerman@0
|
336 for k,v in pairs(Settings.ZoneFilter[GetCurrentMapContinent()]) do
|
only1yzerman@0
|
337 avoidZones[k] = true;
|
only1yzerman@0
|
338 end
|
only1yzerman@0
|
339 end
|
only1yzerman@0
|
340
|
only1yzerman@0
|
341 local avoidNodes = {}; -- which node types to ignore
|
only1yzerman@0
|
342
|
only1yzerman@0
|
343 if settingsFilter then
|
only1yzerman@0
|
344 for k,v in pairs(settingsFilter) do
|
only1yzerman@0
|
345 avoidNodes[k] = true;
|
only1yzerman@0
|
346 end
|
only1yzerman@0
|
347 end
|
only1yzerman@0
|
348
|
only1yzerman@0
|
349 local minimapSize = Minimap:GetWidth() / 2 - 2;
|
only1yzerman@0
|
350 Bloodhound2.ResetCircles();
|
only1yzerman@0
|
351
|
only1yzerman@0
|
352 for key, node in pairs(nodes) do
|
only1yzerman@0
|
353 if (avoidNodes[node.N] ~= true) and (avoidZones[node.Z] ~= true) and (multiZone or (node.Z == z)) then
|
only1yzerman@0
|
354 local dx = node.X - gx;
|
only1yzerman@0
|
355 local dy = node.Y - gy;
|
only1yzerman@0
|
356 local rsqrd = dx * dx + dy * dy;
|
only1yzerman@0
|
357 local r = sqrt(rsqrd); -- distance to node
|
only1yzerman@0
|
358 local age = now - node.TimeStamp; -- time since last inspected
|
only1yzerman@0
|
359
|
only1yzerman@0
|
360 if (r < inspectionRadius) then
|
only1yzerman@0
|
361 node.TimeStamp = now;
|
only1yzerman@0
|
362 else
|
only1yzerman@0
|
363 --[[
|
only1yzerman@0
|
364 The magnitude of the force is proportional to the age and inversely
|
only1yzerman@0
|
365 proportional to the square of the distance, and the direction is towards
|
only1yzerman@0
|
366 the node. The math for this starts out as
|
only1yzerman@0
|
367
|
only1yzerman@0
|
368 local force = age / rsqrd
|
only1yzerman@0
|
369 local angle = math.atan2(dy, dx)
|
only1yzerman@0
|
370 fx = fx + force * math.cos(angle)
|
only1yzerman@0
|
371 fy = fy + force * math.sin(angle)
|
only1yzerman@0
|
372
|
only1yzerman@0
|
373 But cos(angle) is just dx/r and sin(angle) is just dy/r, so we don't
|
only1yzerman@0
|
374 actually need atan2, cos, and sin and instead we can write this as
|
only1yzerman@0
|
375 ]]
|
only1yzerman@0
|
376 local force = age / (r * rsqrd)
|
only1yzerman@0
|
377 fx = fx + force * dx
|
only1yzerman@0
|
378 fy = fy + force * dy
|
only1yzerman@0
|
379 end
|
only1yzerman@0
|
380
|
only1yzerman@0
|
381 if (r * circleScale < minimapSize) and (age > 60) then -- draw ruby
|
only1yzerman@0
|
382 local alpha = r / (minimapSize / circleScale) / 0.7 - 0.3;
|
only1yzerman@0
|
383 alpha = max(0, alpha);
|
only1yzerman@0
|
384 Bloodhound2.SetCircle(dx * cf - dy * sf, dy * cf + dx * sf, alpha);
|
only1yzerman@0
|
385 end
|
only1yzerman@0
|
386 end
|
only1yzerman@0
|
387 end
|
only1yzerman@0
|
388
|
only1yzerman@0
|
389 Bloodhound2.HideExtraCircles();
|
only1yzerman@0
|
390 return fx, fy;
|
only1yzerman@0
|
391 end
|
only1yzerman@0
|
392
|
only1yzerman@0
|
393
|
only1yzerman@0
|
394
|
only1yzerman@0
|
395
|
only1yzerman@0
|
396
|
only1yzerman@0
|
397
|
only1yzerman@0
|
398
|
only1yzerman@0
|
399 ----------------------------------------------------------------------------------------------------
|
only1yzerman@0
|
400 -------- REPARENT THE MINIMAP FOR 3RD PARTY MINIMAPS AND HUDS
|
only1yzerman@0
|
401 -------- - Added by Zasurus(www.curseforge.com/profiles/Zasurus/) for MiniHugeHUD
|
only1yzerman@0
|
402 ----------------------------------------------------------------------------------------------------
|
only1yzerman@0
|
403 function Bloodhound2.ReparentMinimap(NewMinimap, MinimapName)
|
only1yzerman@0
|
404 Bloodhound2.OnUpdateScript(nil, 1000000)
|
only1yzerman@0
|
405 -- Hide the circles currently on the minimap
|
only1yzerman@0
|
406 Bloodhound2.ResetCircles();
|
only1yzerman@0
|
407 Bloodhound2.HideExtraCircles();
|
only1yzerman@0
|
408 -- Hide this minimap's copy of the arrow
|
only1yzerman@0
|
409 if Bloodhound2.GravityTexture then
|
only1yzerman@0
|
410 Bloodhound2.GravityTexture:Hide();
|
only1yzerman@0
|
411 end;
|
only1yzerman@0
|
412 -- Store the current set of circles and arrow on this minimap for later
|
only1yzerman@0
|
413 Minimap.Bloodhound2Circles = circles;
|
only1yzerman@0
|
414 Minimap.Bloodhound2Arrow = Bloodhound2.GravityTexture;
|
only1yzerman@0
|
415 -- Pull back (or create for circles) the arrow and circles for this minimap
|
only1yzerman@0
|
416 circles = NewMinimap.Bloodhound2Circles or {};
|
only1yzerman@0
|
417 ZasCircles = circles;
|
only1yzerman@0
|
418 Bloodhound2.GravityTexture = NewMinimap.Bloodhound2Arrow;
|
only1yzerman@0
|
419 -- Move Bloodhound2's Local Minimap pointer to the new minimap
|
only1yzerman@0
|
420 Minimap = NewMinimap;
|
only1yzerman@0
|
421 Minimap.MinimapName = MinimapName;
|
only1yzerman@0
|
422 -- Update all points
|
only1yzerman@0
|
423 Bloodhound2.UpdateMinimap();
|
only1yzerman@0
|
424 end
|
only1yzerman@0
|
425 ---------------------------------------------------------------------------------------------------- |