From: terencehill Date: Mon, 14 Oct 2024 11:15:43 +0000 (+0200) Subject: Replace # with attacker name in trigger_hurt entity murder message X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=169a46e98a550327093c169c74155ca1ed74e9af;p=xonotic%2Fxonotic-data.pk3dir.git Replace # with attacker name in trigger_hurt entity murder message --- diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index 40cba807a..fd61b5686 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -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"), "") diff --git a/qcsrc/common/notifications/all.qh b/qcsrc/common/notifications/all.qh index 7c0fa18d8..8f5d7f246 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -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) diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 1a1ebdba7..e99689d27 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -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); diff --git a/qcsrc/server/damage.qc b/qcsrc/server/damage.qc index 7ca8ea090..b681ff54d 100644 --- a/qcsrc/server/damage.qc +++ b/qcsrc/server/damage.qc @@ -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,