]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Refactored leads announcer
authorz411 <z411@omaera.org>
Tue, 10 Nov 2020 09:42:06 +0000 (06:42 -0300)
committerz411 <z411@omaera.org>
Tue, 10 Nov 2020 09:42:06 +0000 (06:42 -0300)
qcsrc/common/gamemodes/gamemode/deathmatch/sv_deathmatch.qc
qcsrc/common/gamemodes/gamemode/duel/sv_duel.qc
qcsrc/common/gamemodes/gamemode/tdm/sv_tdm.qc
qcsrc/common/notifications/all.inc
qcsrc/server/mutators/events.qh
qcsrc/server/scores.qc
qcsrc/server/scores.qh
qcsrc/server/world.qc

index fd7a718b770f65843aeea1c613386065a01ed065..d82143d8091faf62d29c5d751853da0819a83f87 100644 (file)
@@ -6,6 +6,12 @@ MUTATOR_HOOKFUNCTION(dm, Scores_CountFragsRemaining)
        return true;
 }
 
+MUTATOR_HOOKFUNCTION(dm, Scores_AnnounceLeads)
+{
+       // enable leads announcer
+       return true;
+}
+
 MUTATOR_HOOKFUNCTION(dm, FragCenterMessage)
 {
        // Use normal notifications in warmup
@@ -39,4 +45,4 @@ MUTATOR_HOOKFUNCTION(dm, FragCenterMessage)
        );
        
        return true;
-}
\ No newline at end of file
+}
index fc662e2a9fa826648cebfcb875b493ef1a4c40db..2cb1c8d5eb0c960c706f4034d6451d13d42e9f2a 100644 (file)
@@ -11,6 +11,12 @@ MUTATOR_HOOKFUNCTION(duel, Scores_CountFragsRemaining)
        return true;
 }
 
+MUTATOR_HOOKFUNCTION(duel, Scores_AnnounceLeads)
+{
+       // enable leads announcer
+       return true;
+}
+
 MUTATOR_HOOKFUNCTION(duel, FilterItemDefinition)
 {
        entity definition = M_ARGV(0, entity);
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 70818b856a1d165f09399bc1e85f171c8c49235b..e4196239b5ecec0beec1718a7e6d9a318ba9a551 100644 (file)
        MSG_ANNCE_NOTIF(LEAD_TIED,                  N__ALWAYS, "leadtied",          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)
-       MULTITEAM_ANNCE(ROUND_TEAM_SCORES,                      N__ALWAYS, "scores_%s",                 CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
-       MULTITEAM_ANNCE(WINS,                                           N__ALWAYS, "wins_%s",                   CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+       MULTITEAM_ANNCE(TEAM_SCORES,                            N__ALWAYS, "scores_%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(TEAM_LEADS,                                     N__ALWAYS, "leads_%s",                  CH_INFO, VOL_BASEVOICE, ATTEN_NONE, ANNCE_DEFTIME)
+       MSG_ANNCE_NOTIF(TEAM_LEADS_TIED,            N__ALWAYS, "leads_tied",        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)
index 35a8f6fd93b7f31900f8d8eb8341815c99f69e65..05d21ababbc0e9b21923014da854b038d4976fca 100644 (file)
@@ -849,6 +849,7 @@ MUTATOR_HOOKABLE(FireBullet_Hit, EV_FireBullet_Hit);
 MUTATOR_HOOKABLE(FixPlayermodel, EV_FixPlayermodel);
 
 /** Return error to play frag remaining announcements */
+MUTATOR_HOOKABLE(Scores_AnnounceLeads, EV_NO_ARGS);
 MUTATOR_HOOKABLE(Scores_CountFragsRemaining, EV_NO_ARGS);
 
 #define EV_GrappleHookThink(i, o) \
index 8906547c496cbdf43b6fdb10f1778fc9f8fbd97b..2874a84106de1af9068a13cb593da189bde3b154 100644 (file)
@@ -412,6 +412,24 @@ float PlayerScore_Compare(entity t1, entity t2, bool strict)
        return result.x;
 }
 
+bool Score_NewLeader()
+{
+       if(teamplay) {
+               if (WinningConditionHelper_winnerteam != WinningConditionHelper_winnerteam_last && (WinningConditionHelper_secondteam || WinningConditionHelper_equality))
+               {
+                       WinningConditionHelper_winnerteam_last = WinningConditionHelper_winnerteam;
+                       return true;
+               }
+       } else {
+               if (WinningConditionHelper_winner != WinningConditionHelper_winner_last && (WinningConditionHelper_second || WinningConditionHelper_equality))
+               {
+                       WinningConditionHelper_winner_last = WinningConditionHelper_winner;
+                       return true;
+               }
+       }
+       return false;
+}
+
 void WinningConditionHelper(entity this)
 {
        float c;
index 288eaf0c11a717d7a9f1a91668eb8c25b91ac49c..e446a6227742bf2cebe45019e71049c288d08330 100644 (file)
@@ -108,6 +108,7 @@ void WinningConditionHelper(entity this);
 float WinningConditionHelper_topscore;      ///< highest score
 float WinningConditionHelper_secondscore;   ///< second highest score
 float WinningConditionHelper_winnerteam;    ///< the color of the winning team, or -1 if none
+float WinningConditionHelper_winnerteam_last;
 float WinningConditionHelper_secondteam;    ///< the color of the second team, or -1 if none
 float WinningConditionHelper_equality;      ///< we have no winner
 entity WinningConditionHelper_winner;       ///< the winning player, or NULL if none
@@ -142,3 +143,6 @@ string GetTeamScoreString(float tm, float shortString);
  * nospectators: exclude spectators
  */
 entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators);
+
+// z411
+bool Score_NewLeader();
index 3a27c66f0297444d6ba6b0dd59f1bb6fbbb9ee94..84586cb73f1723a7a44fad1a42fc1d4f98729f90 100644 (file)
@@ -1307,7 +1307,7 @@ void NextLevel()
        
        // send winner notification
        if(teamplay) {
-               Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, APP_TEAM_NUM(WinningConditionHelper_winnerteam, ANNCE_WINS));
+               Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, APP_TEAM_NUM(WinningConditionHelper_winnerteam, ANNCE_TEAM_WINS));
        }
 
        if(autocvar_sv_eventlog)
@@ -1445,6 +1445,27 @@ void ClearWinners()
        FOREACH_CLIENT(IS_PLAYER(it), { it.winning = 0; });
 }
 
+void AnnounceNewLeader()
+{
+       if(teamplay) {
+               if (WinningConditionHelper_equality)
+                       Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_TEAM_LEADS_TIED);
+               else
+                       Send_Notification(NOTIF_ALL, 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);
+               }
+       }
+}
+
 float WinningCondition_Scores(float limit, float leadlimit)
 {
        // TODO make everything use THIS winning condition (except LMS)
@@ -1509,21 +1530,10 @@ float WinningCondition_Scores(float limit, float leadlimit)
                }
        }
        
-       // z411
-       if (WinningConditionHelper_winner != WinningConditionHelper_winner_last && (WinningConditionHelper_second || WinningConditionHelper_equality))
-       {
-               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);
-               }
-               
-               WinningConditionHelper_winner_last = WinningConditionHelper_winner;
+       // z411 - lead announcer
+       if(MUTATOR_CALLHOOK(Scores_AnnounceLeads)) {
+               if (Score_NewLeader())
+                       AnnounceNewLeader();
        }
        
        bool fraglimit_reached = (limit && WinningConditionHelper_topscore >= limit);
@@ -2304,7 +2314,7 @@ void RunThink(entity this)
 bool autocvar_sv_freezenonclients;
 void Physics_Frame()
 {
-       if(autocvar_sv_freezenonclients)
+       if(autocvar_sv_freezenonclients || game_timeout)
                return;
 
        IL_EACH(g_moveables, true,