X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fgamemodes%2Fgamemode%2Fclanarena%2Fsv_clanarena.qc;h=b62fcfbd1a13a87146140e48179593c551a780bf;hb=6491b766d925a1088212e86cf4767d4be7bf6a4f;hp=7a16141fc8ebbe89409b947cdfd9b979da571233;hpb=9e0107ad74a31422e209d4f97dbc4fdc9b669727;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc index 7a16141fc..b62fcfbd1 100644 --- a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc +++ b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc @@ -20,15 +20,22 @@ void CA_count_alive_players() for (int i = 1; i <= NUM_TEAMS; ++i) { Team_SetNumberOfAlivePlayers(Team_GetTeamFromIndex(i), 0); + Team_SetNumberOfPlayers(Team_GetTeamFromIndex(i), 0); } - FOREACH_CLIENT(IS_PLAYER(it) && Entity_HasValidTeam(it), + FOREACH_CLIENT(Entity_HasValidTeam(it), { ++total_players; - if (IS_DEAD(it)) + entity team_ = Entity_GetTeam(it); + + int num_total = Team_GetNumberOfPlayers(team_); + ++num_total; + Team_SetNumberOfPlayers(team_, num_total); + + if (IS_DEAD(it) || !IS_PLAYER(it)) { continue; } - entity team_ = Entity_GetTeam(it); + int num_alive = Team_GetNumberOfAlivePlayers(team_); ++num_alive; Team_SetNumberOfAlivePlayers(team_, num_alive); @@ -44,6 +51,22 @@ void CA_count_alive_players() void nades_Clear(entity player); +entity ca_LastPlayer(float tm) +{ + entity last_pl = NULL; + FOREACH_CLIENT(IS_PLAYER(it) && it.team == tm, { + if (!IS_DEAD(it)) + { + if (!last_pl) + last_pl = it; + else + return NULL; + } + }); + return last_pl; +} + + int CA_PreventStalemate() { //LOG_INFO("PreventStalemate running"); @@ -140,28 +163,59 @@ float CA_CheckWinner() if (!winner_team) return 0; + bool perfect = false; if(winner_team > 0) { + entity tm = Team_GetTeam(winner_team); + entity last_pl = ca_LastPlayer(winner_team); + + if(last_pl && Team_GetNumberOfPlayers(tm) >= 3) { + Give_Medal(last_pl, DEFENSE); + } + Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN)); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN)); + if(fragsleft > 1) Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, APP_TEAM_NUM(winner_team, ANNCE_ROUND_TEAM_WIN)); TeamScore_AddToTeam(winner_team, ST_CA_ROUNDS, +1); + + if (Team_GetNumberOfPlayers(tm) >= 3 && + Team_GetNumberOfAlivePlayers(tm) == Team_GetNumberOfPlayers(tm)) + perfect = true; } else if(winner_team == -1) { Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED); + Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_ROUND_TIED); } else if(winner_team == -2) { Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER); + Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_ROUND_OVER); } allowed_to_spawn = false; - game_stopped = true; + if(autocvar_g_ca_round_stop) + game_stopped = true; round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit); - FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); }); + FOREACH_CLIENT(IS_PLAYER(it), { + nades_Clear(it); + + // Give perfect medal if everyone in the winner team is alive + if(perfect && it.team == winner_team) { + Give_Medal(it, PERFECT); + } + + // Give accuracy medal for each weapon above 50% + entity ra = it.roundaccuracy; + for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) { + if(ra.accuracy_fired[w] > 1 && (ra.accuracy_hit[w] / ra.accuracy_fired[w]) > 0.5) { + Give_Medal(it, ACCURACY); + } + } + }); return 1; } @@ -270,6 +324,9 @@ MUTATOR_HOOKFUNCTION(ca, PutClientInServer) Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE); } } + + if (!warmup_stage) + eliminatedPlayers.SendFlags |= 1; } MUTATOR_HOOKFUNCTION(ca, reset_map_players) @@ -291,6 +348,12 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_players) return true; } +MUTATOR_HOOKFUNCTION(ca, Scores_CountFragsRemaining) +{ + // announce remaining frags + return true; +} + MUTATOR_HOOKFUNCTION(ca, reset_map_global) { allowed_to_spawn = true; @@ -323,8 +386,10 @@ void ca_LastPlayerForTeam_Notify(entity this) if (!warmup_stage && round_handler_IsActive() && round_handler_IsRoundStarted()) { entity pl = ca_LastPlayerForTeam(this); - if (pl) + if (pl) { Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE); + Send_Notification(NOTIF_ONE, pl, MSG_ANNCE, ANNCE_ALONE); + } } } @@ -504,12 +569,6 @@ MUTATOR_HOOKFUNCTION(ca, PlayerRegen) return true; } -MUTATOR_HOOKFUNCTION(ca, Scores_CountFragsRemaining) -{ - // announce remaining frags - return true; -} - MUTATOR_HOOKFUNCTION(ca, SpectateSet) { entity client = M_ARGV(0, entity);