From: Samual Lenks Date: Mon, 1 Oct 2012 18:30:09 +0000 (-0400) Subject: Rewrite killnotify system a bit, plus add the other team declarations X-Git-Tag: xonotic-v0.7.0~62^2~23^2~391 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c9e8a72fe6b835416ca65d78fea8cb16626a4dc6;p=xonotic%2Fxonotic-data.pk3dir.git Rewrite killnotify system a bit, plus add the other team declarations --- diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 2e3607ff4..4ceae0202 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1598,31 +1598,10 @@ string Weapon_KillMessage(float deathtype) return w_deathtypestring; } -#define KN_MAX_ENTRIES 10 -float kn_index; -float killnotify_times[KN_MAX_ENTRIES]; -float killnotify_deathtype[KN_MAX_ENTRIES]; -float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y" -string killnotify_attackers[KN_MAX_ENTRIES]; -string killnotify_victims[KN_MAX_ENTRIES]; -void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn) -{ - --kn_index; - if (kn_index == -1) - kn_index = KN_MAX_ENTRIES-1; - killnotify_times[kn_index] = time; - killnotify_deathtype[kn_index] = wpn; - killnotify_actiontype[kn_index] = actiontype; - if(killnotify_attackers[kn_index]) - strunzone(killnotify_attackers[kn_index]); - killnotify_attackers[kn_index] = strzone(attacker); - if(killnotify_victims[kn_index]) - strunzone(killnotify_victims[kn_index]); - killnotify_victims[kn_index] = strzone(victim); -} void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim { + /* float w; float alsoprint, gentle; alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled @@ -2042,7 +2021,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s if(alsoprint) print(sprintf(_("%s^7 has dropped the ball!\n"), s1)); } - } + }*/ } void HUD_KillCenterprint(string s1, string s2, float type, float msg) @@ -2132,7 +2111,7 @@ void HUD_KillCenterprint(string s1, string s2, float type, float msg) } } -void HUD_Notify (void) +void HUD_Notify(void) { if(!autocvar__hud_configure) { @@ -2168,12 +2147,9 @@ void HUD_Notify (void) float fadetime; fadetime = autocvar_hud_panel_notify_fadetime; - string s; - - vector pos_attacker, pos_victim; - vector weap_pos; + vector pos_attacker, pos_victim, pos_icon; float width_attacker; - string attacker, victim; + string attacker, victim, icon; float i, j, w, type, step, limit; if(autocvar_hud_panel_notify_flip) //order items from the top down @@ -2199,234 +2175,62 @@ void HUD_Notify (void) a = entries - 1 - i; attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors); victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors); - s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname); + icon = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname); a = bound(0, (when - a) / 4, 1); goto hud_config_notifyprint; } - - if (j == KN_MAX_ENTRIES) - j = 0; - - if(killnotify_times[j] + when > time) - a = 1; - else if(fadetime) - { - a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1); - if(!a) - { - break; - } - } else { - break; - } - - s = ""; - - type = killnotify_deathtype[j]; - w = DEATH_WEAPONOF(type); + if (j == KN_MAX_ENTRIES) + j = 0; - // TODO: maybe print in team colors? - // - // Y [used by] X - if(killnotify_actiontype[j] == 0) - { - if(type == DEATH_GENERIC) - { - s = "notify_death"; - } - else if(type == DEATH_NOAMMO) - { - s = "notify_outofammo"; - } - else if(type == DEATH_KILL) - { - s = "notify_selfkill"; - } - else if(type == DEATH_CAMP) - { - s = "notify_camping"; - } - else if(type == KILL_TEAM_RED) - { - s = "notify_teamkill_red"; - } - else if(type == KILL_TEAM_BLUE) - { - s = "notify_teamkill_blue"; - } - else if(type == DEATH_DROWN) - { - s = "notify_water"; - } - else if(type == DEATH_SLIME) - { - s = "notify_slime"; - } - else if(type == DEATH_LAVA) - { - s = "notify_lava"; - } - else if(type == DEATH_FALL) - { - s = "notify_fall"; - } - else if(type == DEATH_SHOOTING_STAR) - { - s = "notify_shootingstar"; - } - else if(type == DEATH_HURTTRIGGER || type == DEATH_CUSTOM) - { - s = "notify_death"; - } - else if(type == INFO_GOTFLAG) - { - if(killnotify_victims[j] == "^1RED^7 flag") - { - s = "notify_red_taken"; - } - else - { - s = "notify_blue_taken"; - } - } - else if(type == INFO_RETURNFLAG) - { - if(killnotify_victims[j] == "^1RED^7 flag") - { - s = "notify_red_returned"; - } - else - { - s = "notify_blue_returned"; - } - } - else if(type == INFO_LOSTFLAG) - { - if(killnotify_victims[j] == "^1RED^7 flag") - { - s = "notify_red_lost"; - } - else - { - s = "notify_blue_lost"; - } - } - else if(type == INFO_CAPTUREFLAG) + if(killnotify_times[j] + when > time) + a = 1; + else if(fadetime) { - if(killnotify_victims[j] == "^1RED^7 flag") + a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1); + if(!a) { - s = "notify_red_captured"; - } - else - { - s = "notify_blue_captured"; + break; } } - else if(type == KA_DROPBALL) - { - s = "notify_balldropped"; - } - else if(type == KA_PICKUPBALL) + else { - s = "notify_ballpickedup"; + break; } - attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors); - pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight))); - weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height; - - if(s != "") - { - drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL); - } + attacker = killnotify_attackers[j]; + victim = killnotify_victims[j]; + icon = killnotify_icon[j]; } - // X [did action to] Y - else + + //type = killnotify_deathtype[j]; + //w = DEATH_WEAPONOF(type); + + if(icon != "") { - if(type & HITTYPE_SECONDARY && w == WEP_LASER) - { - s = "notify_melee_laser"; - } - else if(type & HITTYPE_SECONDARY && w == WEP_SHOTGUN) - { - s = "notify_melee_shotgun"; - } - else if(type & HITTYPE_HEADSHOT && (w == WEP_RIFLE || w == WEP_MINSTANEX)) // all headshot weapons go here - { - s = "notify_headshot"; - } - else if(WEP_VALID(w)) + if((attacker != "") && (victim == "")) { - self = get_weaponinfo(w); - s = strcat("weapon", self.netname); - } - else if(type == KILL_TEAM_RED) - { - s = "notify_teamkill_red"; - } - else if(type == KILL_TEAM_BLUE) - { - s = "notify_teamkill_red"; - } - else if(type == DEATH_TELEFRAG) - { - s = "notify_telefrag"; - } - else if(type == DEATH_DROWN) - { - s = "notify_water"; - } - else if(type == DEATH_SLIME) - { - s = "notify_slime"; - } - else if(type == DEATH_LAVA) - { - s = "notify_lava"; - } - else if(type == DEATH_FALL) - { - s = "notify_fall"; - } - else if(type == DEATH_SHOOTING_STAR) - { - s = "notify_shootingstar"; - } - else if(type == DEATH_HURTTRIGGER || type == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right? - { - s = "notify_void"; - } - else if(type == RACE_SERVER_RECORD) - { - s = "race_newrecordserver"; - } - else if(type == RACE_NEW_RANK) - { - s = "race_newrankyellow"; - } - else if(type == RACE_NEW_TIME) - { - s = "race_newtime"; + // Y [used by] X + attacker = textShortenToWidth(attacker, 0.73 * mySize_x - height, fontsize, stringwidth_colors); + pos_attacker = pos + eX * (0.27 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight))); + pos_icon = pos + eX * 0.25 * mySize_x - eX * height + eY * i * height; + + drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL); } - else if(type == RACE_FAIL) + else if((attacker != "") && (victim != "")) { - s = "race_newfail"; - } - - attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors); - victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors); + // X [did action to] Y + attacker = textShortenToWidth(attacker, 0.48 * mySize_x - height, fontsize, stringwidth_colors); + victim = textShortenToWidth(victim, 0.48 * mySize_x - height, fontsize, stringwidth_colors); :hud_config_notifyprint - width_attacker = stringwidth(attacker, TRUE, fontsize); - pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight))); - pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight))); - weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height; + width_attacker = stringwidth(attacker, TRUE, fontsize); + pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight))); + pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight))); + pos_icon = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height; - if(s != "") - { - drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL); drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL); } diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 8a4d97d9f..e8491da84 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -36,10 +36,14 @@ var float autocvar_notification_ctf_pickup_enemy_verbose = TRUE; #define ADD_CSQC_AUTOCVAR(name) #endif -string team_name_red = _("RED"); -string team_name_blue = _("BLUE"); -string team_color_red = _("^1"); -string team_color_blue = _("^4"); +string team_name_red = _("Red"); +string team_name_blue = _("Blue"); +string team_name_yellow = _("Yellow"); +string team_name_pink = _("Pink"); +string team_color_red = "^1"; +string team_color_blue = "^4"; +string team_color_yellow = ""; +string team_color_pink = ""; // ==================================== @@ -82,46 +86,43 @@ string team_color_blue = _("^4"); ARIRE unir frk jvgu lbhe bja zbgure. (gvc sbe zvxrrhfn) -- Don't pay attention to this ^_^ */ -// flag.netname = ((teamnumber) ? "^1RED^7 flag" : "^4BLUE^7 flag"); // weaponorder[f1].netname - -#define MULTITEAM_INFO(prefix,teams,strnum,flnum,args,icon,normal,gentle) \ - MSG_INFO_NOTIF(prefix##RED, strnum, flnum, args, sprintf(icon, strtolower(team_name_red)), TEAM_CCR(normal, team_color_red, team_name_red), TEAM_CCR(gentle, team_color_red, team_name_red)) \ - MSG_INFO_NOTIF(prefix##BLUE, strnum, flnum, args, sprintf(icon, strtolower(team_name_blue)), TEAM_CCR(normal, team_color_blue, team_name_blue), TEAM_CCR(gentle, team_color_blue, team_name_blue)) \ +#define MULTITEAM_INFO(prefix,teams,strnum,flnum,args,hudargs,icon,normal,gentle) \ + MSG_INFO_NOTIF(prefix##RED, strnum, flnum, args, hudargs, sprintf(icon, strtolower(team_name_red)), TCR(normal, team_color_red, strtoupper(team_name_red)), TCR(gentle, team_color_red, strtoupper(team_name_red))) \ + MSG_INFO_NOTIF(prefix##BLUE, strnum, flnum, args, hudargs, sprintf(icon, strtolower(team_name_blue)), TCR(normal, team_color_blue, strtoupper(team_name_blue)), TCR(gentle, team_color_blue, strtoupper(team_name_blue))) \ #if teams >= 3 \ - MSG_INFO_NOTIF(prefix##YELLOW, strnum, flnum, args, sprintf(icon, strtolower(team_name_yellow)), TEAM_CCR(normal, team_color_yellow, team_name_yellow), TEAM_CCR(gentle, team_color_yellow, team_name_yellow)) \ + MSG_INFO_NOTIF(prefix##YELLOW, strnum, flnum, args, hudargs, sprintf(icon, strtolower(team_name_yellow)), TCR(normal, team_color_yellow, strtoupper(team_name_yellow)), TCR(gentle, team_color_yellow, strtoupper(team_name_yellow))) \ #endif \ #if teams >= 4 \ - MSG_INFO_NOTIF(prefix##PINK, strnum, flnum, args, sprintf(icon, strtolower(team_name_pink)), TEAM_CCR(normal, team_color_pink, team_name_pink), TEAM_CCR(gentle, team_color_pink, team_name_pink)) \ + MSG_INFO_NOTIF(prefix##PINK, strnum, flnum, args, hudargs, sprintf(icon, strtolower(team_name_pink)), TCR(normal, team_color_pink, strtoupper(team_name_pink)), TCR(gentle, team_color_pink, strtoupper(team_name_pink))) \ #endif #define MSG_INFO_NOTIFICATIONS \ - MSG_INFO_NOTIF(INFO_EMPTY, 0, 0, NO_STR_ARG, "", "", "") \ - MULTITEAM_INFO(INFO_SCORES_, 2, 0, 0, NO_STR_ARG, "", _("^TC^TT ^BGteam scores!\n"), "") \ - MULTITEAM_INFO(INFO_CTF_FLAGRETURN_DROPPED_, 2, 0, 0, NO_STR_ARG, "", _("^BGThe ^TC^TT^BG flag was dropped in the base and returned itself\n"), "") \ - MULTITEAM_INFO(INFO_CTF_FLAGRETURN_DAMAGED_, 2, 0, 0, NO_STR_ARG, "", _("^BGThe ^TC^TT^BG flag was destroyed and returned to base\n"), "") \ - MULTITEAM_INFO(INFO_CTF_FLAGRETURN_SPEEDRUN_, 2, 0, 1, f1/100, "", _("^BGThe ^TC^TT^BG flag became impatient after ^F1%.2f^BG seconds and returned itself\n"), "") \ - MULTITEAM_INFO(INFO_CTF_FLAGRETURN_NEEDKILL_, 2, 0, 0, NO_STR_ARG, "", _("^BGThe ^TC^TT^BG flag fell somewhere it couldn't be reached and returned to base\n"), "") \ - MULTITEAM_INFO(INFO_CTF_FLAGRETURN_ABORTRUN_, 2, 0, 0, NO_STR_ARG, "", _("^BGThe ^TC^TT^BG flag was returned to base by its owner\n"), "") \ - MULTITEAM_INFO(INFO_CTF_FLAGRETURN_TIMEOUT_, 2, 0, 0, NO_STR_ARG, "", _("^BGThe ^TC^TT^BG flag has returned to the base\n"), "") \ - MULTITEAM_INFO(INFO_CTF_PICKUP_, 2, 1, 0, s1, "notify_%s_taken", _("^BG%s^BG got the ^TC^TT^BG flag\n"), "") \ - MULTITEAM_INFO(INFO_CTF_RETURN_, 2, 1, 0, s1, "notify_%s_returned", _("^BG%s^BG returned the ^TC^TT^BG flag\n"), "") \ - MULTITEAM_INFO(INFO_CTF_LOST_, 2, 1, 0, s1, "notify_%s_lost", _("^BG%s^BG lost the ^TC^TT^BG flag\n"), "") \ - MULTITEAM_INFO(INFO_CTF_CAPTURE_, 2, 1, 0, s1, "notify_%s_capture", _("^BG%s^BG captured the ^TC^TT^BG flag\n"), "") \ - MULTITEAM_INFO(INFO_CTF_CAPTURE_TIME_, 2, 1, 1, XPND2(s1, f1/100), "notify_%s_capture", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%.2f^BG seconds\n"), "") \ - MULTITEAM_INFO(INFO_CTF_CAPTURE_BROKEN_, 2, 2, 2, XPND4(s1, f1/100, s2, f2/100), "notify_%s_capture", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%.2f^BG seconds, breaking ^BG%s^BG's previous record of ^F2%.2f^BG seconds\n"), "") \ - MULTITEAM_INFO(INFO_CTF_CAPTURE_UNBROKEN_, 2, 2, 2, XPND4(s1, f1/100, s2, f2/100), "notify_%s_capture", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F2%.2f^BG seconds, failing to break ^BG%s^BG's previous record of ^F1%.2f^BG seconds\n"), "") \ + MSG_INFO_NOTIF(INFO_EMPTY, 0, 0, NO_STR_ARG, XPND2("", ""), "", "", "") \ + MULTITEAM_INFO(INFO_SCORES_, 2, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^TC^TT ^BGteam scores!\n"), "") \ + MULTITEAM_INFO(INFO_CTF_FLAGRETURN_DROPPED_, 2, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^BGThe ^TC^TT^BG flag was dropped in the base and returned itself\n"), "") \ + MULTITEAM_INFO(INFO_CTF_FLAGRETURN_DAMAGED_, 2, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^BGThe ^TC^TT^BG flag was destroyed and returned to base\n"), "") \ + MULTITEAM_INFO(INFO_CTF_FLAGRETURN_SPEEDRUN_, 2, 0, 1, f1/100, XPND2("", ""), "", _("^BGThe ^TC^TT^BG flag became impatient after ^F1%.2f^BG seconds and returned itself\n"), "") \ + MULTITEAM_INFO(INFO_CTF_FLAGRETURN_NEEDKILL_, 2, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^BGThe ^TC^TT^BG flag fell somewhere it couldn't be reached and returned to base\n"), "") \ + MULTITEAM_INFO(INFO_CTF_FLAGRETURN_ABORTRUN_, 2, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^BGThe ^TC^TT^BG flag was returned to base by its owner\n"), "") \ + MULTITEAM_INFO(INFO_CTF_FLAGRETURN_TIMEOUT_, 2, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^BGThe ^TC^TT^BG flag has returned to the base\n"), "") \ + MULTITEAM_INFO(INFO_CTF_PICKUP_, 2, 1, 0, s1, XPND2(s1, ""), "notify_%s_taken", _("^BG%s^BG got the ^TC^TT^BG flag\n"), "") \ + MULTITEAM_INFO(INFO_CTF_RETURN_, 2, 1, 0, s1, XPND2(s1, ""), "notify_%s_returned", _("^BG%s^BG returned the ^TC^TT^BG flag\n"), "") \ + MULTITEAM_INFO(INFO_CTF_LOST_, 2, 1, 0, s1, XPND2(s1, ""), "notify_%s_lost", _("^BG%s^BG lost the ^TC^TT^BG flag\n"), "") \ + MULTITEAM_INFO(INFO_CTF_CAPTURE_, 2, 1, 0, s1, XPND2(s1, ""), "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag\n"), "") \ + MULTITEAM_INFO(INFO_CTF_CAPTURE_TIME_, 2, 1, 1, XPND2(s1, f1/100), XPND2(s1, ""), "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%.2f^BG seconds\n"), "") \ + MULTITEAM_INFO(INFO_CTF_CAPTURE_BROKEN_, 2, 2, 2, XPND4(s1, f1/100, s2, f2/100), XPND2(s1, ""), "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%.2f^BG seconds, breaking ^BG%s^BG's previous record of ^F2%.2f^BG seconds\n"), "") \ + MULTITEAM_INFO(INFO_CTF_CAPTURE_UNBROKEN_, 2, 2, 2, XPND4(s1, f1/100, s2, f2/100), XPND2(s1, ""), "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F2%.2f^BG seconds, failing to break ^BG%s^BG's previous record of ^F1%.2f^BG seconds\n"), "") \ #undef MSG_INFO_NOTIF - #define MULTITEAM_CENTER(prefix,teams,strnum,flnum,args,cpid,durcnt,normal,gentle) \ - MSG_CENTER_NOTIF(prefix##RED, strnum, flnum, args, cpid, durcnt, TEAM_CCR(normal, team_color_red, team_name_red), TEAM_CCR(gentle, team_color_red, team_name_red)) \ - MSG_CENTER_NOTIF(prefix##BLUE, strnum, flnum, args, cpid, durcnt, TEAM_CCR(normal, team_color_blue, team_name_blue), TEAM_CCR(gentle, team_color_blue, team_name_blue)) \ + MSG_CENTER_NOTIF(prefix##RED, strnum, flnum, args, cpid, durcnt, TCR(normal, team_color_red, strtoupper(team_name_red)), TCR(gentle, team_color_red, strtoupper(team_name_red))) \ + MSG_CENTER_NOTIF(prefix##BLUE, strnum, flnum, args, cpid, durcnt, TCR(normal, team_color_blue, strtoupper(team_name_blue)), TCR(gentle, team_color_blue, strtoupper(team_name_blue))) \ #if teams >= 3 \ - MSG_CENTER_NOTIF(prefix##YELLOW, strnum, flnum, args, cpid, durcnt, TEAM_CCR(normal, team_color_yellow, team_name_yellow), TEAM_CCR(gentle, team_color_yellow, team_name_yellow)) \ + MSG_CENTER_NOTIF(prefix##YELLOW, strnum, flnum, args, cpid, durcnt, TCR(normal, team_color_yellow, strtoupper(team_name_yellow)), TCR(gentle, team_color_yellow, strtoupper(team_name_yellow))) \ #endif \ #if teams >= 4 \ - MSG_CENTER_NOTIF(prefix##PINK, strnum, flnum, args, cpid, durcnt, TEAM_CCR(normal, team_color_pink, team_name_pink), TEAM_CCR(gentle, team_color_pink, team_name_pink)) \ + MSG_CENTER_NOTIF(prefix##PINK, strnum, flnum, args, cpid, durcnt, TCR(normal, team_color_pink, strtoupper(team_name_pink)), TCR(gentle, team_color_pink, strtoupper(team_name_pink))) \ #endif #define MSG_CENTER_NOTIFICATIONS \ MSG_CENTER_NOTIF(CENTER_EMPTY, 0, 0, NO_STR_ARG, NO_CPID, XPND2(0, 0), "", "") \ @@ -246,7 +247,7 @@ string Get_Field_Value(float field, float net_type, float net_name) { case MSG_INFO: { - #define MSG_INFO_NOTIF(name,strnum,flnum,args,icon,normal,gentle) \ + #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) \ { NOTIF_MATCH(name, net_name) { GET_FIELD_VALUE_OUTPUT(field,name,strnum,flnum) } } MSG_INFO_NOTIFICATIONS break; @@ -271,11 +272,11 @@ string Get_Field_Value(float field, float net_type, float net_name) return output; } -string TEAM_CCR(string input, string teamcolor, string teamtext) +// team code replace +string TCR(string input, string teamcolor, string teamtext) { input = strreplace("^TC", teamcolor, input); input = strreplace("^TT", teamtext, input); - return input; } @@ -287,9 +288,7 @@ string CCR(string input) input = strreplace("^K1", "^1", input); // autocvar_notification_colors_K1 input = strreplace("^K2", "^3", input); // autocvar_notification_colors_K2 input = strreplace("^BG", "^7", input); // autocvar_notification_colors_BG - input = strreplace("^N", "^7", input); // "none"-- reset to white - return input; } @@ -299,14 +298,43 @@ string CCR(string input) // =============================== #ifdef CSQC +#define KN_MAX_ENTRIES 10 +float kn_index; +float killnotify_times[KN_MAX_ENTRIES]; +string killnotify_icon[KN_MAX_ENTRIES]; +string killnotify_attackers[KN_MAX_ENTRIES]; +string killnotify_victims[KN_MAX_ENTRIES]; +// 0 = "Y [used by] X", 1 = "X [did action to] Y" +void HUD_Notify_Push(string icon, string attacker, string victim) +{ + if(icon != "") + { + --kn_index; + if (kn_index == -1) { kn_index = KN_MAX_ENTRIES-1; } + killnotify_times[kn_index] = time; + + // icon + if(killnotify_icon[kn_index]) { strunzone(killnotify_icon[kn_index]); } + killnotify_icon[kn_index] = strzone(icon); + + // attacker + if(killnotify_attackers[kn_index]) { strunzone(killnotify_attackers[kn_index]); } + killnotify_attackers[kn_index] = strzone(attacker); + + // victim + if(killnotify_victims[kn_index]) { strunzone(killnotify_victims[kn_index]); } + killnotify_victims[kn_index] = strzone(victim); + } +} + void Local_Notification(float net_type, float net_name, string s1, string s2, float f1, float f2, float f3) { switch(net_type) { case MSG_INFO: { - #define MSG_INFO_NOTIF(name,strnum,flnum,args,icon,normal,gentle) \ - { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } } + #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) \ + { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); if(strtolower(icon) != "") { HUD_Notify_Push(icon, hudargs); } } } MSG_INFO_NOTIFICATIONS break; } @@ -356,7 +384,7 @@ void Send_Notification(entity client, float net_type, float net_name, string s1, { if(net_type && net_name) { - print("notification: ", Get_Field_Value(F_NAME, net_type, net_name), ": ", ftos(net_name), ".\n"); + //print("notification: ", Get_Field_Value(F_NAME, net_type, net_name), ": ", ftos(net_name), ".\n"); float stringcount = stof(Get_Field_Value(F_STRNUM, net_type, net_name)); float floatcount = stof(Get_Field_Value(F_FLNUM, net_type, net_name)); @@ -396,7 +424,7 @@ void Send_Notification(entity client, float net_type, float net_name, string s1, if(!server_is_local && (net_type == MSG_INFO)) { - #define MSG_INFO_NOTIF(name,strnum,flnum,args,icon,normal,gentle) \ + #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) \ { NOTIF_MATCH(name, net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } } MSG_INFO_NOTIFICATIONS }