I'd do something like this:
Code:
local alert = "%s is hogging the %s! (%d)"
local foods = {
[126503] = true, -- Banquet of the Brew
[126504] = true, -- Great Banquet of the Brew
[126492] = true, -- Banquet of the Grill
[126494] = true, -- Great Banquet of the Grill
[126501] = true, -- Banquet of the Oven
[126502] = true, -- Great Banquet of the Oven
[126497] = true, -- Banquet of the Pot
[126498] = true, -- Great Banquet of the Pot
[126499] = true, -- Banquet of the Steamer
[126500] = true, -- Great Banquet of the Steamer
[126595] = true, -- Banquet of the Wok
[126596] = true, -- Great Banquet of the Wok
[104958] = true, -- Pandaren Banquet
[105193] = true, -- Great Pandaren Banquet
}
local counts = {}
local endTimes = {}
local started = 0
local f = CreateFrame("Frame", "FoodHog", UIParent)
f:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
f:SetScript("OnEvent", function(self, event, unit, spellName, _, _, spellID)
if event == "UNIT_SPELLCAST_SUCCEEDED" then
if foods[spellID] then
started = GetTime()
self:RegisterEvent("UNIT_AURA")
print("|cff33ff99FoodHog:|r Monitoring", spellName)
end
else
if GetTime() - started > 180 then
return self:UnregisterEvent("UNIT_AURA")
end
local _, _, _, _, _, _, endTime = UnitAura(unit, "Food")
if endTime then
local name, server = UnitName(unit)
if server and server ~= "" then
name = name.."-"..server
end
local t = endTimes[name]
if t and t ~= endTime and endTime - t < 20 then
counts[name] = 1 + (counts[name] or 0)
if counts[name] > 2 then
print("|cff33ff99FoodHog:|r", format(alert, name, counts[name]))
end
end
endTimes[name] = endTime
end
end
end)
UNIT_SPELLCAST_SUCCEEDED fires a lot less often that COMBAT_LOG_EVENT_UNFILTERED, and gives you the same info for your purposes, so you should use that.
Currently it doesn't track different banquets separately, so if someone clicks multiple banquets repeatedly, it will warn about them, but this seems fine.