mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-26 01:26:01 +00:00
feigndeath: use UnitIsFeignDeath + GetUnitField, drop tooltip cache
ClassicAPI's UnitIsFeignDeath reads UNIT_FIELD_FLAGS bit 29 directly —
the authoritative server flag, no detection guesswork needed. Combined
with Nampower's GetUnitField("health"), we read live HP off the
descriptor instead of caching the moment-of-death healthbar value via
libtipscan.
Drops the name-keyed cache, the UNIT_HEALTH / PLAYER_TARGET_CHANGED
event handlers, and the tooltip scanner. Also fixes the staleness bug
where a feigning hunter taking further damage kept showing the cached
snapshot from when feign first triggered — live read updates with
every UnitHealth call now.
This commit is contained in:
+5
-24
@@ -1,29 +1,10 @@
|
||||
pfUI:RegisterModule("feigndeath", function ()
|
||||
local cache = { }
|
||||
local scanner = libtipscan:GetScanner("feigndeath")
|
||||
local healthbar = scanner: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
|
||||
scanner:SetUnit("target")
|
||||
cache[UnitName("target")] = healthbar:GetValue()
|
||||
elseif event == "UNIT_HEALTH" and UnitIsDead(arg1) and UnitName(arg1) then
|
||||
scanner:SetUnit(arg1)
|
||||
cache[UnitName(arg1)] = healthbar:GetValue()
|
||||
elseif event == "UNIT_HEALTH" and UnitName(arg1) then
|
||||
cache[UnitName(arg1)] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
local oldUnitHealth = UnitHealth
|
||||
function UnitHealth(arg)
|
||||
if UnitIsDead(arg) and cache[UnitName(arg)] then
|
||||
return cache[UnitName(arg)]
|
||||
else
|
||||
return oldUnitHealth(arg)
|
||||
function UnitHealth(unit)
|
||||
if UnitIsFeignDeath(unit) then
|
||||
local hp = GetUnitField(unit, "health")
|
||||
if hp and hp > 0 then return hp end
|
||||
end
|
||||
return oldUnitHealth(unit)
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user