BigBrother: Add weapon enchantments.

This commit is contained in:
Casper V. Kristensen 2020-09-29 03:40:04 +02:00
parent 88a470d81a
commit c62b7a875f
Signed by: caspervk
GPG key ID: 289CA03790535054
2 changed files with 66 additions and 4 deletions

View file

@ -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 BigBrotherDB = {} -- default value, will be overwritten by the game if persistent data exists
local frame = CreateFrame("FRAME") local weaponEnchantments = {
frame:RegisterEvent("ENCOUNTER_START") ["Sharpen Weapon - Critical"] = {22756, 1800}, -- Elemental Sharpening Stone
frame:SetScript("OnEvent", function(self, event, encounterID, encounterName, difficultyID, groupSize) ["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 if not IsInRaid() then
return return
end 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 = {} local classBuffs = {}
for className, _ in pairs(RAID_CLASS_COLORS) do for className, _ in pairs(RAID_CLASS_COLORS) do
classBuffs[className] = {} classBuffs[className] = {}
end end
for m = 1, GetNumGroupMembers() do for m = 1, GetNumGroupMembers() do
local unit = "raid" .. m local unit = "raid" .. m
local name = UnitName(unit)
local unitBuffs = {} local unitBuffs = {}
for b = 1, 40 do for b = 1, 40 do
_, _, _, _, _, _, _, _, _, spellId = UnitBuff(unit, b) _, _, _, _, _, _, _, _, _, spellId = UnitBuff(unit, b)
@ -27,8 +46,12 @@ frame:SetScript("OnEvent", function(self, event, encounterID, encounterName, dif
end end
unitBuffs[b] = spellId unitBuffs[b] = spellId
end end
if unitWeaponBuffs[name] ~= nil then
local weaponEnchantmentSpellId, weaponEnchantmentExpireTime = unpack(unitWeaponBuffs[name])
table.insert(unitBuffs, weaponEnchantmentSpellId)
end
local _, className = UnitClass(unit) local _, className = UnitClass(unit)
classBuffs[className][UnitName(unit)] = unitBuffs classBuffs[className][name] = unitBuffs
end end
table.insert(BigBrotherDB, { table.insert(BigBrotherDB, {
@ -38,4 +61,22 @@ frame:SetScript("OnEvent", function(self, event, encounterID, encounterName, dif
encounterName = encounterName, encounterName = encounterName,
buffs = classBuffs, 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) end)
for k, v in pairs(events) do
frame:RegisterEvent(k) -- register all events for which handlers have been defined
end

View file

@ -40,6 +40,27 @@ Zanza:
- Warrior - 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: Alcohol:
color: "b99863" color: "b99863"
ids: ids: