mischivin@0
|
1
|
mischivin@0
|
2 function WM_Debug()
|
mischivin@0
|
3 print("debug text")
|
mischivin@0
|
4 end
|
mischivin@0
|
5
|
mischivin@0
|
6 --indexes corrispond to map IDs that contain valid flight points for the Flight Masters Whistle
|
mischivin@0
|
7 local validIDs = { [1014] = true, [1015] = true, [1017] = true, [1018] = true, [1024] = true, [1033] = true, [1096] = true }
|
mischivin@0
|
8
|
mischivin@0
|
9 local WhistleLoc = CreateFrame("FRAME", "WhistleLOC", WorldMapPOIFrame)
|
mischivin@0
|
10 WhistleLoc:SetSize(64, 64)
|
mischivin@0
|
11 WhistleLoc:SetPoint("CENTER", 0, 0)
|
mischivin@0
|
12 WhistleLoc:Show()
|
mischivin@0
|
13
|
mischivin@0
|
14 --[[local Rotate = WhistleLoc:CreateTexture()
|
mischivin@0
|
15 Rotate:SetTexture("Interface\minimap\UI-Minimap-Ping-Rotate")
|
mischivin@0
|
16 Rotate:SetPoint("CENTER")
|
mischivin@0
|
17 Rotate:SetSize(48, 48)
|
mischivin@0
|
18 Rotate:SetVertexColor(0.9, 0.1, 0.1)
|
mischivin@0
|
19
|
mischivin@0
|
20 local Ring = WhistleLoc:CreateTexture()
|
mischivin@0
|
21 Ring:SetTexture("Interface\minimap\UI-Minimap-Ping-Center")
|
mischivin@0
|
22 Ring:SetPoint("CENTER")
|
mischivin@0
|
23 Ring:SetSize(32, 32)
|
mischivin@0
|
24 Ring:SetVertexColor(0.9, 0.1, 0.1)]]
|
mischivin@0
|
25
|
mischivin@0
|
26
|
mischivin@0
|
27
|
mischivin@0
|
28
|
mischivin@0
|
29 local function GetDistance(nX, nY)
|
mischivin@0
|
30 local pX, pY = GetPlayerMapPosition("player")
|
mischivin@0
|
31
|
mischivin@0
|
32 local dX = pX - nX
|
mischivin@0
|
33 local dY = pY - nY
|
mischivin@0
|
34
|
mischivin@0
|
35 return math.sqrt( ( dX^2 ) + ( dY^2 ) )
|
mischivin@0
|
36 end
|
mischivin@0
|
37
|
mischivin@0
|
38 local function GetNode()
|
mischivin@0
|
39 local node
|
mischivin@0
|
40 local distance
|
mischivin@0
|
41 local index
|
mischivin@0
|
42 for k = 1, GetNumMapLandmarks() do
|
mischivin@0
|
43 local n = {}
|
mischivin@0
|
44 n.type, n.name, n.description, n.textureIndex, n.x, n.y = GetMapLandmarkInfo(k)
|
mischivin@0
|
45 if n.type == LE_MAP_LANDMARK_TYPE_TAXINODE then --LE_MAP_LANDMARK_TYPE_TAXINODE is a constant defined by Blizzard
|
mischivin@0
|
46 local d = GetDistance(n.x, n.y)
|
mischivin@0
|
47 if distance == nil or d < distance then
|
mischivin@0
|
48 n.index = k
|
mischivin@0
|
49 distance = d
|
mischivin@0
|
50 node = n
|
mischivin@0
|
51 end
|
mischivin@0
|
52 end
|
mischivin@0
|
53 end
|
mischivin@0
|
54 print("The closest node is... " .. node.name)
|
mischivin@0
|
55 return node
|
mischivin@0
|
56 end
|
mischivin@0
|
57
|
mischivin@0
|
58 local function UpdateWhistleMaster()
|
mischivin@0
|
59 if GetCurrentMapContinent() == 8 and validIDs[ select(1, GetCurrentMapAreaID() ) ] then
|
mischivin@0
|
60 local closest = GetNode()
|
mischivin@0
|
61 WhistleLoc:SetPoint("CENTER", "WorldMapFramePOI" .. closest.index, 0, 0)
|
mischivin@0
|
62 WhistleLoc:Show()
|
mischivin@0
|
63 WhistlePing.Ping:Play()
|
mischivin@0
|
64 else
|
mischivin@0
|
65 WhistleLoc:Hide()
|
mischivin@0
|
66 WhistlePing.Ping:Stop()
|
mischivin@0
|
67 print("wrong continent for whistle master")
|
mischivin@0
|
68 end
|
mischivin@0
|
69 end
|
mischivin@0
|
70
|
mischivin@0
|
71 local mapVisible = false
|
mischivin@0
|
72
|
mischivin@0
|
73 local function EventHandler(self, event, ...)
|
mischivin@0
|
74 if ( (event == "WORLD_MAP_UPDATE") and WorldMapFrame:IsVisible() ) then
|
mischivin@0
|
75 mapVisible = true
|
mischivin@0
|
76 UpdateWhistleMaster()
|
mischivin@0
|
77 end
|
mischivin@0
|
78 if ( (mapVisible) and not WorldMapFrame:IsVisible() ) then
|
mischivin@0
|
79 mapVisible = false
|
mischivin@0
|
80 end
|
mischivin@0
|
81 end
|
mischivin@0
|
82
|
mischivin@0
|
83
|
mischivin@0
|
84
|
mischivin@0
|
85 local WhistleMaster = CreateFrame("FRAME", "WhistleMaster", WorldMapPOIFrame)
|
mischivin@0
|
86 WhistleMaster:RegisterEvent("WORLD_MAP_UPDATE")
|
mischivin@0
|
87 WhistleMaster:SetScript("OnEvent", EventHandler)
|
mischivin@0
|
88
|