diff --git a/Cork.lua b/Cork.lua index 75bc6dd..4c3df26 100644 --- a/Cork.lua +++ b/Cork.lua @@ -5,7 +5,7 @@ local _ _, Cork.MYCLASS = UnitClass("player") -Cork.corks, Cork.db, Cork.dbpc, Cork.defaultspc = {}, {}, {}, {} +Cork.corks, Cork.db, Cork.dbpc, Cork.dbcrossspec, Cork.defaultspc = {}, {}, {}, {}, {} Cork.sortedcorks = {} local defaults = {point = "TOP", x = 0, y = -100, showanchor = true, debug = false, bindwheel = false} @@ -22,12 +22,16 @@ ae.RegisterEvent("Cork", "ADDON_LOADED", function(event, addon) if addon:lower() ~= "cork" then return end CorkDB = setmetatable(CorkDB or {}, {__index = defaults}) - CorkDBPC = CorkDBPC or {{},{},{},{}} - if not CorkDBPC[1] then CorkDBPC = {CorkDBPC, {}, {}, {}} end - for _, i in ipairs({2,3,4}) do - if not CorkDBPC[i] then CorkDBPC[i] = {} end - end + CorkDBPC = CorkDBPC or {{},{},{}} -- Third group is cross-spec + if not CorkDBPC[1] then CorkDBPC = {CorkDBPC, {}, {}} end + if not CorkDBPC[3] then + CorkDBPC[3] = { ['Garrison cache-lastopen'] = math.max(CorkDBPC[1]['Garrison cache-lastopen'] or 0, + CorkDBPC[2]['Garrison cache-lastopen'] or 0) } + CorkDBPC[1]['Garrison cache-lastopen'] = nil + CorkDBPC[2]['Garrison cache-lastopen'] = nil + end Cork.db = CorkDB + Cork.dbcrossspec = CorkDBPC[3] anchor:SetPoint(Cork.db.point, Cork.db.x, Cork.db.y) if not Cork.db.showanchor then anchor:Hide() end @@ -38,19 +42,19 @@ end) local meta = {__index = Cork.defaultspc} ae.RegisterEvent("Cork", "PLAYER_LOGIN", function() - local lastspec = GetSpecialization() - Cork.dbpc = setmetatable(CorkDBPC[lastspec], meta) + local lastgroup = GetActiveSpecGroup() + Cork.dbpc = setmetatable(CorkDBPC[lastgroup], meta) for _,dataobj in pairs(Cork.sortedcorks) do if dataobj.Init then dataobj:Init() end end for _,dataobj in pairs(Cork.sortedcorks) do dataobj:Scan() end ae.RegisterEvent("Cork", "ZONE_CHANGED_NEW_AREA", Cork.Update) ae.RegisterEvent("Cork", "PLAYER_TALENT_UPDATE", function() - if lastspec == GetSpecialization() then return end + if lastgroup == GetActiveSpecGroup() then return end - lastspec = GetSpecialization() + lastgroup = GetActiveSpecGroup() for i,v in pairs(Cork.defaultspc) do if Cork.dbpc[i] == v then Cork.dbpc[i] = nil end end - Cork.dbpc = setmetatable(CorkDBPC[lastspec], meta) + Cork.dbpc = setmetatable(CorkDBPC[lastgroup], meta) if Cork.config.Update then Cork.config:Update() end for name,dataobj in pairs(Cork.corks) do if dataobj.Init then dataobj:Init() end end diff --git a/modules/Capsules.lua b/modules/Capsules.lua index c63e7cb..50b9bba 100644 --- a/modules/Capsules.lua +++ b/modules/Capsules.lua @@ -32,6 +32,17 @@ local OPENABLE_IDS = { [141990] = true, -- Greater Highmountain Tribe Insignia [141991] = true, -- Greater Wardens Insignia [141992] = true, -- Greater Nightfallen Insignia + [129036] = true, -- Ancient Mana Fragment + [129097] = true, -- Ancient Mana Gem + [129098] = true, -- Ancient Mana Stone + [139786] = true, -- Ancient Mana Crystal + [139884] = true, -- Ancient Mana Fragments + [139890] = true, -- Ancient Mana Gem + [141655] = true, -- Shimmering Ancient Mana Cluster + [143733] = true, -- Ancient Mana Shards + [143734] = true, -- Ancient Mana Crystal Cluster + [143735] = true, -- Ancient Mana Shards + [143748] = true, -- Leyscale Koi } diff --git a/modules/DeathKnight.lua b/modules/DeathKnight.lua index 5a7f279..7a11597 100644 --- a/modules/DeathKnight.lua +++ b/modules/DeathKnight.lua @@ -4,9 +4,3 @@ if Cork.MYCLASS ~= "DEATHKNIGHT" then return end -- Path of Frost local spellname, _, icon = GetSpellInfo(3714) Cork:GenerateSelfBuffer(spellname, icon) - - --- Horn of Winter -local spellname, _, icon = GetSpellInfo(57330) -local str_earth = GetSpellInfo(58646) -- Strength of Earth -Cork:GenerateSelfBuffer(spellname, icon, str_earth) diff --git a/modules/Dig.lua b/modules/Dig.lua new file mode 100644 index 0000000..53b6c87 --- /dev/null +++ b/modules/Dig.lua @@ -0,0 +1,52 @@ + +local myname, Cork = ... + +local IconLine = Cork.IconLine +local ldb, ae = LibStub:GetLibrary("LibDataBroker-1.1"), LibStub("AceEvent-3.0") + +Cork.defaultspc["Archaeology solve-enabled"] = true + +local dataobj2 = ldb:NewDataObject("Cork Archaeology Solving", { + type = "cork", + tiptext = "Warn when you can solve archeology artifacts" +}) + +local solveRace = nil + +function dataobj2:Scan() + if not Cork.dbpc["Archaeology solve-enabled"] then + dataobj2.player = nil + solveRace = nil + return + end + + local raceCount = GetNumArchaeologyRaces() + + for race = 1, raceCount do + local name,_,_,have,need,max=GetArchaeologyRaceInfo(race) + + if(have>need) then + SetSelectedArtifact(race) + local _1,_2,_3,_4,_5,_6,_7 = GetSelectedArtifactInfo() + dataobj2.player = IconLine(_4, name.."Artifact ("..have.."/"..need..")") + solveRace = race + return + end + end + + dataobj2.player = nil + solveRace = nil +end + +ae.RegisterEvent("Cork Archaeology Solving", "ARCHAEOLOGY_FIND_COMPLETE", dataobj2.Scan) +ae.RegisterEvent("Cork Archaeology Solving", "ARTIFACT_COMPLETE", dataobj2.Scan) +ae.RegisterEvent("Cork Archaeology Solving", "ARTIFACT_UPDATE", dataobj2.Scan) +ae.RegisterEvent("Cork Archaeology Solving", "BAG_UPDATE_DELAYED", dataobj2.Scan) +ae.RegisterEvent("Cork Archaeology Solving", "LOOT_CLOSED", dataobj2.Scan) + +function dataobj2:CorkIt(frame) + if dataobj2.player and solveRace then + local macro = "/script SetSelectedArtifact("..solveRace..") SolveArtifact()" + return frame:SetManyAttributes("type1", "macro", "macrotext1", macro) + end +end diff --git a/modules/Hunter.lua b/modules/Hunter.lua deleted file mode 100644 index f3ae016..0000000 --- a/modules/Hunter.lua +++ /dev/null @@ -1,3 +0,0 @@ - -local myname, Cork = ... -if Cork.MYCLASS ~= "HUNTER" then return end diff --git a/modules/Monk.lua b/modules/Monk.lua index b2f5f87..e7a46e2 100644 --- a/modules/Monk.lua +++ b/modules/Monk.lua @@ -2,6 +2,7 @@ local myname, Cork = ... if Cork.MYCLASS ~= "MONK" then return end + -- Enlightenment (EXP boost buff) local UnitAura = Cork.UnitAura or UnitAura local ldb, ae = LibStub:GetLibrary("LibDataBroker-1.1"), LibStub("AceEvent-3.0") diff --git a/modules/Paladin.lua b/modules/Paladin.lua index 77c205e..c1b9e9e 100644 --- a/modules/Paladin.lua +++ b/modules/Paladin.lua @@ -1,93 +1,13 @@ local myname, Cork = ... if Cork.MYCLASS ~= "PALADIN" then return end -local ldb, ae = LibStub:GetLibrary("LibDataBroker-1.1"), LibStub("AceEvent-3.0") + + -- Righteous Fury local spellname, _, icon = GetSpellInfo(25780) Cork:GenerateSelfBuffer(spellname, icon) --- Greater Blessings are any combination of 2 blessings across the whole raid. -local spellnames = {(GetSpellInfo(203538)), (GetSpellInfo(203539))} -local _, _, icon = GetSpellInfo(203538) -local rolespells = {TANK=1, DAMAGER=2, HEALER=3} -local dataobj = ldb:NewDataObject("Cork Greater Blessings", { - type = "cork", - corktype = "buff", - tiplink = GetSpellLink(203538) -}) - -function dataobj:Init() - Cork.defaultspc["Greater Blessings-enabled"] = GetSpellInfo(spellnames[1]) ~= nil -end - -local raidunits, partyunits, otherunits = {}, {}, { ["player"] = true } -for i=1,40 do raidunits["raid"..i] = i end -for i=1,4 do partyunits["party"..i] = i end -function dataobj:Test(unit) - if not UnitExists(unit) or (unit ~= "player" and UnitIsUnit(unit, "player")) - or (IsInRaid() and partyunits[unit]) - or (not raidunits[unit] and not partyunits[unit] and not otherunits[unit]) then return 0 end - local count = 0 - for _, spellname in ipairs(spellnames) do - if UnitAura(unit, spellname, nil, "PLAYER") then - count = count + 1 - end - end - return count -end -function dataobj:Scan(enteringcombat) - if not Cork.dbpc["Greater Blessings-enabled"] or (IsResting() and not Cork.db.debug) or (enteringcombat or InCombatLockdown()) then - self.player = nil - return - end - local count = self:Test("player") - -- We can't scan the same unit twice or we'll get inaccurate results - if IsInRaid() then - for k, _ in pairs(raidunits) do - count = count + self:Test(k) - if count >= 2 then break end - end - elseif IsInGroup() then - for k, _ in pairs(partyunits) do - count = count + self:Test(k) - if count >= 2 then break end - end - end - if count < 2 then - self.player = Cork.IconLine(icon, string.format("Greater Blessings (%d)", 2 - count)) - else - self.player = nil - end -end -function dataobj:CorkIt(frame) - if self.player and Cork.SpellCastableOnUnit(spellnames[1], "player") then - -- figure out which spell in the list we don't have - -- prioritize the first spell based on our role - local role = GetSpecializationRole(GetSpecialization()) - local rolespell = rolespells[role] - if role and not UnitAura("player", spellnames[rolespell], nil, "PLAYER") then -- should this be player-only? - return frame:SetManyAttributes("type1", "spell", "spell", spellnames[rolespell], "unit", "player") - end - -- otherwise just do the spells in order - for _, spellname in ipairs(spellnames) do - if not UnitAura("player", spellname, nil, "PLAYER") then -- should this be player-only? - return frame:SetManyAttributes("type1", "spell", "spell", spellname, "unit", "player") - end - end - end -end -local function isScanUnit(unit) - return not not (raidunits[unit] or partyunits[unit] or otherunits[unit]) -end -function dataobj:TestUnit(event, unit) - if isScanUnit(unit) then self:Scan() end -end -ae.RegisterEvent(dataobj, "UNIT_AURA", "TestUnit") -ae.RegisterEvent(dataobj, "GROUP_ROSTER_UPDATE", "TestUnit") -ae.RegisterEvent(dataobj, "PLAYER_UPDATE_RESTING", function () dataobj:Scan() end) -ae.RegisterEvent(dataobj, "PLAYER_REGEN_DISABLED", function () dataobj:Scan(true) end) -ae.RegisterEvent(dataobj, "PLAYER_REGEN_ENABLED", function () dataobj:Scan() end) -- Beacon of Light local spellname, _, icon = GetSpellInfo(53563) diff --git a/modules/Priest.lua b/modules/Priest.lua deleted file mode 100644 index dfb19f6..0000000 --- a/modules/Priest.lua +++ /dev/null @@ -1,3 +0,0 @@ - -local myname, Cork = ... -if Cork.MYCLASS ~= "PRIEST" then return end diff --git a/modules/Shaman.lua b/modules/Shaman.lua deleted file mode 100644 index a86ff6f..0000000 --- a/modules/Shaman.lua +++ /dev/null @@ -1,3 +0,0 @@ - -local myname, Cork = ... -if Cork.MYCLASS ~= "SHAMAN" then return end diff --git a/modules/Warlock.lua b/modules/Warlock.lua index c3622f8..94944d4 100644 --- a/modules/Warlock.lua +++ b/modules/Warlock.lua @@ -7,7 +7,6 @@ if Cork.MYCLASS ~= "WARLOCK" then return end local spellname, _, icon = GetSpellInfo(108503) Cork:GenerateSelfBuffer(spellname, icon) - -- Soulstone local spellname, _, icon = GetSpellInfo(20707) local dataobj = Cork:GenerateLastBuffedBuffer(spellname, icon) diff --git a/modules/WarlockSoulLink.lua b/modules/WarlockSoulLink.lua deleted file mode 100644 index 56063c4..0000000 --- a/modules/WarlockSoulLink.lua +++ /dev/null @@ -1,33 +0,0 @@ - -local myname, Cork = ... -if Cork.MYCLASS ~= "WARLOCK" then return end - -local myname, Cork = ... -local UnitAura = UnitAura -local ldb, ae = LibStub:GetLibrary("LibDataBroker-1.1"), LibStub("AceEvent-3.0") - - -local soul_link_enabled = select(5, GetTalentInfo(3,1,GetActiveSpecGroup())) -if soul_link_enabled then - local spellname, _, icon = GetSpellInfo(108415) - local IconLine = Cork.IconLine(icon, spellname) - - local dataobj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("Cork "..spellname, {type = "cork", tiplink = GetSpellLink(spellname)}) - - function dataobj:Init() Cork.defaultspc[spellname.."-enabled"] = GetSpellInfo(spellname) ~= nil end - - local function Test(unit) - if Cork.dbpc[spellname.."-enabled"] and UnitExists("pet") and not UnitIsDead("pet") and not UnitAura("pet", spellname) and UnitName("pet") ~= UNKNOWN and not IsMounted() then - return IconLine - end - end - - ae.RegisterEvent("Cork "..spellname, "UNIT_PET", function(event, unit) if unit == "player" then dataobj.pet = Test() end end) - ae.RegisterEvent("Cork "..spellname, "UNIT_AURA", function(event, unit) if unit == "pet" then dataobj.pet = Test() end end) - - function dataobj:Scan() self.pet = Test() end - - function dataobj:CorkIt(frame) - if self.pet then return frame:SetManyAttributes("type1", "spell", "spell", spellname) end - end -end diff --git a/modules/Warrior.lua b/modules/Warrior.lua deleted file mode 100644 index e139784..0000000 --- a/modules/Warrior.lua +++ /dev/null @@ -1,3 +0,0 @@ - -local myname, Cork = ... -if Cork.MYCLASS ~= "WARRIOR" then return end