Open Raid Library Update

This commit is contained in:
Tercio Jose
2023-01-30 16:21:53 -03:00
parent c474b762bb
commit 0802fc55c1
5 changed files with 130 additions and 41 deletions
+9 -3
View File
@@ -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)
+9 -4
View File
@@ -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
+42 -5
View File
@@ -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)
@@ -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