vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Name: Tourist-2.0
3 Revision: $Rev: 10004 $
4 Author(s): ckknight (ckknight@gmail.com)
5 Website: http://ckknight.wowinterface.com/
6 Documentation: http://wiki.wowace.com/index.php/Tourist-2.0
7 SVN: http://svn.wowace.com/root/trunk/TouristLib/Tourist-2.0
8 Description: A library to provide information about zones and instances.
9 Dependencies: AceLibrary, Babble-Zone-2.0, AceConsole-2.0 (optional)
10 ]]
11  
12 local MAJOR_VERSION = "Tourist-2.0"
13 local MINOR_VERSION = "$Revision: 10004 $"
14  
15 if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
16 if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
17  
18 if not AceLibrary:HasInstance("Babble-Zone-2.0") then error(MAJOR_VERSION .. " requires Babble-Zone-2.0") end
19  
20 local Tourist = {}
21 local events = {}
22  
23 local Z = AceLibrary("Babble-Zone-2.0")
24  
25 local playerLevel = 1
26 local _,race = UnitRace("player")
27 local isHorde = (race == "Orc" or race == "Troll" or race == "Tauren" or race == "Scourge")
28  
29 function events:PLAYER_LEVEL_UP()
30 playerLevel = UnitLevel("player")
31 for k in pairs(self.recZones) do
32 self.recZones[k] = nil
33 end
34 for k in pairs(self.recInstances) do
35 self.recInstances[k] = nil
36 end
37 for zone in self.lowZones do
38 if not self:IsHostile(zone) then
39 local low, high = self:GetLevel(zone)
40 if not self:IsInstance(zone) then
41 if low <= playerLevel and playerLevel <= high then
42 self.recZones[zone] = true
43 end
44 elseif self:IsBattleground(zone) then
45 if playerLevel >= low and (playerLevel == 60 or math.mod(playerLevel, 10) >= 6) then
46 self.recInstances[zone] = true
47 end
48 else
49 if low <= playerLevel and playerLevel <= high then
50 self.recInstances[zone] = true
51 end
52 end
53 end
54 end
55 end
56  
57 events.PLAYER_ENTERING_WORLD = events.PLAYER_LEVEL_UP
58  
59 function Tourist:GetLevel(zone)
60 self:argCheck(zone, 2, "string")
61 if self:IsBattleground(zone) then
62 if zone == Z["Alterac Valley"] then
63 return 51, 60
64 elseif playerLevel == 60 then
65 return 60, 60
66 elseif playerLevel >= 50 then
67 return 50, 59
68 elseif playerLevel >= 40 then
69 return 40, 49
70 elseif playerLevel >= 30 then
71 return 30, 39
72 elseif playerLevel >= 20 or zone == Z["Arathi Basin"] then
73 return 20, 29
74 else
75 return 10, 19
76 end
77 end
78 return self.lowZones[zone] or -6, self.highZones[zone] or -6
79 end
80  
81 function Tourist:GetLevelColor(zone)
82 self:argCheck(zone, 2, "string")
83 if self:IsBattleground(zone) then
84 if (playerLevel < 51 and zone == Z["Alterac Valley"]) or (playerLevel < 20 and zone == Z["Arathi Basin"]) or (playerLevel < 10 and zone == Z["Warsong Gulch"]) then
85 return 1, 0, 0
86 end
87 local playerLevel = playerLevel
88 if zone == Z["Alterac Valley"] then
89 playerLevel = playerLevel - 1
90 end
91 if playerLevel == 60 then
92 return 1, 1, 0
93 end
94 playerLevel = math.mod(playerLevel, 10)
95 if playerLevel <= 5 then
96 return 1, playerLevel / 10, 0
97 elseif playerLevel <= 7 then
98 return 1, (playerLevel - 3) / 4, 0
99 else
100 return (9 - playerLevel) / 2, 1, 0
101 end
102 end
103 local low, high = self:GetLevel(zone)
104  
105 if playerLevel <= low - 3 then
106 return 1, 0, 0
107 elseif playerLevel <= low then
108 return 1, (playerLevel - low - 3) / -6, 0
109 elseif playerLevel <= (low + high) / 2 then
110 return 1, (playerLevel - low) / (high - low) + 0.5, 0
111 elseif playerLevel <= high then
112 return 2 * (playerLevel - high) / (low - high), 1, 0
113 elseif playerLevel <= high + 3 then
114 local num = (playerLevel - high) / 6
115 return num, 1 - num, num
116 else
117 return 0.5, 0.5, 0.5
118 end
119 end
120  
121 function Tourist:GetFactionColor(zone)
122 self:argCheck(zone, 2, "string")
123 if self:IsAlliance(zone) then
124 if not isHorde then
125 return 0, 1, 0
126 else
127 return 1, 0, 0
128 end
129 elseif self:IsHorde(zone) then
130 if isHorde then
131 return 0, 1, 0
132 else
133 return 1, 0, 0
134 end
135 else
136 return 1, 1, 0
137 end
138 end
139  
140 local retNil = function() end
141 local retOne = function(zone, state)
142 if state ~= nil then
143 return
144 else
145 return zone
146 end
147 end
148  
149 local function iterZoneInstances(zone, position)
150 local k = next(zone, position)
151 return k
152 end
153  
154 function Tourist:IterateZoneInstances(zone)
155 self:argCheck(zone, 2, "string")
156 if type(self.zoneInstances[zone]) == nil then
157 return retNil, nil, nil
158 elseif type(self.zoneInstances[zone]) == "table" then
159 return iterZoneInstances, self.zoneInstances[zone], nil
160 else
161 return retOne, self.zoneInstances[zone], nil
162 end
163 end
164  
165 function Tourist:DoesZoneHaveInstances(zone)
166 self:argCheck(zone, 2, "string")
167 return self.zoneInstances[zone] ~= nil
168 end
169  
170 local zonesInstances
171 local function initZonesInstances()
172 if not zonesInstances then
173 zonesInstances = {}
174 for zone in pairs(self.lowZones) do
175 zonesInstances[zone] = true
176 end
177 end
178 initZonesInstances = nil
179 end
180  
181 local function zoneInstanceIter(_, position)
182 local k = next(zonesInstances, position)
183 return k
184 end
185 function Tourist:IterateZonesAndInstances()
186 if initZonesInstances then
187 initZonesInstances()
188 end
189 return zoneInstanceIter, nil, nil
190 end
191  
192 local function zoneIter(_, position)
193 local k = next(zonesInstances, position)
194 while k ~= nil and self:IsInstance(k) do
195 k = next(zonesInstances, k)
196 end
197 return k
198 end
199 function Tourist:IterateZones()
200 if initZonesInstances then
201 initZonesInstances()
202 end
203 return zoneIter, nil, nil
204 end
205  
206 local function instanceIter(_, position)
207 local k = next(zonesInstances, position)
208 while k ~= nil and not self:IsInstance(k) do
209 k = next(zonesInstances, k)
210 end
211 return k
212 end
213 function Tourist:IterateInstances()
214 if initZonesInstances then
215 initZonesInstances()
216 end
217 return instanceIter, nil, nil
218 end
219  
220 local function bgIter(_, position)
221 local k = next(zonesInstances, position)
222 while k ~= nil and not self:IsBattleground(k) do
223 k = next(zonesInstances, k)
224 end
225 return k
226 end
227 function Tourist:IterateBattlegrounds()
228 if initZonesInstances then
229 initZonesInstances()
230 end
231 return bgIter, nil, nil
232 end
233  
234 local function allianceIter(_, position)
235 local k = next(zonesInstances, position)
236 while k ~= nil and not self:IsAlliance(k) do
237 k = next(zonesInstances, k)
238 end
239 return k
240 end
241 function Tourist:IterateAlliance()
242 if initZonesInstances then
243 initZonesInstances()
244 end
245 return allianceIter, nil, nil
246 end
247  
248 local function hordeIter(_, position)
249 local k = next(zonesInstances, position)
250 while k ~= nil and not self:IsHorde(k) do
251 k = next(zonesInstances, k)
252 end
253 return k
254 end
255 function Tourist:IterateHorde()
256 if initZonesInstances then
257 initZonesInstances()
258 end
259 return hordeIter, nil, nil
260 end
261  
262 function Tourist:IterateFriendly()
263 if isHorde then
264 return self:IterateHordeZonesInstances()
265 else
266 return self:IterateAllianceZonesInstances()
267 end
268 end
269  
270 function Tourist:IterateHostile()
271 if isHorde then
272 return self:IterateAllianceZonesInstances()
273 else
274 return self:IterateHordeZonesInstances()
275 end
276 end
277  
278 local function contestedIter(_, position)
279 local k = next(zonesInstances, position)
280 while k ~= nil and (self:IsAlliance(k) or self:IsHorde(k)) do
281 k = next(zonesInstances, k)
282 end
283 return k
284 end
285 function Tourist:IterateContested()
286 if initZonesInstances then
287 initZonesInstances()
288 end
289 return contestedIter, nil, nil
290 end
291  
292 local function recZoneIter(recZones, position)
293 local k = next(recZones, position)
294 return k
295 end
296 function Tourist:IterateRecommendedZones()
297 return recZoneIter, self.recZones, nil
298 end
299  
300 function Tourist:IterateRecommendedInstances()
301 return recZoneIter, self.recInstances, nil
302 end
303  
304 function Tourist:HasRecommendedInstances()
305 return next(self.recInstances) ~= nil
306 end
307  
308 function Tourist:IsInstance(zone)
309 self:argCheck(zone, 2, "string")
310 return self.instances[zone] ~= nil
311 end
312  
313 function Tourist:IsZone(zone)
314 self:argCheck(zone, 2, "string")
315 return self.instances[zone] == nil and not self.lowZones[zone] ~= nil
316 end
317  
318 function Tourist:IsZoneOrInstance(zone)
319 self:argCheck(zone, 2, "string")
320 return self.lowZones[zone] ~= nil
321 end
322  
323 function Tourist:IsBattleground(zone)
324 self:argCheck(zone, 2, "string")
325 return zone == Z["Warsong Gulch"] or zone == Z["Arathi Basin"] or zone == Z["Alterac Valley"]
326 end
327  
328 function Tourist:IsAlliance(zone)
329 self:argCheck(zone, 2, "string")
330 return zone == Z["Ironforge"] or zone == Z["Stormwind City"] or zone == Z["Dun Morogh"] or zone == Z["Elwynn Forest"] or zone == Z["Loch Modan"] or zone == Z["Westfall"] or zone == Z["Darnassus"] or zone == Z["Teldrassil"] or zone == Z["Darkshore"] or zone == Z["The Stockade"] or zone == Z["Gnomeregan"] or zone == Z["The Deadmines"]
331 end
332  
333 function Tourist:IsHorde(zone)
334 self:argCheck(zone, 2, "string")
335 return zone == Z["Undercity"] or zone == Z["Orgrimmar"] or zone == Z["Thunder Bluff"] or zone == Z["Tirisfal Glades"] or zone == Z["Silverpine Forest"] or zone == Z["Durotar"] or zone == Z["Mulgore"] or zone == Z["The Barrens"] or zone == Z["Ragefire Chasm"] or zone == Z["Shadowfang Keep"] or zone == Z["Wailing Caverns"]
336 end
337  
338 function Tourist:IsFriendly(zone)
339 self:argCheck(zone, 2, "string")
340 if isHorde then
341 return self:IsHorde(zone)
342 else
343 return self:IsAlliance(zone)
344 end
345 end
346  
347 function Tourist:IsHostile(zone)
348 self:argCheck(zone, 2, "string")
349 if isHorde then
350 return self:IsAlliance(zone)
351 else
352 return self:IsHorde(zone)
353 end
354 end
355  
356 function Tourist:IsContested(zone)
357 self:argCheck(zone, 2, "string")
358 return not self:IsAlliance(zone) and not self:IsHorde(zone)
359 end
360  
361 local function activate(self, oldLib, oldDeactivate)
362 if oldLib then
363 self.frame = oldLib.frame
364 self.frame:UnregisterAllEvents()
365 self.lowZones = oldLib.lowZones
366 self.highZones = oldLib.highZones
367 self.zoneInstances = oldLib.zoneInstances
368 self.instances = oldLib.instances
369 self.recZones = oldLib.recZones
370 self.recInstances = oldLib.recInstances
371 for k in pairs(self.lowZones) do
372 self.lowZones[k] = nil
373 end
374 for k in pairs(self.highZones) do
375 self.highZones[k] = nil
376 end
377 for k in pairs(self.zoneInstances) do
378 self.zoneInstances[k] = nil
379 end
380 for k in pairs(self.instances) do
381 self.instances[k] = nil
382 end
383 else
384 self.frame = CreateFrame("Frame", "TouristLibFrame", UIParent)
385 self.lowZones = {}
386 self.highZones = {}
387 self.zoneInstances = {}
388 self.instances = {}
389 self.recZones = {}
390 self.recInstances = {}
391 end
392 self.frame:RegisterEvent("PLAYER_LEVEL_UP")
393 self.frame:RegisterEvent("PLAYER_ENTERING_WORLD")
394 self.frame:SetScript("OnEvent", function()
395 events[event](self)
396 end)
397 -- Eastern Kingdoms
398 self.lowZones[Z["Booty Bay"]] = -6
399 self.highZones[Z["Booty Bay"]] = -6
400 self.lowZones[Z["Deeprun Tram"]] = -6
401 self.highZones[Z["Deeprun Tram"]] = -6
402 self.lowZones[Z["Ironforge"]] = -6
403 self.highZones[Z["Ironforge"]] = -6
404 self.lowZones[Z["Stormwind City"]] = -6
405 self.highZones[Z["Stormwind City"]] = -6
406 self.lowZones[Z["Elwynn Forest"]] = 1
407 self.highZones[Z["Elwynn Forest"]] = 10
408 self.lowZones[Z["Dun Morogh"]] = 1
409 self.highZones[Z["Dun Morogh"]] = 10
410 self.lowZones[Z["Tirisfal Glades"]] = 1
411 self.highZones[Z["Tirisfal Glades"]] = 10
412 self.lowZones[Z["Loch Modan"]] = 10
413 self.highZones[Z["Loch Modan"]] = 20
414 self.lowZones[Z["Silverpine Forest"]] = 10
415 self.highZones[Z["Silverpine Forest"]] = 20
416 self.lowZones[Z["Westfall"]] = 10
417 self.highZones[Z["Westfall"]] = 20
418 self.lowZones[Z["Redridge Mountains"]] = 15
419 self.highZones[Z["Redridge Mountains"]] = 25
420 self.lowZones[Z["Duskwood"]] = 18
421 self.highZones[Z["Duskwood"]] = 30
422 self.lowZones[Z["Hillsbrad Foothills"]] = 20
423 self.highZones[Z["Hillsbrad Foothills"]] = 30
424 self.lowZones[Z["Wetlands"]] = 20
425 self.highZones[Z["Wetlands"]] = 30
426 self.lowZones[Z["Alterac Mountains"]] = 30
427 self.highZones[Z["Alterac Mountains"]] = 40
428 self.lowZones[Z["Arathi Highlands"]] = 30
429 self.highZones[Z["Arathi Highlands"]] = 40
430 self.lowZones[Z["Stranglethorn Vale"]] = 30
431 self.highZones[Z["Stranglethorn Vale"]] = 45
432 self.lowZones[Z["Badlands"]] = 35
433 self.highZones[Z["Badlands"]] = 45
434 self.lowZones[Z["Swamp of Sorrows"]] = 35
435 self.highZones[Z["Swamp of Sorrows"]] = 45
436 self.lowZones[Z["Deadwind Pass"]] = 37
437 self.highZones[Z["Deadwind Pass"]] = 60
438 self.lowZones[Z["The Hinterlands"]] = 40
439 self.highZones[Z["The Hinterlands"]] = 50
440 self.lowZones[Z["Searing Gorge"]] = 43
441 self.highZones[Z["Searing Gorge"]] = 50
442 self.lowZones[Z["Blasted Lands"]] = 45
443 self.highZones[Z["Blasted Lands"]] = 55
444 self.lowZones[Z["Burning Steppes"]] = 50
445 self.highZones[Z["Burning Steppes"]] = 58
446 self.lowZones[Z["Western Plaguelands"]] = 51
447 self.highZones[Z["Western Plaguelands"]] = 58
448 self.lowZones[Z["Eastern Plaguelands"]] = 53
449 self.highZones[Z["Eastern Plaguelands"]] = 60
450  
451 -- Kalimdor
452 self.lowZones[Z["Ratchet"]] = -6
453 self.highZones[Z["Ratchet"]] = -6
454 self.lowZones[Z["Gadgetzan"]] = -6
455 self.highZones[Z["Gadgetzan"]] = -6
456 self.lowZones[Z["Orgrimmar"]] = -6
457 self.highZones[Z["Orgrimmar"]] = -6
458 self.lowZones[Z["Thunder Bluff"]] = -6
459 self.highZones[Z["Thunder Bluff"]] = -6
460 self.lowZones[Z["Undercity"]] = -6
461 self.highZones[Z["Undercity"]] = -6
462 self.lowZones[Z["Durotar"]] = 1
463 self.highZones[Z["Durotar"]] = 10
464 self.lowZones[Z["Mulgore"]] = 1
465 self.highZones[Z["Mulgore"]] = 10
466 self.lowZones[Z["Darkshore"]] = 10
467 self.highZones[Z["Darkshore"]] = 20
468 self.lowZones[Z["The Barrens"]] = 10
469 self.highZones[Z["The Barrens"]] = 25
470 self.lowZones[Z["Stonetalon Mountains"]] = 15
471 self.highZones[Z["Stonetalon Mountains"]] = 27
472 self.lowZones[Z["Ashenvale"]] = 18
473 self.highZones[Z["Ashenvale"]] = 30
474 self.lowZones[Z["Thousand Needles"]] = 25
475 self.highZones[Z["Thousand Needles"]] = 35
476 self.lowZones[Z["Desolace"]] = 30
477 self.highZones[Z["Desolace"]] = 40
478 self.lowZones[Z["Dustwallow Marsh"]] = 35
479 self.highZones[Z["Dustwallow Marsh"]] = 45
480 self.lowZones[Z["Feralas"]] = 40
481 self.highZones[Z["Feralas"]] = 50
482 self.lowZones[Z["Tanaris"]] = 40
483 self.highZones[Z["Tanaris"]] = 50
484 self.lowZones[Z["Azshara"]] = 45
485 self.highZones[Z["Azshara"]] = 55
486 self.lowZones[Z["Felwood"]] = 48
487 self.highZones[Z["Felwood"]] = 55
488 self.lowZones[Z["Un'Goro Crater"]] = 48
489 self.highZones[Z["Un'Goro Crater"]] = 55
490 self.lowZones[Z["Silithus"]] = 55
491 self.highZones[Z["Silithus"]] = 60
492 self.lowZones[Z["Winterspring"]] = 55
493 self.highZones[Z["Winterspring"]] = 60
494 self.lowZones[Z["Hyjal"]] = 60
495 self.highZones[Z["Hyjal"]] = 60
496 self.lowZones[Z["Moonglade"]] = -6
497 self.highZones[Z["Moonglade"]] = -6
498 self.lowZones[Z["Darnassus"]] = -6
499 self.highZones[Z["Darnassus"]] = -6
500 self.lowZones[Z["Teldrassil"]] = 1
501 self.highZones[Z["Teldrassil"]] = 10
502  
503 -- Battlegrounds (Tiered)
504 self.lowZones[Z["Alterac Valley"]] = -6
505 self.highZones[Z["Alterac Valley"]] = -6
506 self.lowZones[Z["Warsong Gulch"]] = -6
507 self.highZones[Z["Warsong Gulch"]] = -6
508 self.lowZones[Z["Arathi Basin"]] = -6
509 self.highZones[Z["Arathi Basin"]] = -6
510  
511 -- Instances
512 if GetLocale() == "enUS" then
513 self.lowZones[Z["The Stockade"]] = 24
514 self.highZones[Z["The Stockade"]] = 32
515 self.lowZones[Z["Ragefire Chasm"]] = 13
516 self.highZones[Z["Ragefire Chasm"]] = 18
517 self.lowZones[Z["Zul'Farrak"]] = 44
518 self.highZones[Z["Zul'Farrak"]] = 54
519 self.lowZones[Z["The Deadmines"]] = 17
520 self.highZones[Z["The Deadmines"]] = 26
521 self.lowZones[Z["Wailing Caverns"]] = 17
522 self.highZones[Z["Wailing Caverns"]] = 24
523 self.lowZones[Z["Gnomeregan"]] = 29
524 self.highZones[Z["Gnomeregan"]] = 38
525 self.lowZones[Z["Razorfen Kraul"]] = 29
526 self.highZones[Z["Razorfen Kraul"]] = 38
527 self.lowZones[Z["Blackfathom Deeps"]] = 24
528 self.highZones[Z["Blackfathom Deeps"]] = 32
529 self.lowZones[Z["Shadowfang Keep"]] = 22
530 self.highZones[Z["Shadowfang Keep"]] = 30
531 self.lowZones[Z["Scarlet Monastery"]] = 34
532 self.highZones[Z["Scarlet Monastery"]] = 45
533 self.lowZones[Z["Uldaman"]] = 41
534 self.highZones[Z["Uldaman"]] = 51
535 self.lowZones[Z["Razorfen Downs"]] = 37
536 self.highZones[Z["Razorfen Downs"]] = 46
537 self.lowZones[Z["Maraudon"]] = 46
538 self.highZones[Z["Maraudon"]] = 55
539 self.lowZones[Z["Onyxia's Lair"]] = 60
540 self.highZones[Z["Onyxia's Lair"]] = 62
541 self.lowZones[Z["Blackrock Mountain"]] = 42
542 self.highZones[Z["Blackrock Mountain"]] = 54
543 self.lowZones[Z["Caverns of Time"]] = 43
544 self.highZones[Z["Caverns of Time"]] = 61
545 self.lowZones[Z["The Temple of Atal'Hakkar"]] = 50
546 self.highZones[Z["The Temple of Atal'Hakkar"]] = 60
547 self.lowZones[Z["Dire Maul"]] = 56
548 self.highZones[Z["Dire Maul"]] = 60
549 self.lowZones[Z["Blackrock Depths"]] = 52
550 self.highZones[Z["Blackrock Depths"]] = 60
551 self.lowZones[Z["Blackrock Spire"]] = 55
552 self.highZones[Z["Blackrock Spire"]] = 60
553 self.lowZones[Z["Stratholme"]] = 58
554 self.highZones[Z["Stratholme"]] = 60
555 self.lowZones[Z["Molten Core"]] = 60
556 self.highZones[Z["Molten Core"]] = 62
557 self.lowZones[Z["Scholomance"]] = 58
558 self.highZones[Z["Scholomance"]] = 60
559 self.lowZones[Z["Blackwing Lair"]] = 60
560 self.highZones[Z["Blackwing Lair"]] = 62
561 self.lowZones[Z["Zul'Gurub"]] = 60
562 self.highZones[Z["Zul'Gurub"]] = 62
563 self.lowZones[Z["Ruins of Ahn'Qiraj"]] = 60
564 self.highZones[Z["Ruins of Ahn'Qiraj"]] = 65
565 self.lowZones[Z["Temple of Ahn'Qiraj"]] = 60
566 self.highZones[Z["Temple of Ahn'Qiraj"]] = 65
567 self.lowZones[Z["Naxxramas"]] = 60
568 self.highZones[Z["Naxxramas"]] = 70
569 else
570 self.lowZones[Z["The Stockade"]] = 23
571 self.highZones[Z["The Stockade"]] = 26
572 self.lowZones[Z["Ragefire Chasm"]] = 13
573 self.highZones[Z["Ragefire Chasm"]] = 15
574 self.lowZones[Z["Zul'Farrak"]] = 43
575 self.highZones[Z["Zul'Farrak"]] = 47
576 self.lowZones[Z["The Deadmines"]] = 15
577 self.highZones[Z["The Deadmines"]] = 20
578 self.lowZones[Z["Wailing Caverns"]] = 15
579 self.highZones[Z["Wailing Caverns"]] = 21
580 self.lowZones[Z["Gnomeregan"]] = 24
581 self.highZones[Z["Gnomeregan"]] = 33
582 self.lowZones[Z["Razorfen Kraul"]] = 25
583 self.highZones[Z["Razorfen Kraul"]] = 35
584 self.lowZones[Z["Blackfathom Deeps"]] = 20
585 self.highZones[Z["Blackfathom Deeps"]] = 27
586 self.lowZones[Z["Shadowfang Keep"]] = 18
587 self.highZones[Z["Shadowfang Keep"]] = 25
588 self.lowZones[Z["Scarlet Monastery"]] = 30
589 self.highZones[Z["Scarlet Monastery"]] = 40
590 self.lowZones[Z["Uldaman"]] = 35
591 self.highZones[Z["Uldaman"]] = 45
592 self.lowZones[Z["Razorfen Downs"]] = 35
593 self.highZones[Z["Razorfen Downs"]] = 40
594 self.lowZones[Z["Maraudon"]] = 40
595 self.highZones[Z["Maraudon"]] = 49
596 self.lowZones[Z["Onyxia's Lair"]] = 60
597 self.highZones[Z["Onyxia's Lair"]] = 62
598 self.lowZones[Z["Blackrock Mountain"]] = 42
599 self.highZones[Z["Blackrock Mountain"]] = 54
600 self.lowZones[Z["Caverns of Time"]] = -6
601 self.highZones[Z["Caverns of Time"]] = -6
602 self.lowZones[Z["The Temple of Atal'Hakkar"]] = 44
603 self.highZones[Z["The Temple of Atal'Hakkar"]] = 50
604 self.lowZones[Z["Dire Maul"]] = 56
605 self.highZones[Z["Dire Maul"]] = 60
606 self.lowZones[Z["Blackrock Depths"]] = 48
607 self.highZones[Z["Blackrock Depths"]] = 56
608 self.lowZones[Z["Blackrock Spire"]] = 53
609 self.highZones[Z["Blackrock Spire"]] = 60
610 self.lowZones[Z["Stratholme"]] = 55
611 self.highZones[Z["Stratholme"]] = 60
612 self.lowZones[Z["Molten Core"]] = 60
613 self.highZones[Z["Molten Core"]] = 62
614 self.lowZones[Z["Scholomance"]] = 56
615 self.highZones[Z["Scholomance"]] = 60
616 self.lowZones[Z["Blackwing Lair"]] = 60
617 self.highZones[Z["Blackwing Lair"]] = 62
618 self.lowZones[Z["Zul'Gurub"]] = 60
619 self.highZones[Z["Zul'Gurub"]] = 62
620 self.lowZones[Z["Ruins of Ahn'Qiraj"]] = 60
621 self.highZones[Z["Ruins of Ahn'Qiraj"]] = 65
622 self.lowZones[Z["Temple of Ahn'Qiraj"]] = 60
623 self.highZones[Z["Temple of Ahn'Qiraj"]] = 65
624 self.lowZones[Z["Naxxramas"]] = 60
625 self.highZones[Z["Naxxramas"]] = 70
626 end
627  
628 self.zoneInstances[Z["Stormwind City"]] = Z["The Stockade"]
629 self.zoneInstances[Z["Elwynn Forest"]] = self.zoneInstances[Z["Stormwind City"]]
630 self.zoneInstances[Z["Orgrimmar"]] = Z["Ragefire Chasm"]
631 self.zoneInstances[Z["Durotar"]] = self.zoneInstances[Z["Orgrimmar"]]
632 self.zoneInstances[Z["Dun Morogh"]] = Z["Gnomeregan"]
633 self.zoneInstances[Z["Ironforge"]] = self.zoneInstances[Z["Dun Morogh"]]
634 self.zoneInstances[Z["Tirisfal Glades"]] = Z["Scarlet Monastery"]
635 self.zoneInstances[Z["Undercity"]] = self.zoneInstances[Z["Tirisfal Glades"]]
636 self.zoneInstances[Z["Westfall"]] = Z["The Deadmines"]
637 self.zoneInstances[Z["Silverpine Forest"]] = Z["Shadowfang Keep"]
638 self.zoneInstances[Z["Alterac Mountains"]] = Z["Alterac Valley"]
639 self.zoneInstances[Z["Arathi Highlands"]] = Z["Arathi Basin"]
640 self.zoneInstances[Z["Stranglethorn Vale"]] = Z["Zul'Gurub"]
641 self.zoneInstances[Z["Swamp of Sorrows"]] = Z["The Temple of Atal'Hakkar"]
642 self.zoneInstances[Z["Searing Gorge"]] = {
643 [Z["Molten Core"]] = true,
644 [Z["Blackwing Lair"]] = true,
645 [Z["Blackrock Spire"]] = true,
646 [Z["Blackrock Depths"]] = true,
647 }
648 self.zoneInstances[Z["Blackrock Mountain"]] = self.zoneInstances[Z["Searing Gorge"]]
649 self.zoneInstances[Z["Burning Steppes"]] = self.zoneInstances[Z["Searing Gorge"]]
650 self.zoneInstances[Z["Eastern Plaguelands"]] = {
651 [Z["Stratholme"]] = true,
652 [Z["Naxxramas"]] = true
653 }
654 self.zoneInstances[Z["Western Plaguelands"]] = Z["Scholomance"]
655 self.zoneInstances[Z["The Barrens"]] = {
656 [Z["Wailing Caverns"]] = true,
657 [Z["Razorfen Kraul"]] = true,
658 [Z["Razorfen Downs"]] = true
659 }
660 self.zoneInstances[Z["Ashenvale"]] = Z["Blackfathom Deeps"]
661 if UnitFactionGroup("player") == "Horde" then
662 self.zoneInstances[Z["The Barrens"]][Z["Warsong Gulch"]] = true
663 else
664 self.zoneInstances[Z["Ashenvale"]] = {
665 [Z["Blackfathom Deeps"]] = true,
666 [Z["Warsong Gulch"]] = true
667 }
668 end
669 self.zoneInstances[Z["Desolace"]] = Z["Maraudon"]
670 self.zoneInstances[Z["Dustwallow Marsh"]] = Z["Onyxia's Lair"]
671 self.zoneInstances[Z["Feralas"]] = Z["Dire Maul"]
672 self.zoneInstances[Z["Silithus"]] = {
673 [Z["Ruins of Ahn'Qiraj"]] = true,
674 [Z["Temple of Ahn'Qiraj"]] = true
675 }
676 self.zoneInstances[Z["Tanaris"]] = Z["Zul'Farrak"]
677 self.zoneInstances[Z["Badlands"]] = Z["Uldaman"]
678  
679 for _,instances in pairs(self.zoneInstances) do
680 if type(instances) == "table" then
681 for instance in pairs(instances) do
682 self.instances[instance] = true
683 end
684 else
685 self.instances[instances] = true
686 end
687 end
688  
689 events.PLAYER_LEVEL_UP(self)
690  
691 if oldDeactivate then
692 oldDeactivate(oldLib)
693 end
694 end
695  
696 local function external(self, major, instance)
697 if major == "AceConsole-2.0" then
698 local print = print
699 if DEFAULT_CHAT_FRAME then
700 function print(text)
701 DEFAULT_CHAT_FRAME:AddMessage(text)
702 end
703 end
704 instance.RegisterChatCommand(self, { "/tourist", "/touristLib" }, {
705 name = MAJOR_VERSION .. "." .. string.gsub(MINOR_VERSION, ".-(%d+).*", "%1"),
706 desc = "A library to provide information about zones and instances.",
707 type = "group",
708 args = {
709 zone = {
710 name = "Zone",
711 desc = "Get information about a zone",
712 type = "text",
713 usage = "<zone name>",
714 get = false,
715 set = function(text)
716 local type
717 if self:IsBattleground(text) then
718 type = "Battleground"
719 elseif self:IsInstance(text) then
720 type = "Instance"
721 else
722 type = "Zone"
723 end
724 local faction
725 if self:IsAlliance(text) then
726 faction = "Alliance"
727 elseif self:IsHorde(text) then
728 faction = "Horde"
729 else
730 faction = "Contested"
731 end
732 if self:IsHostile(text) then
733 faction = faction .. " (hostile)"
734 elseif self:IsFriendly(text) then
735 faction = faction .. " (friendly)"
736 end
737 local low, high = self:GetLevel(text)
738 print("|cffffff7f" .. text .. "|r")
739 print(" |cffffff7fType: [|r" .. type .. "|cffffff7f]|r")
740 print(" |cffffff7fFaction: [|r" .. faction .. "|cffffff7f]|r")
741 if low ~= -6 and high ~= -6 then
742 print(" |cffffff7fLevels: [|r" .. low .. "-" .. high .. "|cffffff7f]|r")
743 end
744 if self:DoesZoneHaveInstances(text) then
745 print(" |cffffff7fInstances:|r")
746 for instance in self:IterateZoneInstances(text) do
747 local isBG = self:IsBattleground(instance) and " (BG)" or ""
748 local low, high = self:GetLevel(instance)
749 local faction = ""
750 if self:IsAlliance(instance) then
751 faction = " - Alliance"
752 elseif self:IsHorde(instance) then
753 faction = " - Horde"
754 end
755 if self:IsHostile(instance) then
756 faction = faction .. " (hostile)"
757 elseif self:IsFriendly(instance) then
758 faction = faction .. " (friendly)"
759 end
760 print(" " .. instance .. isBG .. " - " .. low .. "-" .. high .. faction)
761 end
762 end
763 end,
764 validate = function(text)
765 return self:IsZoneOrInstance(text)
766 end
767 },
768 recommend = {
769 name = "Recommended Zones",
770 desc = "List recommended zones",
771 type = "execute",
772 func = function()
773 print("|cffffff7fRecomended zones:|r")
774 for zone in self:IterateRecommendedZones() do
775 local low, high = self:GetLevel(zone)
776 local faction = ""
777 if self:IsAlliance(zone) then
778 faction = " - Alliance"
779 elseif self:IsHorde(zone) then
780 faction = " - Horde"
781 end
782 if self:IsHostile(zone) then
783 faction = faction .. " (hostile)"
784 elseif self:IsFriendly(zone) then
785 faction = faction .. " (friendly)"
786 end
787 print(" |cffffff7f" .. zone .. "|r - " .. low .. "-" .. high .. faction)
788 end
789 if self:HasRecommendedInstances() then
790 print("|cffffff7fRecomended instances:|r")
791 for instance in self:IterateRecommendedInstances() do
792 local isBG = self:IsBattleground(instance) and " (BG)" or ""
793 local low, high = self:GetLevel(instance)
794 local faction = ""
795 if self:IsAlliance(instance) then
796 faction = " - Alliance"
797 elseif self:IsHorde(instance) then
798 faction = " - Horde"
799 end
800 if self:IsHostile(instance) then
801 faction = faction .. " (hostile)"
802 elseif self:IsFriendly(instance) then
803 faction = faction .. " (friendly)"
804 end
805 print(" |cffffff7f" .. instance .. "|r" .. isBG .. " - " .. low .. "-" .. high .. faction)
806 end
807 end
808 end
809 }
810 }
811 }, "TOURIST")
812 end
813 end
814  
815 AceLibrary:Register(Tourist, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
816 Tourist = nil