From: terencehill Date: Tue, 5 Jul 2022 13:27:57 +0000 (+0200) Subject: LMS: allow players to get back into the game if they spectated; players who spectated... X-Git-Tag: xonotic-v0.8.6~67^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6e305da5c6e279e91b6bdd10f48e25970d6b0645;p=xonotic%2Fxonotic-data.pk3dir.git LMS: allow players to get back into the game if they spectated; players who spectated no longer appears among players who get eliminated with rank N/A --- diff --git a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc index e3ebfefd3..db81f0d34 100644 --- a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc +++ b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc @@ -223,17 +223,11 @@ MUTATOR_HOOKFUNCTION(lms, reset_map_players) { FOREACH_CLIENT(true, { if (it.frags == FRAGS_PLAYER_OUT_OF_GAME) - { - // players who forfeited (rank >= 256) become spectators - if (it.lms_spectate_warning == 2) - it.frags = FRAGS_SPECTATOR; - else - it.frags = FRAGS_PLAYER; - } + it.frags = FRAGS_PLAYER; CS(it).killcount = 0; INGAME_STATUS_CLEAR(it); - it.lms_spectate_warning = 0; + it.lms_spectate = false; GameRules_scoring_add(it, LMS_RANK, -GameRules_scoring_add(it, LMS_RANK, 0)); GameRules_scoring_add(it, LMS_LIVES, -GameRules_scoring_add(it, LMS_LIVES, 0)); @@ -271,14 +265,11 @@ bool lms_AddPlayer(entity player) } if (warmup_stage || time <= game_starttime) { - if(player.lms_spectate_warning) - { - player.lms_spectate_warning = 0; - GameRules_scoring_add(player, LMS_RANK, -GameRules_scoring_add(player, LMS_RANK, 0)); - int lives = GameRules_scoring_add(player, LMS_LIVES, 0); - if(lives <= 0) - GameRules_scoring_add(player, LMS_LIVES, LMS_NewPlayerLives()); - } + player.lms_spectate = false; + GameRules_scoring_add(player, LMS_RANK, -GameRules_scoring_add(player, LMS_RANK, 0)); + int lives = GameRules_scoring_add(player, LMS_LIVES, 0); + if(lives <= 0) + GameRules_scoring_add(player, LMS_LIVES, LMS_NewPlayerLives()); } else { @@ -347,7 +338,7 @@ void lms_RemovePlayer(entity player) float player_rank = GameRules_scoring_add(player, LMS_RANK, 0); if (!player_rank) { - if (player.lms_spectate_warning < 2) + if (!player.lms_spectate) { player.frags = FRAGS_PLAYER_OUT_OF_GAME; int pl_cnt = 0; @@ -358,40 +349,29 @@ void lms_RemovePlayer(entity player) } else if (INGAME(player)) { - int min_forfeiter_rank = 665; // different from 666 FOREACH_CLIENT(it != player, { - // update rank of other players that were eliminated + // update rank of other players if (it.frags == FRAGS_PLAYER_OUT_OF_GAME) - { - float it_rank = GameRules_scoring_add(it, LMS_RANK, 0); - if (it_rank > player_rank && it_rank <= 256) - GameRules_scoring_add(it, LMS_RANK, -1); - if (it_rank > 256 && it_rank <= min_forfeiter_rank) - min_forfeiter_rank = it_rank - 1; - } - else if (it.frags != FRAGS_SPECTATOR) - { - float tl = GameRules_scoring_add(it, LMS_LIVES, 0); - if(tl < lms_lowest_lives) - lms_lowest_lives = tl; - } + GameRules_scoring_add(it, LMS_RANK, -1); }); - GameRules_scoring_add(player, LMS_RANK, min_forfeiter_rank); + int rank = GameRules_scoring_add(player, LMS_RANK, 0); + GameRules_scoring_add(player, LMS_RANK, -rank); if(!warmup_stage) GameRules_scoring_add(player, LMS_LIVES, -GameRules_scoring_add(player, LMS_LIVES, 0)); - player.frags = FRAGS_PLAYER_OUT_OF_GAME; + player.frags = FRAGS_SPECTATOR; TRANSMUTE(Observer, player); + INGAME_STATUS_CLEAR(player); + player.lms_spectate = false; + CS(player).killcount = FRAGS_SPECTATOR; } if (autocvar_g_lms_leader_lives_diff > 0) lms_UpdateLeaders(); } - if (CS(player).killcount != FRAGS_SPECTATOR && player.lms_spectate_warning < 3) + if (CS(player).killcount != FRAGS_SPECTATOR) { - if (GameRules_scoring_add(player, LMS_RANK, 0) > 0 && player.lms_spectate_warning < 2) + if (GameRules_scoring_add(player, LMS_RANK, 0) > 0) Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_NOLIVES, player.netname); - else - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_FORFEIT, player.netname); } } @@ -399,8 +379,7 @@ MUTATOR_HOOKFUNCTION(lms, ClientDisconnect) { entity player = M_ARGV(0, entity); - // no further message other than the disconnect message - player.lms_spectate_warning = 3; + player.lms_spectate = true; lms_RemovePlayer(player); INGAME_STATUS_CLEAR(player); @@ -424,7 +403,7 @@ MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver) else { if (is_forced) - player.lms_spectate_warning = 2; + player.lms_spectate = true; if (!GameRules_scoring_add(player, LMS_RANK, 0)) lms_RemovePlayer(player); } @@ -695,7 +674,7 @@ MUTATOR_HOOKFUNCTION(lms, ItemTouch) MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE) { FOREACH_CLIENT(IS_REAL_CLIENT(it), { - if (INGAME(it) && it.lms_spectate_warning < 2) + if (INGAME(it)) ++M_ARGV(0, int); // activerealplayers ++M_ARGV(1, int); // realplayers }); @@ -706,23 +685,13 @@ MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE) MUTATOR_HOOKFUNCTION(lms, ClientCommand_Spectate) { entity player = M_ARGV(0, entity); - - if(warmup_stage || time < game_starttime || player.lms_spectate_warning) + if(player.frags != FRAGS_SPECTATOR && player.frags != FRAGS_PLAYER_OUT_OF_GAME) { - // for the forfeit message... - player.lms_spectate_warning = 2; - } - else - { - if(player.frags != FRAGS_SPECTATOR && player.frags != FRAGS_PLAYER_OUT_OF_GAME) - { - player.lms_spectate_warning = 1; - sprint(player, "^1WARNING:^7 you can't rejoin this match after spectating. Use the same command again to spectate anyway.\n"); - Send_Notification(NOTIF_ONE_ONLY, player, MSG_CENTER, CENTER_LMS_SPECWARN); - } - return MUT_SPECCMD_RETURN; + player.lms_spectate = true; + return MUT_SPECCMD_CONTINUE; } - return MUT_SPECCMD_CONTINUE; + // ranked players (out of game) can no longer become real spectators + return MUT_SPECCMD_RETURN; } MUTATOR_HOOKFUNCTION(lms, CheckRules_World) diff --git a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qh b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qh index bf02920d2..8019c76dd 100644 --- a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qh +++ b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qh @@ -3,10 +3,9 @@ #include #include -// 1 when player presses F3 to spectate for the first time (he only gets a warning) -// 2 when player goes spectator (presses F3 to spectate for the second time) -// 3 when player disconnects -.int lms_spectate_warning; +// set before a lms_RemovePlayer call, if true player becomes a real spectator +// otherwise it gets eliminated becoming spectator but as player out of game with a rank +.bool lms_spectate; #define autocvar_g_lms_lives_override cvar("g_lms_lives_override") string autocvar_g_lms_weaponarena = "most_available"; diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index 69483bfc3..53724a4dd 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -388,7 +388,6 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input != MULTITEAM_INFO(KEYHUNT_DESTROYED, N_CONSOLE, 1, 0, "s1", "", "", _("^BG%s^BG destroyed the ^TC^TT Key"), "", KEY) MULTITEAM_INFO(KEYHUNT_PICKUP, N_CONSOLE, 1, 0, "s1", "", "", _("^BG%s^BG picked up the ^TC^TT Key"), "", KEY) - MSG_INFO_NOTIF(LMS_FORFEIT, N_CHATCON, 1, 0, "s1", "", "", _("^BG%s^F3 forfeited"), "") MSG_INFO_NOTIF(LMS_NOLIVES, N_CONSOLE, 1, 0, "s1", "", "", _("^BG%s^F3 has no more lives left"), "") MSG_INFO_NOTIF(MONSTERS_DISABLED, N_CONSOLE, 0, 0, "", "", "", _("^BGMonsters are currently disabled"), "") @@ -704,7 +703,7 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input != MULTITEAM_CENTER(KEYHUNT_START, N_ENABLE, 0, 0, "", CPID_KEYHUNT, "0 0", _("^BGYou are starting with the ^TC^TT Key"), "", KEY) MSG_CENTER_NOTIF(LMS_NOLIVES, N_ENABLE, 0, 0, "", CPID_LMS, "0 0", _("^BGYou have no lives left, you must wait until the next match"), "") - MSG_CENTER_NOTIF(LMS_SPECWARN, N_ENABLE, 0, 0, "", CPID_LMS, "0 0", _("^F4WARNING:^BG you can't rejoin this match after spectating.\nUse the same command again to spectate anyway."), "") + // TODO update notifications.cfg MSG_CENTER_NOTIF(LMS_VISIBLE_LEADER, N_ENABLE, 0, 0, "", CPID_LMS, "0 0", _("^BGEnemies can now see you on radar!"), "") MSG_CENTER_NOTIF(LMS_VISIBLE_OTHER, N_ENABLE, 0, 0, "", CPID_LMS, "0 0", _("^BGLeaders can now be seen by enemies on radar!"), "")