Release Candidate 1

This commit is contained in:
Tercio Jose
2022-11-18 16:54:25 -03:00
parent bbbda84c68
commit 1c8dfb3ab7
96 changed files with 3053 additions and 1427 deletions
+85 -73
View File
@@ -14,7 +14,18 @@ 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:
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
@@ -25,29 +36,14 @@ Change Log:
* openRaidLib.GetFlaskTierFromAura(auraInfo)
* openRaidLib.GetFoodInfoBySpellId(spellId)
* openRaidLib.GetFoodTierFromAura(auraInfo)
- added dragonflight talents support
* added dragonflight talents support
* added openRaidLib.RequestCooldownInfo(spellId)
* added openRaidLib.AddCooldownFilter(filterName, spells)
- ensure to register events after 'PLAYER_ENTERING_WORLD' has triggered
- added openRaidLib.RequestCooldownInfo(spellId)
- added openRaidLib.AddCooldownFilter(filterName, spells)
- if Ace Comm is installed, use it
- added "KeystoneWipe" callback
- finished keystone info, see docs
- added interrupts to cooldown tracker, new filter: "interrupt"
- after encounter_end cooldowns now check for cooldowns reset.
- each module now controls what to do with regen_enabled.
- filter cooldowns done.
- move portions of the code to other files to make this one smaller.
- major function and variables rename.
- implemented pvp talents.
- player information is always available even when not in a group.
- added cooldown check to se which cooldown has removed or added into the list.
- added two new callbacks: "CooldownAdded" and "CooldownRemoved", see documents.
TODO:
- make talents changes also send only cooldowns added or changed
- add into gear info how many tier set parts the player has
- raid lockouts normal-heroic-mythic
- soulbind character (covenant choise) - probably not used in 10.0
BUGS:
- after a /reload, it is not starting new tickers for spells under cooldown
@@ -68,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 = 69
local CONST_LIB_VERSION = 72
LIB_OPEN_RAID_CAN_LOAD = false
local unpack = table.unpack or _G.unpack
@@ -133,6 +129,7 @@ local unpack = table.unpack or _G.unpack
local CONST_COOLDOWN_INDEX_TIMEOFFSET = 3
local CONST_COOLDOWN_INDEX_DURATION = 4
local CONST_COOLDOWN_INDEX_UPDATETIME = 5
local CONST_COOLDOWN_INDEX_AURA_DURATION = 6
local GetContainerNumSlots = GetContainerNumSlots or C_Container.GetContainerNumSlots
local GetContainerItemID = GetContainerItemID or C_Container.GetContainerItemID
@@ -1632,14 +1629,14 @@ local cooldownTimeLeftCheck_Ticker = function(tickerObject)
end
tickerObject.cooldownTimeLeft = tickerObject.cooldownTimeLeft - CONST_COOLDOWN_CHECK_INTERVAL
local timeLeft, charges, startTimeOffset, duration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
local bUpdateLocally = false
--is the spell ready to use?
if (timeLeft == 0) then
--it's ready
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, 0, charges, 0, 0)
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, 0, charges, 0, 0, 0)
openRaidLib.CooldownManager.CooldownTickers[spellId] = nil
tickerObject:Cancel()
bUpdateLocally = true
@@ -1647,7 +1644,7 @@ local cooldownTimeLeftCheck_Ticker = function(tickerObject)
--check if the time left has changed, this check if the cooldown got its time reduced and if the cooldown time has been slow down by modRate
if (not openRaidLib.isNearlyEqual(tickerObject.cooldownTimeLeft, timeLeft, CONST_COOLDOWN_TIMELEFT_HAS_CHANGED)) then
--there's a deviation, send a comm to communicate the change in the time left
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration)
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration, auraDuration)
tickerObject.cooldownTimeLeft = timeLeft
bUpdateLocally = true
end
@@ -1655,9 +1652,9 @@ local cooldownTimeLeftCheck_Ticker = function(tickerObject)
if (bUpdateLocally) then
--get the cooldown time for this spell
local timeLeft, charges, startTimeOffset, duration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) --return 5 values
--update the cooldown
openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, startTimeOffset, duration)
openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, startTimeOffset, duration, auraDuration) --need 7 values
local playerCooldownTable = openRaidLib.GetUnitCooldowns(playerName)
local cooldownInfo = openRaidLib.GetUnitCooldownInfo(playerName, spellId)
@@ -1696,7 +1693,7 @@ end
function openRaidLib.CooldownManager.CleanupCooldownTickers()
for spellId, tickerObject in pairs(openRaidLib.CooldownManager.CooldownTickers) do
local timeLeft, charges, startTimeOffset, duration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
if (timeLeft == 0) then
tickerObject:Cancel()
openRaidLib.CooldownManager.CooldownTickers[spellId] = nil
@@ -1722,22 +1719,26 @@ end
local cooldownGetSpellInfo = function(unitName, spellId)
local unitCooldownTable = cooldownGetUnitTable(unitName)
local spellIdTable = unitCooldownTable[spellId]
return spellIdTable
local cooldownInfo = unitCooldownTable[spellId]
return cooldownInfo
end
--update a single cooldown timer
--called when the player casted a cooldown and when received a cooldown update from another player
--only update the db, no other action is taken
function openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, newTimeLeft, newCharges, startTimeOffset, duration)
--cooldownInfo: [1] timeLeft [2] charges [3] startOffset [4] duration [5] updateTime [6] auraDuration
function openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, newTimeLeft, newCharges, startTimeOffset, duration, auraDuration)
--get the cooldown table where all cooldowns are stored for this unit
local unitCooldownTable = cooldownGetUnitTable(unitName)
local spellIdTable = unitCooldownTable[spellId] or {}
spellIdTable[CONST_COOLDOWN_INDEX_TIMELEFT] = newTimeLeft
spellIdTable[CONST_COOLDOWN_INDEX_CHARGES] = newCharges
spellIdTable[CONST_COOLDOWN_INDEX_TIMEOFFSET] = startTimeOffset
spellIdTable[CONST_COOLDOWN_INDEX_DURATION] = duration
spellIdTable[CONST_COOLDOWN_INDEX_UPDATETIME] = GetTime()
unitCooldownTable[spellId] = spellIdTable
--is this a cooldown info?
local cooldownInfo = unitCooldownTable[spellId] or {}
cooldownInfo[CONST_COOLDOWN_INDEX_TIMELEFT] = newTimeLeft
cooldownInfo[CONST_COOLDOWN_INDEX_CHARGES] = newCharges
cooldownInfo[CONST_COOLDOWN_INDEX_TIMEOFFSET] = startTimeOffset
cooldownInfo[CONST_COOLDOWN_INDEX_DURATION] = duration
cooldownInfo[CONST_COOLDOWN_INDEX_UPDATETIME] = GetTime()
cooldownInfo[CONST_COOLDOWN_INDEX_AURA_DURATION] = auraDuration
unitCooldownTable[spellId] = cooldownInfo
end
--API Calls
@@ -1774,6 +1775,10 @@ end
return openRaidLib.CooldownManager.DoesSpellPassFilters(spellId, filter)
end
function openRaidLib.GetSpellFilters(spellId, defaultFilterOnly, customFiltersOnly)
return openRaidLib.CooldownManager.GetSpellFilters(spellId, defaultFilterOnly, customFiltersOnly)
end
--return values about the cooldown time
--values returned: timeLeft, charges, timeOffset, duration, updateTime
function openRaidLib.GetCooldownTimeFromUnitSpellID(unitId, spellId)
@@ -1781,7 +1786,7 @@ end
if (unitCooldownsTable) then
local cooldownInfo = unitCooldownsTable[spellId]
if (cooldownInfo) then
return unpack(cooldownInfo)
return openRaidLib.CooldownManager.GetCooldownInfoValues(cooldownInfo)
end
end
end
@@ -1790,7 +1795,7 @@ end
--values returned: timeLeft, charges, timeOffset, duration, updateTime
function openRaidLib.GetCooldownTimeFromCooldownInfo(cooldownInfo)
if (cooldownInfo) then
return unpack(cooldownInfo)
return openRaidLib.CooldownManager.GetCooldownInfoValues(cooldownInfo)
end
end
@@ -1833,12 +1838,12 @@ end
--values returned: isReady, timeLeft, charges, normalized percent, minValue, maxValue, currentValue
--values are in the GetTime() format
function openRaidLib.GetCooldownStatusFromUnitSpellID(unitId, spellId)
local timeLeft, charges, timeOffset, duration, updateTime
local timeLeft, charges, timeOffset, duration, updateTime, auraDuration
local unitCooldownsTable = openRaidLib.GetUnitCooldowns(unitId)
if (unitCooldownsTable) then
local cooldownInfo = unitCooldownsTable[spellId]
if (cooldownInfo) then
timeLeft, charges, timeOffset, duration, updateTime = unpack(cooldownInfo)
timeLeft, charges, timeOffset, duration, updateTime, auraDuration = openRaidLib.CooldownManager.GetCooldownInfoValues(cooldownInfo)
end
end
@@ -1851,39 +1856,40 @@ end
--values are in the GetTime() format
--GetPercentFromCooldownInfo
function openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
local timeLeft, charges, timeOffset, duration, updateTime = unpack(cooldownInfo)
local timeLeft, charges, timeOffset, duration, updateTime, auraDuration = openRaidLib.CooldownManager.GetCooldownInfoValues(cooldownInfo)
return calculatePercent(timeOffset, duration, updateTime, charges)
end
--internals
function openRaidLib.CooldownManager.GetCooldownInfoValues(cooldownInfo)
local timeLeft, charges, timeOffset, duration, updateTime, auraDuration = unpack(cooldownInfo)
return timeLeft, charges, timeOffset, duration, updateTime, auraDuration
end
function openRaidLib.CooldownManager.OnPlayerCast(event, spellId, isPlayerPet) --~cast
--player casted a spell, check if the spell is registered as cooldown
--local playerSpec = openRaidLib.GetPlayerSpecId() --should be deprecated with cooldowns from spellbook
--if (playerSpec) then
--if (LIB_OPEN_RAID_COOLDOWNS_BY_SPEC[playerSpec] and LIB_OPEN_RAID_COOLDOWNS_BY_SPEC[playerSpec][spellId]) then --kinda deprecated with the new spell from spellbook
--issue: pet spells isn't in this table yet, might mess with pet interrupts
if (LIB_OPEN_RAID_PLAYERCOOLDOWNS[spellId]) then --check if the casted spell is a cooldown the player has available
local playerName = UnitName("player")
--issue: pet spells isn't in this table yet, might mess with pet interrupts
if (LIB_OPEN_RAID_PLAYERCOOLDOWNS[spellId]) then --check if the casted spell is a cooldown the player has available
local playerName = UnitName("player")
--get the cooldown time for this spell
local timeLeft, charges, startTimeOffset, duration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
--get the cooldown time for this spell
local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) --return 5 values
--update the cooldown
openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, startTimeOffset, duration)
local cooldownInfo = cooldownGetSpellInfo(playerName, spellId)
--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)
--trigger a public callback
local playerCooldownTable = openRaidLib.GetUnitCooldowns(playerName)
openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", "player", spellId, cooldownInfo, playerCooldownTable, openRaidLib.CooldownManager.UnitData)
--send to comm
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration)
--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)
end
--end
--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)
end
end
--when the player is ressed while in a group, send the cooldown list
@@ -2015,8 +2021,8 @@ function openRaidLib.CooldownManager.OnReceiveUnitCooldownChanges(data, unitName
local cooldownsAddedUnpacked = openRaidLib.UnpackTable(addedCooldowns, 1, true, true, 5)
for spellId, cooldownInfo in pairs(cooldownsAddedUnpacked) do
--add the spell into the list of cooldowns of this unit
local timeLeft, charges, timeOffset, duration = unpack(cooldownInfo)
openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, timeLeft, charges, timeOffset, duration)
local timeLeft, charges, timeOffset, duration, updateTime, auraDuration = openRaidLib.CooldownManager.GetCooldownInfoValues(cooldownInfo)
openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, timeLeft, charges, timeOffset, duration, auraDuration)
--mark the filter cache of this unit as dirt
openRaidLib.CooldownManager.NeedRebuildFilters[unitName] = true
@@ -2054,15 +2060,16 @@ function openRaidLib.CooldownManager.CheckForSpellsAdeedOrRemoved()
for spellId, cooldownInfo in pairs(newCooldownList) do
if (not currentCooldowns[spellId]) then
--a spell has been added
local timeLeft, charges, timeOffset, duration = unpack(cooldownInfo)
openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, timeOffset, duration)
local timeLeft, charges, timeOffset, duration, updateTime, auraDuration = openRaidLib.CooldownManager.GetCooldownInfoValues(cooldownInfo)
openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, timeOffset, duration, auraDuration)
local timeLeft, charges, startTimeOffset, duration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) --return 5 values
spellsAdded[#spellsAdded+1] = spellId
spellsAdded[#spellsAdded+1] = timeLeft
spellsAdded[#spellsAdded+1] = charges
spellsAdded[#spellsAdded+1] = startTimeOffset
spellsAdded[#spellsAdded+1] = duration
spellsAdded[#spellsAdded+1] = auraDuration
--mark the filter cache of this unit as dirt
openRaidLib.CooldownManager.NeedRebuildFilters[playerName] = true
@@ -2126,6 +2133,7 @@ openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNUPDATE_PREFIX, function(
local charges = tonumber(dataAsArray[3])
local startTime = tonumber(dataAsArray[4])
local duration = tonumber(dataAsArray[5])
local auraDuration = tonumber(dataAsArray[6])
--check integrity
if (not spellId or spellId == 0) then
@@ -2142,10 +2150,14 @@ openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNUPDATE_PREFIX, function(
elseif (not duration) then
return openRaidLib.DiagnosticError("CooldownManager|comm received|duration is invalid")
elseif (not auraDuration) then
return openRaidLib.DiagnosticError("CooldownManager|comm received|auraDuration is invalid")
end
--update
openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, cooldownTimer, charges, startTime, duration)
--unitName, spellId, cooldownTimer, charges, startTime, duration, auraDuration
openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, cooldownTimer, charges, startTime, duration, auraDuration)
local cooldownInfo = cooldownGetSpellInfo(unitName, spellId)
local unitCooldownTable = openRaidLib.GetUnitCooldowns(unitName)
@@ -2180,8 +2192,8 @@ function openRaidLib.CooldownManager.SendAllPlayerCooldowns()
end
--send to comm a specific cooldown that was just used, a charge got available or its cooldown is over (ready to use)
function openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, cooldownTimeLeft, charges, startTimeOffset, duration)
local dataToSend = "" .. CONST_COMM_COOLDOWNUPDATE_PREFIX .. "," .. spellId .. "," .. cooldownTimeLeft .. "," .. charges .. "," .. startTimeOffset .. "," .. duration
function openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, cooldownTimeLeft, charges, startTimeOffset, duration, auraDuration)
local dataToSend = "" .. CONST_COMM_COOLDOWNUPDATE_PREFIX .. "," .. spellId .. "," .. cooldownTimeLeft .. "," .. charges .. "," .. startTimeOffset .. "," .. duration .. "," .. auraDuration
openRaidLib.commHandler.SendCommData(dataToSend)
diagnosticComm("SendPlayerCooldownUpdate| " .. dataToSend) --debug
end
@@ -2219,8 +2231,8 @@ function openRaidLib.CooldownManager.OnReceiveRequestForCooldownInfoUpdate(data,
end
--get the cooldown time for this spell
local timeLeft, charges, startTimeOffset, duration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration)
local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration, auraDuration)
end
openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNREQUEST_PREFIX, openRaidLib.CooldownManager.OnReceiveRequestForCooldownInfoUpdate)
@@ -2533,7 +2545,7 @@ C_Timer.After(0.1, function()
--trigger a cooldown usage
local duration = cooldownInfo.duration
--time left, charges, startTimeOffset, duration
openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, duration, 0, 0, duration)
openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, duration, 0, 0, duration, 0)
local cooldownInfo = cooldownGetSpellInfo(unitName, spellId)
local unitCooldownsTable = openRaidLib.GetUnitCooldowns(unitName)