diff --git a/GridStatusSmartHealing.lua b/GridStatusSmartHealing.lua
index 7b13636..49f5efb 100644
--- a/GridStatusSmartHealing.lua
+++ b/GridStatusSmartHealing.lua
@@ -137,8 +137,6 @@ function GridStatusSmartHealing:RegisterStatus(module, status, desc, options, in
end
function GridStatusSmartHealing:PostInitialize()
- self.roster = {};
-
-- Do now so modulePrototype can register Options for modules
self:InitializeOptions();
end
@@ -166,10 +164,14 @@ function GridStatusSmartHealing:DoEnable(force)
return;
end
self:Debug("Enabling", self.moduleName);
+ --[[
self:UpdateRoster();
self:RegisterEvent("PLAYER_MEMBERS_CHANGED", "UpdateRoster");
self:RegisterEvent("RAID_ROSTER_UPDATE", "UpdateRoster");
+ ]]
+
+ --GridRoster:RegisterMessage("Grid_RosterUpdated");
BlankFrame:SetScript("OnUpdate", function(_, timer)
return self:OnUpdate(timer);
@@ -201,8 +203,6 @@ function GridStatusSmartHealing:DoDisable()
if (NumEnabled == 0) then
self:Debug("Disabling", self.moduleName);
BlankFrame:SetScript("OnUpdate", nil);
- self:UnregisterEvent("PLAYER_MEMBERS_CHANGED");
- self:UnregisterEvent("RAID_ROSTER_UPDATE");
end
end
@@ -237,35 +237,40 @@ function GridStatusSmartHealing:OnUpdate(elapsed)
self:UpdateData();
self:UpdateAll();
else
+ SetMapToCurrentZone();
self:Debug("Update Map Failed");
self:ClearAll();
end
end
end
+function GridStatusSmartHealing:GetUnitInfo(guid)
+ return self.state.data[guid];
+end
+
function GridStatusSmartHealing:UpdateData()
self.state.data = {};
self.state.x = self.state.x * self.state.mapWidth;
self.state.y = self.state.y * self.state.mapHeight;
- for i = 1, 8 do
- for _, unitId in pairs(self.roster[i]) do
- local unitX, unitY = GetPlayerMapPosition(unitId);
- if (unitX ~= 0 or unitY ~= 0 and IsValidTarget(unitId)) then
- local health = UnitHealth(unitId);
- local maxHealth = UnitHealthMax(unitId);
+ for _guid, _unitId in GridRoster:IterateRoster() do
+ local unitX, unitY = GetPlayerMapPosition(_unitId);
- self.state.data[unitId] =
- {
- guid = UnitGUID(unitId),
+ if (unitX ~= 0 or unitY ~= 0 and self:IsValidHealTarget(_unitId)) then
+ local health = UnitHealth(_unitId);
+ local maxHealth = UnitHealthMax(_unitId);
+
+ self.state.data[_guid] =
+ {
+ unitId = _unitId,
+ guid = _guid,
x = unitX * self.state.mapWidth,
y = unitY * self.state.mapHeight,
health = health,
maxHealth = maxHealth,
missingHealth = maxHealth - health,
percent = maxHealth / health,
- };
- end
+ };
end
end
end
@@ -289,7 +294,8 @@ function GridStatusSmartHealing:UpdateMap()
return false;
end
-function GridStatusSmartHealing:UpdateRoster()
+--[[ -- Now using GridRoster
+function GridStatusSmartHealing:Grid_RosterUpdated()
self.roster = { [1] = {}, [2] = {}, [3] = {}, [4] = {}, [5] = {}, [6] = {}, [7] = {}, [8] = {} };
local RaidMemberNum = GetNumGroupMembers();
@@ -316,6 +322,7 @@ function GridStatusSmartHealing:UpdateRoster()
end
end
end
+]]
function GridStatusSmartHealing:Enabled(statusModule)
return statusModule.db.profile.enable;
diff --git a/GridStatusSmartHealing.toc b/GridStatusSmartHealing.toc
index 7a6327c..b437996 100644
--- a/GridStatusSmartHealing.toc
+++ b/GridStatusSmartHealing.toc
@@ -3,7 +3,7 @@
## Notes: Adds statuses to grid for best targets for smart heals.
## Dependencies: Grid, LibMapData-1.0
## Author: Tirds
-## Version: v0.3b
+## Version: v0.3.1
## X-GridStatusModule: GridStatusSmartHealing
GridStatusSmartHealing.lua
diff --git a/status/chainheal.lua b/status/chainheal.lua
index 32d6589..9076d67 100644
--- a/status/chainheal.lua
+++ b/status/chainheal.lua
@@ -1,4 +1,5 @@
local GridStatus = Grid:GetModule("GridStatus");
+local GridRoster = Grid:GetModule("GridRoster");
local SmartHealing = GridStatus:GetModule("GridStatusSmartHealing");
local GridStatusSmartHealing_ChainHeal = SmartHealing:NewModule("GridStatusSmartHealing_ChainHeal", "AceEvent-3.0");
@@ -161,14 +162,11 @@ function GridStatusSmartHealing_ChainHeal:Update()
-- all players missing health
local deficits = {};
- -- find players missing health
- for i = 1, 8 do
- for _, unitId in pairs(SmartHealing.roster[i]) do
- local info = SmartHealing.state.data[unitId];
- if (info and info.missingHealth > 0 and SmartHealing:IsValidHealTarget(unitId)) then
- info.unitId = unitId;
- table.insert(deficits, info);
- end
+ for guid, unitId in GridRoster:IterateRoster() do
+ local info = SmartHealing:GetUnitInfo(guid);
+ -- if info == nil, probably a pet.
+ if (info ~= nil and unitId and info.missingHealth > 0 and SmartHealing:IsValidHealTarget(unitId)) then
+ table.insert(deficits, info);
end
end
@@ -181,7 +179,7 @@ function GridStatusSmartHealing_ChainHeal:Update()
local paths = {};
local numDeficits = #deficits;
- SmartHealing:Debug("NumDeficts", numDeficits);
+ self:Debug("NumDeficts", numDeficits);
for i = 1, numDeficits do
local curUnit = deficits[i];
@@ -228,7 +226,7 @@ function GridStatusSmartHealing_ChainHeal:Update()
return a.totalHeal > b.totalHeal;
end);
- SmartHealing:Debug("Paths found: ", #paths);
+ self:Debug("Paths found: ", #paths);
if (#paths == 0) then
return;
diff --git a/status/playersinarea.lua b/status/playersinarea.lua
index 25b82e6..5a1dda6 100644
--- a/status/playersinarea.lua
+++ b/status/playersinarea.lua
@@ -1,4 +1,5 @@
local GridStatus = Grid:GetModule("GridStatus");
+local GridRoster = Grid:GetModule("GridRoster");
local SmartHealing = GridStatus:GetModule("GridStatusSmartHealing");
local GridStatusSmartHealing_InArea = SmartHealing:NewModule("GridStatusSmartHealing_InArea", "AceEvent-3.0");
@@ -158,15 +159,11 @@ function GridStatusSmartHealing_InArea:Update()
local deficits = {};
- for i = 1, 8 do
- for _, unitId in pairs(SmartHealing.roster[i]) do
- local info = SmartHealing.state.data[unitId];
- if (info and SmartHealing:IsValidHealTarget(unitId)) then
- if ((Settings.sortMethod == "missingHealth" and info.missingHealth > 0) or Settings.sortMethod == "bestTarget") then
- info.unitId = unidId;
- table.insert(deficits, info);
- end
- end
+ for guid, unitId in GridRoster:IterateRoster() do
+ local info = SmartHealing:GetUnitInfo(guid);
+ -- if info == nil, probably a pet.
+ if (info ~= nil and ((Settings.sortMethod == "missingHealth" and info.missingHealth > 0) or Settings.sortMethod == "bestTarget")) then
+ table.insert(deficits, info);
end
end
@@ -203,7 +200,7 @@ function GridStatusSmartHealing_InArea:Update()
end
end
- SmartHealing:Debug("NumTargets", #targets);
+ self:Debug("NumTargets", #targets);
if (Settings.sortMethod == "missingHealth") then
table.sort(targets, function(a, b)