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