]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Replace # with attacker name in trigger_hurt entity murder message
authorterencehill <piuntn@gmail.com>
Mon, 14 Oct 2024 11:15:43 +0000 (13:15 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 14 Oct 2024 11:15:43 +0000 (13:15 +0200)
qcsrc/common/notifications/all.inc
qcsrc/common/notifications/all.qh
qcsrc/common/util.qh
qcsrc/server/damage.qc

index 40cba807a3e756de34c51be341bf45564029f431..fd61b5686605f7b77be8960736ba330a2d0e82e6 100644 (file)
@@ -304,7 +304,7 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input !=
     MSG_INFO_NOTIF(DEATH_MURDER_VH_WAKI_GUN,                N_CONSOLE,  3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_death",         _("^BG%s%s^K1 was bolted down by ^BG%s^K1's Racer%s%s"), "")
     MSG_INFO_NOTIF(DEATH_MURDER_VH_WAKI_ROCKET,             N_CONSOLE,  3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_death",         _("^BG%s%s^K1 couldn't find shelter from ^BG%s^K1's Racer%s%s"), "")
     MSG_INFO_NOTIF(DEATH_MURDER_VOID,                       N_CONSOLE,  3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_void",          _("^BG%s%s^K1 was thrown into a world of hurt by ^BG%s^K1%s%s"), "")
-    MSG_INFO_NOTIF(DEATH_MURDER_VOID_ENT,                   N_CONSOLE,  4, 2, "spree_inf s1 s3 s2 s4loc spree_end", "s2 s1",            "notify_void",            "^BG%s%s^K1 %s ^BG%s^K1%s%s", "")
+    MSG_INFO_NOTIF(DEATH_MURDER_VOID_ENT,                   N_CONSOLE,  4, 2, "spree_inf s1 s3#s2 #s2 s4loc spree_end", "s2 s1",        "notify_void",            "^BG%s%s^K1 %s%s%s%s", "")
 
     MSG_INFO_NOTIF(DEATH_SELF_AUTOTEAMCHANGE,               N_CONSOLE,  2, 1, "s1 death_team s2loc", "",        "",                     _("^BG%s^K1 was moved into the %s%s"), "")
     MSG_INFO_NOTIF(DEATH_SELF_BETRAYAL,                     N_CONSOLE,  2, 1, "s1 s2loc spree_lost", "s1",      "notify_teamkill_red",  _("^BG%s^K1 became enemies with the Lord of Teamplay%s%s"), "")
index 7c0fa18d85abd331d6ea1801c11dd1f0d7112bbc..8f5d7f24656341b2a99fca1b732c3d836f60663b 100644 (file)
@@ -401,6 +401,24 @@ float notif_queue_next_time;
 int notif_queue_length;
 
 void Local_Notification_Queue_Process();
+
+// replaces # with attacker_name in ent_msg (if not found attacker_name is appended)
+string hash_replace(string full_msg, int ent_msg_num, string ent_msg, string attacker_name)
+{
+       int s_ofs = 0;
+       while (--ent_msg_num >= 0)
+               s_ofs += strstrofs(full_msg, "%s", s_ofs);
+       string col = find_last_color_code(substring(full_msg, 0, s_ofs));
+
+       int hash_ofs = strstrofs(ent_msg, "#", 0);
+       if (hash_ofs < 0)
+               ent_msg = strcat(ent_msg, " ", CCR("^BG"), attacker_name, col);
+       else
+               ent_msg = strreplace("#", strcat(CCR("^BG"), attacker_name, col), ent_msg);
+       return ent_msg;
+}
+
+#define HASH_REPLACE(full_msg, num, attacker_name) hash_replace(input, num, s##num, attacker_name)
 #endif
 
 string arg_slot[NOTIF_MAX_ARGS];
@@ -460,6 +478,10 @@ string BUFF_NAME(int i);
        ARG_CASE(ARG_DC,        "item_centime",  ftos(autocvar_notification_item_centerprinttime)) \
        ARG_CASE(ARG_SV,        "death_team",    Team_ColoredFullName(f1)) \
        ARG_CASE(ARG_CS,        "death_team",    Team_ColoredFullName(f1 - 1)) \
+       ARG_CASE(ARG_SV,        "s3#s2",         s3) \
+       ARG_CASE(ARG_SV,        "#s2",           s2) \
+       ARG_CASE(ARG_CS,        "s3#s2",         HASH_REPLACE(input, 3, s2)) \
+       ARG_CASE(ARG_CS,        "#s2",           "") \
        ARG_CASE(ARG_CS_SV_HA,  "minigame1_name",find(NULL,netname,s1).descriptor.message) \
        ARG_CASE(ARG_CS_SV_HA,  "minigame1_d",   find(NULL,netname,s1).descriptor.netname)
 
index 1a1ebdba7fb9593faebb5a13301fe0fc0c59c4e9..e99689d27ea0560dc9731faa4cc28dbff56137ab 100644 (file)
@@ -289,3 +289,5 @@ float cvar_or(string cv, float v);
 float blink_synced(float base, float range, float freq, float start_time, int start_blink);
 
 float blink(float base, float range, float freq);
+
+string find_last_color_code(string s);
index 7ca8ea090a1185ccd29b171bc6413daf9733acd1..b681ff54d04608740b2799a62ba482f12a22c2d6 100644 (file)
@@ -429,7 +429,6 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                        {
                                if (DEATH_ENT(deathtype) == DEATH_HURTTRIGGER)
                                {
-                                       // FIXME if # is present inside .message2 then it is should be replaced with attacker's name
                                        bool msg_from_ent = (inflictor && inflictor.message2 != "");
                                        Obituary_SpecialDeath(targ, true, msg_from_ent, deathtype,
                                                targ.netname,