Add files via upload

This commit is contained in:
Relationship
2026-07-10 09:44:50 +01:00
committed by GitHub
parent 16705f72ac
commit 77154b7b11
6 changed files with 141 additions and 93 deletions
+39 -56
View File
@@ -420,61 +420,33 @@ function addon.Threat:GetThreatPercent(unit)
-- If the mob is targeting an outsider -> show player's threat
-- Otherwise -> show the best (highest) threat from any member
-- The threat bar on a nameplate is always displayed from the
-- PLAYER's point of view: "how close am I to pulling aggro
-- off whoever currently has it?". Showing another group
-- member's percentage would incorrectly make every mob a
-- party member is tanking read as 100% — that is the bug
-- users describe as "snap causes all party-combat enemies
-- to show 100%". So: always return the player's own value
-- here. If the player has no threat on this mob, return 0
-- so the bar hides.
if mobTargetName == playerName then
-- Mob is attacking the player - show player's own threat
return playerPct, playerSit
elseif mobTargetName and partyNames[mobTargetName] then
-- Mob is attacking a group member - show that member's threat
-- Look up that member's threat from the group scan
local memberUnit = partyNames[mobTargetName]
local memberPct = nil
local memberSit = nil
if hasUnitDetailedThreatSituation then
local _, status, _, rawPct = SafeCall5(UnitDetailedThreatSituation, memberUnit, unit)
if rawPct then
memberPct = math.min(100, math.max(0, rawPct))
memberSit = status or 0
end
end
if not memberPct and hasGetThreatPercent then
local pct = SafeCall2(GetThreatPercent, memberUnit, unit)
if pct then
memberPct = math.min(100, math.max(0, pct))
if hasUnitThreatSituation then
memberSit = SafeCall2(UnitThreatSituation, memberUnit, unit) or 0
else
if memberPct >= 100 then memberSit = 3
elseif memberPct >= 60 then memberSit = 2
elseif memberPct >= 30 then memberSit = 1
else memberSit = 0 end
end
end
end
if not memberPct and hasUnitThreatSituation then
memberSit = SafeCall2(UnitThreatSituation, memberUnit, unit) or 0
if memberSit == 0 then memberPct = 0
elseif memberSit == 1 then memberPct = 25
elseif memberSit == 2 then memberPct = 60
elseif memberSit == 3 then memberPct = 100 end
end
if memberPct then
return memberPct, memberSit or 0
end
-- Fallback: can't get specific member data, use best
return bestPct, bestSit
else
-- Mob targets an outsider, or we can't see its target.
-- Show player's threat if they have any, otherwise the
-- best group threat.
-- Mob is attacking a group member. Show the player's
-- own relative threat, not the party member's.
if playerPct > 0 then
return playerPct, playerSit
end
return bestPct, bestSit
return 0, 0
else
-- Mob targets an outsider, or we can't see its target.
-- Show player's own threat only.
if playerPct > 0 then
return playerPct, playerSit
end
return 0, 0
end
end
@@ -600,13 +572,18 @@ function addon.Threat:GetThreatPercent(unit)
threatPct = 100
situation = 3
elseif partyNames[mobTargetName] then
-- Mob is targeting a PARTY/RAID member.
-- That member has aggro - show high threat.
-- This is the KEY fix: previously showed only 60%/30%
-- for mobs targeting group members. Now shows 100%
-- because that group member IS the one being attacked.
threatPct = 100
situation = 3
-- Mob is targeting a PARTY/RAID member. The party member
-- has aggro, NOT the player. Showing 100% here would
-- incorrectly light every mob in party combat up as full
-- aggro on the player. Show a low estimate instead — the
-- player is not in the aggro seat.
if UnitIsUnit("target", unit) then
threatPct = 20
situation = 0
else
threatPct = 0
situation = 0
end
else
-- Mob is targeting someone outside the party
-- (another player, a pet, etc.)
@@ -663,7 +640,13 @@ function addon.Threat:UpdateUnitThreat(unit)
and mobTargetName and playerName and mobTargetName == playerName then
local ok_pc, pc = pcall(UnitAffectingCombat, "player")
if ok_pc and pc then
pct = 100
-- Player is being targeted, so they have aggro. Force
-- pct to at least 100 without clobbering a real value
-- above 100 (which happens when the player is top and
-- well ahead of the second-highest threat holder).
if not pct or pct < 100 then
pct = 100
end
situation = 3
targetSnapped = true
end