Xiiph@0
|
1 local L = LibStub("AceLocale-3.0"):GetLocale("ICU")
|
Xiiph@0
|
2 if not L then return end
|
Xiiph@0
|
3
|
Xiiph@0
|
4 local icu = LibStub("AceAddon-3.0"):NewAddon("ICU", "AceEvent-3.0", "AceTimer-3.0");
|
Xiiph@0
|
5
|
Xiiph@4
|
6 -- Move global namespace to local
|
Xiiph@4
|
7 local _G = _G;
|
Xiiph@4
|
8
|
Xiiph@2
|
9 -- UTF8
|
Xiiph@6
|
10 local raidMap = {
|
Xiiph@6
|
11 bwd = L["Blackwing Descent"],
|
Xiiph@6
|
12 bot = L["The Bastion of Twilight"],
|
Xiiph@6
|
13 tfw = L["Throne of the Four Winds"],
|
Xiiph@6
|
14 bh = L["Baradin Hold"],
|
Xiiph@6
|
15 }
|
Xiiph@6
|
16
|
Xiiph@0
|
17 -- Accepted flasks
|
Xiiph@0
|
18 local flaskID = {
|
Xiiph@0
|
19 79469, -- Flask of Steelskin
|
Xiiph@0
|
20 79470, -- Flask of the Draconic Mind
|
Xiiph@0
|
21 79471, -- Flask of the Winds
|
Xiiph@0
|
22 79472, -- Flask of Titanic Strength
|
Xiiph@0
|
23 94160, -- Flask of Flowing Water
|
Xiiph@11
|
24
|
Xiiph@11
|
25 92725, -- Cauldron Agility
|
Xiiph@11
|
26 92729, -- Cauldron Stamina
|
Xiiph@11
|
27 92730, -- Cauldron Intellect
|
Xiiph@11
|
28 92731, -- Cauldron Strength
|
Xiiph@0
|
29 };
|
Xiiph@0
|
30
|
Xiiph@0
|
31 -- Accepted well-fed buffs
|
Xiiph@0
|
32 local foodID = {
|
Xiiph@0
|
33 87545, -- 90 Strength
|
Xiiph@0
|
34 87546, -- 90 Agility
|
Xiiph@0
|
35 87547, -- 90 Intellect
|
Xiiph@0
|
36 87548, -- 90 Spirit
|
Xiiph@0
|
37 87549, -- 90 Mastery
|
Xiiph@0
|
38 87550, -- 90 Hit
|
Xiiph@0
|
39 87551, -- 90 Crit
|
Xiiph@0
|
40 87552, -- 90 Haste
|
Xiiph@11
|
41 87635, -- 90 Expertise
|
Xiiph@11
|
42 87554, -- 90 Dodge
|
Xiiph@11
|
43 87555, -- 90 Parry
|
Xiiph@0
|
44 };
|
Xiiph@0
|
45
|
Xiiph@0
|
46
|
Xiiph@0
|
47 local minFlaskDuration = 10;
|
Xiiph@0
|
48 local noFlask, noFood, hasLowDuration = {},{},{};
|
Xiiph@13
|
49 local notReady, notReadyAFK, responders = {},{},{};
|
Xiiph@13
|
50 local disabledZone = false;
|
Xiiph@0
|
51
|
Xiiph@0
|
52 local defaults = {
|
Xiiph@0
|
53 profile = {
|
Xiiph@0
|
54 checkFlask = true,
|
Xiiph@0
|
55 checkFood = true,
|
Xiiph@0
|
56 checkLowFlaskDuration = true,
|
Xiiph@0
|
57 remindRaider = true,
|
Xiiph@0
|
58 reportResults = true,
|
Xiiph@0
|
59 reportDestination = "OFFICER",
|
Xiiph@0
|
60 manualCheckOnly = false,
|
Xiiph@0
|
61 checkAfterFinish = true,
|
Xiiph@0
|
62 advertiseICU = true,
|
Xiiph@0
|
63 noFoodMessage = L["Well Fed reminder!"],
|
Xiiph@0
|
64 noFlaskMessage = L["Flask reminder!"],
|
Xiiph@0
|
65 lowFlaskDurationMessage = L["Your Flask runs out in less than 10 minutes!"],
|
Xiiph@1
|
66 disabledZones = {},
|
Xiiph@3
|
67 enableAllZones = true,
|
Xiiph@7
|
68 announceReadyCheck = true,
|
Xiiph@0
|
69 }
|
Xiiph@0
|
70 }
|
Xiiph@0
|
71
|
Xiiph@0
|
72 function icu:OnInitialize()
|
Xiiph@0
|
73 self.db = LibStub("AceDB-3.0"):New("icuDB", defaults, true)
|
Xiiph@0
|
74
|
Xiiph@0
|
75 self.db.RegisterCallback(self, "OnProfileChanged", "refreshConfig")
|
Xiiph@0
|
76 self.db.RegisterCallback(self, "OnProfileCopied", "refreshConfig")
|
Xiiph@0
|
77 self.db.RegisterCallback(self, "OnProfileReset", "refreshConfig")
|
Xiiph@0
|
78
|
Xiiph@0
|
79 self.options = self:getOptions()
|
Xiiph@0
|
80
|
Xiiph@0
|
81 local AceConfig = LibStub("AceConfig-3.0")
|
Xiiph@0
|
82 local AceConfigDialog = LibStub("AceConfigDialog-3.0")
|
Xiiph@0
|
83
|
Xiiph@0
|
84 AceConfig:RegisterOptionsTable("ICU", self.options, {"icu"})
|
Xiiph@0
|
85
|
Xiiph@0
|
86 AceConfigDialog:AddToBlizOptions("ICU", nil, nil, "general")
|
Xiiph@1
|
87 AceConfigDialog:AddToBlizOptions("ICU", "Whispers","ICU","messages")
|
Xiiph@1
|
88 AceConfigDialog:AddToBlizOptions("ICU", "Disabled Zones","ICU","zones")
|
Xiiph@3
|
89 AceConfigDialog:AddToBlizOptions("ICU", "Profiles","ICU","profile")
|
Xiiph@7
|
90
|
Xiiph@7
|
91 -- Ready check confirm event registration
|
Xiiph@7
|
92 if self.db.profile.announceReadyCheck then
|
Xiiph@7
|
93 self:RegisterEvent("READY_CHECK_CONFIRM");
|
Xiiph@7
|
94 end
|
Xiiph@7
|
95
|
Xiiph@7
|
96 -- Ready check event registration
|
Xiiph@7
|
97 if not self.db.profile.manualCheckOnly then
|
Xiiph@7
|
98 icu:RegisterEvent("READY_CHECK");
|
Xiiph@7
|
99 end
|
Xiiph@0
|
100 end
|
Xiiph@0
|
101
|
Xiiph@0
|
102 function icu:refreshConfig()
|
Xiiph@0
|
103 --print("ICU: Config refreshing ...");
|
Xiiph@0
|
104
|
Xiiph@0
|
105 if self.db.profile.manualCheckOnly then
|
Xiiph@0
|
106 icu:UnregisterEvent("READY_CHECK");
|
Xiiph@0
|
107 else
|
Xiiph@0
|
108 icu:RegisterEvent("READY_CHECK");
|
Xiiph@0
|
109 end
|
Xiiph@0
|
110
|
Xiiph@7
|
111 if not self.db.profile.announceReadyCheck then
|
Xiiph@7
|
112 icu:UnregisterEvent("READY_CHECK_CONFIRM");
|
Xiiph@7
|
113 else
|
Xiiph@7
|
114 icu:RegisterEvent("READY_CHECK_CONFIRM");
|
Xiiph@7
|
115 end
|
Xiiph@7
|
116
|
Xiiph@0
|
117 --print("ICU: Config refreshed!");
|
Xiiph@0
|
118 end
|
Xiiph@0
|
119
|
Xiiph@0
|
120 function icu:config()
|
Xiiph@0
|
121 InterfaceOptionsFrame_OpenToCategory("ICU")
|
Xiiph@0
|
122 end
|
Xiiph@0
|
123
|
Xiiph@0
|
124 function icu:getOptions()
|
Xiiph@0
|
125 local options = {
|
Xiiph@0
|
126 handler = icu,
|
Xiiph@0
|
127 type = 'group',
|
Xiiph@0
|
128 args = {
|
Xiiph@0
|
129 config = {
|
Xiiph@0
|
130 name = L["Options"],
|
Xiiph@0
|
131 desc = L["Shows the blizzard addon configuration window"],
|
Xiiph@0
|
132 type = 'execute',
|
Xiiph@0
|
133 func = "config",
|
Xiiph@0
|
134 hidden = true,
|
Xiiph@0
|
135 cmdHidden = false,
|
Xiiph@0
|
136 },
|
Xiiph@0
|
137 check = {
|
Xiiph@0
|
138 name = L["Raid Check"],
|
Xiiph@0
|
139 desc = L["Checks the raid for flask/food buffs"],
|
Xiiph@0
|
140 type = 'execute',
|
Xiiph@0
|
141 func = function() self:inspectRaid(false) end,
|
Xiiph@0
|
142 hidden = true,
|
Xiiph@0
|
143 cmdHidden = false,
|
Xiiph@0
|
144 },
|
Xiiph@0
|
145 quiet = {
|
Xiiph@0
|
146 name = L["Raid Check (Silent)"],
|
Xiiph@0
|
147 desc = L["Checks the raid for flask/food buffs, but does not remind raiders, regardless of other settings."],
|
Xiiph@0
|
148 type = 'execute',
|
Xiiph@0
|
149 func = function() self:inspectRaid(true) end,
|
Xiiph@0
|
150 hidden = true,
|
Xiiph@0
|
151 cmdHidden = false,
|
Xiiph@0
|
152 },
|
Xiiph@0
|
153 general = {
|
Xiiph@0
|
154 name = L["General Settings"],
|
Xiiph@0
|
155 type = 'group',
|
Xiiph@0
|
156 args = {
|
Xiiph@7
|
157 advertiseICU = {
|
Xiiph@7
|
158 type = 'toggle',
|
Xiiph@7
|
159 order = 1,
|
Xiiph@7
|
160 width = 'full',
|
Xiiph@7
|
161 name = L["Advertise ICU"],
|
Xiiph@7
|
162 desc = L["Let everyone know you are using ICU! Prefixes whispers and reports"],
|
Xiiph@7
|
163 set = function(o,v,...) self.db.profile.advertiseICU = v end,
|
Xiiph@7
|
164 get = function() return self.db.profile.advertiseICU end,
|
Xiiph@7
|
165 },
|
Xiiph@0
|
166 checkFlask = {
|
Xiiph@0
|
167 type = 'toggle',
|
Xiiph@7
|
168 order = 2,
|
Xiiph@0
|
169 name = L["Check for Flask"],
|
Xiiph@0
|
170 desc = L["Checks the raid for valid flasks and reports results"],
|
Xiiph@0
|
171 set = function(o,v,...) self.db.profile.checkFlask = v end,
|
Xiiph@0
|
172 get = function() return self.db.profile.checkFlask end,
|
Xiiph@0
|
173 },
|
Xiiph@0
|
174 checkLowFlaskDuration = {
|
Xiiph@0
|
175 type = 'toggle',
|
Xiiph@7
|
176 order = 3,
|
Xiiph@0
|
177 name = L["Flask expiration"],
|
Xiiph@0
|
178 desc = L["Check for soon to expire flask buffs"],
|
Xiiph@0
|
179 set = function(o,v,...) self.db.profile.checkLowFlaskDuration = v end,
|
Xiiph@0
|
180 get = function() return self.db.profile.checkLowFlaskDuration end,
|
Xiiph@0
|
181 },
|
Xiiph@0
|
182 checkFood = {
|
Xiiph@0
|
183 type = 'toggle',
|
Xiiph@7
|
184 order = 4,
|
Xiiph@0
|
185 name = L["Check for Food"],
|
Xiiph@0
|
186 desc = L["Checks the raid for valid food buffs and reports results"],
|
Xiiph@0
|
187 set = function(o,v,...) self.db.profile.checkFood = v end,
|
Xiiph@0
|
188 get = function() return self.db.profile.checkFood end,
|
Xiiph@0
|
189 },
|
Xiiph@0
|
190 remindRaider = {
|
Xiiph@0
|
191 type = 'toggle',
|
Xiiph@7
|
192 order = 5,
|
Xiiph@7
|
193 width = 'full',
|
Xiiph@0
|
194 name = L["Raid reminder"],
|
Xiiph@0
|
195 desc = L["Whisper the raider lacking (or soon to expire, if enabled) food/flask buff a reminder"],
|
Xiiph@0
|
196 set = function(o,v,...) self.db.profile.remindRaider = v end,
|
Xiiph@0
|
197 get = function() return self.db.profile.remindRaider end,
|
Xiiph@0
|
198 },
|
Xiiph@7
|
199 breakOne = {
|
Xiiph@7
|
200 type = 'description',
|
Xiiph@7
|
201 fontSize = 'large',
|
Xiiph@7
|
202 name = ' ',
|
Xiiph@7
|
203 order = 7,
|
Xiiph@7
|
204 width = 'full',
|
Xiiph@7
|
205 },
|
Xiiph@7
|
206 manualCheckOnly = {
|
Xiiph@7
|
207 type = 'toggle',
|
Xiiph@7
|
208 order = 8,
|
Xiiph@7
|
209 name = L["Manual checks only"],
|
Xiiph@7
|
210 desc = L["Only perform buff checks if initiated manually (via /icu check)"],
|
Xiiph@7
|
211 set = function(o,v,...) self.db.profile.manualCheckOnly = v; self:refreshConfig() end,
|
Xiiph@7
|
212 get = function() return self.db.profile.manualCheckOnly end,
|
Xiiph@7
|
213 },
|
Xiiph@7
|
214 checkAfterFinish = {
|
Xiiph@7
|
215 type = 'toggle',
|
Xiiph@7
|
216 order = 9,
|
Xiiph@7
|
217 width = 'full',
|
Xiiph@7
|
218 name = L["Inspect AFTER ready check finishes"],
|
Xiiph@7
|
219 desc = L["Don't check buffs until the ready check has finished (or timed out)"],
|
Xiiph@7
|
220 set = function(o,v,...) self.db.profile.checkAfterFinish = v end,
|
Xiiph@7
|
221 get = function() return self.db.profile.checkAfterFinish end,
|
Xiiph@7
|
222 },
|
Xiiph@7
|
223 breakTwo = {
|
Xiiph@7
|
224 type = 'description',
|
Xiiph@7
|
225 fontSize = 'large',
|
Xiiph@7
|
226 name = ' ',
|
Xiiph@7
|
227 order = 10,
|
Xiiph@7
|
228 width = 'full',
|
Xiiph@7
|
229 },
|
Xiiph@7
|
230 announceReadyCheck = {
|
Xiiph@7
|
231 type = 'toggle',
|
Xiiph@7
|
232 order = 11,
|
Xiiph@7
|
233 name = L["Report ready checks"],
|
Xiiph@7
|
234 desc = L["Report the results of ready checks"],
|
Xiiph@7
|
235 width = 'double',
|
Xiiph@7
|
236 set = function(o,v,...) self.db.profile.announceReadyCheck = v; self:refreshConfig() end,
|
Xiiph@7
|
237 get = function() return self.db.profile.announceReadyCheck end,
|
Xiiph@7
|
238 },
|
Xiiph@0
|
239 reportResults = {
|
Xiiph@0
|
240 type = 'toggle',
|
Xiiph@7
|
241 order = 12,
|
Xiiph@7
|
242 width = 'full',
|
Xiiph@7
|
243 name = L["Report buff checks"],
|
Xiiph@7
|
244 desc = L["Report flask/food check results"],
|
Xiiph@0
|
245 set = function(o,v,...) self.db.profile.reportResults = v end,
|
Xiiph@0
|
246 get = function() return self.db.profile.reportResults end,
|
Xiiph@0
|
247 },
|
Xiiph@0
|
248 reportDestination = {
|
Xiiph@0
|
249 type = 'select',
|
Xiiph@7
|
250 order = 13,
|
Xiiph@0
|
251 style = "dropdown",
|
Xiiph@0
|
252 name = L["Report Destination"],
|
Xiiph@0
|
253 desc = L["Report the results to the following channel"],
|
Xiiph@0
|
254 values = {
|
Xiiph@0
|
255 ["OFFICER"] = L["Officer"],
|
Xiiph@0
|
256 ["SAY"] = L["Say"],
|
Xiiph@0
|
257 ["RAID"] = L["Raid"],
|
Xiiph@0
|
258 ["GUILD"] = L["Guild"],
|
Xiiph@0
|
259 ["SELF"] = L["Self"],
|
Xiiph@0
|
260 },
|
Xiiph@0
|
261 set = function(o,v,...) self.db.profile.reportDestination = v end,
|
Xiiph@0
|
262 get = function() return self.db.profile.reportDestination end,
|
Xiiph@0
|
263 },
|
Xiiph@1
|
264 },
|
Xiiph@1
|
265 },
|
Xiiph@1
|
266 messages = {
|
Xiiph@1
|
267 name = L["Messages"],
|
Xiiph@1
|
268 type = 'group',
|
Xiiph@1
|
269 args = {
|
Xiiph@1
|
270 noFlaskMessage = {
|
Xiiph@1
|
271 type = 'input',
|
Xiiph@1
|
272 width = 'double',
|
Xiiph@1
|
273 name = L["Flask reminder"],
|
Xiiph@1
|
274 desc = L["Message whispered to raiders missing a cataclysm flask"],
|
Xiiph@1
|
275 set = function(o,v,...) self.db.profile.noFlaskMessage = v end,
|
Xiiph@1
|
276 get = function() return self.db.profile.noFlaskMessage end,
|
Xiiph@1
|
277 },
|
Xiiph@1
|
278 lowFlaskDurationMessage = {
|
Xiiph@1
|
279 type = 'input',
|
Xiiph@1
|
280 width = 'double',
|
Xiiph@1
|
281 name = L["Flask expiration"],
|
Xiiph@1
|
282 desc = L["Message whispered to raiders with less than 10 minutes left on their flask"],
|
Xiiph@1
|
283 set = function(o,v,...) self.db.profile.lowFlaskDurationMessage = v end,
|
Xiiph@1
|
284 get = function() return self.db.profile.lowFlaskDurationMessage end,
|
Xiiph@1
|
285 },
|
Xiiph@1
|
286 noFoodMessage = {
|
Xiiph@1
|
287 type = 'input',
|
Xiiph@1
|
288 width = 'double',
|
Xiiph@1
|
289 name = L["Food reminder"],
|
Xiiph@1
|
290 desc = L["Message whispered to raiders missing the well-fed buff"],
|
Xiiph@1
|
291 set = function(o,v,...) self.db.profile.noFoodMessage = v end,
|
Xiiph@1
|
292 get = function() return self.db.profile.noFoodMessage end,
|
Xiiph@1
|
293 },
|
Xiiph@1
|
294 },
|
Xiiph@1
|
295 },
|
Xiiph@1
|
296 zones = {
|
Xiiph@1
|
297 name = L["Disabled Zones"],
|
Xiiph@1
|
298 type = 'group',
|
Xiiph@3
|
299 set = function(i,v)
|
Xiiph@3
|
300 self.db.profile.disabledZones[i[#i]] = v;
|
Xiiph@3
|
301 end,
|
Xiiph@3
|
302 get = function(i)
|
Xiiph@3
|
303 return self.db.profile.disabledZones[i[#i]];
|
Xiiph@3
|
304 end,
|
Xiiph@1
|
305 args = {
|
Xiiph@1
|
306 help = {
|
Xiiph@1
|
307 type = 'description',
|
Xiiph@1
|
308 name = L['Toggle ICU automatic checking |cffcc0000off|r in the selected zones.'],
|
Xiiph@1
|
309 width = 'full',
|
Xiiph@1
|
310 order = 0,
|
Xiiph@0
|
311 },
|
Xiiph@3
|
312 breakOne = {
|
Xiiph@3
|
313 type = 'description',
|
Xiiph@7
|
314 fontSize = 'large',
|
Xiiph@7
|
315 name = ' ',
|
Xiiph@3
|
316 order = 1,
|
Xiiph@3
|
317 width = 'full',
|
Xiiph@3
|
318 },
|
Xiiph@3
|
319 enableAllZones = {
|
Xiiph@3
|
320 type = 'toggle',
|
Xiiph@3
|
321 name = L["Enable ICU in all zones"],
|
Xiiph@3
|
322 order = 2,
|
Xiiph@3
|
323 width = 'full',
|
Xiiph@3
|
324 set = function (i,v)
|
Xiiph@3
|
325 self.db.profile.enableAllZones = v;
|
Xiiph@3
|
326 self.options.args.zones.args.bwd.disabled = v;
|
Xiiph@3
|
327 self.options.args.zones.args.bot.disabled = v;
|
Xiiph@3
|
328 self.options.args.zones.args.tfw.disabled = v;
|
Xiiph@3
|
329 self.options.args.zones.args.bh.disabled = v;
|
Xiiph@3
|
330 end,
|
Xiiph@3
|
331 get = function (i) return self.db.profile.enableAllZones end,
|
Xiiph@3
|
332 },
|
Xiiph@3
|
333 breakTwo = {
|
Xiiph@3
|
334 type = 'description',
|
Xiiph@7
|
335 fontSize = 'large',
|
Xiiph@7
|
336 name = ' ',
|
Xiiph@3
|
337 order = 3,
|
Xiiph@3
|
338 width = 'full',
|
Xiiph@3
|
339 },
|
Xiiph@1
|
340 bwd = {
|
Xiiph@1
|
341 type = 'toggle',
|
Xiiph@1
|
342 name = L["Blackwing Descent"],
|
Xiiph@1
|
343 width = 'double',
|
Xiiph@3
|
344 disabled = self.db.profile.enableAllZones,
|
Xiiph@0
|
345 },
|
Xiiph@1
|
346 bot = {
|
Xiiph@1
|
347 type = 'toggle',
|
Xiiph@5
|
348 name = L["The Bastion of Twilight"],
|
Xiiph@1
|
349 width = 'double',
|
Xiiph@3
|
350 disabled = self.db.profile.enableAllZones,
|
Xiiph@0
|
351 },
|
Xiiph@1
|
352 tfw = {
|
Xiiph@1
|
353 type = 'toggle',
|
Xiiph@1
|
354 name = L["Throne of the Four Winds"],
|
Xiiph@1
|
355 width = 'double',
|
Xiiph@3
|
356 disabled = self.db.profile.enableAllZones,
|
Xiiph@1
|
357 },
|
Xiiph@1
|
358 bh = {
|
Xiiph@1
|
359 type = 'toggle',
|
Xiiph@1
|
360 name = L["Baradin Hold"],
|
Xiiph@1
|
361 width = 'double',
|
Xiiph@3
|
362 disabled = self.db.profile.enableAllZones,
|
Xiiph@1
|
363 },
|
Xiiph@3
|
364
|
Xiiph@0
|
365 }
|
Xiiph@0
|
366 },
|
Xiiph@0
|
367 profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db),
|
Xiiph@0
|
368 },
|
Xiiph@0
|
369 }
|
Xiiph@0
|
370 return options
|
Xiiph@0
|
371 end
|
Xiiph@0
|
372
|
Xiiph@1
|
373 function icu:inspectRaid(silent,automatic)
|
Xiiph@6
|
374
|
Xiiph@1
|
375 -- Check if any zones have been disabled
|
Xiiph@3
|
376 if automatic and not self.db.profile.enableAllZones then
|
Xiiph@1
|
377 local currentZone = GetRealZoneText();
|
Xiiph@6
|
378 for k,v in pairs(self.db.profile.disabledZones) do
|
Xiiph@6
|
379 if currentZone == raidMap[k] and v then
|
Xiiph@13
|
380 disabledZone = true;
|
Xiiph@13
|
381 return true;
|
Xiiph@3
|
382 end
|
Xiiph@6
|
383 end
|
Xiiph@1
|
384 end
|
Xiiph@1
|
385
|
Xiiph@0
|
386 local icuAd = "";
|
Xiiph@0
|
387
|
Xiiph@3
|
388 -- Not in a raid group
|
Xiiph@0
|
389 if GetNumRaidMembers() == 0 then
|
Xiiph@0
|
390 return true
|
Xiiph@0
|
391 end
|
Xiiph@0
|
392
|
Xiiph@0
|
393 if self.db.profile.advertiseICU then
|
Xiiph@0
|
394 icuAd = L["ICU"] .. ": ";
|
Xiiph@0
|
395 else
|
Xiiph@0
|
396 icuAd = "";
|
Xiiph@0
|
397 end
|
Xiiph@0
|
398
|
Xiiph@0
|
399 for i = 1, GetNumRaidMembers() do
|
Xiiph@0
|
400 local raider = GetRaidRosterInfo(i);
|
Xiiph@0
|
401 if raider then
|
Xiiph@0
|
402
|
Xiiph@0
|
403 local hasFood, hasFlask, hasLowDuration = icu:validateBuffs(i);
|
Xiiph@0
|
404
|
Xiiph@0
|
405 if not hasFood and self.db.profile.checkFood then
|
Xiiph@0
|
406 noFood[#noFood+1] = raider;
|
Xiiph@0
|
407 -- Tell player
|
Xiiph@0
|
408 if self.db.profile.remindRaider and not silent then
|
Xiiph@0
|
409 SendChatMessage(icuAd .. self.db.profile.noFoodMessage,"WHISPER",nil,raider);
|
Xiiph@0
|
410 end
|
Xiiph@0
|
411 end
|
Xiiph@0
|
412
|
Xiiph@0
|
413 if not hasFlask and self.db.profile.checkFlask then
|
Xiiph@0
|
414 noFlask[#noFlask+1] = raider;
|
Xiiph@0
|
415 -- Tell player
|
Xiiph@0
|
416 if self.db.profile.remindRaider and not silent then
|
Xiiph@0
|
417 SendChatMessage(icuAd .. self.db.profile.noFlaskMessage,"WHISPER",nil,raider);
|
Xiiph@0
|
418 end
|
Xiiph@0
|
419 elseif hasLowDuration and not silent then
|
Xiiph@0
|
420 if self.db.profile.remindRaider and self.db.profile.checkLowFlaskDuration then
|
Xiiph@0
|
421 SendChatMessage(icuAd .. self.db.profile.lowFlaskDurationMessage,"WHISPER",nil,raider);
|
Xiiph@0
|
422 end
|
Xiiph@0
|
423 end
|
Xiiph@0
|
424 end
|
Xiiph@0
|
425
|
Xiiph@0
|
426 end
|
Xiiph@0
|
427
|
Xiiph@7
|
428 -- Announce the report if inspectRaid was by a slash command instead of ready check event
|
Xiiph@7
|
429 if not automatic then
|
Xiiph@7
|
430 self:announceReport(false);
|
Xiiph@7
|
431 end
|
Xiiph@7
|
432 end
|
Xiiph@7
|
433
|
Xiiph@7
|
434 function icu:announceReport(automatic)
|
Xiiph@7
|
435 SendChatMessage("---- "..L["ICU"].." "..L["Report"].." ----",self.db.profile.reportDestination,nil,nil);
|
Xiiph@7
|
436
|
Xiiph@13
|
437 -- Check if inspection got aborted due to the current zone being disabled
|
Xiiph@13
|
438 if disabledZone then
|
Xiiph@13
|
439 if self.db.profile.reportDestination == "SELF" then
|
Xiiph@13
|
440 DEFAULT_CHAT_FRAME:AddMessage(L["No checking performed, zone disabled."]);
|
Xiiph@13
|
441 else
|
Xiiph@13
|
442 SendChatMessage(L["No checking performed, zone disabled."],self.db.profile.reportDestination,nil,nil);
|
Xiiph@13
|
443 end
|
Xiiph@13
|
444 else
|
Xiiph@13
|
445 -- Check flask
|
Xiiph@13
|
446 if #noFlask > 0 and self.db.profile.checkFlask then
|
Xiiph@13
|
447 local reportFlaskMessage = L["Missing Flask"]..": " .. table.concat(noFlask, ", ");
|
Xiiph@13
|
448
|
Xiiph@13
|
449 if self.db.profile.reportDestination == "SELF" then
|
Xiiph@13
|
450 DEFAULT_CHAT_FRAME:AddMessage(reportFlaskMessage);
|
Xiiph@13
|
451 else
|
Xiiph@13
|
452 SendChatMessage(reportFlaskMessage,self.db.profile.reportDestination,nil,nil);
|
Xiiph@13
|
453 end
|
Xiiph@13
|
454 elseif self.db.profile.checkFlask then -- Nobody is missing a flask
|
Xiiph@13
|
455 if self.db.profile.reportDestination == "SELF" then
|
Xiiph@13
|
456 DEFAULT_CHAT_FRAME:AddMessage(L["Nobody is missing a proper flask."]);
|
Xiiph@13
|
457 else
|
Xiiph@13
|
458 SendChatMessage(L["Nobody is missing a proper flask."],self.db.profile.reportDestination,nil,nil);
|
Xiiph@13
|
459 end
|
Xiiph@13
|
460 end
|
Xiiph@7
|
461
|
Xiiph@13
|
462 -- Check food
|
Xiiph@13
|
463 if #noFood > 0 and self.db.profile.checkFood then
|
Xiiph@13
|
464 local reportFoodMessage = L["Missing Food"]..": " .. table.concat(noFood, ", ");
|
Xiiph@13
|
465
|
Xiiph@13
|
466 if self.db.profile.reportDestination == "SELF" then
|
Xiiph@13
|
467 DEFAULT_CHAT_FRAME:AddMessage(reportFoodMessage);
|
Xiiph@13
|
468 else
|
Xiiph@13
|
469 SendChatMessage(reportFoodMessage,self.db.profile.reportDestination,nil,nil);
|
Xiiph@13
|
470 end
|
Xiiph@13
|
471 elseif self.db.profile.checkFood then -- Nobody is missing a food buff
|
Xiiph@13
|
472 if self.db.profile.reportDestination == "SELF" then
|
Xiiph@13
|
473 DEFAULT_CHAT_FRAME:AddMessage(L["Nobody is missing a proper food buff."]);
|
Xiiph@13
|
474 else
|
Xiiph@13
|
475 SendChatMessage(L["Nobody is missing a proper food buff."],self.db.profile.reportDestination,nil,nil);
|
Xiiph@13
|
476 end
|
Xiiph@7
|
477 end
|
Xiiph@0
|
478 end
|
Xiiph@7
|
479 -- Check ready
|
Xiiph@7
|
480 if automatic and self.db.profile.announceReadyCheck then -- Check was initialized by ready check event
|
Xiiph@7
|
481 if (#notReady > 0) or (#notReadyAFK > 0) then
|
Xiiph@7
|
482 local reportNotReady = L["Not Ready"]..": " .. table.concat(notReady, ", ") .. (#notReadyAFK > 0 and #notReady > 0 and ", " or "") .. table.concat(notReadyAFK, ", ");
|
Xiiph@0
|
483
|
Xiiph@0
|
484 if self.db.profile.reportDestination == "SELF" then
|
Xiiph@7
|
485 DEFAULT_CHAT_FRAME:AddMessage(reportNotReady);
|
Xiiph@0
|
486 else
|
Xiiph@7
|
487 SendChatMessage(reportNotReady,self.db.profile.reportDestination,nil,nil);
|
Xiiph@0
|
488 end
|
Xiiph@7
|
489 else -- Everyone is ready
|
Xiiph@4
|
490 if self.db.profile.reportDestination == "SELF" then
|
Xiiph@7
|
491 DEFAULT_CHAT_FRAME:AddMessage(L["Everyone is ready."]);
|
Xiiph@4
|
492 else
|
Xiiph@7
|
493 SendChatMessage(L["Everyone is ready."],self.db.profile.reportDestination,nil,nil);
|
Xiiph@4
|
494 end
|
Xiiph@0
|
495 end
|
Xiiph@0
|
496 end
|
Xiiph@0
|
497
|
Xiiph@7
|
498 self:wipeTables();
|
Xiiph@0
|
499 end
|
Xiiph@0
|
500
|
Xiiph@0
|
501 function icu:validateBuffs(playerIndex)
|
Xiiph@0
|
502 local i = 1;
|
Xiiph@0
|
503 local hasFood, hasFlask, hasLowDuration = false, false, false;
|
Xiiph@0
|
504 local name, _, _, _, _, _, expirationTime, _, _, _, spellId = UnitBuff("raid"..playerIndex,i);
|
Xiiph@0
|
505
|
Xiiph@0
|
506 while name do
|
Xiiph@0
|
507 -- Check for food
|
Xiiph@0
|
508 if not hasFood then
|
Xiiph@0
|
509 for k,v in ipairs(foodID) do
|
Xiiph@0
|
510 if v == spellId then
|
Xiiph@0
|
511 hasFood = true;
|
Xiiph@0
|
512 end
|
Xiiph@0
|
513 end
|
Xiiph@0
|
514 end
|
Xiiph@0
|
515 -- Check for flask
|
Xiiph@0
|
516 if not hasFlask then
|
Xiiph@0
|
517 for k,v in ipairs(flaskID) do
|
Xiiph@0
|
518 if v == spellId then
|
Xiiph@0
|
519 hasFlask = true;
|
Xiiph@0
|
520 -- Check if low duration
|
Xiiph@13
|
521 if expirationTime and ((expirationTime-GetTime())/60) < minFlaskDuration then
|
Xiiph@0
|
522 hasLowDuration = true;
|
Xiiph@0
|
523 end
|
Xiiph@0
|
524 end
|
Xiiph@0
|
525 end
|
Xiiph@0
|
526 end
|
Xiiph@0
|
527 i = i + 1;
|
Xiiph@0
|
528 name, _, _, _, _, _, expirationTime, _, _, _, spellId = UnitBuff("raid"..playerIndex,i);
|
Xiiph@0
|
529 end
|
Xiiph@0
|
530
|
Xiiph@0
|
531 return hasFood, hasFlask, hasLowDuration;
|
Xiiph@0
|
532 end
|
Xiiph@0
|
533
|
Xiiph@7
|
534 function icu:READY_CHECK(event,requester)
|
Xiiph@0
|
535 --print("Ready check init!");
|
Xiiph@0
|
536 if self.db.profile.manualCheckOnly then
|
Xiiph@0
|
537 icu:UnregisterEvent("READY_CHECK");
|
Xiiph@0
|
538 return true;
|
Xiiph@0
|
539 end
|
Xiiph@0
|
540
|
Xiiph@7
|
541 responders[#responders+1] = requester;
|
Xiiph@7
|
542
|
Xiiph@7
|
543 if not self.db.profile.checkAfterFinish and GetNumRaidMembers() then
|
Xiiph@1
|
544 self:inspectRaid(nil,true);
|
Xiiph@0
|
545 else
|
Xiiph@0
|
546 self:ScheduleTimer("READY_CHECK_FINISHED", 30);
|
Xiiph@0
|
547 self:RegisterEvent("READY_CHECK_FINISHED");
|
Xiiph@0
|
548 end
|
Xiiph@0
|
549 end
|
Xiiph@0
|
550
|
Xiiph@7
|
551 function icu:wipeTables()
|
Xiiph@7
|
552 -- Wipe tables
|
Xiiph@7
|
553 wipe(noFlask);
|
Xiiph@7
|
554 wipe(noFood);
|
Xiiph@7
|
555 wipe(hasLowDuration);
|
Xiiph@7
|
556 wipe(notReady);
|
Xiiph@7
|
557 wipe(notReadyAFK);
|
Xiiph@7
|
558 wipe(responders);
|
Xiiph@13
|
559 disabledZone = false;
|
Xiiph@7
|
560 end
|
Xiiph@7
|
561
|
Xiiph@0
|
562 function icu:READY_CHECK_FINISHED()
|
Xiiph@0
|
563 --print("Ready check finish!");
|
Xiiph@0
|
564 self:UnregisterEvent("READY_CHECK_FINISHED");
|
Xiiph@0
|
565 self:CancelAllTimers();
|
Xiiph@7
|
566
|
Xiiph@7
|
567 -- Not in a raid group
|
Xiiph@7
|
568 if GetNumRaidMembers() then
|
Xiiph@7
|
569 self:inspectRaid(nil,true);
|
Xiiph@7
|
570
|
Xiiph@7
|
571 if self.db.profile.announceReadyCheck then
|
Xiiph@7
|
572 self:confirmReady();
|
Xiiph@7
|
573 end
|
Xiiph@7
|
574
|
Xiiph@7
|
575 self:announceReport(true);
|
Xiiph@7
|
576 end
|
Xiiph@7
|
577 end
|
Xiiph@7
|
578
|
Xiiph@7
|
579 function icu:READY_CHECK_CONFIRM(event,unit,status)
|
Xiiph@7
|
580 local raider = UnitName(unit);
|
Xiiph@13
|
581
|
Xiiph@13
|
582 --@debug@
|
Xiiph@13
|
583 print(unit);
|
Xiiph@13
|
584 --@end-debug@
|
Xiiph@13
|
585
|
Xiiph@13
|
586 -- Check if the latest entires contain the raider...
|
Xiiph@13
|
587 -- The event fires twice for units in your party,
|
Xiiph@13
|
588 -- and may fire a THIRD time if you have the person targetted ...
|
Xiiph@13
|
589 if (responders[#responders] == raider or responders[#responders-1] == raider) then return end
|
Xiiph@7
|
590
|
Xiiph@7
|
591 -- Raider is NOT afk, but might not be ready
|
Xiiph@7
|
592 responders[#responders+1] = raider;
|
Xiiph@7
|
593
|
Xiiph@7
|
594 -- 1 ready, 0 not ready
|
Xiiph@7
|
595 if not status then
|
Xiiph@7
|
596 notReady[#notReady+1] = raider;
|
Xiiph@7
|
597 end
|
Xiiph@7
|
598 end
|
Xiiph@7
|
599
|
Xiiph@7
|
600 function icu:confirmReady()
|
Xiiph@7
|
601 local numRaiders, matchFound = GetNumRaidMembers(), false;
|
Xiiph@7
|
602
|
Xiiph@7
|
603 --@debug@
|
Xiiph@7
|
604 print(#responders);
|
Xiiph@7
|
605 --@end-debug@
|
Xiiph@7
|
606
|
Xiiph@7
|
607 if #responders < numRaiders then
|
Xiiph@7
|
608 for i = 1, numRaiders do
|
Xiiph@7
|
609 matchFound = false;
|
Xiiph@7
|
610
|
Xiiph@7
|
611 -- Get raider name
|
Xiiph@7
|
612 local raider = GetRaidRosterInfo(i);
|
Xiiph@7
|
613
|
Xiiph@7
|
614 --@debug@
|
Xiiph@7
|
615 print(raider);
|
Xiiph@7
|
616 --@end-debug@
|
Xiiph@7
|
617
|
Xiiph@7
|
618 for i = 1, #responders do
|
Xiiph@7
|
619 print("Iterating through responders ...");
|
Xiiph@7
|
620 print(responders[i],raider);
|
Xiiph@7
|
621 if responders[i] == raider then
|
Xiiph@7
|
622 --@debug@
|
Xiiph@7
|
623 print(responders[i],raider);
|
Xiiph@7
|
624 --@end-debug@
|
Xiiph@7
|
625 matchFound = true;
|
Xiiph@7
|
626 break;
|
Xiiph@7
|
627 end
|
Xiiph@7
|
628 end
|
Xiiph@7
|
629
|
Xiiph@7
|
630 if not matchFound and raider then
|
Xiiph@7
|
631 --@debug@
|
Xiiph@7
|
632 print("Tag following raider as AFK: ",raider,matchFound);
|
Xiiph@7
|
633 --@end-debug@
|
Xiiph@7
|
634 notReadyAFK[#notReadyAFK+1] = raider .. " (AFK)";
|
Xiiph@7
|
635 elseif not raider then -- GetRaidRosterInfo did not return a proper name, out of bounds??
|
Xiiph@7
|
636 print("Something is wrong ...");
|
Xiiph@7
|
637 else
|
Xiiph@7
|
638 --@debug@
|
Xiiph@7
|
639 print(i,raider);
|
Xiiph@7
|
640 --@end-debug@
|
Xiiph@7
|
641 end
|
Xiiph@7
|
642 end
|
Xiiph@7
|
643 end
|
Xiiph@0
|
644 end
|
Xiiph@0
|
645
|
Xiiph@1
|
646 function icu:getDB()
|
Xiiph@1
|
647 return self.db;
|
Xiiph@0
|
648 end
|
Xiiph@1
|
649
|
Xiiph@4
|
650 local function filterChat(self, event, msg)
|
Xiiph@1
|
651 local db = icu:getDB();
|
Xiiph@4
|
652 if msg == db.profile.noFoodMessage or msg == db.profile.noFlaskMessage or msg == db.profile.lowFlaskDurationMessage or msg == (L["ICU"]..": "..db.profile.noFoodMessage) or msg == (L["ICU"]..": "..db.profile.noFlaskMessage) or msg == (L["ICU"]..": "..db.profile.lowFlaskDurationMessage) then return true end
|
Xiiph@1
|
653 end
|
Xiiph@13
|
654 ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER_INFORM", filterChat)
|
Xiiph@0
|
655
|