From 26e72173c63e00578c9ac5919b73fe0a8bf6f21b Mon Sep 17 00:00:00 2001 From: AlmTech Date: Thu, 5 Sep 2019 19:53:55 +0200 Subject: [PATCH] Added damage scaling and better death effects --- gamemode/core/client/cl_config_vars.lua | 3 ++- gamemode/core/client/cl_hud.lua | 13 ++++++++--- gamemode/core/server/sv_player_damage.lua | 27 +++++++++++++++++++++++ gamemode/init.lua | 1 + gamemode/settings/sv_settings.lua | 18 +++++++++++++++ 5 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 gamemode/core/server/sv_player_damage.lua create mode 100644 gamemode/settings/sv_settings.lua diff --git a/gamemode/core/client/cl_config_vars.lua b/gamemode/core/client/cl_config_vars.lua index 5d74b9c..aa6de83 100644 --- a/gamemode/core/client/cl_config_vars.lua +++ b/gamemode/core/client/cl_config_vars.lua @@ -6,4 +6,5 @@ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ Quantum.Client.Config = {} -Quantum.Client.Config.EnableHUD = true \ No newline at end of file +Quantum.Client.Config.EnableHUD = true +Quantum.Client.ShowCrosshair = true \ No newline at end of file diff --git a/gamemode/core/client/cl_hud.lua b/gamemode/core/client/cl_hud.lua index 129df8e..52d94ee 100644 --- a/gamemode/core/client/cl_hud.lua +++ b/gamemode/core/client/cl_hud.lua @@ -17,6 +17,7 @@ end) local scale = Quantum.Client.ResolutionScale local barW, barH = 250 * scale, 10 * scale +local radius = 1 * scale local padding = 2 * scale local sw, sh = ScrW(), ScrH() @@ -34,24 +35,30 @@ function GM:HUDPaint() surface.SetDrawColor( 0, 0, 0, 200 ) surface.DrawRect( sw/2 - barW/2, sh*0.9, barW, barH ) - -- Health + -- Health bar 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 ) - -- Text + -- Health 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 ) + + -- 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 end end end hook.Add( "RenderScreenspaceEffects", "Quantum_HUD_RenderLowHealth", function() - if( LocalPlayer():Health() / LocalPlayer():GetMaxHealth() <= 0.15 ) then + if( LocalPlayer():Health() / LocalPlayer():GetMaxHealth() <= 0.20 ) then DrawMotionBlur( 0.4, 0.8, 0.1 ) DrawColorModify( { [ "$pp_colour_addr" ] = 0, diff --git a/gamemode/core/server/sv_player_damage.lua b/gamemode/core/server/sv_player_damage.lua new file mode 100644 index 0000000..cef02a0 --- /dev/null +++ b/gamemode/core/server/sv_player_damage.lua @@ -0,0 +1,27 @@ +-- __ _ _______ _ __ +-- / / /\ | | |__ __| | | \ \ +-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ +-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > +-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / +-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ + +local damagescales = { + [HITGROUP_HEAD] = Quantum.Server.Settings.DamageScale[HITGROUP_HEAD], + [HITGROUP_CHEST] = Quantum.Server.Settings.DamageScale[HITGROUP_CHEST], + [HITGROUP_STOMACH] = Quantum.Server.Settings.DamageScale[HITGROUP_STOMACH], + [HITGROUP_LEFTARM] = Quantum.Server.Settings.DamageScale[HITGROUP_LEFTARM], + [HITGROUP_RIGHTARM] = Quantum.Server.Settings.DamageScale[HITGROUP_RIGHTARM], + [HITGROUP_LEFTLEG] = Quantum.Server.Settings.DamageScale[HITGROUP_LEFTLEG], + [HITGROUP_RIGHTLEG] = Quantum.Server.Settings.DamageScale[HITGROUP_RIGHTLEG] +} + +function GM:ScalePlayerDamage( pl, hitgroup, dmginfo ) -- This is used for getting shot etc + if( damagescales[hitgroup] ~= nil ) then dmginfo:ScaleDamage( damagescales[hitgroup] ) end + Quantum.Debug( tostring(pl) .. " got damaged (" .. tostring(hitgroup) .. " : " .. tostring(dmginfo) ) +end + +function GM:GetFallDamage( pl, vel ) + return vel / 8 -- Makes the player take more "realistic" fall damage +end + +function GM:PlayerDeathSound() return true end \ No newline at end of file diff --git a/gamemode/init.lua b/gamemode/init.lua index 2c37c86..1109f07 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -12,6 +12,7 @@ if SERVER then include( "shared.lua" ) Quantum.Server = {} + include( "settings/sv_settings.lua" ) -- include the settings -- Add all core files diff --git a/gamemode/settings/sv_settings.lua b/gamemode/settings/sv_settings.lua new file mode 100644 index 0000000..8957052 --- /dev/null +++ b/gamemode/settings/sv_settings.lua @@ -0,0 +1,18 @@ +-- __ _ _______ _ __ +-- / / /\ | | |__ __| | | \ \ +-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ +-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > +-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / +-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ + + Quantum.Server.Settings = {} + +Quantum.Server.Settings.DamageScale = { -- The scale of the damage for each hitgroup + [HITGROUP_HEAD] = 4, + [HITGROUP_CHEST] = 2, + [HITGROUP_STOMACH] = 1.5, + [HITGROUP_LEFTARM] = 0.8, + [HITGROUP_RIGHTARM] = 0.8, + [HITGROUP_LEFTLEG] = 1, + [HITGROUP_RIGHTLEG] = 1 +} \ No newline at end of file