]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added a delay (1sec default) before counting round's score for CA, FT and Survival...
authorDr. Jaska <drjaska83@gmail.com>
Sun, 2 Jun 2024 15:55:19 +0000 (15:55 +0000)
committerDr. Jaska <drjaska83@gmail.com>
Sun, 2 Jun 2024 15:55:19 +0000 (15:55 +0000)
gamemodes-server.cfg
qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc
qcsrc/server/round_handler.qc
qcsrc/server/round_handler.qh
qcsrc/server/world.qc

index a859acbded174ebaf334b8725ea30439b342c45a..bef7f6292fb3b5b419c6ff0683b17aeae8ee95c4 100644 (file)
@@ -262,6 +262,7 @@ set g_ca_spectate_enemies 0 "allow eliminated players to spectate enemy players
 set g_ca_warmup 10 "time players get to run around before the round starts"
 set g_ca_damage2score 100  "every this amount of damage done give players 1 point"
 set g_ca_round_timelimit 180 "round time limit in seconds"
+set g_ca_round_enddelay 1 "seconds of delay for score evaluation after round could end"
 set g_ca_teams_override 0
 set g_ca_team_spawns 0 "when 1, players spawn from the team spawnpoints of the map, if any"
 set g_ca_teams 0
@@ -412,6 +413,7 @@ set g_freezetag_revive_nade 1 "Enable reviving from own nade explosion"
 set g_freezetag_revive_nade_health 40 "Amount of health player has if they revived from their own nade explosion"
 set g_freezetag_revive_time_to_score 1.5 "every this amount of seconds give players reviving a frozen teammate 1 point"
 set g_freezetag_round_timelimit 360 "round time limit in seconds"
+set g_freezetag_round_enddelay 1 "seconds of delay for score evaluation after round could end"
 set g_freezetag_revive_auto 1 "automatically revive frozen players after some time (g_freezetag_frozen_maxtime)"
 set g_freezetag_revive_auto_progress 1 "start the automatic reviving progress as soon as the player gets frozen"
 set g_freezetag_revive_auto_reducible 1 "reduce auto-revival time when frozen players are hit by enemies; set to -1 to reduce it even when they are hit by teammates"
@@ -697,3 +699,4 @@ set g_survival_punish_teamkill 1 "kill the player when they kill an ally"
 set g_survival_reward_survival 1 "give a point to all surviving players if the round timelimit is reached, in addition to the points given for kills"
 set g_survival_warmup 10 "how long the players will have time to run around the map before the round starts"
 set g_survival_round_timelimit 120 "round time limit in seconds"
+set g_survival_round_enddelay 1 "seconds of delay for score evaluation after round could end"
index 3fab3fb3e07781da879c5c6d23507105f93ee4ca..dbb089ab0e6244e8dc47e1c3de4f92896f3297bb 100644 (file)
@@ -138,6 +138,7 @@ int CA_PreventStalemate()
        return -2; // Equality. Can't avoid the stalemate.
 }
 
+float autocvar_g_ca_round_enddelay = 1;
 float CA_CheckWinner()
 {
        int winner_team = 0;
@@ -158,7 +159,29 @@ float CA_CheckWinner()
        if (!winner_team)
                winner_team = Team_GetWinnerAliveTeam();
        if (!winner_team)
+       {
+               // Dr. Jaska:
+               // reset delay time here only for consistency
+               // CA players currently have no known ways to resurrect
+               round_handler_ResetEndDelayTime();
                return 0;
+       }
+
+       // delay round ending a bit
+       if (autocvar_g_ca_round_enddelay
+               && round_handler_GetEndTime() > 0
+               && round_handler_GetEndTime() - time > 0) // don't delay past timelimit
+       {
+               if (round_handler_GetEndDelayTime() == -1)
+               {
+                       round_handler_SetEndDelayTime(min(time + autocvar_g_ca_round_enddelay, round_handler_GetEndTime()));
+                       return 0;
+               }
+               else if (round_handler_GetEndDelayTime() >= time)
+               {
+                       return 0;
+               }
+       }
 
        if(winner_team > 0)
        {
index 3f7fff9ebe3ad5bfc01b4f1ae582c26b4b273ddb..21639bfad48a00a01f70e262b43d6fed388da5fd 100644 (file)
@@ -86,9 +86,11 @@ bool freezetag_CheckTeams()
 void nades_Clear(entity);
 void nades_GiveBonus(entity player, float score);
 
+float autocvar_g_freezetag_round_enddelay = 1;
 bool freezetag_CheckWinner()
 {
-       if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
+       if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0
+               && round_handler_GetEndDelayTime() == -1)
        {
                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
@@ -104,7 +106,26 @@ bool freezetag_CheckWinner()
 
        int winner_team = Team_GetWinnerAliveTeam();
        if (!winner_team)
+       {
+               round_handler_ResetEndDelayTime();
                return false;
+       }
+
+       // delay round ending a bit
+       if (autocvar_g_freezetag_round_enddelay
+               && round_handler_GetEndTime() > 0
+               && round_handler_GetEndTime() - time > 0) // don't delay past timelimit
+       {
+               if (round_handler_GetEndDelayTime() == -1)
+               {
+                       round_handler_SetEndDelayTime(min(time + autocvar_g_freezetag_round_enddelay, round_handler_GetEndTime()));
+                       return 0;
+               }
+               else if (round_handler_GetEndDelayTime() >= time)
+               {
+                       return 0;
+               }
+       }
 
        if(winner_team > 0)
        {
index 20bff56b1a667899a4948daf208673d05e963ac8..deaae435c1b6e7289e826e1fa3965eb15bf8304b 100644 (file)
@@ -78,9 +78,11 @@ void Surv_UpdateScores(bool timed_out)
        });
 }
 
+float autocvar_g_survival_round_enddelay = 1;
 float Surv_CheckWinner()
 {
-       if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
+       if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0
+               && autocvar_g_survival_round_enddelay == -1)
        {
                // if the match times out, survivors win too!
                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_SURVIVAL_SURVIVOR_WIN);
@@ -110,9 +112,29 @@ float Surv_CheckWinner()
        });
        if(survivor_count > 0 && hunter_count > 0)
        {
+               // Dr. Jaska:
+               // reset delay time here only for consistency
+               // Survival players currently have no known ways to resurrect
+               round_handler_ResetEndDelayTime();
                return 0;
        }
 
+       // delay round ending a bit
+       if (autocvar_g_survival_round_enddelay
+               && round_handler_GetEndTime() > 0
+               && round_handler_GetEndTime() - time > 0) // don't delay past timelimit
+       {
+               if (round_handler_GetEndDelayTime() == -1)
+               {
+                       round_handler_SetEndDelayTime(min(time + autocvar_g_survival_round_enddelay, round_handler_GetEndTime()));
+                       return 0;
+               }
+               else if (round_handler_GetEndDelayTime() >= time)
+               {
+                       return 0;
+               }
+       }
+
        if(hunter_count > 0) // hunters win
        {
                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_SURVIVAL_HUNTER_WIN);
index d47aad441ec4add47fcbd7cba5eb8c39b5b0dc75..191051e4d6dfd4b6fbe80faaa7c7c25573c34043 100644 (file)
@@ -67,6 +67,7 @@ void round_handler_Think(entity this)
                        // schedule a new round
                        this.wait = true;
                        this.nextthink = time + this.delay;
+                       round_handler_ResetEndDelayTime();
                }
                else
                {
@@ -108,6 +109,7 @@ void round_handler_Spawn(bool() canRoundStart_func, bool() canRoundEnd_func, voi
        this.canRoundEnd = canRoundEnd_func;
        this.roundStart = roundStart_func;
        this.wait = false;
+       round_handler_ResetEndDelayTime();
        round_handler_Init(5, 5, 180);
        this.nextthink = time;
 
@@ -118,6 +120,7 @@ void round_handler_Reset(float next_think)
 {
        entity this = round_handler;
        this.wait = false;
+       round_handler_ResetEndDelayTime();
        if (this.count)
                if (this.cnt < this.count + 1) this.cnt = this.count + 1;
        this.nextthink = next_think;
index 5979eb5c33f810faeb55f2add99f7574533fc121..96e63a621ef9e33e47c549113d4875a98825832a 100644 (file)
@@ -8,6 +8,7 @@ entity round_handler;
                        // reaches 0 when the round starts
 .float round_timelimit;
 .float round_endtime;
+.float round_enddelaytime;
 .bool() canRoundStart;
 .bool() canRoundEnd;
 .void() roundStart;
@@ -22,3 +23,6 @@ void round_handler_Remove();
 #define round_handler_CountdownRunning() (!round_handler.wait && round_handler.cnt)
 #define round_handler_IsRoundStarted() (!round_handler.wait && !round_handler.cnt)
 #define round_handler_GetEndTime() (round_handler.round_endtime)
+#define round_handler_GetEndDelayTime() (round_handler.round_enddelaytime)
+#define round_handler_SetEndDelayTime(t) (round_handler.round_enddelaytime = t)
+#define round_handler_ResetEndDelayTime() (round_handler.round_enddelaytime = -1)
index 8eae8685b5f3be22356c409daf0a4c28d3609c93..f051eea48ba8666375c81a5c802c44d6de2eaacc 100644 (file)
@@ -432,6 +432,7 @@ void cvar_changes_init()
                BADPREFIX("sv_vote_");
                BADPREFIX("timelimit_");
                BADPRESUFFIX("g_", "_round_timelimit");
+               BADPRESUFFIX("g_", "_round_enddelay");
 
                // allowed changes to server admins (please sync this to server.cfg)
                // vi commands: