annotate ICU.lua @ 10:065ef4e56c25

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