diff --git a/Libs/DF/cooltip.lua b/Libs/DF/cooltip.lua index cc69ff2c..57cae134 100644 --- a/Libs/DF/cooltip.lua +++ b/Libs/DF/cooltip.lua @@ -15,7 +15,7 @@ local max = math.max --api locals local PixelUtil = PixelUtil or DFPixelUtil -local version = 9 +local version = 10 local CONST_MENU_TYPE_MAINMENU = "main" local CONST_MENU_TYPE_SUBMENU = "sub" @@ -2169,6 +2169,11 @@ function DF:CreateCoolTip() end end + --get the value of the fixed parameter + function gameCooltip:GetFixedParameter() + return gameCooltip.FixedValue + end + --set a fixed value for menu, the fixedValue is sent with the menu callback function function gameCooltip:SetFixedParameter(value, injected) if (injected ~= nil) then @@ -3072,6 +3077,10 @@ function DF:CreateCoolTip() return gameCooltip:ShowCooltip(frame, menuType, color) end + function gameCooltip:IsShown() + return frame1:IsShown() + end + function gameCooltip:ShowCooltip(frame, menuType, color) frame1:SetFrameStrata("TOOLTIP") frame2:SetFrameStrata("TOOLTIP") diff --git a/Libs/LibOpenRaid/GetPlayerInformation.lua b/Libs/LibOpenRaid/GetPlayerInformation.lua index e17c384e..ed0c9158 100644 --- a/Libs/LibOpenRaid/GetPlayerInformation.lua +++ b/Libs/LibOpenRaid/GetPlayerInformation.lua @@ -701,12 +701,13 @@ end --@spellId: the spellId to check for cooldown --return timeLeft, charges, startTimeOffset, duration, buffDuration function openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) - --check if is a charge spell + --get the cooldown info from the cooldowns database of the lib local cooldownInfo = LIB_OPEN_RAID_COOLDOWNS_INFO[spellId] if (cooldownInfo) then local buffDuration = getAuraDuration(spellId) + local chargesAvailable, chargesTotal, start, duration = GetSpellCharges(spellId) - if chargesAvailable then + if (chargesAvailable) then if (chargesAvailable == chargesTotal) then return 0, chargesTotal, 0, 0, 0 --all charges are ready to use else @@ -716,13 +717,13 @@ function openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) return ceil(timeLeft), chargesAvailable, startTimeOffset, duration, buffDuration --time left, charges, startTime, duration, buffDuration end else - local start, duration = GetSpellCooldown(spellId) - if (start == 0) then --cooldown is ready + local startTime, cooldownDuration = GetSpellCooldown(spellId) + if (startTime == 0) then --cooldown is ready return 0, 1, 0, 0, 0 --time left, charges, startTime else - local timeLeft = start + duration - GetTime() - local startTimeOffset = start - GetTime() - return ceil(timeLeft), 0, ceil(startTimeOffset), duration, buffDuration --time left, charges, startTime, duration, buffDuration + local timeLeft = startTime + cooldownDuration - GetTime() + local startTimeOffset = startTime - GetTime() + return ceil(timeLeft), 0, ceil(startTimeOffset), cooldownDuration, buffDuration --time left, charges, startTime, duration, buffDuration end end else diff --git a/Libs/LibOpenRaid/LibOpenRaid.lua b/Libs/LibOpenRaid/LibOpenRaid.lua index ace138c9..280df352 100644 --- a/Libs/LibOpenRaid/LibOpenRaid.lua +++ b/Libs/LibOpenRaid/LibOpenRaid.lua @@ -2,7 +2,7 @@ --[=[ Please refer to the docs.txt within this file folder for a guide on how to use this library. -If you get lost on implementing the lib, be free to contact Tercio on Details! discord: https://discord.gg/AGSzAZX or email to terciob@gmail.com +If you get lost on implementing the lib, be free to contact Tercio on Details! discord: https://discord.gg/AGSzAZX or email to terciob19@hotmail.com UnitID: UnitID use: "player", "target", "raid18", "party3", etc... @@ -14,23 +14,6 @@ Code Rules: - Internal callbacks are the internal communication of the library, e.g. when an event triggers it send to all modules that registered that event. - Public callbacks are callbacks registered by an external addon. -Change Log (most recent on 2022 Nov 18): - - added racials with cooldown type 9 - - added buff duration in the index 6 of the cooldownInfo table returned on any cooldown event - - added 'durationSpellId' for cooldowns where the duration effect is another spell other than the casted cooldown spellId, add this member on cooldown table at LIB_OPEN_RAID_COOLDOWNS_INFO - -------- Nov 07 and older - - added: - * added openRaidLib.GetSpellFilters(spellId, defaultFilterOnly, customFiltersOnly) (see docs) - - passing a spellId of a non registered cooldown on LIB_OPEN_RAID_COOLDOWNS_INFO will trigger a diagnostic error if diagnostic errors are enabled. - - player cast doesn't check anymore for cooldowns in the player spec, now it check towards the cache LIB_OPEN_RAID_PLAYERCOOLDOWNS. - LIB_OPEN_RAID_PLAYERCOOLDOWNS is a cache built with cooldowns present in the player spellbook. - - - things to maintain now has 1 file per expansion - - player conduits, covenant internally renamed to playerInfo1 and playerInfo2 to make the lib more future proof - - player conduits tree is now Borrowed Talents Tree, for future proof - - removed the talent size limitation on 7 indexes - - added: * openRaidLib.GetFlaskInfoBySpellId(spellId) * openRaidLib.GetFlaskTierFromAura(auraInfo) @@ -39,14 +22,14 @@ Change Log (most recent on 2022 Nov 18): * added dragonflight talents support * added openRaidLib.RequestCooldownInfo(spellId) * added openRaidLib.AddCooldownFilter(filterName, spells) - - ensure to register events after 'PLAYER_ENTERING_WORLD' has triggered TODO: - - add into gear info how many tier set parts the player has + - [not required as the lib is passing the entire gear equipped] add into gear info how many tier set parts the player has - raid lockouts normal-heroic-mythic BUGS: - after a /reload, it is not starting new tickers for spells under cooldown + - (asakawa report) after receiving a comm, the callback is firing twice --]=] @@ -64,7 +47,7 @@ if (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE and not isExpansion_Dragonflight()) t end local major = "LibOpenRaid-1.0" -local CONST_LIB_VERSION = 87 +local CONST_LIB_VERSION = 90 if (not LIB_OPEN_RAID_MAX_VERSION) then LIB_OPEN_RAID_MAX_VERSION = CONST_LIB_VERSION @@ -813,6 +796,8 @@ end --openRaidLib.AuraTracker.StartScanUnitAuras("player") + openRaidLib.StartScanningCooldownsRoutine() + if (IsInGroup()) then openRaidLib.RequestAllData() openRaidLib.UpdateUnitIDCache() @@ -1688,8 +1673,81 @@ openRaidLib.CooldownManager = { HasFullCooldownList = {}, --store player names with the library } +function openRaidLib.StartScanningCooldownsRoutine() + --store spells which isn't ready (most likelly it is on cooldown) + local spellCooldownControl = {} + local startTime = GetTime() + local playerName = UnitName("player") + + --currently this is running only for the spells which doesn't have charges + + C_Timer.NewTicker(0.5, function() + --technically, the deltaTie is 0.5, but it is framerate dependent, so we calculate it + local deltaTime = GetTime() - startTime + startTime = GetTime() + + --check first if the list of cooldown spells is ready + if (LIB_OPEN_RAID_PLAYERCOOLDOWNS) then + for spellId, spellData in pairs(LIB_OPEN_RAID_PLAYERCOOLDOWNS) do + local hasCharges = spellData.charges >= 2 + if (not hasCharges) then + local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) + + --check if the spell is on cooldown + if (timeLeft > 0) then + if (not spellCooldownControl[spellId]) then + --put the spell on cooldown + spellCooldownControl[spellId] = { + onCooldown = true, + timeLeft = timeLeft, + } + else + --the spell is already on cooldown, check if the time left has changed + local deprectedTimeLeft = spellCooldownControl[spellId].timeLeft - deltaTime + if (not openRaidLib.isNearlyEqual(deprectedTimeLeft, timeLeft, 1.5)) then + --if the prediction failed, then the cooldown time left got changed, the code doesn't know if it got shorter or longer + openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration, auraDuration) + + --update locally + --get the cooldown time for this spell + openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, startTimeOffset, duration, auraDuration) --need 7 values + local playerCooldownTable = openRaidLib.GetUnitCooldowns(playerName) + local cooldownInfo = openRaidLib.GetUnitCooldownInfo(playerName, spellId) + openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", "player", spellId, cooldownInfo, playerCooldownTable, openRaidLib.CooldownManager.UnitData) + end + + --update the time left on the control table for this spell + spellCooldownControl[spellId].timeLeft = timeLeft + end + else + --the spell has no cooldown, check if it was on cooldown before + if (spellCooldownControl[spellId]) then + spellCooldownControl[spellId] = nil + + --on ENCOUNTER_END all cooldowns are reset, this may trigger a few cooldowns getting ready + --as the lib send a full cooldown update when the encounter end, it is better avoid sending a cooldown update from here + local encounterEndTime = openRaidLib.CooldownManager.EncounterEndTime + if (not encounterEndTime or GetTime() > encounterEndTime+1) then + openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, 0, charges, 0, 0, 0) + + --update locally + --get the cooldown time for this spell + openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, startTimeOffset, duration, auraDuration) --need 7 values + local playerCooldownTable = openRaidLib.GetUnitCooldowns(playerName) + local cooldownInfo = openRaidLib.GetUnitCooldownInfo(playerName, spellId) + openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", "player", spellId, cooldownInfo, playerCooldownTable, openRaidLib.CooldownManager.UnitData) + end + end + end + end + end + end + end) +end + --check if a cooldown time has changed or finished ---this function run within a ticker, the internal is CONST_COOLDOWN_CHECK_INTERVAL +--this function run within a ticker, the interval is CONST_COOLDOWN_CHECK_INTERVAL +--atm the ticker is only running for spells with 2 or more charges delcared in the things to maintain list local cooldownTimeLeftCheck_Ticker = function(tickerObject) local spellId = tickerObject.spellId @@ -1735,24 +1793,29 @@ local cooldownTimeLeftCheck_Ticker = function(tickerObject) end --after a spell is casted by the player, start a ticker to check its cooldown -local cooldownStartTicker = function(spellId, cooldownTimeLeft) +---@spellId: number ---is the spell id of the spell that was casted +---@cooldownTimeLeft: number ---is the time left of the cooldown +---@chargesOnFile: number ---is the amount of charges declared in the things to maintain +local cooldownStartTicker = function(spellId, cooldownTimeLeft, chargesOnFile) local existingTicker = openRaidLib.CooldownManager.CooldownTickers[spellId] if (existingTicker) then --if a ticker already exists, might be the cooldown of a charge --if the ticker isn't about to expire, just keep the timer --when the ticker finishes it'll check again for charges - if (existingTicker.startTime + existingTicker.cooldownTimeLeft - GetTime() > 2) then - return + if (chargesOnFile and chargesOnFile >= 2) then + if (existingTicker.startTime + existingTicker.cooldownTimeLeft - GetTime() > 2) then + return + end end - --cancel the existing ticker + --check if the existing ticker is not cancelled if (not existingTicker:IsCancelled()) then existingTicker:Cancel() end end --create a new ticker - local maxTicks = ceil(cooldownTimeLeft / CONST_COOLDOWN_CHECK_INTERVAL) + local maxTicks = ceil(cooldownTimeLeft / CONST_COOLDOWN_CHECK_INTERVAL) + 1 local newTicker = C_Timer.NewTicker(CONST_COOLDOWN_CHECK_INTERVAL, cooldownTimeLeftCheck_Ticker, maxTicks) --store the ticker @@ -1763,6 +1826,7 @@ local cooldownStartTicker = function(spellId, cooldownTimeLeft) newTicker.endTime = GetTime() + cooldownTimeLeft end +--called from the encounter end event, check all tickers and cancel those with a cooldown time left of 0 function openRaidLib.CooldownManager.CleanupCooldownTickers() for spellId, tickerObject in pairs(openRaidLib.CooldownManager.CooldownTickers) do local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) @@ -1773,6 +1837,10 @@ function openRaidLib.CooldownManager.CleanupCooldownTickers() end end +---get the table containing all cooldowns for a unit +---@param unitName string +---@param shouldWipe boolean +---@return table local cooldownGetUnitTable = function(unitName, shouldWipe) local unitCooldownTable = openRaidLib.CooldownManager.UnitData[unitName] --check if the unit has a cooldownTable @@ -1871,8 +1939,8 @@ end end end - --return a table containing values about the cooldown time - --values returned: {timeLeft, charges, timeOffset, duration, updateTime} + ---return a table containing values about the cooldown time + ---values returned: {timeLeft, charges, timeOffset, duration, updateTime} function openRaidLib.GetUnitCooldownInfo(unitId, spellId) local unitCooldownsTable = openRaidLib.GetUnitCooldowns(unitId) if (unitCooldownsTable) then @@ -1881,6 +1949,7 @@ end end end + ---comment: this function is used to calculate the percent of a cooldown local calculatePercent = function(timeOffset, duration, updateTime, charges) timeOffset = abs(timeOffset) local minValue = updateTime - timeOffset @@ -1958,9 +2027,10 @@ end --send to comm openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration, auraDuration) - --create a timer to monitor the time of this cooldown - --as there's just a few of them to monitor, there's no issue on creating one timer per spell - cooldownStartTicker(spellId, timeLeft) + --create a ticker to monitor spells with charges + if (LIB_OPEN_RAID_COOLDOWNS_INFO[spellId].charges >= 2) then + cooldownStartTicker(spellId, timeLeft, LIB_OPEN_RAID_COOLDOWNS_INFO[spellId].charges) + end end end @@ -1995,9 +2065,10 @@ end --check cooldown reset after a raid encounter ends finishing ongoing timeLeft tickers function openRaidLib.CooldownManager.CheckCooldownsAfterEncounterEnd() openRaidLib.CooldownManager.CleanupCooldownTickers() - openRaidLib.Schedules.NewUniqueTimer(1 + math.random(1, 4), openRaidLib.CooldownManager.SendAllPlayerCooldowns, "CooldownManager", "sendAllPlayerCooldowns_Schedule") + openRaidLib.Schedules.NewUniqueTimer(3 + math.random(1, 4), openRaidLib.CooldownManager.SendAllPlayerCooldowns, "CooldownManager", "sendAllPlayerCooldowns_Schedule") end function openRaidLib.CooldownManager.OnEncounterEnd() + openRaidLib.CooldownManager.EncounterEndTime = GetTime() --run on next frame openRaidLib.Schedules.NewUniqueTimer(0.1, openRaidLib.CooldownManager.CheckCooldownsAfterEncounterEnd, "CooldownManager", "encounterEndCooldownsCheck_Schedule") end @@ -2208,7 +2279,8 @@ end --adds a list of cooldowns for another player in the group --this is only called from the received cooldown list from comm function openRaidLib.CooldownManager.AddUnitCooldownsList(unitName, cooldownsTable, noCallback) - local unitCooldownTable = cooldownGetUnitTable(unitName, true) --sending true to wipe previous data + local bShouldWipe = true + local unitCooldownTable = cooldownGetUnitTable(unitName, bShouldWipe) --sending true to wipe previous data openRaidLib.TCopy(unitCooldownTable, cooldownsTable) --add the unitName to the list of units detected with the lib @@ -2595,67 +2667,5 @@ openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNREQUEST_PREFIX, openRaid openRaidLib.internalCallback.RegisterCallback("mythicDungeonEnd", openRaidLib.KeystoneInfoManager.OnMythicDungeonFinished) -------------------------------------------------------------------------------------------------------------------------------- ---data - ---vintage cooldown tracker and interrupt tracker -C_Timer.After(0.1, function() - local vintageCDTrackerFrame = CreateFrame("frame") - vintageCDTrackerFrame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") - local allCooldownsFromLib = LIB_OPEN_RAID_COOLDOWNS_INFO - local recentCastedSpells = {} - - vintageCDTrackerFrame:SetScript("OnEvent", function(self, event, ...) - if (event == "UNIT_SPELLCAST_SUCCEEDED") then - local unit, castGUID, spellId = ... - - local unitIsThePlayer = UnitIsUnit(unit, "player") - if (not unitIsThePlayer) then - local unitName = GetUnitName(unit, true) - local hasLib = openRaidLib.CooldownManager.HasFullCooldownList[unitName] - 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) - --check for cast_success spam from channel spells - local unitCastCooldown = recentCastedSpells[unitName] - if (not unitCastCooldown) then - unitCastCooldown = {} - recentCastedSpells[unitName] = unitCastCooldown - end - - if (not unitCastCooldown[spellId] or unitCastCooldown[spellId]+5 < GetTime()) then - unitCastCooldown[spellId] = GetTime() - - --trigger a cooldown usage - local duration = cooldownInfo.duration - --time left, charges, startTimeOffset, duration - openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, duration, 0, 0, duration, 0) - local cooldownInfo = cooldownGetSpellInfo(unitName, spellId) - local unitCooldownsTable = openRaidLib.GetUnitCooldowns(unitName) - - --trigger a public callback - openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", openRaidLib.GetUnitID(unitName), spellId, cooldownInfo, unitCooldownsTable, openRaidLib.CooldownManager.UnitData) - end - end - end - end - end - end - end) -end) tempCache.RestoreData() - - ---[=[ -3x ...ns/Details/Libs/LibOpenRaid/GetPlayerInformation.lua:603: attempt to index field '?' (a nil value) -[string "@Interface/AddOns/Details/Libs/LibOpenRaid/GetPlayerInformation.lua"]:634: in function `GetPlayerCooldownStatus' -[string "@Interface/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua"]:1696: in function `CleanupCooldownTickers' -[string "@Interface/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua"]:1925: in function <...face/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua:1924> -[string "=[C]"]: in function `xpcall' -[string "@Interface/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua"]:506: in function <...face/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua:496> - - - -]=] \ No newline at end of file diff --git a/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua b/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua index ecbd978a..7fc263da 100644 --- a/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua +++ b/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua @@ -121,7 +121,7 @@ do [INVSLOT_MAINHAND] = true, [INVSLOT_FEET] = true, [INVSLOT_WRIST] = true, - [INVSLOT_HAND] = true, + [INVSLOT_HAND] = false, } -- how to get the enchantId: @@ -839,4 +839,4 @@ do end end) loadLibDatabase() -end \ No newline at end of file +end