Add files via upload
This commit is contained in:
@@ -390,21 +390,24 @@ function addon.Nameplates:ScanForNameplates()
|
||||
local nameplate = children[i]
|
||||
|
||||
if nameplate and not knownPlates[nameplate] then
|
||||
-- Quick visibility filter - don't scan invisible frames
|
||||
-- Only mark a plate as "known" once we have actually
|
||||
-- attached a threat bar to it. Vanilla recycles nameplate
|
||||
-- frames from a pool: a currently-invisible plate frame
|
||||
-- can (and usually will) reappear later for another mob.
|
||||
-- If we flagged it known while invisible, we would never
|
||||
-- attach a bar when it became visible again — that is the
|
||||
-- root cause of "plates stop appearing after changing a
|
||||
-- setting" (RecreateAll clears knownPlates, then this
|
||||
-- scan runs while some pooled plates are hidden).
|
||||
if nameplate:IsVisible() then
|
||||
knownPlates[nameplate] = true
|
||||
|
||||
-- Check if this frame is a nameplate
|
||||
local healthBar, nameText = self:IdentifyNameplate(nameplate)
|
||||
|
||||
if healthBar then
|
||||
knownPlates[nameplate] = true
|
||||
self:AttachThreatBar(nameplate, healthBar, nameText)
|
||||
end
|
||||
else
|
||||
-- Mark as known even if invisible; we'll handle
|
||||
-- visibility in the update loop
|
||||
knownPlates[nameplate] = true
|
||||
end
|
||||
-- Invisible plates are intentionally left un-flagged so
|
||||
-- the periodic scan will re-check them once they show.
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -894,26 +897,34 @@ function addon.Nameplates:ApplyThreatToPlate(data, pct, situation)
|
||||
|
||||
data.container:Show()
|
||||
|
||||
-- Smooth the percentage
|
||||
-- Preserve the RAW threat percent (may exceed 100 when the player
|
||||
-- is the top threat holder and well ahead of the runner-up). The
|
||||
-- text label shows this uncapped value so the user can see e.g.
|
||||
-- "185%" for a tank comfortably holding threat. The bar fill
|
||||
-- itself is clamped to 0-100 because the statusbar range is fixed.
|
||||
local rawPct = pct or 0
|
||||
|
||||
-- Smooth the percentage (bar fill only — clamp to 0..100)
|
||||
local oldPct = data.lastPct or 0
|
||||
local barPct = math.min(100, math.max(0, rawPct))
|
||||
local smoothPct
|
||||
-- Snap instantly when jumping to full aggro (100%) or dropping to 0
|
||||
-- Snap instantly when jumping to full aggro or dropping to 0
|
||||
-- (mob switched target). Smooth intermediate transitions moderately.
|
||||
if pct == 0 or pct >= 99.5 or math.abs(pct - oldPct) > 40 then
|
||||
smoothPct = pct
|
||||
if barPct == 0 or barPct >= 99.5 or math.abs(barPct - oldPct) > 40 then
|
||||
smoothPct = barPct
|
||||
else
|
||||
smoothPct = oldPct + (pct - oldPct) * 0.6
|
||||
smoothPct = oldPct + (barPct - oldPct) * 0.6
|
||||
end
|
||||
data.lastPct = smoothPct
|
||||
|
||||
smoothPct = math.min(100, math.max(0, smoothPct))
|
||||
pct = math.min(100, math.max(0, pct))
|
||||
|
||||
-- Update bar value
|
||||
-- Update bar value (0-100 range)
|
||||
data.bar:SetValue(smoothPct)
|
||||
|
||||
-- Update bar colour (smooth gradient)
|
||||
local r, g, b = addon.Media.GetThreatColour(pct)
|
||||
-- Update bar colour (smooth gradient) — driven by barPct so colours
|
||||
-- top out at aggro red even if rawPct exceeds 100.
|
||||
local r, g, b = addon.Media.GetThreatColour(barPct)
|
||||
data.bar:SetStatusBarColor(r, g, b, RelationshipsThreatPlatesDB.barAlpha or 1)
|
||||
|
||||
-- Update statusbar texture vertex colour
|
||||
@@ -948,7 +959,7 @@ function addon.Nameplates:ApplyThreatToPlate(data, pct, situation)
|
||||
end
|
||||
end
|
||||
|
||||
-- Update text
|
||||
-- Update text — uses rawPct so values above 100% are shown as-is.
|
||||
if data.text then
|
||||
local textStr
|
||||
if RelationshipsThreatPlatesDB.tankMode and data.plateName then
|
||||
@@ -958,26 +969,29 @@ function addon.Nameplates:ApplyThreatToPlate(data, pct, situation)
|
||||
textStr = addon.Threat:GetTankDisplayForMob(data.plateName)
|
||||
if not textStr or textStr == "--" then
|
||||
-- Fall back to % when no absolute values are available.
|
||||
textStr = math.floor(pct + 0.5) .. "%"
|
||||
textStr = math.floor(rawPct + 0.5) .. "%"
|
||||
end
|
||||
else
|
||||
textStr = math.floor(pct + 0.5) .. "%"
|
||||
textStr = math.floor(rawPct + 0.5) .. "%"
|
||||
end
|
||||
data.text:SetText(textStr)
|
||||
|
||||
if pct >= 90 then
|
||||
if rawPct >= 100 then
|
||||
-- Aggro / over-aggro: bright red text so the top holder
|
||||
-- stands out even when the bar itself is pegged at full.
|
||||
data.text:SetTextColor(1, 0.2, 0.2, 1)
|
||||
elseif pct >= 60 then
|
||||
elseif rawPct >= 60 then
|
||||
data.text:SetTextColor(1, 0.9, 0.8, 1)
|
||||
else
|
||||
data.text:SetTextColor(1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- Update threat glow
|
||||
-- Update threat glow (drive by clamped barPct so it caps at max intensity)
|
||||
if data.threatGlow then
|
||||
if pct >= 80 then
|
||||
local intensity = (pct - 80) / 20
|
||||
if barPct >= 80 then
|
||||
local intensity = (barPct - 80) / 20
|
||||
if intensity > 1 then intensity = 1 end
|
||||
data.threatGlow:SetVertexColor(0.9, 0, 0, 0.6 * intensity)
|
||||
data.threatGlow:Show()
|
||||
else
|
||||
@@ -1213,7 +1227,7 @@ function addon.Nameplates:UpdateAllPlates()
|
||||
-- If a group member is in combat, show a default
|
||||
-- threat bar. The mob is fighting someone.
|
||||
if groupInCombat then
|
||||
self:ApplyThreatToPlate(data, 100, 3)
|
||||
self:ApplyThreatToPlate(data, 20, 0) -- was 100,3: showing full aggro for any party-combat mob with no threat data was misleading
|
||||
else
|
||||
data.container:Hide()
|
||||
end
|
||||
@@ -1232,7 +1246,7 @@ function addon.Nameplates:UpdateAllPlates()
|
||||
if pct > 0 then
|
||||
self:ApplyThreatToPlate(data, pct, sit or 0)
|
||||
else
|
||||
self:ApplyThreatToPlate(data, 100, 3)
|
||||
self:ApplyThreatToPlate(data, 20, 0) -- was 100,3: showing full aggro for any party-combat mob with no threat data was misleading
|
||||
end
|
||||
else
|
||||
-- Grace period expired and health still at 100%.
|
||||
@@ -1265,7 +1279,7 @@ function addon.Nameplates:UpdateAllPlates()
|
||||
if not data.combatDetectedAt then
|
||||
data.combatDetectedAt = now
|
||||
end
|
||||
self:ApplyThreatToPlate(data, 100, 3)
|
||||
self:ApplyThreatToPlate(data, 20, 0) -- was 100,3: showing full aggro for any party-combat mob with no threat data was misleading
|
||||
else
|
||||
-- Can't confirm mob is attacking anyone.
|
||||
-- It might be idle. Don't show bar.
|
||||
@@ -1307,7 +1321,7 @@ function addon.Nameplates:UpdateAllPlates()
|
||||
-- In combat but no threat data — mob is being
|
||||
-- attacked by someone we can't track.
|
||||
if groupInCombat then
|
||||
self:ApplyThreatToPlate(data, 100, 3)
|
||||
self:ApplyThreatToPlate(data, 20, 0) -- was 100,3: showing full aggro for any party-combat mob with no threat data was misleading
|
||||
else
|
||||
data.container:Hide()
|
||||
end
|
||||
@@ -1316,7 +1330,7 @@ function addon.Nameplates:UpdateAllPlates()
|
||||
-- In combat (health dropping) but no ThreatEngine data.
|
||||
-- Show default high-threat bar.
|
||||
if groupInCombat then
|
||||
self:ApplyThreatToPlate(data, 100, 3)
|
||||
self:ApplyThreatToPlate(data, 20, 0) -- was 100,3: showing full aggro for any party-combat mob with no threat data was misleading
|
||||
else
|
||||
data.container:Hide()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user