diff --git a/PallyPower.lua b/PallyPower.lua index d5f5a23..62a51ff 100644 --- a/PallyPower.lua +++ b/PallyPower.lua @@ -69,7 +69,7 @@ do end PallyPower.Credits1 = "PallyPower - by Aznamir (Lightbringer US)" -PallyPower.Credits2 = "Updated for Classic by Dyaxler, Es, and gallantron" +PallyPower.Credits2 = "Updated for Classic by Dyaxler, Es, gallantron and irregularly by Zid" function PallyPower:Debug(s) if (PP_DebugEnabled) then @@ -174,7 +174,6 @@ function PallyPower:OnEnable() self:ScanSpells() self:ScanCooldowns() self:RegisterEvent("CHAT_MSG_ADDON") - self:RegisterEvent("CHAT_MSG_SYSTEM") self:RegisterEvent("ZONE_CHANGED") self:RegisterEvent("ZONE_CHANGED_NEW_AREA") self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") @@ -186,6 +185,7 @@ function PallyPower:OnEnable() self:RegisterBucketEvent("SPELLS_CHANGED", 1, "SPELLS_CHANGED") self:RegisterBucketEvent("PLAYER_ENTERING_WORLD", 2, "PLAYER_ENTERING_WORLD") self:RegisterBucketEvent({"GROUP_ROSTER_UPDATE", "PLAYER_REGEN_ENABLED", "UNIT_PET", "UNIT_AURA"}, 1, "UpdateRoster") + self:RegisterBucketEvent({"GROUP_ROSTER_UPDATE"}, 1, "UpdateAllPallys") if isPally then self:ScheduleRepeatingTimer(self.ScanInventory, 60, self) self.ButtonsUpdate(self) @@ -1613,43 +1613,44 @@ function PallyPower:GROUP_LEFT(event) self:UpdateRoster() end -function PallyPower:CHAT_MSG_SYSTEM(event, text) +function PallyPower:UpdateAllPallys() if not initialized then return end - if text then - if strfind(text, "leaves the party.") or strfind(text, "has left the raid group") or strfind(text, "has left the instance group.") then - local _, _, pname = strfind(text, "(.+) leaves the party.") - local _, _, rname = strfind(text, "(.+) has left the raid group") - local _, _, bgname = strfind(text, "(.+) has left the instance group.") - local playerName - if pname then - playerName = pname - elseif rname then - playerName = rname - elseif bgname then - playerName = bgname - end - for name in pairs(AllPallys) do - if name == playerName then - C_Timer.After( - 2.0, - function() - AllPallys = {} - SyncList = {} - self:ScanSpells() - self:ScanCooldowns() - self:ScanInventory() - self:SendSelf() - self:SendMessage("REQ") - self:UpdateLayout() - self:UpdateRoster() - end - ) - end - end + + local units + if IsInRaid() then + units = raid_units + else + units = party_units + end + + local countAllPallys = 0 + for _ in pairs(AllPallys) do countAllPallys = countAllPallys + 1 end + + local found = 0 + for _, unitid in pairs(units) do + if unitid and (not unitid:find("pet")) and UnitExists(unitid) then + if AllPallys[GetUnitName(unitid, true)] then found = found + 1 end end end + + if found < countAllPallys then -- Zid: if AllPallys count is reduced do a fresh setup + C_Timer.After( + 0.5, + function() + AllPallys = {} + SyncList = {} + self:ScanSpells() + self:ScanCooldowns() + self:ScanInventory() + self:SendSelf() + self:SendMessage("REQ") + self:UpdateLayout() + self:UpdateRoster() + end + ) + end end function PallyPower:UNIT_SPELLCAST_SUCCEEDED(event, unitTarget, castGUID, spellID)