You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.5 KiB
76 lines
2.5 KiB
5 years ago
|
-- __ _ _______ _ __
|
||
|
-- / / /\ | | |__ __| | | \ \
|
||
|
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
|
||
|
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
|
||
|
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
|
||
|
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
|
||
|
|
||
5 years ago
|
local enabledHUDs = {
|
||
|
["CHudChat"] = true,
|
||
|
["CHudGMod"] = true
|
||
|
}
|
||
|
|
||
|
hook.Add( "HUDShouldDraw", "Quantum_RemoveDefualtHUD", function( hudid )
|
||
|
return enabledHUDs[hudid] ~= nil
|
||
|
end)
|
||
|
|
||
|
|
||
|
local scale = Quantum.Client.ResolutionScale
|
||
|
local barW, barH = 250 * scale, 10 * scale
|
||
5 years ago
|
local radius = 1 * scale
|
||
5 years ago
|
local padding = 2 * scale
|
||
|
local sw, sh = ScrW(), ScrH()
|
||
|
|
||
|
function GM:HUDPaint()
|
||
|
local hp = LocalPlayer():Health()
|
||
|
local lasthp = hp
|
||
|
local maxhp = LocalPlayer():GetMaxHealth()
|
||
|
|
||
|
if( Quantum.Client.Config.EnableHUD ) then
|
||
5 years ago
|
if( !LocalPlayer():Alive() ) then
|
||
|
surface.SetDrawColor( 0, 0, 0, 255 )
|
||
|
surface.DrawRect( 0, 0, sw, sh )
|
||
|
else
|
||
|
-- Health border
|
||
|
surface.SetDrawColor( 0, 0, 0, 200 )
|
||
|
surface.DrawRect( sw/2 - barW/2, sh*0.9, barW, barH )
|
||
|
|
||
5 years ago
|
-- Health bar
|
||
5 years ago
|
surface.SetDrawColor( 168, 62, 50, 255 )
|
||
|
surface.DrawRect( ( sw/2 - barW/2 ) + padding/2, (sh*0.9) + padding/2, math.Clamp( (barW - padding) * hp/maxhp, 0, barW - padding ), barH - padding )
|
||
5 years ago
|
|
||
5 years ago
|
-- Health Text
|
||
5 years ago
|
surface.SetFont( "q_HUD" )
|
||
|
surface.SetTextColor( 255, 255, 255, 255 )
|
||
|
local hptxt = tostring( 100 * (hp/maxhp) .. "%" )
|
||
|
local txtW, txtH = surface.GetTextSize( hptxt )
|
||
|
surface.SetTextPos( ( ( sw/2 - txtW/2 ) + padding/2 ), ( ( sh*0.9 - txtH/2 ) ) )
|
||
|
surface.DrawText( hptxt )
|
||
5 years ago
|
|
||
|
-- Crosshair
|
||
|
if( Quantum.Client.ShowCrosshair ) then
|
||
|
surface.SetDrawColor( 255, 255, 255, 200 )
|
||
|
surface.DrawRect( sw/2 - radius, sh/2 - radius, radius*2, radius*2 )
|
||
|
end
|
||
5 years ago
|
end
|
||
5 years ago
|
end
|
||
|
|
||
5 years ago
|
end
|
||
|
|
||
|
hook.Add( "RenderScreenspaceEffects", "Quantum_HUD_RenderLowHealth", function()
|
||
5 years ago
|
if( LocalPlayer():Health() / LocalPlayer():GetMaxHealth() <= 0.25 ) then
|
||
5 years ago
|
DrawMotionBlur( 0.4, 0.8, 0.1 )
|
||
|
DrawColorModify( {
|
||
|
[ "$pp_colour_addr" ] = 0,
|
||
|
[ "$pp_colour_addg" ] = 0,
|
||
|
[ "$pp_colour_addb" ] = 0,
|
||
5 years ago
|
[ "$pp_colour_brightness" ] = Lerp( LocalPlayer():Health() / LocalPlayer():GetMaxHealth(), -0.25, 0 ),
|
||
|
[ "$pp_colour_contrast" ] = Lerp( LocalPlayer():Health() / LocalPlayer():GetMaxHealth(), 0.2, 1 ),
|
||
5 years ago
|
[ "$pp_colour_colour" ] = Lerp( LocalPlayer():Health() / LocalPlayer():GetMaxHealth(), 0.8, 1 ),
|
||
5 years ago
|
[ "$pp_colour_mulr" ] = 0,
|
||
|
[ "$pp_colour_mulg" ] = 0,
|
||
|
[ "$pp_colour_mulb" ] = 0
|
||
|
} )
|
||
|
end
|
||
5 years ago
|
end)
|