From: z411 Date: Mon, 30 Jan 2023 10:41:47 +0000 (-0300) Subject: Add team scoring/lead announcing X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=38ef43276fb82db1525c503dd7cc640092733c0b;p=xonotic%2Fxonotic-data.pk3dir.git Add team scoring/lead announcing --- diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 5fbb2b2a6..0065cc69d 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -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 diff --git a/qcsrc/common/gamemodes/gamemode/tdm/sv_tdm.qc b/qcsrc/common/gamemodes/gamemode/tdm/sv_tdm.qc index 5e8508896..3bd9cb564 100644 --- a/qcsrc/common/gamemodes/gamemode/tdm/sv_tdm.qc +++ b/qcsrc/common/gamemodes/gamemode/tdm/sv_tdm.qc @@ -70,3 +70,9 @@ MUTATOR_HOOKFUNCTION(tdm, Scores_CountFragsRemaining) // announce remaining frags return true; } + +MUTATOR_HOOKFUNCTION(tdm, Scores_AnnounceLeads) +{ + // enable leads announcer + return true; +} diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index da62077c6..85fdcd514 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -98,12 +98,20 @@ #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) @@ -202,9 +210,25 @@ 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 diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 18a048fc1..d6cb8f271 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -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 index 000000000..d29982032 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 index 000000000..20dc6c91b 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 index 000000000..5d33c807b 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 index 000000000..ff508bc73 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 index 000000000..05991b2ab 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 index 000000000..706be3f66 Binary files /dev/null and b/sound/announcer/default/scores_yellow.ogg differ