diff --git a/Libs/LibOpenRaid/Functions.lua b/Libs/LibOpenRaid/Functions.lua index 501ed0d5..50eab896 100644 --- a/Libs/LibOpenRaid/Functions.lua +++ b/Libs/LibOpenRaid/Functions.lua @@ -18,7 +18,9 @@ local CONST_COOLDOWN_TYPE_DEFENSIVE_TARGET = 3 local CONST_COOLDOWN_TYPE_DEFENSIVE_RAID = 4 local CONST_COOLDOWN_TYPE_UTILITY = 5 local CONST_COOLDOWN_TYPE_INTERRUPT = 6 -local CONST_COOLDOWN_TYPE_ITEM = 10 +local CONST_COOLDOWN_TYPE_ITEMHEAL = 10 +local CONST_COOLDOWN_TYPE_ITEMPOWER = 11 +local CONST_COOLDOWN_TYPE_ITEMUTIL = 12 --hold spellIds and which custom caches the spell is in --map[spellId] = map[filterName] = true @@ -180,7 +182,9 @@ local filterStringToCooldownType = { ["ofensive"] = CONST_COOLDOWN_TYPE_OFFENSIVE, ["utility"] = CONST_COOLDOWN_TYPE_UTILITY, ["interrupt"] = CONST_COOLDOWN_TYPE_INTERRUPT, - ["item"] = CONST_COOLDOWN_TYPE_ITEM, + ["itemutil"] = CONST_COOLDOWN_TYPE_ITEMUTIL, + ["itemheal"] = CONST_COOLDOWN_TYPE_ITEMHEAL, + ["itempower"] = CONST_COOLDOWN_TYPE_ITEMPOWER, } local filterStringToCooldownTypeReverse = { @@ -190,7 +194,9 @@ local filterStringToCooldownTypeReverse = { [CONST_COOLDOWN_TYPE_OFFENSIVE] = "ofensive", [CONST_COOLDOWN_TYPE_UTILITY] = "utility", [CONST_COOLDOWN_TYPE_INTERRUPT] = "interrupt", - [CONST_COOLDOWN_TYPE_ITEM] = "item", + [CONST_COOLDOWN_TYPE_ITEMUTIL] = "itemutil", + [CONST_COOLDOWN_TYPE_ITEMHEAL] = "itemheal", + [CONST_COOLDOWN_TYPE_ITEMPOWER] = "itempower", } local removeSpellFromCustomFilterCache = function(spellId, filterName) diff --git a/Libs/LibOpenRaid/GetPlayerInformation.lua b/Libs/LibOpenRaid/GetPlayerInformation.lua index 44b52900..56982ce7 100644 --- a/Libs/LibOpenRaid/GetPlayerInformation.lua +++ b/Libs/LibOpenRaid/GetPlayerInformation.lua @@ -19,6 +19,11 @@ local CONST_BTALENT_VERSION_COVENANTS = 9 local CONST_SPELLBOOK_CLASSSPELLS_TABID = 2 local CONST_SPELLBOOK_GENERAL_TABID = 1 +local CONST_ISITEM_BY_TYPEID = { + [10] = true, --healing items + [11] = true, --attack items + [12] = true, --utility items +} local GetItemInfo = GetItemInfo local GetItemStats = GetItemStats @@ -580,9 +585,9 @@ local updateCooldownAvailableList = function() --build a list of all spells assigned as cooldowns for the player class for spellID, spellData in pairs(LIB_OPEN_RAID_COOLDOWNS_INFO) do --type 10 is an item cooldown and does not have a class or raceid - if (spellData.class == playerClass or spellData.raceid == playerRaceId or spellData.type == 10) then --need to implement here to get the racial as racial cooldowns does not carry a class + if (spellData.class == playerClass or spellData.raceid == playerRaceId or CONST_ISITEM_BY_TYPEID[spellData.type]) then --need to implement here to get the racial as racial cooldowns does not carry a class --type 10 is an item cooldown and does not have a spellbook entry - if (spellBookSpellList[spellID] or spellData.type == 10) then + if (spellBookSpellList[spellID] or CONST_ISITEM_BY_TYPEID[spellData.type]) then LIB_OPEN_RAID_PLAYERCOOLDOWNS[spellID] = spellData end end @@ -711,8 +716,8 @@ end ---@return number buffDuration function openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) --check if is a charge spell - local cooldownInfo = LIB_OPEN_RAID_COOLDOWNS_INFO[spellId] - if (cooldownInfo) then + local spellData = LIB_OPEN_RAID_COOLDOWNS_INFO[spellId] + if (spellData) then local buffDuration = getAuraDuration(spellId) local chargesAvailable, chargesTotal, start, duration = GetSpellCharges(spellId) if chargesAvailable then diff --git a/Libs/LibOpenRaid/LibOpenRaid.lua b/Libs/LibOpenRaid/LibOpenRaid.lua index 334e8041..a1de9b88 100644 --- a/Libs/LibOpenRaid/LibOpenRaid.lua +++ b/Libs/LibOpenRaid/LibOpenRaid.lua @@ -64,7 +64,7 @@ if (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE and not isExpansion_Dragonflight()) t end local major = "LibOpenRaid-1.0" -local CONST_LIB_VERSION = 94 +local CONST_LIB_VERSION = 95 if (not LIB_OPEN_RAID_MAX_VERSION) then LIB_OPEN_RAID_MAX_VERSION = CONST_LIB_VERSION @@ -1962,10 +1962,28 @@ end --get the cooldown time for this spell local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) --return 5 values + --check for shared cooldown time - warning: this block of code is duplicated at "openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNUPDATE_PREFIX" + local spellData = LIB_OPEN_RAID_COOLDOWNS_INFO[spellId] + local sharedCooldownId = spellData and spellData.shareid + if (sharedCooldownId) then + local spellsWithSharedCooldown = LIB_OPEN_RAID_COOLDOWNS_SHARED_ID[sharedCooldownId] + for thisSpellId in pairs(spellsWithSharedCooldown) do + --don't run for the spell that triggered the shared cooldown + if (thisSpellId ~= spellId) then + openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, thisSpellId, timeLeft, charges, startTimeOffset, duration, auraDuration) + + local cooldownInfo = cooldownGetSpellInfo(playerName, thisSpellId) + local unitCooldownTable = openRaidLib.GetUnitCooldowns(playerName) + + --trigger a public callback + openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", openRaidLib.GetUnitID(playerName), thisSpellId, cooldownInfo, unitCooldownTable, openRaidLib.CooldownManager.UnitData) + end + end + end + --update the cooldown openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, startTimeOffset, duration, auraDuration) --receive 7 values local cooldownInfo = cooldownGetSpellInfo(playerName, spellId) - --trigger a public callback local playerCooldownTable = openRaidLib.GetUnitCooldowns(playerName) openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", "player", spellId, cooldownInfo, playerCooldownTable, openRaidLib.CooldownManager.UnitData) @@ -2274,6 +2292,25 @@ openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNUPDATE_PREFIX, function( return openRaidLib.DiagnosticError("CooldownManager|comm received|auraDuration is invalid") end + --check for shared cooldown time + local spellData = LIB_OPEN_RAID_COOLDOWNS_INFO[spellId] --warning this block of code is duplicated at warning: this block of code is duplicated at "openRaidLib.CooldownManager.OnPlayerCast" + local sharedCooldownId = spellData and spellData.shareid + if (sharedCooldownId) then + local spellsWithSharedCooldown = LIB_OPEN_RAID_COOLDOWNS_SHARED_ID[sharedCooldownId] + for thisSpellId in pairs(spellsWithSharedCooldown) do + --don't run for the spell that triggered the shared cooldown + if (thisSpellId ~= spellId) then + openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, thisSpellId, cooldownTimer, charges, startTime, duration, auraDuration) + + local cooldownInfo = cooldownGetSpellInfo(unitName, thisSpellId) + local unitCooldownTable = openRaidLib.GetUnitCooldowns(unitName) + + --trigger a public callback + openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", openRaidLib.GetUnitID(unitName), thisSpellId, cooldownInfo, unitCooldownTable, openRaidLib.CooldownManager.UnitData) + end + end + end + --update --unitName, spellId, cooldownTimer, charges, startTime, duration, auraDuration openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, cooldownTimer, charges, startTime, duration, auraDuration) @@ -2630,8 +2667,8 @@ C_Timer.After(0.1, function() if (unitName and not hasLib) then local unitInGroup = UnitInParty(unit) or UnitInRaid(unit) if (unitInGroup) then - local cooldownInfo = allCooldownsFromLib[spellId] - if (cooldownInfo) then -- and not openRaidLib.GetUnitCooldown(unitName) + local spellData = allCooldownsFromLib[spellId] + if (spellData) then -- and not openRaidLib.GetUnitCooldown(unitName) --check for cast_success spam from channel spells local unitCastCooldown = recentCastedSpells[unitName] if (not unitCastCooldown) then @@ -2643,7 +2680,7 @@ C_Timer.After(0.1, function() unitCastCooldown[spellId] = GetTime() --trigger a cooldown usage - local duration = cooldownInfo.duration + local duration = spellData.duration --time left, charges, startTimeOffset, duration openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, duration, 0, 0, duration, 0) local cooldownInfo = cooldownGetSpellInfo(unitName, spellId) diff --git a/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua b/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua index b2310a15..9612eaa9 100644 --- a/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua +++ b/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua @@ -256,13 +256,19 @@ do -- 7 dispel -- 8 crowd control -- 9 racials - -- 10 items + -- 10 item heal + -- 11 item power + -- 12 item utility - --attack potions - [371024] = {cooldown = 300, duration = 30, specs = {}, talent = false, charges = 1, class = "", type = 10}, --Elemental Potion of Power --defensive potions [6262] = {cooldown = 60, duration = 0, specs = {}, talent = false, charges = 1, class = "", type = 10}, --Healthstone - [370511] = {cooldown = 300, duration = 0, specs = {}, talent = false, charges = 1, class = "", type = 10}, --Refreshing Healing Potion + [370511] = {cooldown = 300, duration = 0, specs = {}, talent = false, charges = 1, class = "", type = 10, shareid = 101}, --Refreshing Healing Potion + + --attack potions + [371024] = {cooldown = 300, duration = 30, specs = {}, talent = false, charges = 1, class = "", type = 11, shareid = 101}, --Elemental Potion of Power + + --utility potions + [371124] = {cooldown = 300, duration = 0, specs = {}, talent = false, charges = 1, class = "", type = 12, shareid = 101}, --exp9 invisibility potion --racials --maintanance: login into the new race and type /run Details.GenerateRacialSpellList() @@ -665,12 +671,23 @@ do --this table store all cooldowns the player currently have available LIB_OPEN_RAID_PLAYERCOOLDOWNS = {} - LIB_OPEN_RAID_COOLDOWNS_BY_SPEC = {}; + LIB_OPEN_RAID_COOLDOWNS_BY_SPEC = {} - for spellID,spellData in pairs(LIB_OPEN_RAID_COOLDOWNS_INFO) do - for _,specID in ipairs(spellData.specs) do - LIB_OPEN_RAID_COOLDOWNS_BY_SPEC[specID] = LIB_OPEN_RAID_COOLDOWNS_BY_SPEC[specID] or {}; - LIB_OPEN_RAID_COOLDOWNS_BY_SPEC[specID][spellID] = spellData.type; + --spells or items with a shared cooldown + --the list is build in the loop below + --format: table[sharedID] = { [spellID] = type, [spellID] = type, [spellID] = type, ... } + LIB_OPEN_RAID_COOLDOWNS_SHARED_ID = {} + + for spellID, spellData in pairs(LIB_OPEN_RAID_COOLDOWNS_INFO) do + for _, specID in ipairs(spellData.specs) do + LIB_OPEN_RAID_COOLDOWNS_BY_SPEC[specID] = LIB_OPEN_RAID_COOLDOWNS_BY_SPEC[specID] or {} + LIB_OPEN_RAID_COOLDOWNS_BY_SPEC[specID][spellID] = spellData.type + end + + if (spellData.shareid) then + local id = spellData.shareid + LIB_OPEN_RAID_COOLDOWNS_SHARED_ID[id] = LIB_OPEN_RAID_COOLDOWNS_SHARED_ID[id] or {} + LIB_OPEN_RAID_COOLDOWNS_SHARED_ID[id][spellID] = spellData.type end end diff --git a/frames/window_cdtracker.lua b/frames/window_cdtracker.lua index 8f3b542b..2884d80d 100644 --- a/frames/window_cdtracker.lua +++ b/frames/window_cdtracker.lua @@ -324,17 +324,15 @@ end end local xPos = 1 - local yPos = 0 - local maxHeight = 0 - local maxWidth = Details.ocd_tracker.width + 2 local cooldownFrameIndex = 1 + local lineIndex = 1 + local totalLinesUsed = 0 for classId = 1, 13 do local cooldownFrameList = cooldownsOrganized[classId] for index, cooldownFrame in ipairs(cooldownFrameList) do local cooldownInfo = cooldownFrame.cooldownInfo local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) - --local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromUnitSpellID(cooldownFrame.unitName, cooldownFrame.spellId) if (not isReady) then cooldownFrame:SetTimer(currentValue, minValue, maxValue) @@ -342,30 +340,34 @@ end cooldownFrame:SetTimer() end - --positioning - if (cooldownFrameIndex % Details.ocd_tracker.lines_per_column == 0) then + cooldownFrame:ClearAllPoints() + local yLocation = (lineIndex - 1) * Details.ocd_tracker.height * -1 + cooldownFrame:SetPoint("topleft", screenPanel, "topleft", xPos, yLocation - 1) + + lineIndex = lineIndex + 1 + + if (lineIndex > Details.ocd_tracker.lines_per_column) then xPos = xPos + Details.ocd_tracker.width + 2 - maxWidth = xPos + Details.ocd_tracker.width + 2 - yPos = 0 - end - cooldownFrame:SetPoint("topleft", screenPanel, "topleft", xPos, yPos) - yPos = yPos - Details.ocd_tracker.height - 1 - if (yPos < maxHeight) then - maxHeight = yPos + lineIndex = 1 end cooldownFrameIndex = cooldownFrameIndex + 1 + totalLinesUsed = totalLinesUsed + 1 end end - maxHeight = abs(maxHeight) - - if (maxHeight == 0) then + if (totalLinesUsed == 0) then screenPanel:Hide() return end - screenPanel:SetSize(maxWidth, maxHeight) + local totalColumns = ceil(totalLinesUsed / Details.ocd_tracker.lines_per_column) + local maxRows = math.min(Details.ocd_tracker.lines_per_column, totalLinesUsed) + + local width = 1 + totalColumns * Details.ocd_tracker.width + (totalColumns * 2) + local height = 2 + maxRows * Details.ocd_tracker.height + + screenPanel:SetSize(width, height) screenPanel:Show() end @@ -538,15 +540,37 @@ end {--filter: item cooldowns type = "toggle", - get = function() return Details.ocd_tracker.filters["item"] end, + get = function() return Details.ocd_tracker.filters["itemheal"] end, set = function(self, fixedparam, value) - Details.ocd_tracker.filters["item"] = value + Details.ocd_tracker.filters["itemheal"] = value Details222.CooldownTracking.RefreshCooldownFrames() end, - name = "Item Cooldowns", + name = "Item: Healing", desc = "Example: Healthstone.", }, + {--filter: item cooldowns + type = "toggle", + get = function() return Details.ocd_tracker.filters["itempower"] end, + set = function(self, fixedparam, value) + Details.ocd_tracker.filters["itempower"] = value + Details222.CooldownTracking.RefreshCooldownFrames() + end, + name = "Item: Power Increase", + desc = "Example: Elemental Potion of Power.", + }, + + {--filter: item cooldowns + type = "toggle", + get = function() return Details.ocd_tracker.filters["itemutil"] end, + set = function(self, fixedparam, value) + Details.ocd_tracker.filters["itemutil"] = value + Details222.CooldownTracking.RefreshCooldownFrames() + end, + name = "Item: Utility", + desc = "Example: Invisibility Potion.", + }, + {type = "breakline"}, {--bar width