]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add team scoring/lead announcing
authorz411 <z411@omaera.org>
Mon, 30 Jan 2023 10:41:47 +0000 (07:41 -0300)
committerz411 <z411@omaera.org>
Mon, 30 Jan 2023 11:04:22 +0000 (08:04 -0300)
qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc
qcsrc/common/gamemodes/gamemode/tdm/sv_tdm.qc
qcsrc/common/notifications/all.inc
qcsrc/server/world.qc
sound/announcer/default/scores_blue.ogg [new file with mode: 0644]
sound/announcer/default/scores_enemy.ogg [new file with mode: 0644]
sound/announcer/default/scores_pink.ogg [new file with mode: 0644]
sound/announcer/default/scores_red.ogg [new file with mode: 0644]
sound/announcer/default/scores_team.ogg [new file with mode: 0644]
sound/announcer/default/scores_yellow.ogg [new file with mode: 0644]

index 5fbb2b2a68ea985daa18c8200f533973b7c8a433..0065cc69d321b27f48216e8dc7efb25dd0ea72bf 100644 (file)
@@ -612,6 +612,9 @@ void ctf_Handle_Capture(entity flag, entity toucher, int capturetype)
        if(!old_time || new_time < old_time)
                GameRules_scoring_add(player, CTF_CAPTIME, new_time - old_time);
 
+       // announcer
+       AnnounceScores(player.team);
+
        // effects
        Send_Effect_(flag.capeffect, flag.origin, '0 0 0', 1);
 #if 0
index 5e850889679fd1ebceb5992b86cbc6f605c044a4..3bd9cb5648bad21295a2aa7ecc0e3b11251d878f 100644 (file)
@@ -70,3 +70,9 @@ MUTATOR_HOOKFUNCTION(tdm, Scores_CountFragsRemaining)
        // announce remaining frags
        return true;
 }
+
+MUTATOR_HOOKFUNCTION(tdm, Scores_AnnounceLeads)
+{
+       // enable leads announcer
+       return true;
+}
index da62077c6a3498d6b9d877c93405948537284f29..85fdcd5144bf1175e582db49ad6d26a7cf7233e1 100644 (file)
 #define N_GNTLOFF 1
 #define N__ALWAYS 2
 
-#define MULTITEAM_ANNCE(prefix, defaultvalue, sound, channel, volume, position) \
+// default time for announcer queue (time to wait before the next announcer is played)
+// -1 = bypass queue and play the announcer immediately
+// 0 = use the announcer sound length
+// >0 = use the specified time in seconds
+#define ANNCE_INSTANT -1
+#define ANNCE_LENGTH 0
+#define ANNCE_DEFTIME 2
+
+#define MULTITEAM_ANNCE(prefix, defaultvalue, sound, channel, volume, position, queuetime) \
     NOTIF_ADD_AUTOCVAR(ANNCE_##prefix, defaultvalue) \
-    MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_1, prefix##_RED, prefix, defaultvalue, sprintf(sound, strtolower(STATIC_NAME_TEAM_1)), channel, volume, position) \
-    MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_2, prefix##_BLUE, prefix, defaultvalue, sprintf(sound, strtolower(STATIC_NAME_TEAM_2)), channel, volume, position) \
-    MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_3, prefix##_YELLOW, prefix, defaultvalue, sprintf(sound, strtolower(STATIC_NAME_TEAM_3)), channel, volume, position) \
-    MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_4, prefix##_PINK, prefix, defaultvalue, sprintf(sound, strtolower(STATIC_NAME_TEAM_4)), channel, volume, position)
+    MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_1, prefix##_RED, prefix, defaultvalue, sprintf(sound, strtolower(STATIC_NAME_TEAM_1)), channel, volume, position, queuetime) \
+    MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_2, prefix##_BLUE, prefix, defaultvalue, sprintf(sound, strtolower(STATIC_NAME_TEAM_2)), channel, volume, position, queuetime) \
+    MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_3, prefix##_YELLOW, prefix, defaultvalue, sprintf(sound, strtolower(STATIC_NAME_TEAM_3)), channel, volume, position, queuetime) \
+    MSG_ANNCE_NOTIF_TEAM(NUM_TEAM_4, prefix##_PINK, prefix, defaultvalue, sprintf(sound, strtolower(STATIC_NAME_TEAM_4)), channel, volume, position, queuetime)
 
 // MSG_ANNCE_NOTIFICATIONS
     MSG_ANNCE_NOTIF(ACHIEVEMENT_AIRSHOT,        N_GNTLOFF, "airshot",           CH_INFO, VOL_BASEVOICE, ATTEN_NONE)
     MSG_ANNCE_NOTIF(VOTE_CALL,                  N__ALWAYS, "votecall",          CH_INFO, VOL_BASEVOICE, ATTEN_NONE)
     MSG_ANNCE_NOTIF(VOTE_FAIL,                  N__ALWAYS, "votefail",          CH_INFO, VOL_BASEVOICE, ATTEN_NONE)
 
-    MSG_ANNCE_NOTIF(LEAD_GAINED,                N__ALWAYS, "leadgained",        CH_INFO, VOL_BASEVOICE, ATTEN_NONE)
-    MSG_ANNCE_NOTIF(LEAD_LOST,                  N__ALWAYS, "leadlost",          CH_INFO, VOL_BASEVOICE, ATTEN_NONE)
-    MSG_ANNCE_NOTIF(LEAD_TIED,                  N__ALWAYS, "leadtied",          CH_INFO, VOL_BASEVOICE, ATTEN_NONE)
+    MSG_ANNCE_NOTIF(LEAD_GAINED,                N__ALWAYS, "leadgained",        CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MSG_ANNCE_NOTIF(LEAD_LOST,                  N__ALWAYS, "leadlost",          CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MSG_ANNCE_NOTIF(LEAD_TIED,                  N__ALWAYS, "leadtied",          CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+
+    MSG_ANNCE_NOTIF(TEAM_SCORES_TEAM,           N__ALWAYS, "scores_team",       CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MSG_ANNCE_NOTIF(TEAM_SCORES_ENEMY,          N__ALWAYS, "scores_enemy",      CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MULTITEAM_ANNCE(TEAM_SCORES,                N__ALWAYS, "scores_%s",         CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+
+    MSG_ANNCE_NOTIF(TEAM_LEADS_TEAM,            N__ALWAYS, "leads_team",        CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MSG_ANNCE_NOTIF(TEAM_LEADS_ENEMY,           N__ALWAYS, "leads_enemy",       CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MSG_ANNCE_NOTIF(TEAM_LEADS_TIED,            N__ALWAYS, "teamstied",         CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MULTITEAM_ANNCE(TEAM_LEADS,                 N__ALWAYS, "leads_%s",          CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+
+    MULTITEAM_ANNCE(TEAM_WINS,                  N__ALWAYS, "wins_%s",           CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+
+    MULTITEAM_ANNCE(ROUND_TEAM_WIN,             N__ALWAYS, "round_win_%s",      CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MSG_ANNCE_NOTIF(ROUND_OVER,                 N__ALWAYS, "round_over",        CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MSG_ANNCE_NOTIF(ROUND_TIED,                 N__ALWAYS, "round_tied",        CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+    MSG_ANNCE_NOTIF(ALONE,                      N__ALWAYS, "alone",             CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
 
 #undef N___NEVER
 #undef N_GNTLOFF
index 18a048fc1b3371fb466e6f4d94fb3d5375cb2997..d6cb8f271e5731824ce2e22417877ea894c2e6ba 100644 (file)
@@ -1429,24 +1429,37 @@ void ClearWinners()
 
 void AnnounceNewLeader()
 {
-       LOG_INFO("Announce new leader");
        // Don't announce if in warmup or just started
        if(warmup_stage || time - game_starttime < 1) return;
-       if(teamplay) return; // Not implemented in teamplay yet. We need an announcer for that.
 
-       if (WinningConditionHelper_equality)
-       {
-               Send_Notification(NOTIF_ONE, WinningConditionHelper_equality_one, MSG_ANNCE, ANNCE_LEAD_TIED);
-               Send_Notification(NOTIF_ONE, WinningConditionHelper_equality_two, MSG_ANNCE, ANNCE_LEAD_TIED);
-       }
-       else
-       {
-               Send_Notification(NOTIF_ONE, WinningConditionHelper_winner, MSG_ANNCE, ANNCE_LEAD_GAINED);
-               Send_Notification(NOTIF_ONE, WinningConditionHelper_second, MSG_ANNCE, ANNCE_LEAD_LOST);
+       if(teamplay) {
+               if (WinningConditionHelper_equality)
+                       Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_TEAM_LEADS_TIED);
+               else
+                       FOREACH_CLIENT(IS_PLAYER(it), {
+                               if(it.team == WinningConditionHelper_winnerteam)
+                                       Send_Notification(NOTIF_ONE_ONLY, it, MSG_ANNCE, ANNCE_TEAM_LEADS_TEAM);
+                               else
+                                       Send_Notification(NOTIF_ONE_ONLY, it, MSG_ANNCE, ANNCE_TEAM_LEADS_ENEMY);
+                       });
+                       Send_Notification(NOTIF_ALL_SPEC, NULL, MSG_ANNCE, APP_TEAM_NUM(WinningConditionHelper_winnerteam, ANNCE_TEAM_LEADS));
+       } else {
+               if (WinningConditionHelper_equality)
+               {
+                       Send_Notification(NOTIF_ONE, WinningConditionHelper_equality_one, MSG_ANNCE, ANNCE_LEAD_TIED);
+                       Send_Notification(NOTIF_ONE, WinningConditionHelper_equality_two, MSG_ANNCE, ANNCE_LEAD_TIED);
+               }
+               else
+               {
+                       Send_Notification(NOTIF_ONE, WinningConditionHelper_winner, MSG_ANNCE, ANNCE_LEAD_GAINED);
+                       Send_Notification(NOTIF_ONE, WinningConditionHelper_second, MSG_ANNCE, ANNCE_LEAD_LOST);
+               }
        }
 }
 
+int team_scores;
 int fragsleft_last;
+#define AnnounceScores(tm) team_scores = tm;
 float WinningCondition_Scores(float limit, float leadlimit)
 {
        // TODO make everything use THIS winning condition (except LMS)
@@ -1512,12 +1525,22 @@ float WinningCondition_Scores(float limit, float leadlimit)
                }
        }
 
-       // Announce new leader if any
-       if(MUTATOR_CALLHOOK(Scores_AnnounceLeads)) {
+       // Announce scores and new leader if any
+       if(team_scores) {
                if (Score_NewLeader()) {
                        AnnounceNewLeader();
+               } else {
+                       FOREACH_CLIENT(IS_PLAYER(it), {
+                               if(it.team == team_scores)
+                                       Send_Notification(NOTIF_ONE_ONLY, it, MSG_ANNCE, ANNCE_TEAM_SCORES_TEAM);
+                               else
+                                       Send_Notification(NOTIF_ONE_ONLY, it, MSG_ANNCE, ANNCE_TEAM_SCORES_ENEMY);
+                       });
+                       Send_Notification(NOTIF_ALL_SPEC, NULL, MSG_ANNCE, APP_TEAM_NUM(team_scores, ANNCE_TEAM_SCORES));
                }
-       }
+               team_scores = 0;
+       } else if(MUTATOR_CALLHOOK(Scores_AnnounceLeads) && Score_NewLeader()) {
+               AnnounceNewLeader();
 
        bool fraglimit_reached = (limit && WinningConditionHelper_topscore >= limit);
        bool leadlimit_reached = (leadlimit && WinningConditionHelper_topscore - WinningConditionHelper_secondscore >= leadlimit);
diff --git a/sound/announcer/default/scores_blue.ogg b/sound/announcer/default/scores_blue.ogg
new file mode 100644 (file)
index 0000000..d299820
Binary files /dev/null and b/sound/announcer/default/scores_blue.ogg differ
diff --git a/sound/announcer/default/scores_enemy.ogg b/sound/announcer/default/scores_enemy.ogg
new file mode 100644 (file)
index 0000000..20dc6c9
Binary files /dev/null and b/sound/announcer/default/scores_enemy.ogg differ
diff --git a/sound/announcer/default/scores_pink.ogg b/sound/announcer/default/scores_pink.ogg
new file mode 100644 (file)
index 0000000..5d33c80
Binary files /dev/null and b/sound/announcer/default/scores_pink.ogg differ
diff --git a/sound/announcer/default/scores_red.ogg b/sound/announcer/default/scores_red.ogg
new file mode 100644 (file)
index 0000000..ff508bc
Binary files /dev/null and b/sound/announcer/default/scores_red.ogg differ
diff --git a/sound/announcer/default/scores_team.ogg b/sound/announcer/default/scores_team.ogg
new file mode 100644 (file)
index 0000000..05991b2
Binary files /dev/null and b/sound/announcer/default/scores_team.ogg differ
diff --git a/sound/announcer/default/scores_yellow.ogg b/sound/announcer/default/scores_yellow.ogg
new file mode 100644 (file)
index 0000000..706be3f
Binary files /dev/null and b/sound/announcer/default/scores_yellow.ogg differ