From: z411 Date: Tue, 20 Oct 2020 08:59:57 +0000 (-0300) Subject: Display player's place when notifying about frag X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=722ea74921d65929ccbc9fa6a11890de599829c1;p=xonotic%2Fxonotic-data.pk3dir.git Display player's place when notifying about frag --- diff --git a/qcsrc/common/gamemodes/gamemode/deathmatch/sv_deathmatch.qc b/qcsrc/common/gamemodes/gamemode/deathmatch/sv_deathmatch.qc index e622a1942..fd7a718b7 100644 --- a/qcsrc/common/gamemodes/gamemode/deathmatch/sv_deathmatch.qc +++ b/qcsrc/common/gamemodes/gamemode/deathmatch/sv_deathmatch.qc @@ -5,3 +5,38 @@ MUTATOR_HOOKFUNCTION(dm, Scores_CountFragsRemaining) // announce remaining frags return true; } + +MUTATOR_HOOKFUNCTION(dm, FragCenterMessage) +{ + // Use normal notifications in warmup + if(warmup_stage) return false; + + entity attacker = M_ARGV(0, entity); + entity targ = M_ARGV(1, entity); + //float frag_deathtype = M_ARGV(2, float); + int kill_count_to_attacker = M_ARGV(3, int); + int kill_count_to_target = M_ARGV(4, int); + + Send_Notification( + NOTIF_ONE, + attacker, + MSG_CENTER, + CENTER_DEATH_MURDER_DM, + targ.netname, + kill_count_to_attacker, + GameRules_scoring_add(attacker, SCORE, 0) + ); + Send_Notification( + NOTIF_ONE, + targ, + MSG_CHOICE, + CHOICE_FRAGGED, + attacker.netname, + kill_count_to_target, + GetResource(attacker, RES_HEALTH), + GetResource(attacker, RES_ARMOR), + (IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping) + ); + + return true; +} \ No newline at end of file diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index 47139534e..b9ebedc8e 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -628,9 +628,11 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input != #define MURDER_FRAG strcat(BOLD_OPERATOR, _("^K3%sYou fragged ^BG%s")) #define MURDER_FRAG2 strcat(BOLD_OPERATOR, _("^K3%sYou scored against ^BG%s")) + #define MURDER_FRAG3 strcat(BOLD_OPERATOR, _("^K3%sYou fragged ^BG%s"), "\n", "%s^BG place with %s") #define MURDER_FRAGGED _("^K1%sYou were fragged by ^BG%s") #define MURDER_FRAGGED2 _("^K1%sYou were scored against by ^BG%s") MSG_CENTER_NOTIF(DEATH_MURDER_FRAG, N_ENABLE, 1, 1, "spree_cen s1", CPID_Null, "0 0", MURDER_FRAG, MURDER_FRAG2 ) + MSG_CENTER_NOTIF(DEATH_MURDER_DM, N_ENABLE, 1, 2, "spree_cen s1 frag_pos f2", CPID_Null, "0 0", MURDER_FRAG3, "") MSG_CENTER_NOTIF(DEATH_MURDER_FRAGGED, N_ENABLE, 1, 1, "spree_cen s1", CPID_Null, "0 0", MURDER_FRAGGED, MURDER_FRAGGED2 ) MSG_CENTER_NOTIF(DEATH_MURDER_FRAGGED_VERBOSE, N_ENABLE, 1, 4, "spree_cen s1 frag_stats", CPID_Null, "0 0", VERBOSE_MURDER(FRAGGED), VERBOSE_MURDER(FRAGGED2) ) MSG_CENTER_NOTIF(DEATH_MURDER_FRAG_VERBOSE, N_ENABLE, 1, 2, "spree_cen s1 frag_ping", CPID_Null, "0 0", VERBOSE_MURDER(FRAG), VERBOSE_MURDER(FRAG2) ) diff --git a/qcsrc/common/notifications/all.qh b/qcsrc/common/notifications/all.qh index 1c6aa2037..8044ee93c 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -455,7 +455,7 @@ string BUFF_NAME(int i); ARG_CASE(ARG_CS, "join_key", getcommandkey(_("jump"), "+jump")) \ ARG_CASE(ARG_CS, "frag_ping", notif_arg_frag_ping(true, f2)) \ ARG_CASE(ARG_CS, "frag_stats", notif_arg_frag_stats(f2, f3, f4)) \ - /*ARG_CASE(ARG_CS, "frag_pos", ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))*/ \ + ARG_CASE(ARG_CS, "frag_pos", notif_arg_frag_pos(f2)) \ ARG_CASE(ARG_CS, "spree_cen", (autocvar_notification_show_sprees ? notif_arg_spree_cen(f1) : "")) \ ARG_CASE(ARG_CS_SV, "spree_inf", (autocvar_notification_show_sprees ? notif_arg_spree_inf(1, input, s2, f2) : "")) \ ARG_CASE(ARG_CS_SV, "spree_end", (autocvar_notification_show_sprees ? notif_arg_spree_inf(-1, "", "", f1) : "")) \ @@ -483,6 +483,61 @@ MACRO_END SPREE_ITEM(15, 15, _("MAYHEM! "), _("%s^K1 executed MAYHEM! %s^BG"), _("%s^K1 made FIFTEEN SCORES IN A ROW! %s^BG")) \ #ifdef CSQC +string notif_arg_frag_pos(int score) +{ + entity pl; + int place = 1; + string str, color, tail; + bool tied = false; + + for(pl = players.sort_next; pl; pl = pl.sort_next) { + if(pl.team == NUM_SPECTATOR) continue; + if(pl.(scores(SP_SCORE)) == score) break; + ++place; + } + + entity prev = pl.sort_prev; + entity next = pl.sort_next; + if(prev && prev.(scores(SP_SCORE)) == score) + tied = true; + if(next && next.(scores(SP_SCORE)) == score) + tied = true; + + switch(place) { + case 1: + color = "^4"; + break; + case 2: + color = "^1"; + break; + case 3: + color = "^3"; + break; + default: + color = ""; + } + + switch(place % 10) { + case 1: + tail = "st"; + break; + case 2: + tail = "nd"; + break; + case 3: + tail = "rd"; + break; + default: + tail = "th"; + } + + str = strcat(color, ftos(place), tail); + if(tied) + return strcat("Tied for ", str); + else + return str; +} + string notif_arg_frag_ping(bool newline, float fping) { string s = newline ? "\n" : " ";