comparison ICU.lua @ 13:ed15bd476bbb beta

+ Added notification when checking is cancelled due to a disabled zone. Fixed a bug causing players to sometimes show as away/not ready more than once (event fire a third time if player is targeted and in your raid sub-group). Fixed chat filter for outgoing whispers sent by ICU.
author Xiiph
date Mon, 21 Feb 2011 23:58:36 +0100
parents 2d952bc9897a
children 21cefa363c73
comparison
equal deleted inserted replaced
12:2d952bc9897a 13:ed15bd476bbb
44 }; 44 };
45 45
46 46
47 local minFlaskDuration = 10; 47 local minFlaskDuration = 10;
48 local noFlask, noFood, hasLowDuration = {},{},{}; 48 local noFlask, noFood, hasLowDuration = {},{},{};
49 local notReady, notReadyAFK, responders = {}, {}, {}; 49 local notReady, notReadyAFK, responders = {},{},{};
50 local disabledZone = false;
50 51
51 local defaults = { 52 local defaults = {
52 profile = { 53 profile = {
53 checkFlask = true, 54 checkFlask = true,
54 checkFood = true, 55 checkFood = true,
374 -- Check if any zones have been disabled 375 -- Check if any zones have been disabled
375 if automatic and not self.db.profile.enableAllZones then 376 if automatic and not self.db.profile.enableAllZones then
376 local currentZone = GetRealZoneText(); 377 local currentZone = GetRealZoneText();
377 for k,v in pairs(self.db.profile.disabledZones) do 378 for k,v in pairs(self.db.profile.disabledZones) do
378 if currentZone == raidMap[k] and v then 379 if currentZone == raidMap[k] and v then
379 return true 380 disabledZone = true;
381 return true;
380 end 382 end
381 end 383 end
382 end 384 end
383 385
384 local icuAd = ""; 386 local icuAd = "";
430 end 432 end
431 433
432 function icu:announceReport(automatic) 434 function icu:announceReport(automatic)
433 SendChatMessage("---- "..L["ICU"].." "..L["Report"].." ----",self.db.profile.reportDestination,nil,nil); 435 SendChatMessage("---- "..L["ICU"].." "..L["Report"].." ----",self.db.profile.reportDestination,nil,nil);
434 436
435 -- Check flask 437 -- Check if inspection got aborted due to the current zone being disabled
436 if #noFlask > 0 and self.db.profile.checkFlask then 438 if disabledZone then
437 local reportFlaskMessage = L["Missing Flask"]..": " .. table.concat(noFlask, ", "); 439 if self.db.profile.reportDestination == "SELF" then
440 DEFAULT_CHAT_FRAME:AddMessage(L["No checking performed, zone disabled."]);
441 else
442 SendChatMessage(L["No checking performed, zone disabled."],self.db.profile.reportDestination,nil,nil);
443 end
444 else
445 -- Check flask
446 if #noFlask > 0 and self.db.profile.checkFlask then
447 local reportFlaskMessage = L["Missing Flask"]..": " .. table.concat(noFlask, ", ");
448
449 if self.db.profile.reportDestination == "SELF" then
450 DEFAULT_CHAT_FRAME:AddMessage(reportFlaskMessage);
451 else
452 SendChatMessage(reportFlaskMessage,self.db.profile.reportDestination,nil,nil);
453 end
454 elseif self.db.profile.checkFlask then -- Nobody is missing a flask
455 if self.db.profile.reportDestination == "SELF" then
456 DEFAULT_CHAT_FRAME:AddMessage(L["Nobody is missing a proper flask."]);
457 else
458 SendChatMessage(L["Nobody is missing a proper flask."],self.db.profile.reportDestination,nil,nil);
459 end
460 end
438 461
439 if self.db.profile.reportDestination == "SELF" then 462 -- Check food
440 DEFAULT_CHAT_FRAME:AddMessage(reportFlaskMessage); 463 if #noFood > 0 and self.db.profile.checkFood then
441 else 464 local reportFoodMessage = L["Missing Food"]..": " .. table.concat(noFood, ", ");
442 SendChatMessage(reportFlaskMessage,self.db.profile.reportDestination,nil,nil); 465
443 end 466 if self.db.profile.reportDestination == "SELF" then
444 elseif self.db.profile.checkFlask then -- Nobody is missing a flask 467 DEFAULT_CHAT_FRAME:AddMessage(reportFoodMessage);
445 if self.db.profile.reportDestination == "SELF" then 468 else
446 DEFAULT_CHAT_FRAME:AddMessage(L["Nobody is missing a proper flask."]); 469 SendChatMessage(reportFoodMessage,self.db.profile.reportDestination,nil,nil);
447 else 470 end
448 SendChatMessage(L["Nobody is missing a proper flask."],self.db.profile.reportDestination,nil,nil); 471 elseif self.db.profile.checkFood then -- Nobody is missing a food buff
449 end 472 if self.db.profile.reportDestination == "SELF" then
450 end 473 DEFAULT_CHAT_FRAME:AddMessage(L["Nobody is missing a proper food buff."]);
451 474 else
452 -- Check food 475 SendChatMessage(L["Nobody is missing a proper food buff."],self.db.profile.reportDestination,nil,nil);
453 if #noFood > 0 and self.db.profile.checkFood then 476 end
454 local reportFoodMessage = L["Missing Food"]..": " .. table.concat(noFood, ", "); 477 end
455 478 end
456 if self.db.profile.reportDestination == "SELF" then
457 DEFAULT_CHAT_FRAME:AddMessage(reportFoodMessage);
458 else
459 SendChatMessage(reportFoodMessage,self.db.profile.reportDestination,nil,nil);
460 end
461 elseif self.db.profile.checkFood then -- Nobody is missing a food buff
462 if self.db.profile.reportDestination == "SELF" then
463 DEFAULT_CHAT_FRAME:AddMessage(L["Nobody is missing a proper food buff."]);
464 else
465 SendChatMessage(L["Nobody is missing a proper food buff."],self.db.profile.reportDestination,nil,nil);
466 end
467 end
468
469 -- Check ready 479 -- Check ready
470 if automatic and self.db.profile.announceReadyCheck then -- Check was initialized by ready check event 480 if automatic and self.db.profile.announceReadyCheck then -- Check was initialized by ready check event
471 if (#notReady > 0) or (#notReadyAFK > 0) then 481 if (#notReady > 0) or (#notReadyAFK > 0) then
472 local reportNotReady = L["Not Ready"]..": " .. table.concat(notReady, ", ") .. (#notReadyAFK > 0 and #notReady > 0 and ", " or "") .. table.concat(notReadyAFK, ", "); 482 local reportNotReady = L["Not Ready"]..": " .. table.concat(notReady, ", ") .. (#notReadyAFK > 0 and #notReady > 0 and ", " or "") .. table.concat(notReadyAFK, ", ");
473 483
506 if not hasFlask then 516 if not hasFlask then
507 for k,v in ipairs(flaskID) do 517 for k,v in ipairs(flaskID) do
508 if v == spellId then 518 if v == spellId then
509 hasFlask = true; 519 hasFlask = true;
510 -- Check if low duration 520 -- Check if low duration
511 if expirationTime and ((expirationTime-GetTime())/60) <= minFlaskDuration then 521 if expirationTime and ((expirationTime-GetTime())/60) < minFlaskDuration then
512 hasLowDuration = true; 522 hasLowDuration = true;
513 end 523 end
514 end 524 end
515 end 525 end
516 end 526 end
544 wipe(noFood); 554 wipe(noFood);
545 wipe(hasLowDuration); 555 wipe(hasLowDuration);
546 wipe(notReady); 556 wipe(notReady);
547 wipe(notReadyAFK); 557 wipe(notReadyAFK);
548 wipe(responders); 558 wipe(responders);
559 disabledZone = false;
549 end 560 end
550 561
551 function icu:READY_CHECK_FINISHED() 562 function icu:READY_CHECK_FINISHED()
552 --print("Ready check finish!"); 563 --print("Ready check finish!");
553 self:UnregisterEvent("READY_CHECK_FINISHED"); 564 self:UnregisterEvent("READY_CHECK_FINISHED");
565 end 576 end
566 end 577 end
567 578
568 function icu:READY_CHECK_CONFIRM(event,unit,status) 579 function icu:READY_CHECK_CONFIRM(event,unit,status)
569 local raider = UnitName(unit); 580 local raider = UnitName(unit);
570 -- Seeing we only check in raids, and this event fires twice for unites in your subgroup 581
571 -- Such as Raid1, and Party1 == Same unit 582 --@debug@
572 -- Dont parse the party event 583 print(unit);
573 if string.match(unit,"party") then 584 --@end-debug@
574 return true; 585
575 end 586 -- Check if the latest entires contain the raider...
587 -- The event fires twice for units in your party,
588 -- and may fire a THIRD time if you have the person targetted ...
589 if (responders[#responders] == raider or responders[#responders-1] == raider) then return end
576 590
577 -- Raider is NOT afk, but might not be ready 591 -- Raider is NOT afk, but might not be ready
578 responders[#responders+1] = raider; 592 responders[#responders+1] = raider;
579 593
580 -- 1 ready, 0 not ready 594 -- 1 ready, 0 not ready
635 649
636 local function filterChat(self, event, msg) 650 local function filterChat(self, event, msg)
637 local db = icu:getDB(); 651 local db = icu:getDB();
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 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
639 end 653 end
640 ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER_ICU_INFORM", filterChat) 654 ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER_INFORM", filterChat)
641 655