From bd7b8246039e002d5d044f8a6813ccd80fd3882e Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 20 Mar 2022 20:15:36 +0000 Subject: [PATCH] LMS: end the game if after 30s less than 2 players remain due to forfeits --- gamemodes-server.cfg | 1 + qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc | 25 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index 1d2a0d70a..ba4812b57 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -451,6 +451,7 @@ set g_lms_last_join 3 "if g_lms_join_anytime is 0, new players can only join if set g_lms_join_anytime 1 "1: new players can join, but get same amount of lives as the worst player; 0: new players can only join if the worst active player has (fraglimit - g_lms_last_join) or more lives" set g_lms_items 0 "enables items to spawn, weaponarena still disables weapons and ammo (to force all items to spawn, use g_pickup_items 1 instead)" set g_lms_weaponarena "most_available" "starting weapons - takes the same options as g_weaponarena" +set g_lms_forfeit_min_match_time 30 "end the match early if at least this many seconds have elapsed and less than 2 players are playing due to forfeits" // ========= diff --git a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc index ffc7768e2..c965e7817 100644 --- a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc +++ b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc @@ -7,6 +7,7 @@ #include int autocvar_g_lms_extra_lives; +float autocvar_g_lms_forfeit_min_match_time; bool autocvar_g_lms_join_anytime; int autocvar_g_lms_last_join; bool autocvar_g_lms_items; @@ -43,10 +44,16 @@ int WinningCondition_LMS() entity first_player = NULL; int totalplayers = 0; - FOREACH_CLIENT(IS_PLAYER(it) && it.frags == FRAGS_PLAYER, { - if (!totalplayers) - first_player = it; - ++totalplayers; + int totalplayed = 0; + FOREACH_CLIENT(true, { + if (IS_PLAYER(it) && it.frags == FRAGS_PLAYER) + { + if (!totalplayers) + first_player = it; + ++totalplayers; + } + else if (GameRules_scoring_add(it, LMS_RANK, 0)) + ++totalplayed; }); if (totalplayers) @@ -74,6 +81,11 @@ int WinningCondition_LMS() if (LMS_NewPlayerLives()) { + if (totalplayed && game_starttime > 0 && time > game_starttime + autocvar_g_lms_forfeit_min_match_time) // give players time to join + { + GameRules_scoring_add(first_player, LMS_RANK, 1); + return WINNING_YES; + } // game still running (that is, nobody got removed from the game by a frag yet)? then continue return WINNING_NO; } @@ -91,6 +103,11 @@ int WinningCondition_LMS() // nobody is playing at all... if (LMS_NewPlayerLives()) { + if (totalplayed && game_starttime > 0 && time > game_starttime + autocvar_g_lms_forfeit_min_match_time) // give players time to join + { + ClearWinners(); + return WINNING_YES; + } // wait for players... } else -- 2.39.2