From 6cfb24673c9c2571b9d956c2d30c352ea916a4b7 Mon Sep 17 00:00:00 2001 From: NoM0Re <1629787+NoM0Re@users.noreply.github.com> Date: Sun, 25 Aug 2024 13:13:04 +0200 Subject: [PATCH] Temporary workaround for PUI --- WeakAuras/GenericTrigger.lua | 50 +++++++++++++++++++++++++++--------- WeakAuras/Prototypes.lua | 15 +++++++++++ WeakAuras/Types.lua | 10 ++++---- 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index b900410..68bf589 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -587,8 +587,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 end elseif (data.statesParameter == "unit") then if optionsEvent then - if Private.multiUnitUnits[data.trigger.unit] or data.trigger.unit:sub(1, 9) == "nameplate" then + if Private.multiUnitUnits[data.trigger.unit] then arg1 = next(Private.multiUnitUnits[data.trigger.unit]) + elseif data.trigger.unit:sub(1, 9) == "nameplate" then + arg1 = next(C_NamePlate.GetNamePlates()) else arg1 = data.trigger.unit end @@ -997,8 +999,7 @@ local function MultiUnitLoop(Func, unit, includePets, ...) Func(unit..i, ...) end elseif unit == "nameplate" then - local max = C_NamePlate and C_NamePlate.GetNamePlates and #C_NamePlate.GetNamePlates() or 40 - for i = 1, max do + for i = 1, 400 do Func(unit..i, ...) end elseif unit == "group" then @@ -2500,24 +2501,28 @@ function WeakAuras.WatchUnitChange(unit) local newMarker = GetRaidTargetIndex(unit) or 0 if marker ~= newMarker then watchUnitChange.raidmark[unit] = newMarker - WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + if string.match(unit, "^nameplate%d+$") then + WeakAuras.ScanEvents("UNIT_CHANGED_nameplate", unit) + else + WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + end end end elseif event == "NAME_PLATE_UNIT_ADDED" then local oldGUID = watchUnitChange.unitChangeGUIDS[unit] local newGUID = WeakAuras.UnitExistsFixed(unit) and UnitGUID(unit) if oldGUID ~= newGUID then - WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + WeakAuras.ScanEvents("UNIT_CHANGED_nameplate", unit) end watchUnitChange.unitChangeGUIDS[unit] = newGUID watchUnitChange.raidmark[unit] = GetRaidTargetIndex(unit) or 0 watchUnitChange.nameplateFaction[unit] = WeakAuras.GetPlayerReaction(unit) - WeakAuras.ScanEvents(event, unit) + WeakAuras.ScanEvents("UNIT_CHANGED_nameplate", unit) elseif event == "NAME_PLATE_UNIT_REMOVED" then local oldGUID = watchUnitChange.unitChangeGUIDS[unit] local newGUID = WeakAuras.UnitExistsFixed(unit) and UnitGUID(unit) if oldGUID ~= newGUID then - WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + WeakAuras.ScanEvents("UNIT_CHANGED_nameplate", unit) end watchUnitChange.unitChangeGUIDS[unit] = newGUID watchUnitChange.raidmark[unit] = nil @@ -2528,14 +2533,22 @@ function WeakAuras.WatchUnitChange(unit) local newReaction = WeakAuras.GetPlayerReaction(unit) if oldReaction ~= newReaction then watchUnitChange.nameplateFaction[unit] = newReaction - WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + if string.match(unit, "^nameplate%d+$") then + WeakAuras.ScanEvents("UNIT_CHANGED_nameplate", unit) + else + WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + end end elseif event == "PLAYER_ROLES_ASSIGNED" then for unit in pairs(Private.multiUnitUnits.group) do local oldRaidRole = watchUnitChange.unitRaidRole[unit] local newRaidRole = WeakAuras.UnitRaidRole(unit) if oldRaidRole ~= newRaidRole then - WeakAuras.ScanEvents("UNIT_ROLE_CHANGED_" .. unit, unit) + if string.match(unit, "^nameplate%d+$") then + WeakAuras.ScanEvents("UNIT_ROLE_CHANGED_nameplate", unit) + else + WeakAuras.ScanEvents("UNIT_ROLE_CHANGED_" .. unit, unit) + end watchUnitChange.unitRaidRole[unit] = newRaidRole end end @@ -2550,7 +2563,11 @@ function WeakAuras.WatchUnitChange(unit) or newMarker ~= watchUnitChange.raidmark[unit] or event == "PLAYER_ENTERING_WORLD" then - WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + if string.match(unit, "^nameplate%d+$") then + WeakAuras.ScanEvents("UNIT_CHANGED_nameplate", unit) + else + WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + end watchUnitChange.unitChangeGUIDS[unit] = newGuid watchUnitChange.raidmark[unit] = newMarker @@ -2558,7 +2575,11 @@ function WeakAuras.WatchUnitChange(unit) local newReaction = WeakAuras.GetPlayerReaction(unit) if oldReaction ~= newReaction then watchUnitChange.nameplateFaction[unit] = newReaction - WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + if string.match(unit, "^nameplate%d+$") then + WeakAuras.ScanEvents("UNIT_CHANGED_nameplate", unit) + else + WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) + end end elseif Private.multiUnitUnits.group[unit] then @@ -3463,7 +3484,12 @@ do local function doCastScan(firetime, unit) scheduled_scans[unit][firetime] = nil; - WeakAuras.ScanEvents("CAST_REMAINING_CHECK_" .. string.lower(unit), unit); + + if string.match(unit, "^nameplate%d+$") then + WeakAuras.ScanEvents("CAST_REMAINING_CHECK_nameplate", unit); + else + WeakAuras.ScanEvents("CAST_REMAINING_CHECK_" .. string.lower(unit), unit); + end end function WeakAuras.ScheduleCastCheck(fireTime, unit) scheduled_scans[unit] = scheduled_scans[unit] or {} diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 7dd92da..fee5c15 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -1025,6 +1025,17 @@ local function AddUnitChangeInternalEvents(triggerUnit, t, includePets) elseif triggerUnit == "pet" then WeakAuras.WatchForPetDeath(); tinsert(t, "PET_UPDATE") + elseif (triggerUnit == "nameplate") then + if not WeakAuras.isAwesomeEnabled then return end + tinsert(t, "UNIT_CHANGED_nameplate") + local nameplates = C_NamePlate.GetNamePlates() + if nameplates then + for i, v in pairs(nameplates) do + if v then + WeakAuras.WatchUnitChange("nameplate" .. i) + end + end + end else if Private.multiUnitUnits[triggerUnit] then local isPet @@ -1103,6 +1114,8 @@ local unitHelperFunctions = { tinsert(events, {"UNIT_CHANGED_" .. unit, unit}) end end + elseif trigger.unit == "nameplate" then + tinsert(events, {"UNIT_CHANGED_" .. trigger.unit}) else if trigger.unit then tinsert(events, {"UNIT_CHANGED_" .. trigger.unit, trigger.unit}) @@ -1119,6 +1132,8 @@ local unitHelperFunctions = { tinsert(events, {"UNIT_CHANGED_" .. unit, unit}) end end + elseif trigger.unit == "nameplate" then + tinsert(events, {"UNIT_CHANGED_" .. trigger.unit}) else if trigger.unit then tinsert(events, {"UNIT_CHANGED_" .. trigger.unit, trigger.unit}) diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index 2ceb2f8..143d9a1 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -2675,9 +2675,9 @@ Private.multiUnitId = { ["partypetsonly"] = true, ["raid"] = true, } -if WeakAuras.isAwesomeEnabled then - Private.multiUnitId["nameplate"] = true -end +--if WeakAuras.isAwesomeEnabled then +-- Private.multiUnitId["nameplate"] = true +--end Private.multiUnitUnits = { ["boss"] = {}, @@ -2718,8 +2718,8 @@ end for i = 1, 40 do Private.baseUnitId["raid"..i] = true Private.baseUnitId["raidpet"..i] = true - --Private.baseUnitId["nameplate"..i] = true -- no need to restrict it, blizzard only allows 40 nameplates, we can get all. - --Private.multiUnitUnits.nameplate["nameplate"..i] = true -- no need to restrict it, blizzard only allows 40 nameplates, we can get all. + -- Private.baseUnitId["nameplate"..i] = true -- no need to restrict it, blizzard only allows 40 nameplates, we can get all. + -- Private.multiUnitUnits.nameplate["nameplate"..i] = true -- no need to restrict it, blizzard only allows 40 nameplates, we can get all. Private.multiUnitUnits.group["raid"..i] = true Private.multiUnitUnits.raid["raid"..i] = true Private.multiUnitUnits.group["raidpet"..i] = true