fac8827 - aura updates
[wowui.git] / OmaLog / Logging.lua
1 -- Logging.lua
2 local _;
3 local print = print;
4 local LoggingCombat = LoggingCombat;
5 local GetInstanceInfo = GetInstanceInfo;
6 local CTimerAfter = C_Timer.After;
7 local frame = CreateFrame("Frame", "OmaLogger");
8 frame:Hide();
9
10 local raidIDs = {
11     [2164] = "The Eternal Palace",
12     [2217] = "Ny'alotha",
13     [2296] = "Castle Nathria",
14     [2450] = "Sanctum of Domination",
15 };
16 local dungeonIDs = {
17     [1594] = "The Undermine",
18     [1754] = "Freehold",
19     [1762] = "King's Rest",
20     [1763] = "Atal'Dazar",
21     [1771] = "Tol Dagor",
22     [1822] = "Siege of Boralus",
23     [1841] = "Underrot",
24     [1862] = "Waycrest Manor",
25     [1864] = "Shrine of the Storm",
26     [1877] = "Temple of Sethraliss",
27 };
28
29 local function shouldLog()
30     local _, zoneType, difficulty, _, _, _, _, mapID = GetInstanceInfo();
31     if zoneType == "raid" then print(mapID) end
32     if zoneType == "raid" and raidIDs[mapID] then
33         if difficulty == 17 then -- LFR
34             return false;
35         elseif difficulty == 16 then -- Mythic
36             return true;
37         elseif difficulty == 15 then -- Heroic
38             return true;
39         elseif difficulty == 14 then -- Normal
40             return true;
41         end
42     elseif zoneType == "party" and dungeonIDs[mapID] then
43         if difficulty == 8 or difficulty == 23 then
44             return true;
45         end
46     end
47
48     return false;
49 end
50
51 local prevLogging = nil;
52 local function updateZone()
53     local log = shouldLog();
54     if log then
55         LoggingCombat(true);
56         print("<><><><><><><><><><><>");
57         print("Started Combat Log");
58         print("<><><><><><><><><><><>");
59     elseif prevLogging and LoggingCombat() then
60         print("<><><><><><><><><><><>");
61         print("Ended Combat Log");
62         print("<><><><><><><><><><><>");
63     end
64     prevLogging = log;
65 end
66
67 frame:SetScript("OnEvent", function(self, event)
68     if event == "ZONE_CHANGED_NEW_AREA" or event == "PLAYER_LOGIN" then
69         CTimerAfter(3, updateZone);
70     elseif event == "CHALLENGE_MODE_START" then
71         CTimerAfter(1, updateZone);
72     end
73 end);
74 frame:RegisterEvent("ZONE_CHANGED_NEW_AREA");
75 frame:RegisterEvent("PLAYER_LOGIN");
76 --frame:RegisterEvent("CHALLENGE_MODE_START"); -- for logging M+