feature: implemented HealComm without using whole heavy library to sync for cross-addon compatibility while keeping legacy healbot protocol to sync with older versions also fix unit name regex parsing bugs

This commit is contained in:
Bluewhale1337
2026-09-06 22:20:26 +02:00
parent ebb42f936a
commit 7c45d85030
4 changed files with 77 additions and 32 deletions
+53 -14
View File
@@ -71,33 +71,72 @@ function HealBot_SendAddonMessage(prefix, text)
end end
end end
if not HealBot_IncomingHealers then HealBot_IncomingHealers = {} end
local function SetIncomingHeal(sender, target, amount, protocol)
-- prioritize HealComm over HealBot protocol to avoid double-counting
if HealBot_IncomingHealers[sender] and HealBot_IncomingHealers[sender].protocol == "HealComm" and protocol == "HealBot" then
return
end
-- remove old heal if it exists
if HealBot_IncomingHealers[sender] then
local oldTarget = HealBot_IncomingHealers[sender].target
local oldAmount = HealBot_IncomingHealers[sender].amount
if HealBot_HealsIn[oldTarget] then
HealBot_HealsIn[oldTarget] = HealBot_HealsIn[oldTarget] - oldAmount
if HealBot_HealsIn[oldTarget] < 0 then HealBot_HealsIn[oldTarget] = 0 end
HealBot_RecalcHeals(HealBot_FindUnitID(oldTarget))
end
end
if amount > 0 then
HealBot_IncomingHealers[sender] = { target = target, amount = amount, protocol = protocol }
if not HealBot_HealsIn[target] then HealBot_HealsIn[target] = 0 end
HealBot_HealsIn[target] = HealBot_HealsIn[target] + amount
HealBot_RecalcHeals(HealBot_FindUnitID(target))
else
HealBot_IncomingHealers[sender] = nil
end
end
-- HealBot_OnEvent_AddonMsg: Parses incoming heal data from other clients. -- HealBot_OnEvent_AddonMsg: Parses incoming heal data from other clients.
function HealBot_OnEvent_AddonMsg(this, addon_id, inc_msg, dist_target, sender_id) function HealBot_OnEvent_AddonMsg(this, addon_id, inc_msg, dist_target, sender_id)
if addon_id == HEALBOT_ADDON_ID then
local tmpTest, unitname, heal_val
tmpTest, tmpTest, unitname, heal_val = string.find(inc_msg, ">> (%a+) <<=>> (.%d+) <<" );
if heal_val then
if sender_id == UnitName("player") then return end if sender_id == UnitName("player") then return end
if not HealBot_HealsIn[unitname] then
HealBot_HealsIn[unitname] = 0; if addon_id == "HealComm" then
end -- HealComm protocol (e.g. "Heal/TargetName/Amount/CastTime/")
HealBot_Healers[sender_id] = ">> " .. unitname .. " <<=>> " .. heal_val .. " <<"; local cmd, target, amount, cast_time = strsplit("/", inc_msg)
HealBot_HealsIn[unitname] = HealBot_HealsIn[unitname] + tonumber(heal_val); if cmd == "Heal" and target and amount then
if tonumber(heal_val) > 0 then SetIncomingHeal(sender_id, target, tonumber(amount) or 0, "HealComm")
HealBot_RecalcHeals(HealBot_FindUnitID(unitname)) elseif cmd == "Healstop" then
elseif HealBot_HealsIn[unitname] < 0 then SetIncomingHeal(sender_id, nil, 0, "HealComm")
HealBot_HealsIn[unitname] = 0; elseif cmd == "GrpHeal" and amount then
-- Note: Group heals technically have multiple targets, but this is a simple implementation
-- We'll just track it against the first target to keep it simple, or ignore it.
-- Full GrpHeal parsing would split target1,target2,target3
elseif cmd == "GrpHealstop" then
SetIncomingHeal(sender_id, nil, 0, "HealComm")
end end
elseif addon_id == HEALBOT_ADDON_ID then
local tmpTest, tmpTest, unitname, heal_val = string.find(inc_msg, ">> (.-) <<=>> (.-) <<" );
if heal_val and unitname then
local amount = tonumber(heal_val) or 0
if amount < 0 then amount = 0 end -- HealBot sends negative to cancel
SetIncomingHeal(sender_id, unitname, amount, "HealBot")
end end
elseif addon_id == "HealBot" then elseif addon_id == "HealBot" then
local tmpTest, datatype, datamsg, sender local tmpTest, datatype, datamsg, sender
local PName = UnitName("player"); local PName = UnitName("player");
tmpTest, tmpTest, datatype, sender, datamsg = string.find(inc_msg, ">> (%a+) <<=>> (%a+) <<=>> (.+)"); tmpTest, tmpTest, datatype, sender, datamsg = string.find(inc_msg, ">> (.-) <<=>> (.-) <<=>> (.+)");
if datatype == "RequestVersion" then if datatype == "RequestVersion" then
HealBot_SendAddonMessage("HealBot", ">> SendVersion <<=>> " .. sender .. " <<=>> Version=" .. HEALBOT_VERSION); HealBot_SendAddonMessage("HealBot", ">> SendVersion <<=>> " .. sender .. " <<=>> Version=" .. HEALBOT_VERSION);
elseif datatype == "SendVersion" and PName == sender then elseif datatype == "SendVersion" and PName == sender then
HealBot_AddChat(sender_id .. ": " .. datamsg); HealBot_AddChat(sender_id .. ": " .. datamsg);
end end
elseif addon_id == "CTRA" then elseif addon_id == "CTRA" then
if ( string.sub(inc_msg, 1, 3) == "RES" ) then if ( string.sub(inc_msg, 1, 3) == "RES" ) then
if ( inc_msg == "RESNO" ) then if ( inc_msg == "RESNO" ) then
+2
View File
@@ -159,6 +159,7 @@ function HealBot_Process_HealValue(spell, target)
local uname = UnitName(target) local uname = UnitName(target)
if uname then if uname then
HealBot_SendAddonMessage(HEALBOT_ADDON_ID, ">> " .. uname .. " <<=>> " .. HealBot_HealValue .. " << "); HealBot_SendAddonMessage(HEALBOT_ADDON_ID, ">> " .. uname .. " <<=>> " .. HealBot_HealValue .. " << ");
HealBot_SendAddonMessage("HealComm", "Heal/" .. uname .. "/" .. HealBot_HealValue .. "/1500/");
if not HealBot_HealsIn[uname] then if not HealBot_HealsIn[uname] then
HealBot_HealsIn[uname] = 0; HealBot_HealsIn[uname] = 0;
end end
@@ -217,6 +218,7 @@ function HealBot_StopCasting()
local uname = UnitName(HealBot_CastingTarget) local uname = UnitName(HealBot_CastingTarget)
if uname then if uname then
HealBot_SendAddonMessage(HEALBOT_ADDON_ID, ">> " .. uname .. " <<=>> " .. 0 - HealBot_HealValue .. " << "); HealBot_SendAddonMessage(HEALBOT_ADDON_ID, ">> " .. uname .. " <<=>> " .. 0 - HealBot_HealValue .. " << ");
HealBot_SendAddonMessage("HealComm", "Healstop");
if HealBot_HealsIn[uname] then if HealBot_HealsIn[uname] then
HealBot_HealsIn[uname] = HealBot_HealsIn[uname] - HealBot_HealValue; HealBot_HealsIn[uname] = HealBot_HealsIn[uname] - HealBot_HealValue;
if HealBot_HealsIn[uname] < 0 then if HealBot_HealsIn[uname] < 0 then
+2
View File
@@ -36,6 +36,7 @@ function HealBot_Integrations_Toggle()
HealBot_NampowerFrame:RegisterEvent("AURA_CAST_ON_OTHER") HealBot_NampowerFrame:RegisterEvent("AURA_CAST_ON_OTHER")
HealBot_NampowerFrame:SetScript("OnEvent", function() HealBot_NampowerFrame:SetScript("OnEvent", function()
if not HealBot_Integrations_Nampower_Active then return end if not HealBot_Integrations_Nampower_Active then return end
if event == "AURA_CAST_ON_SELF" or event == "AURA_CAST_ON_OTHER" then
local spellID, caster, target, _, _, _, _, duration = arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 local spellID, caster, target, _, _, _, _, duration = arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8
if not caster or not target or duration <= 0 then return end if not caster or not target or duration <= 0 then return end
@@ -53,6 +54,7 @@ function HealBot_Integrations_Toggle()
if unitID then if unitID then
HealBot_OnEvent_UnitAura(nil, unitID) HealBot_OnEvent_UnitAura(nil, unitID)
end end
end
end) end)
end end
else else
+2
View File
@@ -50,6 +50,8 @@ Default installation path: `C:\Program Files\World of Warcraft\Interface\AddOns\
### Change Log ### Change Log
**v1.7.1** **v1.7.1**
* **Bug Fix - Incoming Heals Comms** - Fixed a regex string parsing bug that caused incoming heals from other HealBot instances to drop if a unit's name contained non-alphabetic characters (e.g. dashes or spaces in pet names).
* **Feature - Standard HealComm Sync** - Implemented lightweight parsing of the standard `HealComm` addon channel. HealBot now perfectly syncs incoming heals with modern raid frames like Luna, Grid, and pfUI, while retaining backwards compatibility with older versions of HealBot.
* **UI Update - Raid Marks** - Anchored raid target icons to top of unit frames instead of center. * **UI Update - Raid Marks** - Anchored raid target icons to top of unit frames instead of center.
* **Bug Fix** - Fixed an issue where the debuff warning sound and UI message would spam repeatedly on every aura update. The warning now only plays once per unique dispellable debuff type applied to a unit. Increased warning trigger range to 40 yards. * **Bug Fix** - Fixed an issue where the debuff warning sound and UI message would spam repeatedly on every aura update. The warning now only plays once per unique dispellable debuff type applied to a unit. Increased warning trigger range to 40 yards.