From: Dr. Jaska Date: Sun, 2 Jun 2024 15:55:19 +0000 (+0000) Subject: Merge branch 'drjaska/round_enddelay' into 'master' X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=01dde529da73fc96e6e4a2a27331bbe6cacb5d8f;hp=f66ee3c1299ca55b7dc56c7613505fe24049a32a;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'drjaska/round_enddelay' into 'master' Added a delay (1sec default) before counting round's score for CA, FT and Survival to allow for ties. See merge request xonotic/xonotic-data.pk3dir!1187 --- diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index a859acbde..bef7f6292 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -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" diff --git a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc index 3fab3fb3e..dbb089ab0 100644 --- a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc +++ b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc @@ -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) { diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc index 3f7fff9eb..21639bfad 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc +++ b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc @@ -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) { diff --git a/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc index 20bff56b1..deaae435c 100644 --- a/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc +++ b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc @@ -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); diff --git a/qcsrc/server/round_handler.qc b/qcsrc/server/round_handler.qc index d47aad441..191051e4d 100644 --- a/qcsrc/server/round_handler.qc +++ b/qcsrc/server/round_handler.qc @@ -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; diff --git a/qcsrc/server/round_handler.qh b/qcsrc/server/round_handler.qh index 5979eb5c3..96e63a621 100644 --- a/qcsrc/server/round_handler.qh +++ b/qcsrc/server/round_handler.qh @@ -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) diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 8eae8685b..f051eea48 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -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: