From 87ab625ca8b58de4d688554e1298e8dd95dd01f3 Mon Sep 17 00:00:00 2001 From: ketmar Date: Wed, 6 Mar 2024 21:00:32 +0000 Subject: [PATCH] script, ui: added "sv_min_startmap_health" cvar FossilOrigin-Name: da831379889a92bc4c28d3a096f8475681c89a8497ff54f529e2efadd9afbdcf --- basev/common/uidef/menus/gameplay.txt | 10 ++++++++++ progs/common/linespec/player/PlayerEx.vc | 6 ++++++ source/server/sv_main.cpp | 2 ++ 3 files changed, 18 insertions(+) diff --git a/basev/common/uidef/menus/gameplay.txt b/basev/common/uidef/menus/gameplay.txt index 82033fd91..a0e544a0b 100644 --- a/basev/common/uidef/menus/gameplay.txt +++ b/basev/common/uidef/menus/gameplay.txt @@ -352,6 +352,16 @@ menudef GameplayOptions { help = "Force default health on new map (but don't reset weapons)."; } + option slider { + title = "Minimum Start Health"; + cvar = sv_min_startmap_health; + min = 0; + max = 100; + step = 5; + help = "Restore player health on a new map to this minimum value?", + "'0' means 'don't restore'."; + } + header ""; diff --git a/progs/common/linespec/player/PlayerEx.vc b/progs/common/linespec/player/PlayerEx.vc index d2df0bed1..fb9d2056e 100644 --- a/progs/common/linespec/player/PlayerEx.vc +++ b/progs/common/linespec/player/PlayerEx.vc @@ -4144,6 +4144,12 @@ PlayerPawn SpawnPlayer (mthing_t *mthing, bool Voodoo) { if ((Level.bResetHealth && !GetCvarB('sv_ignore_reset_health')) || GetCvarB('sv_force_health_reset')) { Health = GetRebornHealth(); EntityEx(MO).Health = Health; + } else { + int rh = clamp(GetCvarI('sv_min_startmap_health'), 0, 200); + if (rh && Health < rh) { + Health = rh; + EntityEx(MO).Health = rh; + } } } diff --git a/source/server/sv_main.cpp b/source/server/sv_main.cpp index 195bb0298..fbb59de71 100644 --- a/source/server/sv_main.cpp +++ b/source/server/sv_main.cpp @@ -138,6 +138,8 @@ static VCvarB sv_ignore_reset_items("sv_ignore_reset_items", false, "Ignore \"re static VCvarB sv_force_pistol_start("sv_force_pistol_start", false, "Start each new map with default weapons?", /*CVAR_ServerInfo|CVAR_Latch|*/CVAR_PreInit|CVAR_NoShadow); static VCvarB sv_force_health_reset("sv_force_health_reset", false, "Start each new map with default health?", /*CVAR_ServerInfo|CVAR_Latch|*/CVAR_PreInit|CVAR_NoShadow); +static VCvarI sv_min_startmap_health("sv_min_startmap_health", "0", "Restore health to this minimum limit on map start (0: don't restore).", /*CVAR_ServerInfo|CVAR_Latch|*/CVAR_PreInit|CVAR_NoShadow); + static VCvarB sv_transporters_absolute("sv_transporters_absolute", true, "Use absolute movement instead of velocity for Boom transporters?", /*CVAR_ServerInfo|CVAR_Latch|*/CVAR_Archive|CVAR_PreInit); static VCvarB mod_allow_server_cvars("mod_allow_server_cvars", false, "Allow server cvars from CVARINFO?", CVAR_Archive|CVAR_PreInit|CVAR_NoShadow); -- 2.11.4.GIT