diff --git a/modules/feigndeath.lua b/modules/feigndeath.lua new file mode 100644 index 00000000..4f12e6c7 --- /dev/null +++ b/modules/feigndeath.lua @@ -0,0 +1,30 @@ +pfUI:RegisterModule("feigndeath", function () + local cache = { } + local healthscan = CreateFrame("GameTooltip", "pfHpScanner", UIParent, "GameTooltipTemplate") + healthscan:SetOwner(healthscan,"ANCHOR_NONE") + local healthbar = healthscan:GetChildren() + + local cache_update = CreateFrame("Frame") + cache_update:RegisterEvent("UNIT_HEALTH") + cache_update:RegisterEvent("PLAYER_TARGET_CHANGED") + cache_update:SetScript("OnEvent", function() + if event == "PLAYER_TARGET_CHANGED" and UnitIsDead("target") then + healthscan:SetUnit("target") + cache[UnitName("target")] = healthbar:GetValue() + elseif event == "UNIT_HEALTH" and UnitIsDead(arg1) then + healthscan:SetUnit(arg1) + cache[UnitName(arg1)] = healthbar:GetValue() + elseif event == "UNIT_HEALTH" then + cache[UnitName(arg1)] = nil + end + end) + + local oldUnitHealth = UnitHealth + function _G.UnitHealth(arg) + if UnitIsDead(arg) and cache[UnitName(arg)] then + return cache[UnitName(arg)] + else + return oldUnitHealth(arg) + end + end +end) diff --git a/pfUI.toc b/pfUI.toc index 7e8c71ff..9079f9d8 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -84,3 +84,4 @@ modules\custom.lua modules\gm.lua modules\mirrortimers.lua modules\socialmod.lua +modules\feigndeath.lua