a756efe - Ancient Curse TMW
[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     [1861] = "Uldir",
12     [2070] = "Battle of Dazal'Alor",
13     [2096] = "Crucible of Storms",
14     [2164] = "The Eternal Palace",
15     [2217] = "Ny'alotha",
16 };
17 local dungeonIDs = {
18     [1594] = "The Undermine",
19     [1754] = "Freehold",
20     [1762] = "King's Rest",
21     [1763] = "Atal'Dazar",
22     [1771] = "Tol Dagor",
23     [1822] = "Siege of Boralus",
24     [1841] = "Underrot",
25     [1862] = "Waycrest Manor",
26     [1864] = "Shrine of the Storm",
27     [1877] = "Temple of Sethraliss",
28 };
29
30 local function shouldLog()
31     local _, zoneType, difficulty, _, _, _, _, mapID = GetInstanceInfo();
32     if zoneType == "raid" then print(mapID) end
33     if zoneType == "raid" and raidIDs[mapID] then
34         if difficulty == 17 then -- LFR
35             return false;
36         elseif difficulty == 16 then -- Mythic
37             return true;
38         elseif difficulty == 15 then -- Heroic
39             return true;
40         elseif difficulty == 14 then -- Normal
41             return true;
42         end
43     elseif zoneType == "party" and dungeonIDs[mapID] then
44         if difficulty == 8 or difficulty == 23 then
45             return true;
46         end
47     end
48
49     return false;
50 end
51
52 local prevLogging = nil;
53 local function updateZone()
54     local log = shouldLog();
55     if log then
56         LoggingCombat(true);
57         print("<><><><><><><><><><><>");
58         print("Started Combat Log");
59         print("<><><><><><><><><><><>");
60     elseif prevLogging and LoggingCombat() then
61         print("<><><><><><><><><><><>");
62         print("Ended Combat Log");
63         print("<><><><><><><><><><><>");
64     end
65     prevLogging = log;
66 end
67
68 frame:SetScript("OnEvent", function(self, event)
69     if event == "ZONE_CHANGED_NEW_AREA" then
70         CTimerAfter(3, updateZone);
71     elseif event == "CHALLENGE_MODE_START" then
72         CTimerAfter(1, updateZone);
73     end
74 end);
75 frame:RegisterEvent("ZONE_CHANGED_NEW_AREA");
76 --frame:RegisterEvent("CHALLENGE_MODE_START"); -- for logging M+