refactor: improve Nampower aura tracking and GUID management integration

This commit is contained in:
Bluewhale1337
2026-11-02 17:13:37 +01:00
parent 7b8c0251fc
commit 5a77b2298d
6 changed files with 375 additions and 200 deletions
+68 -2
View File
@@ -193,7 +193,9 @@ function HealBot_Model:UpdateUnitIdentity(unit)
local guid = HealBot_GetUnitGUID(unit)
if guid and guid ~= "0" and guid ~= "0x0000000000000000" then
self.unitGUIDs[unit] = guid
self.guidUnits[guid] = unit
if unit ~= "target" then
self.guidUnits[guid] = unit
end
end
end
return true -- Identity changed
@@ -201,10 +203,74 @@ function HealBot_Model:UpdateUnitIdentity(unit)
return false
end
-- HealBot_Model:PopulateAllGUIDs: Refreshes unit-to-GUID and GUID-to-unit mappings for all current roster units.
function HealBot_Model:PopulateAllGUIDs()
if not (HealBot_Integrations_SuperWoW_Active or HealBot_Integrations_ClassicAPI_Active or HealBot_Integrations_Nampower_Active) or not HealBot_GetUnitGUID then return end
local playerGuid = HealBot_GetUnitGUID("player")
if playerGuid and playerGuid ~= "0" and playerGuid ~= "0x0000000000000000" then
self.unitGUIDs["player"] = playerGuid
self.guidUnits[playerGuid] = "player"
HealBot_PlayerGUID = playerGuid
end
for _, unit in ipairs(self.partyMembers) do
local guid = HealBot_GetUnitGUID(unit)
if guid and guid ~= "0" and guid ~= "0x0000000000000000" then
self.unitGUIDs[unit] = guid
self.guidUnits[guid] = unit
end
end
for _, unit in ipairs(self.raidMembers) do
local guid = HealBot_GetUnitGUID(unit)
if guid and guid ~= "0" and guid ~= "0x0000000000000000" then
self.unitGUIDs[unit] = guid
self.guidUnits[guid] = unit
end
end
end
-- HealBot_Model:GetUnitByGUID: Internal utility: HealBot_Model:GetUnitByGUID
function HealBot_Model:GetUnitByGUID(guid)
if not guid then return nil end
return self.guidUnits[guid]
local unit = self.guidUnits[guid]
if unit and UnitExists(unit) then return unit end
local lowerGuid = string.lower(guid)
if HealBot_PlayerGUID and string.lower(HealBot_PlayerGUID) == lowerGuid then
self.guidUnits[guid] = "player"
return "player"
end
if HealBot_GetUnitGUID then
local pGuid = HealBot_GetUnitGUID("player")
if pGuid and string.lower(pGuid) == lowerGuid then
self.guidUnits[guid] = "player"
HealBot_PlayerGUID = pGuid
return "player"
end
for i = 1, 40 do
local u = "raid" .. i
if UnitExists(u) then
local uGuid = HealBot_GetUnitGUID(u)
if uGuid and string.lower(uGuid) == lowerGuid then
self.guidUnits[guid] = u
return u
end
end
end
for i = 1, 4 do
local u = "party" .. i
if UnitExists(u) then
local uGuid = HealBot_GetUnitGUID(u)
if uGuid and string.lower(uGuid) == lowerGuid then
self.guidUnits[guid] = u
return u
end
end
end
end
return nil
end
-- HealBot_Model:GetUnitIDByName: Looks up a group unit token by player name.