From 395ee40207e939e7ff28eb5065c844f3aa85b906 Mon Sep 17 00:00:00 2001 From: AlmTech Date: Wed, 4 Sep 2019 21:24:29 +0200 Subject: [PATCH] Fixed HUD and added near death effects --- gamemode/core/client/cl_fonts.lua | 9 ++++++++- gamemode/core/client/cl_hud.lua | 32 +++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/gamemode/core/client/cl_fonts.lua b/gamemode/core/client/cl_fonts.lua index 77fd27b..c08cada 100644 --- a/gamemode/core/client/cl_fonts.lua +++ b/gamemode/core/client/cl_fonts.lua @@ -3,4 +3,11 @@ -- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ -- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > -- \ \ / ____ \| | | | | | | | __/ (__| | | | / / --- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ \ No newline at end of file +-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ + +surface.CreateFont( "q_HUD", { + font = "Arial", + size = 15 * Quantum.Client.ResolutionScale, + antialias = true, + outline = true +}) \ No newline at end of file diff --git a/gamemode/core/client/cl_hud.lua b/gamemode/core/client/cl_hud.lua index 9a9b816..806c62e 100644 --- a/gamemode/core/client/cl_hud.lua +++ b/gamemode/core/client/cl_hud.lua @@ -27,10 +27,6 @@ function GM:HUDPaint() if( Quantum.Client.Config.EnableHUD ) then if !LocalPlayer():Alive() then return end - print( lasthp, LocalPlayer():Health() ) - if( LocalPlayer():Health() ~= lasthp ) then - lasthp = Lerp( 0.5, lasthp, hp ) - end -- Health border surface.SetDrawColor( 0, 0, 0, 200 ) @@ -38,7 +34,31 @@ function GM:HUDPaint() -- Health surface.SetDrawColor( 168, 62, 50, 255 ) - surface.DrawRect( (sw/2 - barW/2) + padding/2, (sh*0.9) + padding/2, barW - padding, barH - padding ) + surface.DrawRect( ( sw/2 - barW/2 ) + padding/2, (sh*0.9) + padding/2, math.Clamp( (barW - padding) * hp/maxhp, 0, barW - padding ), barH - padding ) + + -- Text + 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 ) + end -end \ No newline at end of file +end + +hook.Add( "RenderScreenspaceEffects", "Quantum_HUD_RenderLowHealth", function() + DrawColorModify( { + [ "$pp_colour_addr" ] = 0, + [ "$pp_colour_addg" ] = 0, + [ "$pp_colour_addb" ] = 0, + [ "$pp_colour_brightness" ] = Lerp( LocalPlayer():Health() / LocalPlayer():GetMaxHealth(), -0.75, 0 ), + [ "$pp_colour_contrast" ] = Lerp( LocalPlayer():Health() / LocalPlayer():GetMaxHealth(), 0.6, 1 ), + [ "$pp_colour_colour" ] = Lerp( LocalPlayer():Health() / LocalPlayer():GetMaxHealth(), 0.2, 1 ), + [ "$pp_colour_mulr" ] = 0, + [ "$pp_colour_mulg" ] = 0, + [ "$pp_colour_mulb" ] = 0 + } ) + if( LocalPlayer():Health() / LocalPlayer():GetMaxHealth() <= 0.15 ) then DrawMotionBlur( 0.4, 0.8, 0.1 ) end +end)