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