annotate ICU.lua @ 11:0ed4c1a0412e

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