Make low health overlay not draw over HUDs

This commit is contained in:
LostTrackpad 2024-07-29 22:28:04 +07:00
parent ba49b787c9
commit 900de4c9f4

View file

@ -158,7 +158,9 @@ if CLIENT then
local radial = Material("radial.png")
local dmgalpha = 0
hook.Add("HUDPaint", "NTScreenEffects", function()
hook.Add("PreDrawHUD", "NTScreenEffects", function()
-- Not doing it this way breaks HUDs. And that's not cool.
cam.Start2D()
local ply = LocalPlayer()
if not ply:Alive() then return end
@ -169,10 +171,11 @@ if CLIENT then
dmgalpha = math.min(300 * math.abs(ply:Health() / ply:GetMaxHealth() - 1), 255)
surface.SetMaterial(radial)
surface.SetDrawColor(0, 0, 0, dmgalpha * 0.85)
surface.SetDrawColor(0, 0, 0, dmgalpha * 0.58)
surface.DrawTexturedRect(0, 0, ScrW(), ScrH())
surface.DrawTexturedRectRotated(ScrW() * 0.5, ScrH() * 0.5, ScrW(), ScrH(), 180)
surface.SetDrawColor(255, 25, 25, dmgalpha * math.max(0, math.sin(CurTime() * 6) * 0.045))
surface.SetDrawColor(255, 25, 25, dmgalpha * math.max(0, math.sin(CurTime() * 6) * 0.09))
surface.DrawTexturedRect(0, 0, w, h)
cam.End2D()
end)
end