Fixed Details:FindDebuffDuration(unitId, spellId, casterName) which wasn't taking the casterName in consideration

This commit is contained in:
Tercio Jose
2023-07-18 15:38:15 -03:00
parent 5206d47287
commit 3eebecda83
4 changed files with 173 additions and 168 deletions
+65 -50
View File
@@ -21,6 +21,9 @@
local strsplit = strsplit
local _pcall = pcall
local GetTime = GetTime
local GetUnitName = _G.GetUnitName
local UnitExists = UnitExists
local UnitGUID = UnitGUID
local IsInRaid = IsInRaid --wow api local
local IsInGroup = IsInGroup --wow api local
@@ -30,6 +33,68 @@
local gump = Details.gump --details local
local predicateFunc = function(spellIdToFind, casterName, _, name, icon, applications, dispelName, duration, expirationTime, sourceUnit, isStealable, nameplateShowPersonal, spellId, canApplyAura, isBossAura, isFromPlayerOrPlayerPet, nameplateShowAll, timeMod, applications)
--print(name, texture, count, debuffType, duration, expirationTime, spellID)
if (spellIdToFind == spellId) then
if (casterName == GetUnitName(sourceUnit, true)) then
return true
end
end
end
---find the duration of a buff by passing the spellId and the caster name
---@param unitId unit
---@param spellId spellid
---@param casterName actorname
---@return auraduration|nil auraDuration
---@return number|nil expirationTime
function Details:FindDebuffDuration(unitId, spellId, casterName)
local name, texture, count, debuffType, duration, expirationTime = AuraUtil.FindAura(predicateFunc, unitId, "HARMFUL", spellId, casterName)
if (name) then
return duration, expirationTime
end
end
---return the unitId by passing a unit serial (guid)
---@param unitSerial serial
---@return unit|nil unitId
function Details:FindUnitIDByUnitSerial(unitSerial)
--boss
for i = 1, 9 do
local unitId = Details222.UnitIdCache.Boss[i]
if (UnitExists(unitId)) then
if (UnitGUID(unitId) == unitSerial) then
return unitId
end
else
break
end
end
--nameplate
for i = 1, 40 do
local unitId = Details222.UnitIdCache.Nameplate[i]
if (UnitExists(unitId)) then
if (UnitGUID(unitId) == unitSerial) then
return unitId
end
end
end
--arena enemies
for i = 1, #Details222.UnitIdCache.Arena do
local unitId = Details222.UnitIdCache.Arena[i]
if (UnitExists(unitId)) then
if (UnitGUID(unitId) == unitSerial) then
return unitId
end
else
break
end
end
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--fade handler
@@ -68,56 +133,6 @@
Details.FadeHandler.frames[frame] = nil
end
local predicateFunc = function(spellIdToFind, _, _, name, texture, count, debuffType, duration, expirationTime, _, _, _, spellID)
print(name, texture, count, debuffType, duration, expirationTime, spellID)
if (spellIdToFind == spellID) then
return true
end
end
function Details:FindDebuffDuration(unitId, spellId)
local name, texture, count, debuffType, duration, expirationTime = AuraUtil.FindAura(predicateFunc, unitId, "HARMFUL", spellId)
if (name) then
return duration, expirationTime
end
end
function Details:FindUnitIDByUnitSerial(unitSerial)
--boss
for i = 1, 9 do
local unitId = Details222.UnitIdCache.Boss[i]
if (UnitExists(unitId)) then
if (UnitGUID(unitId) == unitSerial) then
return unitId
end
else
break
end
end
--nameplate
for i = 1, 40 do
local unitId = Details222.UnitIdCache.Nameplate[i]
if (UnitExists(unitId)) then
if (UnitGUID(unitId) == unitSerial) then
return unitId
end
end
end
--arena enemies
for i = 1, #Details222.UnitIdCache.Arena do
local unitId = Details222.UnitIdCache.Arena[i]
if (UnitExists(unitId)) then
if (UnitGUID(unitId) == unitSerial) then
return unitId
end
else
break
end
end
end
Details.FadeHandler.OnUpdateFrame = CreateFrame("frame", "DetailsFadeFrameOnUpdate", UIParent)
Details.FadeHandler.OnUpdateFrame:SetScript("OnUpdate", function(self, deltaTime)
for frame, frameSettings in pairs(Details.FadeHandler.frames) do