Quantcast

Added a new status called PlayersInArea, which will show how many units are in the area of any player in the raid with many changeable settings. In theory this will work for Holy Radiance, effloresce other player targeted aoe spells.

Kyle [01-12-12 - 03:25]
Added a new status called PlayersInArea, which will show how many units are in the area of any player in the raid with many changeable settings. In theory this will work for Holy Radiance, effloresce other player targeted aoe spells.
Added more options to chain heal for maxStatusTargets and Center Text Option.
Filename
GridStatusSmartHealing.toc
status/chainheal.lua
status/playersinarea.lua
diff --git a/GridStatusSmartHealing.toc b/GridStatusSmartHealing.toc
index baca523..62f5db8 100644
--- a/GridStatusSmartHealing.toc
+++ b/GridStatusSmartHealing.toc
@@ -3,10 +3,11 @@
 ## Notes: Adds statuses to grid for best targets for smart heals.
 ## Dependencies: Grid, LibMapData-1.0
 ## Author: Tirds
-## Version: v0.1a
+## Version: v0.2a
 ## X-GridStatusModule: GridStatusSmartHealing

 GridStatusSmartHealing.lua

 # StatusModules
 status\chainheal.lua
+status\playersinarea.lua
diff --git a/status/chainheal.lua b/status/chainheal.lua
index ec0cb2f..40d8dff 100644
--- a/status/chainheal.lua
+++ b/status/chainheal.lua
@@ -3,15 +3,22 @@ local SmartHealing = GridStatus:GetModule("GridStatusSmartHealing");

 local GridStatusSmartHealing_ChainHeal = SmartHealing:NewModule("GridStatusSmartHealing_ChainHeal", "AceEvent-3.0");

+local CenterTextOptions =
+{
+    bestTarget = "Best Target #",
+    estimatedHeal = "Total Estimated Heal"
+};
+
 GridStatusSmartHealing_ChainHeal.defaultDB =
 {
     enable = false,
     color = { r = 0, g = 0, b = 1, a = 1 },
-    range = false,
     priority = 50,
     --
     minjumps = 2,
     color2 = { r = 0, g = 0.5, b = 1, a = 1 },
+    maxTargets = 25,
+    centerTextOption = "bestTarget",
 }

 local options =
@@ -54,6 +61,42 @@ local options =
             color.a = a or 1;
         end,
     },
+    ["maxTargets"] =
+    {
+        order = 110,
+        type = "range",
+        name = "Max Status Targets",
+        desc = "Max number of targets to show",
+        min = 1,
+        max = 40,
+        step = 1,
+        width = "full",
+        get = function()
+            return GridStatusSmartHealing_ChainHeal.db.profile.maxTargets;
+        end,
+        set = function(info, v)
+           GridStatusSmartHealing_ChainHeal.db.profile.maxTargets = v;
+           GridStatusSmartHealing_ChainHeal:ClearAll();
+           GridStatusSmartHealing_ChainHeal:RefreshAll();
+        end,
+    },
+    ["centerTextOption"] =
+    {
+        order = 120,
+        type = "select",
+        name = "Center Text Option",
+        desc = "What center text will display (if selected in indicators)",
+        values = CenterTextOptions,
+        style = "radio",
+        get = function()
+            return GridStatusSmartHealing_ChainHeal.db.profile.centerTextOption;
+        end,
+        set = function(info, v)
+            GridStatusSmartHealing_ChainHeal.db.profile.centerTextOption = v;
+            GridStatusSmartHealing_ChainHeal:ClearAll();
+            GridStatusSmartHealing_ChainHeal:RefreshAll();
+        end,
+    }
 }

 local thisStatus = "alert_gssh_chainheal";
@@ -144,35 +187,36 @@ function GridStatusSmartHealing_ChainHeal:Update()

     for i = 1, numDeficits do
         local curUnit = deficits[i];
+        --[[
         local unitDistance = SmartHealing:Distance(SmartHealing.state, curUnit);
-
         if (UnitInRange(curUnit.unitId)) then
-            -- TotalHeal that can be made
-            curUnit.totalHeal = curUnit.missingHealth;
-            curUnit.jumps = {};
-            -- targets are other units jumped to
-            curUnit.targets = {};
-
-            -- TODO count for earth shield..
-            -- TODO count for riptide
-            curUnit.jumps[1] = (self.chainHeal.jumps[1] > curUnit.missingHealth) and curUnit.missingHealth or self.chainHeal.jumps[1];
-
-            -- now find who we can jump to
-            for x = 1, numDeficits do
-                -- cant jump to self : )
-                if (i ~= x) then
-                    local curUnit2 = deficits[x];
-                    local distance = SmartHealing:Distance(curUnit, curUnit2);
-                    local jump = #curUnit.jumps + 1;
-                    if (jump > 4) then
-                        break;
-                    end
-                    if (distance and distance <= self.chainHeal.distance) then
-                        curUnit.jumps[jump] = (self.chainHeal.jumps[jump] > curUnit2.missingHealth) and curUnit2.missingHealth or self.chainHeal.jumps[jump];
-                        curUnit.totalHeal = curUnit.totalHeal + curUnit.jumps[jump];
-                        -- add curUnit2 to targets
-                        table.insert(curUnit.targets, curUnit2);
-                    end
+        end
+        ]]--
+        -- TotalHeal that can be made
+        curUnit.totalHeal = curUnit.missingHealth;
+        curUnit.jumps = {};
+        -- targets are other units jumped to
+        curUnit.targets = {};
+
+        -- TODO count for earth shield..
+        -- TODO count for riptide
+        curUnit.jumps[1] = (self.chainHeal.jumps[1] > curUnit.missingHealth) and curUnit.missingHealth or self.chainHeal.jumps[1];
+
+        -- now find who we can jump to
+        for x = 1, numDeficits do
+            -- cant jump to self : )
+            if (i ~= x) then
+                local curUnit2 = deficits[x];
+                local distance = SmartHealing:Distance(curUnit, curUnit2);
+                local jump = #curUnit.jumps + 1;
+                if (jump > 4) then
+                    break;
+                end
+                if (distance and distance <= self.chainHeal.distance) then
+                    curUnit.jumps[jump] = (self.chainHeal.jumps[jump] > curUnit2.missingHealth) and curUnit2.missingHealth or self.chainHeal.jumps[jump];
+                    curUnit.totalHeal = curUnit.totalHeal + curUnit.jumps[jump];
+                    -- add curUnit2 to targets
+                    table.insert(curUnit.targets, curUnit2);
                 end
             end
         end
@@ -193,9 +237,19 @@ function GridStatusSmartHealing_ChainHeal:Update()
     end

     for i, path in pairs(paths) do
-        -- guid, status, priority, range, color, text, value
-        --self.core:SendStatusGained(path.guid, thisStatus, Settings.priority, nil, i == 1 and Settings.color or Settings.color2, string.format("%s", path.totalHeal), 1, nil, nil);
-        self.core:SendStatusGained(path.guid, thisStatus, Settings.priority, nil, i == 1 and Settings.color or Settings.color2, string.format("#%s", i), 1, nil, nil);
+        if (i > Settings.maxTargets) then
+            return;
+        end
+
+        local text = '';
+        if (Settings.centerTextOption == "bestTarget") then
+            text = "#" + i;
+        else
+            text = string.format("^%.1fk", path.totalHeal / 1000);
+            --text = path.totalHeal;
+        end
+
+        self.core:SendStatusGained(path.guid, thisStatus, Settings.priority, nil, i == 1 and Settings.color or Settings.color2, string.format("%s", text), 1, nil, nil);
     end
 end

diff --git a/status/playersinarea.lua b/status/playersinarea.lua
new file mode 100644
index 0000000..896259b
--- /dev/null
+++ b/status/playersinarea.lua
@@ -0,0 +1,241 @@
+local GridStatus = Grid:GetModule("GridStatus");
+local SmartHealing = GridStatus:GetModule("GridStatusSmartHealing");
+
+local GridStatusSmartHealing_InArea = SmartHealing:NewModule("GridStatusSmartHealing_InArea", "AceEvent-3.0");
+
+local SortMethods =
+{
+    missingHealth = "Total missing health",
+    mostInArea = "Number of units"
+};
+
+local CenterTextOptions =
+{
+    bestTarget = "Target sort #s",
+    estimatedHeal = "Total Missing Health",
+    numPlayers = "Number of Targets"
+};
+
+GridStatusSmartHealing_InArea.defaultDB =
+{
+    enable = false,
+    color = { r = 1, g = 0, b = 1, a = 0.5 },
+    priority = 50,
+    --
+    rangeFromTarget = 10,
+    sortMethod = "missingHealth",
+    minTargets = 3,
+    maxStatuses = 15,
+    centerTextOption = "bestTarget",
+};
+
+local options =
+{
+    ["rangeFromTarget"] =
+    {
+        order = 100,
+        type = "range",
+        name = "Yards from Unit. (Player in Raid)",
+        desc = "Yards to look around unit. Ex size of Holy Radiance is 10 yards.",
+        min = 1,
+        max = 40,
+        step = 0.5,
+        width = "full",
+        get = function()
+            return GridStatusSmartHealing_InArea.db.profile.rangeFromTarget;
+        end,
+        set = function(info, v)
+            GridStatusSmartHealing_InArea.db.profile.rangeFromTarget = v;
+            GridStatusSmartHealing_InArea:ClearAll();
+            GridStatusSmartHealing_InArea:RefreshAll();
+        end,
+    },
+    ["sortMethod"] =
+    {
+        order = 110,
+        type = "select",
+        name = "Sort Method",
+        desc = "Sort Method in which to display best target",
+        style = "radio",
+        values = SortMethods,
+        get = function()
+            return GridStatusSmartHealing_InArea.db.profile.sortMethod;
+        end,
+        set = function(info, v)
+            GridStatusSmartHealing_InArea.db.profile.sortMethod = v;
+            GridStatusSmartHealing_InArea:ClearAll();
+            GridStatusSmartHealing_InArea:RefreshAll();
+        end,
+    },
+    ["minTargets"] =
+    {
+        order = 130,
+        type = "range",
+        name = "Min Targets in Range",
+        desc = "Min number of targets in range, before showing",
+        min = 0,
+        max = 40,
+        step = 1,
+        width = "full",
+        get = function()
+            return GridStatusSmartHealing_InArea.db.profile.minTargets;
+        end,
+        set = function(info, v)
+           GridStatusSmartHealing_InArea.db.profile.minTargets = v;
+           GridStatusSmartHealing_InArea:ClearAll();
+           GridStatusSmartHealing_InArea:RefreshAll();
+        end,
+    },
+    ["maxStatuses"] =
+    {
+        order = 130,
+        type = "range",
+        name = "Max Status Targets",
+        desc = "Max number of status targets to show",
+        min = 1,
+        max = 40,
+        step = 1,
+        width = "full",
+        get = function()
+            return GridStatusSmartHealing_InArea.db.profile.maxStatuses;
+        end,
+        set = function(info, v)
+           GridStatusSmartHealing_InArea.db.profile.maxStatuses = v;
+           GridStatusSmartHealing_InArea:ClearAll();
+           GridStatusSmartHealing_InArea:RefreshAll();
+        end,
+    },
+    ["centerTextOption"] =
+    {
+        order = 140,
+        type = "select",
+        name = "Center Text Option",
+        desc = "What center text will display (if selected in indicators)",
+        values = CenterTextOptions,
+        style = "radio",
+        get = function()
+            return GridStatusSmartHealing_InArea.db.profile.centerTextOption;
+        end,
+        set = function(info, v)
+            GridStatusSmartHealing_InArea.db.profile.centerTextOption = v;
+            GridStatusSmartHealing_InArea:ClearAll();
+            GridStatusSmartHealing_InArea:RefreshAll();
+        end,
+    }
+}
+
+local thisStatus = "alert_gssh_playersinarea";
+local Settings;
+
+function GridStatusSmartHealing_InArea:OnInitialize()
+    self.super.OnInitialize(self);
+
+    self:RegisterStatus(thisStatus, "Smart Healing - Players in Area", options, false);
+
+    Settings = self.db.profile;
+end
+
+function GridStatusSmartHealing_InArea:OnStatusEnable(status)
+    SmartHealing:DoEnable();
+    --nothing
+    self:RefreshAll();
+end
+
+function GridStatusSmartHealing_InArea:OnStatusDisable(status)
+    SmartHealing:DoDisable();
+    --nothing
+    self:ClearAll();
+end
+
+function GridStatusSmartHealing_InArea:ClearAll()
+    self.core:SendStatusLostAllUnits(thisStatus);
+end
+
+function GridStatusSmartHealing_InArea:RefreshAll()
+    -- nothing.
+end
+
+function GridStatusSmartHealing_InArea:Update()
+    self:ClearAll();
+
+    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
+        end
+    end
+
+    -- sort highest missing health first
+    if (Settings.sortMethod == "missingHealth") then
+        table.sort(deficits, function(a, b)
+            return a.missingHealth > b.missingHealth;
+        end);
+    end
+
+    local targets = {};
+    local numDeficits = #deficits;
+
+    for i = 1, numDeficits do
+        local curUnit = deficits[i];
+
+        curUnit.totalHealthMissing = curUnit.missingHealth;
+        curUnit.targets = {};
+
+        for x = 1, numDeficits do
+            if (i ~= x) then
+                local curUnit2 = deficits[x];
+                local distance = SmartHealing:Distance(curUnit, curUnit);
+
+                if (distance and distance <= Settings.rangeFromTarget) then
+                    curUnit.totalHealthMissing = curUnit.totalHealthMissing + curUnit2.missingHealth;
+                    table.insert(curUnit.targets, curUnit2);
+                end
+            end
+        end
+
+        if (curUnit and curUnit.targets and #curUnit.targets >= Settings.minTargets) then
+            table.insert(targets, curUnit);
+        end
+    end
+
+    SmartHealing:Debug("NumTargets", #targets);
+
+    if (Settings.sortMethod == "missingHealth") then
+        table.sort(targets, function(a, b)
+            return a.totalHealthMissing > b.totalHealthMissing;
+        end);
+    else
+        table.sort(targets, function(a, b)
+            return #a.targets > #b.targets;
+        end);
+    end
+
+    if (#targets == 0) then
+        return;
+    end
+
+    for i, target in pairs(targets) do
+        if (i > Settings.maxStatuses) then
+            return;
+        end
+
+        local text;
+        if (Settings.centerTextOption == "bestTarget") then
+            text = string.format("#%s", i);
+        elseif (Settings.centerTextOption == "numPlayers") then
+            text = string.format("^%s", #target.targets);
+        else
+            --text = (target.totalHealthMissing / 1000) + "k";
+            text = string.format("^%.1fk", target.totalHealthMissing / 1000);
+            --text = target.totalHealthMissing;
+        end
+        self.core:SendStatusGained(target.guid, thisStatus, Settings.priority, nil, Settings.color, string.format("%s", text), 1, nil, nil);
+    end
+end