]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
Merge branch 'master' into z411/bai-server
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / freezetag / sv_freezetag.qc
index 3f7fff9ebe3ad5bfc01b4f1ae582c26b4b273ddb..32bd7acb218793b8365c59670d1b906f35cc4744 100644 (file)
@@ -86,18 +86,36 @@ bool freezetag_CheckTeams()
 void nades_Clear(entity);
 void nades_GiveBonus(entity player, float score);
 
+entity freezetag_LastPlayer(float tm)
+{
+       entity last_pl = NULL;
+       FOREACH_CLIENT(IS_PLAYER(it) && it.team == tm, {
+               if (STAT(FROZEN, it) != FROZEN_NORMAL && GetResource(it, RES_HEALTH) >= 1)
+               {
+                       if (!last_pl)
+                               last_pl = it;
+                       else
+                               return NULL;
+               }
+       });
+       return last_pl;
+}
+
 bool freezetag_CheckWinner()
 {
        if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
        {
                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);
+               
                FOREACH_CLIENT(IS_PLAYER(it), {
                        it.freezetag_frozen_timeout = 0;
                        it.freezetag_revive_time = 0;
                        nades_Clear(it);
                });
-               game_stopped = true;
+               if(autocvar_g_freezetag_round_stop)
+                       game_stopped = true;
                round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
                return true;
        }
@@ -108,14 +126,21 @@ bool freezetag_CheckWinner()
 
        if(winner_team > 0)
        {
-               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));
+               entity last_pl = freezetag_LastPlayer(winner_team);
+               if(last_pl) {
+                       Give_Medal(last_pl, DEFENSE);
+               }
+       
+               Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_SCORES));
+               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_SCORES));
                TeamScore_AddToTeam(winner_team, ST_FT_ROUNDS, +1);
+               if(fragsleft > 1) AnnounceScores(winner_team);
        }
        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);
        }
 
        FOREACH_CLIENT(IS_PLAYER(it), {
@@ -124,7 +149,8 @@ bool freezetag_CheckWinner()
                nades_Clear(it);
        });
 
-       game_stopped = true;
+       if(autocvar_g_freezetag_round_stop)
+               game_stopped = true;
        round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
        return true;
 }
@@ -150,8 +176,10 @@ void freezetag_LastPlayerForTeam_Notify(entity this)
        if(round_handler_IsRoundStarted())
        {
                entity pl = freezetag_LastPlayerForTeam(this);
-               if(pl)
+               if(pl) {
                        Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
+                       Send_Notification(NOTIF_ONE, pl, MSG_ANNCE, ANNCE_ALONE);
+               }
        }
 }
 
@@ -446,9 +474,14 @@ MUTATOR_HOOKFUNCTION(ft, reset_map_players)
 {
        FOREACH_CLIENT(IS_PLAYER(it), {
                CS(it).killcount = 0;
-               it.freezetag_revive_time = 0;
-               it.freezetag_frozen_timeout = -1;
-               PutClientInServer(it);
+               
+               if(autocvar_g_freezetag_round_respawn) {
+                       it.freezetag_frozen_timeout = -1;
+                       PutClientInServer(it);
+               } else {
+                       ResetPlayerResources(it);
+               }
+               
                it.freezetag_frozen_timeout = 0;
        });
        freezetag_count_alive_players();
@@ -465,6 +498,12 @@ MUTATOR_HOOKFUNCTION(ft, Unfreeze)
 {
        entity targ = M_ARGV(0, entity);
        targ.freezetag_frozen_time = 0;
+       
+       if(autocvar_g_freezetag_revive_respawn) {
+               targ.freezetag_frozen_timeout = -1;
+               PutClientInServer(targ);
+       }
+       
        targ.freezetag_frozen_timeout = 0;
 }
 
@@ -650,6 +689,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
                        Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, revivers_first.netname);
                        Send_Notification(NOTIF_ONE, revivers_first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, revivers_first.netname);
+                       Give_Medal(revivers_first, ASSIST);
                        if(autocvar_sv_eventlog)
                        {
                                string revivers = "";