From ba9afa97bf77889a2b7400ae3aed20b7d2ad93c2 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 6 Apr 2025 17:55:26 +0200 Subject: [PATCH] raid-healing-predictions: option to show healing predictions --- ShaguTweaks-extras.toc | 1 + mods/raid-healing-predictions.lua | 57 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 mods/raid-healing-predictions.lua diff --git a/ShaguTweaks-extras.toc b/ShaguTweaks-extras.toc index 643da7d..a3f7918 100644 --- a/ShaguTweaks-extras.toc +++ b/ShaguTweaks-extras.toc @@ -39,6 +39,7 @@ mods\raid-group-header.lua mods\raid-combat-feedback.lua mods\raid-dispel-indicators.lua mods\raid-aggro-indicator.lua +mods\raid-healing-predictions.lua mods\raid-hide-party.lua # reduced actionbar size diff --git a/mods/raid-healing-predictions.lua b/mods/raid-healing-predictions.lua new file mode 100644 index 0000000..06b2c25 --- /dev/null +++ b/mods/raid-healing-predictions.lua @@ -0,0 +1,57 @@ +local _G = ShaguTweaks.GetGlobalEnv() +local T = ShaguTweaks.T + +local module = ShaguTweaks:register({ + title = T["Show Healing Predictions"], + description = T["Show healing predictions that are received in a healcomm compatible protocol."], + expansions = { ["vanilla"] = true, ["tbc"] = false }, + category = T["Raid Frames"], + maintainer = "@shagu (GitHub)", + enabled = nil, +}) + +module.enable = function(self) + ShaguTweaks.UnitFrame_NewComponent('healing predictions', { + events = { }, + + create = function(frame) + -- create green prediction healthbar + frame.predict = frame.bar:CreateTexture(nil, "BORDER") + frame.predict:SetTexture("Interface\\TargetingFrame\\UI-StatusBar") + frame.predict:SetVertexColor(0, 1, 0, 1) + frame.predict:SetPoint("TOPLEFT", frame.bar, "TOPLEFT", 0, 0) + frame.predict:SetPoint("BOTTOMLEFT", frame.bar, "BOTTOMLEFT", 0, 0) + end, + + update = function(frame, event) + -- read predictions + local heal = ShaguTweaks.libpredict:UnitGetIncomingHeals(frame.unitstr) + local res = ShaguTweaks.libpredict:UnitHasIncomingResurrection(frame.unitstr) + + -- update bar size if required + if heal ~= this.predict_lastval then + if heal and heal > 0 then + local health, maxHealth = UnitHealth(frame.unitstr), UnitHealthMax(frame.unitstr) + local healthWidth = 62 * health / maxHealth + local incWidth = 62 * heal / maxHealth + local width = math.min(62, healthWidth + incWidth) + frame.predict:SetWidth(width) + else + frame.predict:SetWidth(-1) + end + + this.predict_lastval = heal + end + + -- update healing state + if heal and heal > 0 then + frame.info = "|cff22ff22+" .. heal .. "|r" + end + + -- update resurrection state + if res then + frame.info = "|cffffff55Resurrecting" + end + end + }) +end