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@3
|
7 --Doesn't work in 1021 (Broken Shore)
|
mischivin@3
|
8 WM_validIDs = { [1014] = true, [1015] = true, [1017] = true, [1018] = true, [1021] = false, [1024] = true, [1033] = true, [1096] = true }
|
mischivin@0
|
9
|
mischivin@0
|
10 local WhistleLoc = CreateFrame("FRAME", "WhistleLOC", WorldMapPOIFrame)
|
mischivin@0
|
11 WhistleLoc:SetSize(64, 64)
|
mischivin@0
|
12 WhistleLoc:SetPoint("CENTER", 0, 0)
|
mischivin@0
|
13 WhistleLoc:Show()
|
mischivin@0
|
14
|
mischivin@3
|
15 WM_ClosestNode = nil
|
mischivin@3
|
16
|
mischivin@0
|
17 local function GetDistance(nX, nY)
|
mischivin@0
|
18 local pX, pY = GetPlayerMapPosition("player")
|
mischivin@21
|
19 local dX, dY
|
mischivin@21
|
20 if pX and pY then
|
mischivin@21
|
21 dX = pX - nX
|
mischivin@21
|
22 dY = pY - nY
|
mischivin@21
|
23 else
|
mischivin@21
|
24 return nil
|
mischivin@21
|
25 end
|
mischivin@0
|
26
|
mischivin@0
|
27 return math.sqrt( ( dX^2 ) + ( dY^2 ) )
|
mischivin@0
|
28 end
|
mischivin@0
|
29
|
mischivin@0
|
30 local function GetNode()
|
mischivin@0
|
31 local node
|
mischivin@0
|
32 local distance
|
mischivin@0
|
33 local index
|
mischivin@0
|
34 for k = 1, GetNumMapLandmarks() do
|
mischivin@0
|
35 local n = {}
|
mischivin@0
|
36 n.type, n.name, n.description, n.textureIndex, n.x, n.y = GetMapLandmarkInfo(k)
|
mischivin@0
|
37 if n.type == LE_MAP_LANDMARK_TYPE_TAXINODE then --LE_MAP_LANDMARK_TYPE_TAXINODE is a constant defined by Blizzard
|
mischivin@0
|
38 local d = GetDistance(n.x, n.y)
|
mischivin@0
|
39 if distance == nil or d < distance then
|
mischivin@0
|
40 n.index = k
|
mischivin@0
|
41 distance = d
|
mischivin@0
|
42 node = n
|
mischivin@0
|
43 end
|
mischivin@0
|
44 end
|
mischivin@0
|
45 end
|
mischivin@0
|
46 return node
|
mischivin@0
|
47 end
|
mischivin@0
|
48
|
mischivin@9
|
49 function UpdateWhistleMaster()
|
mischivin@9
|
50 if GetCurrentMapContinent() == 8 and WM_validIDs[ select(1, GetCurrentMapAreaID() ) ] and GetMapNameByID(GetCurrentMapAreaID()) == GetZoneText() and not GetNumDungeonMapLevels() then
|
mischivin@3
|
51 WM_ClosestNode = GetNode()
|
mischivin@21
|
52 if _G[("WorldMapFramePOI" .. WM_ClosestNode.index)] then
|
mischivin@21
|
53 WhistleLoc:SetPoint("CENTER", "WorldMapFramePOI" .. WM_ClosestNode.index, 0, 0)
|
mischivin@21
|
54 WhistleLoc:Show()
|
mischivin@21
|
55 WhistlePing.Ping:Play()
|
mischivin@21
|
56 return true
|
mischivin@21
|
57 else
|
mischivin@21
|
58 return false
|
mischivin@21
|
59 end
|
mischivin@0
|
60 else
|
mischivin@0
|
61 WhistleLoc:Hide()
|
mischivin@0
|
62 WhistlePing.Ping:Stop()
|
mischivin@3
|
63 return false
|
mischivin@0
|
64 end
|
mischivin@0
|
65 end
|
mischivin@0
|
66
|
mischivin@0
|
67 local mapVisible = false
|
mischivin@0
|
68
|
mischivin@0
|
69 local function EventHandler(self, event, ...)
|
mischivin@0
|
70 if ( (event == "WORLD_MAP_UPDATE") and WorldMapFrame:IsVisible() ) then
|
mischivin@0
|
71 mapVisible = true
|
mischivin@0
|
72 UpdateWhistleMaster()
|
mischivin@0
|
73 end
|
mischivin@0
|
74 if ( (mapVisible) and not WorldMapFrame:IsVisible() ) then
|
mischivin@0
|
75 mapVisible = false
|
mischivin@0
|
76 end
|
mischivin@12
|
77 if (event == "PLAYER_ENTERING_WORLD") then
|
mischivin@5
|
78 WorldMapFrame:Show()
|
mischivin@5
|
79 WorldMapFrame:Hide()
|
mischivin@3
|
80 UpdateWhistleMaster()
|
mischivin@3
|
81 end
|
mischivin@0
|
82 end
|
mischivin@0
|
83
|
mischivin@0
|
84 local WhistleMaster = CreateFrame("FRAME", "WhistleMaster", WorldMapPOIFrame)
|
mischivin@0
|
85 WhistleMaster:RegisterEvent("WORLD_MAP_UPDATE")
|
mischivin@3
|
86 WhistleMaster:RegisterEvent("VARIABLES_LOADED")
|
mischivin@12
|
87 WhistleMaster:RegisterEvent("PLAYER_ENTERING_WORLD")
|
mischivin@0
|
88 WhistleMaster:SetScript("OnEvent", EventHandler)
|
mischivin@0
|
89
|
mischivin@3
|
90 local cleared = true
|
mischivin@3
|
91 local function OnTooltipCleared(self)
|
mischivin@3
|
92 cleared = true
|
mischivin@3
|
93 end
|
mischivin@3
|
94
|
mischivin@3
|
95 local function OnTooltipSetItem(self)
|
mischivin@3
|
96 if cleared then
|
mischivin@3
|
97 local name, tooltipLink = self:GetItem()
|
mischivin@3
|
98 if tooltipLink then
|
mischivin@3
|
99 local item = tooltipLink:match("Hitem:(%d+)")
|
mischivin@3
|
100 if item == "141605" then
|
mischivin@3
|
101 if UpdateWhistleMaster() then
|
mischivin@3
|
102 self:AddLine("\nWhistle Destination:|cFFFFFFFF " .. WM_ClosestNode.name ,0.5,1,0.5, true)
|
mischivin@3
|
103 else
|
mischivin@3
|
104 self:AddLine("\nWhistle Destination:|cFFFFFFFF N/A",0.5,1,0.5, true)
|
mischivin@3
|
105 end
|
mischivin@3
|
106 end
|
mischivin@3
|
107 cleared = true
|
mischivin@3
|
108 end
|
mischivin@3
|
109 end
|
mischivin@3
|
110 end
|
mischivin@3
|
111
|
mischivin@3
|
112 GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@3
|
113 GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@12
|
114 ItemRefTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@12
|
115 ItemRefTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@3
|
116
|