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