Added new plugin to update the comparison window

This commit is contained in:
Tercio Jose
2022-11-26 23:08:49 -03:00
parent e3161ff29c
commit 25cb9e8ffe
11 changed files with 2203 additions and 35 deletions
+61
View File
@@ -662,6 +662,67 @@ function openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
end
end
do
--make new namespace
openRaidLib.AuraTracker = {}
function openRaidLib.AuraTracker.ScanCallback(aura)
local unitId = openRaidLib.AuraTracker.CurrentUnitId
local thisUnitAuras = openRaidLib.AuraTracker.CurrentAuras[unitId]
local auraInfo = C_UnitAuras.GetAuraDataByAuraInstanceID(unitId, aura.auraInstanceID)
if (auraInfo) then
local spellId = auraInfo.spellId
if (spellId) then
thisUnitAuras[spellId] = true
openRaidLib.AuraTracker.AurasFoundOnScan[spellId] = true
end
end
end
function openRaidLib.AuraTracker.ScanPlayerAuras(unitId)
local batchCount = nil
local usePackedAura = true
openRaidLib.AuraTracker.CurrentUnitId = unitId
openRaidLib.AuraTracker.AurasFoundOnScan = {}
AuraUtil.ForEachAura(unitId, "HELPFUL", batchCount, openRaidLib.AuraTracker.ScanCallback, usePackedAura)
local thisUnitAuras = openRaidLib.AuraTracker.CurrentAuras[unitId]
for spellId in pairs(thisUnitAuras) do
if (not openRaidLib.AuraTracker.AurasFoundOnScan[spellId]) then
--aura removed
openRaidLib.internalCallback.TriggerEvent("unitAuraRemoved", unitId, spellId)
end
end
end
--run when the open raid lib loads
function openRaidLib.AuraTracker.StartScanUnitAuras(unitId)
openRaidLib.AuraTracker.CurrentAuras = {
[unitId] = {}
}
local auraFrameEvent = CreateFrame("frame")
auraFrameEvent:RegisterUnitEvent("UNIT_AURA", unitId)
auraFrameEvent:SetScript("OnEvent", function()
openRaidLib.AuraTracker.ScanPlayerAuras(unitId)
end)
end
--test case:
local debugModule = {}
function debugModule.AuraRemoved(event, unitId, spellId)
local spellName = GetSpellInfo(spellId)
--print("aura removed:", unitId, spellId, spellName)
end
openRaidLib.internalCallback.RegisterCallback("unitAuraRemoved", debugModule.AuraRemoved)
end
--which is the main attribute of each spec
--1 Intellect
--2 Agility
+36 -3
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 = 81
local CONST_LIB_VERSION = 82
if (not LIB_OPEN_RAID_MAX_VERSION) then
LIB_OPEN_RAID_MAX_VERSION = CONST_LIB_VERSION
@@ -726,6 +726,7 @@ end
["mythicDungeonStart"] = {},
["playerPetChange"] = {},
["mythicDungeonEnd"] = {},
["unitAuraRemoved"] = {},
}
openRaidLib.internalCallback.RegisterCallback = function(event, func)
@@ -804,10 +805,12 @@ end
["PLAYER_ENTERING_WORLD"] = function(...)
--has the selected character just loaded?
if (not openRaidLib.isFirstEnteringWorld) then
if (not openRaidLib.bHasEnteredWorld) then
--register events
openRaidLib.OnEnterWorldRegisterEvents()
--openRaidLib.AuraTracker.StartScanUnitAuras("player")
if (IsInGroup()) then
openRaidLib.RequestAllData()
openRaidLib.UpdateUnitIDCache()
@@ -845,7 +848,7 @@ end
detailsEventListener:RegisterEvent("UNIT_TALENTS", "UnitTalentsFound")
end
openRaidLib.isFirstEnteringWorld = true
openRaidLib.bHasEnteredWorld = true
end
openRaidLib.internalCallback.TriggerEvent("onEnterWorld")
@@ -1984,6 +1987,35 @@ end
openRaidLib.CooldownManager.CheckCooldownChanges()
end
function openRaidLib.CooldownManager.OnAuraRemoved(event, unitId, spellId)
--under development ~aura
local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
--do need to update?
if (not timeLeft or timeLeft < 1 or not auraDuration or auraDuration < 1) then
return
end
local latencyCompensation = 1
if (spellId) then
if (auraDuration > latencyCompensation) then
--cooldown aura got removed before expiration
local newAuraDuration = 0
local unitName = GetUnitName(unitId, true) or unitId
openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, timeLeft, charges, startTimeOffset, duration, newAuraDuration)
--trigger a public callback
local playerCooldownTable = openRaidLib.GetUnitCooldowns(unitName)
local cooldownInfo = cooldownGetSpellInfo(unitName, spellId)
openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", "player", spellId, cooldownInfo, playerCooldownTable, openRaidLib.CooldownManager.UnitData)
--send to comm
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration, newAuraDuration)
end
end
end
openRaidLib.internalCallback.RegisterCallback("onLeaveGroup", openRaidLib.CooldownManager.OnPlayerLeaveGroup)
openRaidLib.internalCallback.RegisterCallback("playerCast", openRaidLib.CooldownManager.OnPlayerCast)
openRaidLib.internalCallback.RegisterCallback("onPlayerRess", openRaidLib.CooldownManager.OnPlayerRess)
@@ -1992,6 +2024,7 @@ end
openRaidLib.internalCallback.RegisterCallback("onLeaveCombat", openRaidLib.CooldownManager.OnEncounterEnd)
openRaidLib.internalCallback.RegisterCallback("mythicDungeonStart", openRaidLib.CooldownManager.OnMythicPlusStart)
openRaidLib.internalCallback.RegisterCallback("playerPetChange", openRaidLib.CooldownManager.OnPlayerPetChanged)
openRaidLib.internalCallback.RegisterCallback("unitAuraRemoved", openRaidLib.CooldownManager.OnAuraRemoved)
--send a list through comm with cooldowns added or removed
function openRaidLib.CooldownManager.CheckCooldownChanges()
@@ -804,6 +804,59 @@ do
--191427 havoc
}
LIB_OPEN_RAID_SPECID_TO_CLASSID = {
[577] = 12,
[581] = 12,
[250] = 6,
[251] = 6,
[252] = 6,
[71] = 1,
[72] = 1,
[73] = 1,
[62] = 8,
[63] = 8,
[64] = 8,
[259] = 4,
[260] = 4,
[261] = 4,
[102] = 11,
[103] = 11,
[104] = 11,
[105] = 11,
[253] = 3,
[254] = 3,
[255] = 3,
[262] = 7,
[263] = 7,
[264] = 7,
[256] = 5,
[257] = 5,
[258] = 5,
[265] = 9,
[266] = 9,
[267] = 9,
[65] = 2,
[66] = 2,
[70] = 2,
[268] = 10,
[269] = 10,
[270] = 10,
[1467] = 13,
[1468] = 13,
}
LIB_OPEN_RAID_DATABASE_LOADED = true
end