diff --git a/BigBrother/BigBrother.lua b/BigBrother/BigBrother.lua index 18a13db..e55f089 100644 --- a/BigBrother/BigBrother.lua +++ b/BigBrother/BigBrother.lua @@ -7,18 +7,37 @@ print(("Loaded %s v%s by %s."):format(BigBrother.title, BigBrother.version, BigB BigBrotherDB = {} -- default value, will be overwritten by the game if persistent data exists -local frame = CreateFrame("FRAME") -frame:RegisterEvent("ENCOUNTER_START") -frame:SetScript("OnEvent", function(self, event, encounterID, encounterName, difficultyID, groupSize) +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) @@ -27,8 +46,12 @@ frame:SetScript("OnEvent", function(self, event, encounterID, encounterName, dif 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][UnitName(unit)] = unitBuffs + classBuffs[className][name] = unitBuffs end table.insert(BigBrotherDB, { @@ -38,4 +61,22 @@ frame:SetScript("OnEvent", function(self, event, encounterID, encounterName, dif encounterName = encounterName, buffs = classBuffs, }) +end + +function events:COMBAT_LOG_EVENT_UNFILTERED(self, ...) + local timestamp, 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, timestamp + 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 diff --git a/BigBrother/bb/config/buffs.yaml b/BigBrother/bb/config/buffs.yaml index a66f3c2..d8f02f7 100644 --- a/BigBrother/bb/config/buffs.yaml +++ b/BigBrother/bb/config/buffs.yaml @@ -40,6 +40,27 @@ Zanza: - Warrior +Weapon: + color: "afafaf" + ids: + - 22756 # Elemental Sharpening Stone + - 16622 # Dense Sharpening Stone + - 16622 # Dense Weightstone + - 25122 # Brilliant Wizard Oil + - 25123 # Brilliant Mana Oil + required: true + classes: + - Balance Druid + - Druid + - Mage + - Paladin + - Priest + - Retribution Paladin + - Rogue + - Shadow Priest + - Tank Warrior + - Warlock + Alcohol: color: "b99863" ids: