BigBrother = {} BigBrother.title = GetAddOnMetadata("BigBrother", "Title") BigBrother.version = GetAddOnMetadata("BigBrother", "Version") BigBrother.author = GetAddOnMetadata("BigBrother", "Author") BigBrother.Items = {} print(("Loaded %s v%s by %s."):format(BigBrother.title, BigBrother.version, BigBrother.author)) BigBrotherDB = {} -- default value, will be overwritten by the game if persistent data exists local weaponEnchantments = { ["Sharpen Weapon - Critical"] = {22756, 1800}, -- Elemental Sharpening Stone ["Sharpen Blade V"] = {16622, 1800}, -- Dense Sharpening Stone ["Enhance Blunt Weapon V"] = {16622, 1800}, -- Dense Weightstone ["Brilliant Wizard Oil"] = {25122, 1800}, ["Brilliant Mana Oil"] = {25123, 1800}, } local unitWeaponBuffs = {} local frame, events = CreateFrame("FRAME"), {}; function events:ENCOUNTER_START(encounterID, encounterName, difficultyID, groupSize) if not IsInRaid() then return end -- remove expired weapon enchantments local time = GetTime() for name, v in pairs(unitWeaponBuffs) do local weaponEnchantmentSpellId, weaponEnchantmentExpireTime = unpack(v) if time > weaponEnchantmentExpireTime then unitWeaponBuffs[name] = nil end end local classBuffs = {} for className, _ in pairs(RAID_CLASS_COLORS) do classBuffs[className] = {} end for m = 1, GetNumGroupMembers() do local unit = "raid" .. m local name = UnitName(unit) local unitBuffs = {} for b = 1, 40 do _, _, _, _, _, _, _, _, _, spellId = UnitBuff(unit, b) if not spellId then break end unitBuffs[b] = spellId end if unitWeaponBuffs[name] ~= nil then local weaponEnchantmentSpellId, weaponEnchantmentExpireTime = unpack(unitWeaponBuffs[name]) table.insert(unitBuffs, weaponEnchantmentSpellId) end local _, className = UnitClass(unit) classBuffs[className][name] = unitBuffs end table.insert(BigBrotherDB, { date = date("%F %T"), zone = GetRealZoneText(), encounterID = encounterID, encounterName = encounterName, buffs = classBuffs, }) end function events:COMBAT_LOG_EVENT_UNFILTERED(...) local _, event, _, _, name, _, _, _, _, _, _, _, spellName = CombatLogGetCurrentEventInfo() if event ~= "SPELL_CAST_SUCCESS" then return end if weaponEnchantments[spellName] ~= nil then local weaponEnchantmentSpellId, weaponEnchantmentDuration = unpack(weaponEnchantments[spellName]) unitWeaponBuffs[name] = {weaponEnchantmentSpellId, GetTime() + weaponEnchantmentDuration} end end frame:SetScript("OnEvent", function(self, event, ...) events[event](self, ...) end) for k, v in pairs(events) do frame:RegisterEvent(k) -- register all events for which handlers have been defined end