Skip to content

Commit

Permalink
Release Candidate 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Jan 20, 2024
1 parent 4eff7b2 commit b7c2b6c
Show file tree
Hide file tree
Showing 9 changed files with 599 additions and 374 deletions.
72 changes: 36 additions & 36 deletions Libs/LibOpenRaid/GetPlayerInformation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -802,50 +802,52 @@ 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
do if (false) then --do not load this section as it isn't in use
function openRaidLib.AuraTracker.ScanCallback(auraInfo)
if (auraInfo) then
local spellId = auraInfo.spellId
if (spellId) then
local unitId = openRaidLib.AuraTracker.CurrentUnitId
local thisUnitAuras = openRaidLib.AuraTracker.CurrentAuras[unitId]
thisUnitAuras[spellId] = true
openRaidLib.AuraTracker.AurasFoundOnScan[spellId] = true
end
end
end
end

function openRaidLib.AuraTracker.ScanUnitAuras(unitId)
local batchCount = nil
local usePackedAura = true
openRaidLib.AuraTracker.CurrentUnitId = unitId
function openRaidLib.AuraTracker.ScanUnitAuras(unitId)
local maxCount = nil
local bUsePackedAura = true
openRaidLib.AuraTracker.CurrentUnitId = unitId

openRaidLib.AuraTracker.AurasFoundOnScan = {}
AuraUtil.ForEachAura(unitId, "HELPFUL", batchCount, openRaidLib.AuraTracker.ScanCallback, usePackedAura)
openRaidLib.AuraTracker.AurasFoundOnScan = {}

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)
--code of 'ForEachAura' has been updated to use the latest API available
AuraUtil.ForEachAura(unitId, "HELPFUL", maxCount, openRaidLib.AuraTracker.ScanCallback, bUsePackedAura)

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
end

--run when the open raid lib loads
function openRaidLib.AuraTracker.StartScanUnitAuras(unitId)
openRaidLib.AuraTracker.CurrentAuras = {
[unitId] = {}
}
--run when the open raid lib loads
function openRaidLib.AuraTracker.StartScanUnitAuras(unitId) --this function isn't getting called (was called from Entering World event)
openRaidLib.AuraTracker.CurrentAuras = {
[unitId] = {} --storing using the unitId as key, won't work for any other unit other than the "player"
}

local auraFrameEvent = CreateFrame("frame")
auraFrameEvent:RegisterUnitEvent("UNIT_AURA", unitId)
local auraFrameEvent = CreateFrame("frame")
auraFrameEvent:RegisterUnitEvent("UNIT_AURA", unitId)

auraFrameEvent:SetScript("OnEvent", function()
openRaidLib.AuraTracker.ScanUnitAuras(unitId)
end)
end
auraFrameEvent:SetScript("OnEvent", function()
openRaidLib.AuraTracker.ScanUnitAuras(unitId)
end)
end
end end

--test case:
local debugModule = {}
Expand All @@ -854,7 +856,6 @@ do
--print("aura removed:", unitId, spellId, spellName)
end
openRaidLib.internalCallback.RegisterCallback("unitAuraRemoved", debugModule.AuraRemoved)

end


Expand Down Expand Up @@ -899,7 +900,6 @@ do
local casterName = Ambiguate(casterString, "none")
return openRaidLib.AuraTracker.FindBuffDuration(targetName, casterName, spellId)
end

end


Expand Down
52 changes: 32 additions & 20 deletions Libs/LibOpenRaid/LibOpenRaid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ if (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE and not isExpansion_Dragonflight()) t
end

local major = "LibOpenRaid-1.0"
local CONST_LIB_VERSION = 122

local CONST_LIB_VERSION = 124

if (LIB_OPEN_RAID_MAX_VERSION) then
if (CONST_LIB_VERSION <= LIB_OPEN_RAID_MAX_VERSION) then
Expand Down Expand Up @@ -132,6 +133,9 @@ end

local CONST_USE_DEFAULT_SCHEDULE_TIME = true

-- Real throttle is 10 messages per 1 second, but we want to be safe due to fact we dont know when it actually resets
local CONST_COMM_BURST_BUFFER_COUNT = 9

local GetContainerNumSlots = GetContainerNumSlots or C_Container.GetContainerNumSlots
local GetContainerItemID = GetContainerItemID or C_Container.GetContainerItemID
local GetContainerItemLink = GetContainerItemLink or C_Container.GetContainerItemLink
Expand Down Expand Up @@ -485,25 +489,33 @@ end
---@field channel string

---@type {}[]
local commScheduler = {}
local commScheduler = {};

local commBurstBufferCount = CONST_COMM_BURST_BUFFER_COUNT;
local commServerTimeLastThrottleUpdate = GetServerTime();

do
--if there's an old version that already registered the comm ticker, cancel it
if (LIB_OPEN_RAID_COMM_SCHEDULER) then
LIB_OPEN_RAID_COMM_SCHEDULER:Cancel()
LIB_OPEN_RAID_COMM_SCHEDULER:Cancel();
end

--make the lib throttle the comms to one per second
local newTickerHandle = C_Timer.NewTicker(1, function()
for i = #commScheduler, 1, -1 do
local commData = commScheduler[i]
if (commData) then
sendData(commData.data, commData.channel)
table.remove(commScheduler, i)
return
end
local newTickerHandle = C_Timer.NewTicker(0.05, function()
local serverTime = GetServerTime();

-- Replenish the counter if last server time is not the same as the last throttle update
-- Clamp it to CONST_COMM_BURST_BUFFER_COUNT
commBurstBufferCount = math.min((serverTime ~= commServerTimeLastThrottleUpdate) and commBurstBufferCount + 1 or commBurstBufferCount, CONST_COMM_BURST_BUFFER_COUNT);
commServerTimeLastThrottleUpdate = serverTime;

-- while (anything in queue) and (throttle allows it)
while(#commScheduler > 0 and commBurstBufferCount > 0) do
-- FIFO queue
local commData = table.remove(commScheduler, 1);
sendData(commData.data, commData.channel);
commBurstBufferCount = commBurstBufferCount - 1;
end
end)
end);

LIB_OPEN_RAID_COMM_SCHEDULER = newTickerHandle
end
Expand Down Expand Up @@ -531,8 +543,8 @@ end

if (bit.band(flags, CONST_COMM_SENDTO_GUILD)) then --send to guild
if (IsInGuild()) then
local commData = {data = dataEncoded, channel = "GUILD"}
table.insert(commScheduler, commData)
--Guild has no 10 msg restriction so send it directly
sendData(dataEncoded, "GUILD");
end
end
else
Expand Down Expand Up @@ -588,9 +600,9 @@ end
end

local result, errortext = xpcall(callback, geterrorhandler(), unpack(payload))
if (not result) then
sendChatMessage("openRaidLib: error on scheduler:", tickerObject.scheduleName, tickerObject.stack)
end
--if (not result) then
-- sendChatMessage("openRaidLib: error on scheduler:", tickerObject.scheduleName, tickerObject.stack)
--end

return result
end
Expand All @@ -601,7 +613,7 @@ end
local newTimer = C_Timer.NewTimer(time, triggerScheduledTick)
newTimer.payload = payload
newTimer.callback = callback
newTimer.stack = debugstack()
--newTimer.stack = debugstack()
return newTimer
end

Expand All @@ -621,7 +633,7 @@ end
local newTimer = openRaidLib.Schedules.NewTimer(time, callback, ...)
newTimer.namespace = namespace
newTimer.scheduleName = scheduleName
newTimer.stack = debugstack()
--newTimer.stack = debugstack()
newTimer.isUnique = true

local registeredUniqueTimers = openRaidLib.Schedules.registeredUniqueTimers
Expand Down
70 changes: 68 additions & 2 deletions classes/class_damage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3481,6 +3481,7 @@ function damageClass.PredictedAugSpellsOnEnter(self)
local CONST_SPELLID_EBONMIGHT = 395152
local CONST_SPELLID_PRESCIENCE = 410089
local CONST_SPELLID_BLACKATTUNEMENT = 403264
local CONST_SPELLID_BLISTERING_SCALES = 360827

---@type actor[]
local augmentationEvokers = {}
Expand Down Expand Up @@ -3565,7 +3566,7 @@ function damageClass.PredictedAugSpellsOnEnter(self)
GameCooltip:AddLine("", "")
GameCooltip:AddIcon("", nil, nil, 1, 1)

for i = 1, #augmentationEvokers do
for i = 1, #augmentationEvokers do --black attunement
local actorObject = augmentationEvokers[i]
if (actorObject:Name() == actorName) then
local buffUptimeSpellContainer = actorObject:GetSpellContainer("buff")
Expand All @@ -3589,6 +3590,26 @@ function damageClass.PredictedAugSpellsOnEnter(self)
GameCooltip:AddIcon(spellIcon, nil, nil, iconSize, iconSize, iconBorderInfo.L, iconBorderInfo.R, iconBorderInfo.T, iconBorderInfo.B)
end
end

local spellTable = buffUptimeSpellContainer:GetSpell(CONST_SPELLID_BLISTERING_SCALES)
if (spellTable) then
local uptime = spellTable.uptime
local spellName, _, spellIcon = _GetSpellInfo(CONST_SPELLID_BLISTERING_SCALES)
local uptimePercent = uptime / combatTime * 100

if (uptime <= combatTime) then
local minutes, seconds = math.floor(uptime / 60), math.floor(uptime % 60)
if (minutes > 0) then
GameCooltip:AddLine(spellName, minutes .. "m " .. seconds .. "s" .. " (" .. format("%.1f", uptimePercent) .. "%)")
Details:AddTooltipBackgroundStatusbar(false, uptimePercent, true, "limegreen")
else
GameCooltip:AddLine(spellName, seconds .. "s" .. " (" .. format("%.1f", uptimePercent) .. "%)")
Details:AddTooltipBackgroundStatusbar(false, uptimePercent, true, "limegreen")
end

GameCooltip:AddIcon(spellIcon, nil, nil, iconSize, iconSize, iconBorderInfo.L, iconBorderInfo.R, iconBorderInfo.T, iconBorderInfo.B)
end
end
end
end
end
Expand Down Expand Up @@ -3645,7 +3666,7 @@ function damageClass.PredictedAugSpellsOnEnter(self)

if (evokerObject) then
GameCooltip:AddLine("Prescience Uptime by Amount of Applications")
local prescienceData = evokerObject.cleu_prescience_time --real time
local prescienceData = evokerObject.cleu_prescience_time

if (prescienceData) then
prescienceData = prescienceData.stackTime
Expand All @@ -3667,6 +3688,51 @@ function damageClass.PredictedAugSpellsOnEnter(self)
end
end
end

--iterate among all the actors and find which one are healers, then get the amount of mana the evoker restored for that healer
---@type actorcontainer
local resourcesContainer = combatObject:GetContainer(DETAILS_ATTRIBUTE_ENERGY)
local manaRestoredToHealers = {}

for index, actorObject in resourcesContainer:ListActors() do
if (actorObject.spec == 1473) then --this is an aug evoker
local spellContainer = actorObject:GetSpellContainer("spell")
--local spellContainer = actorObject.spells
if (spellContainer) then
local sourceOfMagic = spellContainer:GetSpell(372571)
if (sourceOfMagic) then
for targetName, restoredAmount in pairs(sourceOfMagic.targets) do
manaRestoredToHealers[#manaRestoredToHealers+1] = {targetName, restoredAmount}
end
end
end
end
end

if (#manaRestoredToHealers > 0) then
GameCooltip:AddLine(" ")
GameCooltip:AddIcon(" ", 1, 1, 10, 10)
GameCooltip:AddLine("Mana Restored to Healers:")

table.sort(manaRestoredToHealers, Details.Sort2)

for i = 1, math.min(10, #manaRestoredToHealers) do
local targetName, restoredAmount = unpack(manaRestoredToHealers[i])
local targetActorObject = combatObject(DETAILS_ATTRIBUTE_ENERGY, targetName)

if (targetActorObject) then
local targetClass = targetActorObject:GetActorClass()
local targetName = detailsFramework:AddClassColorToText(targetName, targetClass)
targetName = detailsFramework:AddClassIconToText(targetName, targetName, targetClass)

GameCooltip:AddLine(targetName, Details:Format(restoredAmount))

local spellIcon = GetSpellTexture(372571)
GameCooltip:AddIcon(spellIcon, nil, nil, iconSize, iconSize, iconBorderInfo.L, iconBorderInfo.R, iconBorderInfo.T, iconBorderInfo.B)
Details:AddTooltipBackgroundStatusbar(false, 100, true, "dodgerblue")
end
end
end
end

GameCooltip:AddLine("feature under test, can't disable atm")
Expand Down
Loading

0 comments on commit b7c2b6c

Please sign in to comment.