]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/notifications.qh
Implement mapload specific lifetime of notification entities (plus cvar
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications.qh
index 3d7adfae461ad26e33d648ed412b48f736d1859f..9529720028d9981198d5f0f85f7225de76f6d22e 100644 (file)
@@ -6,8 +6,9 @@
 // main types/groups of notifications
 #define MSG_INFO 1 // "Global" information messages (sent to console, and notify panel if it has an icon)
 #define MSG_CENTER 2 // "Personal" centerprint messages
-#define MSG_WEAPON 3 // "Personal" weapon messages (like "You got the Nex", sent to weapon notify panel)
-#define MSG_DEATH 4 // "Personal" AND "Global" death messages 
+#define MSG_CENTER_KILL 3 // Kill centerprint message
+#define MSG_WEAPON 4 // "Global" weapon messages 
+#define MSG_DEATH 5 // "Personal" AND "Global" death messages 
 
 #define NO_MSG -12345 
 
@@ -56,6 +57,7 @@ void Read_Notification(float is_new);
 #define IFSTR(num) ((num < notif.nent_stringcount) ? ...(num, string) : "")
 #define IFFL(num) ((((notif.nent_stringcount-1) + num) < count) ? ...(((notif.nent_stringcount-1) + num), float) : 0)
 
+void Kill_Notification(float broadcast, entity client, float net_type, float net_name);
 void Send_Notification(float broadcast, entity client, float net_type, float net_name, ...count);
 void Send_Notification_WOVA(float broadcast, entity client, float net_type, float net_name, string s1, string s2, string s3, string s4, float f1, float f2, float f3, float f4);
 void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration, float countdown_num);
@@ -220,7 +222,6 @@ void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration,
        MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_WAKI_DEATH,              3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_death",                 _("^BG%s%s^K1 got caught in the blast when ^BG%s^K1's Racer exploded%s%s\n"), "") \
        MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_RAPT_CANNON,             3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_death",                 _("^BG%s%s^K1 couldn't resist ^BG%s^K1's purple blobs%s%s\n"), "") \
        MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_RAPT_BOMB,               3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_death",                 _("^BG%s%s^K1 was cluster bombed by ^BG%s^K1's Raptor%s%s\n"), "") \
-       MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_RAPT_FRAGMENT,   3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_death",                 _("^BG%s%s^K1 was cluster bombed by ^BG%s^K1's Raptor%s%s\n"), "") \
        MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_RAPT_DEATH,              3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_death",                 _("^BG%s%s^K1 got caught in the blast when ^BG%s^K1's Raptor exploded%s%s\n"), "") \
        MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_BUMB_GUN,                3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_death",                 _("^BG%s%s^K1 saw the pretty lights of ^BG%s^K1's Bumblebee gun%s%s\n"), "") \
        MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_BUMB_DEATH,              3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1",               "notify_death",                 _("^BG%s%s^K1 got caught in the blast when ^BG%s^K1's Bumblebee exploded%s%s\n"), "") \
@@ -244,7 +245,8 @@ void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration,
        MSG_INFO_NOTIF(2, INFO_QUIT_KICK_IDLING,                                1, 0, "s1", "",                                                 "",                                             _("^BG%s^F3 was kicked for idling\n"), "") \
        MSG_INFO_NOTIF(1, INFO_QUIT_KICK_SPECTATING,                    0, 0, "", "",                                                   "",                                             _("^F2You were kicked from the server because you are a spectator and spectators aren't allowed at the moment.\n"), "") \
        MSG_INFO_NOTIF(2, INFO_QUIT_SPECTATE,                                   1, 0, "s1", "",                                                 "",                                             _("^BG%s^F3 is now spectating\n"), "") \
-       MSG_INFO_NOTIF(1, INFO_RACE_FAIL,                                               2, 0, "s1 s2", "s1",                                    "race_newfail",                 "TODO\n", "") \
+       MSG_INFO_NOTIF(1, INFO_RACE_FAIL_RANKED,                                1, 3, "s1 f1ord race_time race_diff", "s1",             "race_newfail", _("^BG%s^BG couldn't break their %s place record of %s %s\n"), "") \
+       MSG_INFO_NOTIF(1, INFO_RACE_FAIL_UNRANKED,                              1, 3, "s1 f1ord race_time race_diff", "s1",             "race_newfail", _("^BG%s^BG couldn't break the %s place record of %s %s\n"), "") \
        MSG_INFO_NOTIF(1, INFO_RACE_NEW_RECORD,                                 2, 0, "s1 s2", "s1",                                    "race_newrecordserver", "TODO\n", "") \
        MSG_INFO_NOTIF(1, INFO_RACE_NEW_TIME,                                   2, 0, "s1 s2", "s1",                                    "race_newtime",                 "TODO\n", "") \
        MSG_INFO_NOTIF(1, INFO_RACE_NEW_RANK,                                   2, 0, "s1 s2", "s1",                                    "race_newrankyellow",   "TODO\n", "") \
@@ -318,6 +320,11 @@ void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration,
        /*MSG_CENTER_NOTIF(1, CENTER_EMPTY,                                                     0, 0, "",                               NO_CPID,                                "0 0", "null", "")*/ \
        MSG_CENTER_NOTIF(1, CENTER_ASSAULT_ATTACKING,                           0, 0, "",                               CPID_ASSAULT_ROLE,              "0 0", _("^BGYou are attacking!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_ASSAULT_DEFENDING,                           0, 0, "",                               CPID_ASSAULT_ROLE,              "0 0", _("^BGYou are defending!"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_ARENA_BEGIN,                                         0, 0, "",                               CPID_ARENA,                             "2 0", _("^F4Begin!"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_ARENA_NEEDPLAYER,                            0, 0, "",                               CPID_ARENA,                             "2 0", _("^BGNeed at least 1 player in each team to play Clan Arena!"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_ARENA_ROUNDSTART,                            0, 1, "",                               CPID_ARENA,                     "1 f1", _("^F4Round will start in ^COUNT"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_COUNTDOWN_BEGIN,                                     0, 0, "",                               CPID_GAMESTART,                 "2 0", _("^F4Begin!"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_COUNTDOWN_GAMESTART,                         0, 1, "",                               CPID_GAMESTART,                 "1 f1", _("^F4Game starts in ^COUNT"), "") \
        MSG_CENTER_NOTIF(1, CENTER_CTF_CAPTURESHIELD_SHIELDED,          0, 0, "",                               CPID_CTF_CAPSHIELD,             "0 0", _("^BGYou are now ^F1shielded^BG from the flag\n^BGfor ^F2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \
        MSG_CENTER_NOTIF(1, CENTER_CTF_CAPTURESHIELD_FREE,                      0, 0, "",                               CPID_CTF_CAPSHIELD,             "0 0", _("^BGYou are now free.\n^BGFeel free to ^F2try to capture^BG the flag again\n^BGif you think you will succeed."), "") \
        MULTITEAM_CENTER(1, CENTER_CTF_PASS_OTHER_, 2,                          2, 0, "s1 s2",                  CPID_CTF_PASS,                  "0 0", _("^BG%s^BG passed the ^TC^TT^BG flag to %s"), "") \
@@ -386,7 +393,11 @@ void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration,
        MSG_CENTER_NOTIF(1, CENTER_KEEPAWAY_DROPPED,                            1, 0, "s1",                     CPID_KEEPAWAY,                  "0 0", _("^BG%s^BG has dropped the ball!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_KEEPAWAY_PICKUP,                                     1, 0, "s1",                     CPID_KEEPAWAY,                  "0 0", _("^BG%s^BG has picked up the ball!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_KEEPAWAY_WARN,                                       0, 0, "",                               CPID_KA_WARN,                   "0 0", _("^BGKilling people while you don't have the ball gives no points!"), "") \
-       MSG_CENTER_NOTIF(1, CENTER_LMS_CAMPCHECK,                                       0, 0, "",                               CPID_LMS_CAMP,                  "0 0", _("^K1Don't camp!"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_LMS_CAMPCHECK,                                       0, 0, "",                               CPID_LMS_CAMP,                  "0 0", _("^F2Don't camp!"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_MINSTA_FINDAMMO,                                     0, 0, "",                               CPID_MINSTA_FINDAMMO,   "1 9", _("^F4^COUNT^BG left to find some ammo!"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_MINSTA_FINDAMMO_FIRST,                       0, 0, "",                               CPID_MINSTA_FINDAMMO,   "1 10", _("^BGGet some ammo or you'll be dead in ^F4^COUNT^BG!"), _("Get some ammo! ^F4^COUNT^BG left!")) \
+       MSG_CENTER_NOTIF(1, CENTER_NIX_COUNTDOWN,                                       0, 2, "weapon",                 CPID_NIX,                               "1 f2", _("^F2^COUNT^BG until weapon change...\nNext weapon: ^F1%s"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_NIX_NEWWEAPON,                                       0, 1, "weapon",                 CPID_NIX,                               "0 0", _("^F2Active weapon: ^F1%s"), "") \
        MSG_CENTER_NOTIF(1, CENTER_JOIN_NOSPAWNS,                                       0, 0, "",                               CPID_PREVENT_JOIN,              "0 0", _("^K1No spawnpoints available!\nHope your team can fix it..."), "") \
        MSG_CENTER_NOTIF(1, CENTER_JOIN_PREVENT,                                        0, 0, "",                               CPID_PREVENT_JOIN,              "0 0", _("^K1You may not join the game at this time.\nThe player limit reached maximum capacity."), "") \
        MSG_CENTER_NOTIF(1, CENTER_OVERTIME_TIME,                                       0, 1, "f1time",                 CPID_OVERTIME,                  "0 0", _("^F2Now playing ^F4OVERTIME^F2!\nAdded ^F4%s ^F2minute(s) to the game!"), "") \
@@ -406,7 +417,9 @@ void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration,
        MULTITEAM_CENTER(1, CENTER_TEAMCHANGE_, 4,                                      0, 1, "",                               CPID_TEAMCHANGE,                "1 f1", _("^BGChanging to ^TC^TT^BG in ^COUNT"), "") \
        MSG_CENTER_NOTIF(1, CENTER_TEAMCHANGE_SPECTATE,                         0, 1, "",                               CPID_TEAMCHANGE,                "1 f1", _("^BGSpectating in ^COUNT"), "") \
        MSG_CENTER_NOTIF(1, CENTER_TEAMCHANGE_AUTO,                                     0, 1, "",                               CPID_TEAMCHANGE,                "1 f1", _("^BGChanging team in ^COUNT"), "") \
-       MSG_CENTER_NOTIF(1, CENTER_TEAMCHANGE_SUICIDE,                          0, 1, "",                               CPID_TEAMCHANGE,                "1 f1", _("^K1Suicide in ^COUNT"), "")
+       MSG_CENTER_NOTIF(1, CENTER_TEAMCHANGE_SUICIDE,                          0, 1, "",                               CPID_TEAMCHANGE,                "1 f1", _("^K1Suicide in ^COUNT"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_TIMEOUT_BEGINNING,                           0, 1, "",                               CPID_TIMEOUT,                   "1 f1", _("^F4Timeout begins in ^COUNT"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_TIMEOUT_ENDING,                                      0, 1, "",                               CPID_TIMEOUT,                   "1 f1", _("^F4Timeout ends in ^COUNT"), "")
 
 #define MSG_WEAPON_NOTIFICATIONS \
        /*MSG_WEAPON_NOTIF(1, WEAPON_EMPTY,                                                     NO_MSG,                                                                         NO_MSG)*/ \
@@ -543,6 +556,8 @@ var float autocvar_notification_show_sprees_info = 3; // 0 = off, 1 = target onl
 var float autocvar_notification_show_sprees_info_newline = FALSE;
 var float autocvar_notification_show_sprees_info_specialonly = TRUE;
 var float autocvar_notification_errors_are_fatal = TRUE;
+var float autocvar_notification_lifetime_runtime = 0.5;
+var float autocvar_notification_lifetime_mapload = 10;
 
 #ifdef SVQC
 .float FRAG_VERBOSE;
@@ -557,7 +572,7 @@ var float autocvar_notification_frag_verbose = TRUE;
 
 // ============================
 //  Notification Argument List
-// ============================
+// ============================ TODO UPDATE THIS
 /*
  These arguments get replaced with the Local_Notification_sprintf
  and Local_Notification_HUD_Notify_Push functions to supply data
@@ -602,31 +617,38 @@ string arg_slot[NOTIF_MAX_ARGS];
 #define ARG_CS 4 // unique result to CSQC
 #define ARG_SV 5 // unique result to SVQC
 
+// todo possible idea.... declare how many floats/strings each arg needs, and then dynamically increment the input
+// this way, we don't need to have duplicates like i.e. s2loc and s3loc
+
 #define NOTIF_ARGUMENT_LIST \
-       ARG_CASE(ARG_CS_SV_HA, "s1",                    s1) \
-       ARG_CASE(ARG_CS_SV_HA, "s2",                    s2) \
-       ARG_CASE(ARG_CS_SV_HA, "s3",                    s3) \
-       ARG_CASE(ARG_CS_SV_HA, "s4",                    s4) \
-       ARG_CASE(ARG_CS_SV, "s2loc",                    (autocvar_notification_show_location ? sprintf( ( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s2) : "")) \
-       ARG_CASE(ARG_CS_SV, "s3loc",                    (autocvar_notification_show_location ? sprintf( ( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s3) : "")) \
-       ARG_CASE(ARG_CS_SV_DC, "f1",                    ftos(f1)) \
-       ARG_CASE(ARG_CS_SV_DC, "f2",                    ftos(f2)) \
-       ARG_CASE(ARG_CS_SV, "f3",                               ftos(f3)) \
-       ARG_CASE(ARG_CS_SV, "f4",                               ftos(f4)) \
-       ARG_CASE(ARG_CS_SV, "f1p2dec",                  ftos_decimals(f1/100, 2)) \
-       ARG_CASE(ARG_CS_SV, "f2p2dec",                  ftos_decimals(f2/100, 2)) \
-       ARG_CASE(ARG_CS, "f1secs",                              count_seconds(f1)) \
-       ARG_CASE(ARG_CS, "pass_key",                    ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : "")) \
-       ARG_CASE(ARG_CS, "frag_ping",                   ((f2 != NO_MSG) ? sprintf(CCR(_("\n(Ping ^2%d^BG)")), f2) : "")) \
-       ARG_CASE(ARG_CS, "frag_stats",                  sprintf(CCR(_("\n(Health ^1%d^BG / Armor ^2%d^BG)%s")), f2, f3, ((f4 != NO_MSG) ? sprintf(CCR(_(" (Ping ^2%d^BG)")), f4) : ""))) \
-       /*ARG_CASE(ARG_CS, "frag_pos",                  ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))*/ \
-       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) : "")) \
-       ARG_CASE(ARG_CS_SV, "spree_lost",               (autocvar_notification_show_sprees ? notif_arg_spree_inf(-2, "", "", f1) : "")) \
-       ARG_CASE(ARG_CS_SV, "weapon_name",              ftos(f1)) \
-       ARG_CASE(ARG_SV, "death_team",                  Team_ColoredFullName(f1)) \
-       ARG_CASE(ARG_CS, "death_team",                  Team_ColoredFullName(f1 - 1))
+       ARG_CASE(ARG_CS_SV_HA,          "s1",                           s1) \
+       ARG_CASE(ARG_CS_SV_HA,          "s2",                           s2) \
+       ARG_CASE(ARG_CS_SV_HA,          "s3",                           s3) \
+       ARG_CASE(ARG_CS_SV_HA,          "s4",                           s4) \
+       ARG_CASE(ARG_CS_SV,             "s2loc",                        (autocvar_notification_show_location ? sprintf(( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s2) : "")) \
+       ARG_CASE(ARG_CS_SV,             "s3loc",                        (autocvar_notification_show_location ? sprintf(( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s3) : "")) \
+       ARG_CASE(ARG_CS_SV_DC,          "f1",                           ftos(f1)) \
+       ARG_CASE(ARG_CS_SV_DC,          "f2",                           ftos(f2)) \
+       ARG_CASE(ARG_CS_SV,             "f3",                           ftos(f3)) \
+       ARG_CASE(ARG_CS_SV,             "f4",                           ftos(f4)) \
+       ARG_CASE(ARG_CS_SV,             "f1p2dec",                      ftos_decimals(f1/100, 2)) \
+       ARG_CASE(ARG_CS_SV,             "f2p2dec",                      ftos_decimals(f2/100, 2)) \
+       ARG_CASE(ARG_CS,                        "f1secs",                       count_seconds(f1)) \
+       ARG_CASE(ARG_CS_SV,                     "f1ord",                        count_ordinal(f1)) \
+       ARG_CASE(ARG_CS,                        "f1time",                       process_time("foobar", f1)) \
+       ARG_CASE(ARG_CS,                        "pass_key",             ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : "")) \
+       ARG_CASE(ARG_CS,                        "frag_ping",            ((f2 != NO_MSG) ? sprintf(CCR(_("\n(Ping ^2%d^BG)")), f2) : "")) \
+       ARG_CASE(ARG_CS,                        "frag_stats",           sprintf(CCR(_("\n(Health ^1%d^BG / Armor ^2%d^BG)%s")), f2, f3, ((f4 != NO_MSG) ? sprintf(CCR(_(" (Ping ^2%d^BG)")), f4) : ""))) \
+       /*ARG_CASE(ARG_CS,                      "frag_pos",                     ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))*/ \
+       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) : "")) \
+       ARG_CASE(ARG_CS_SV,             "spree_lost",           (autocvar_notification_show_sprees ? notif_arg_spree_inf(-2, "", "", f1) : "")) \
+       ARG_CASE(ARG_CS_SV,             "weapon",                       W_Name(f1)) \
+       ARG_CASE(ARG_SV,                        "death_team",           Team_ColoredFullName(f1)) \
+       ARG_CASE(ARG_CS,                        "death_team",           Team_ColoredFullName(f1 - 1)) \
+       ARG_CASE(ARG_CS_SV,                     "race_time",            mmssss(f2)) \
+       ARG_CASE(ARG_CS_SV,             "race_diff",            ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssss(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssss(f3 - f2))))
 
 #define NOTIF_HIT_MAX(count,funcname) if(sel_num == count) { backtrace(sprintf("%s: Hit maximum arguments!\n", funcname)); break; }
 #define NOTIF_HIT_UNKNOWN(token,funcname) { backtrace(sprintf("%s: Hit unknown token in selected string! '%s'\n", funcname, selected)); break; }
@@ -1000,6 +1022,7 @@ string Process_Notif_Args(float arg_type, string args, string notiftype, string
                \
                notif.nent_stringcount = strnum; \
                notif.nent_floatcount = flnum; \
+               if(strnum + flnum > 4) { print(sprintf("^1NOTIFICATION HAS TOO MANY ARGUMENTS FOR BROKEN VARARGS: ^7net_type = MSG_%s, net_name = %s\n", strtoupper(#type), #name)); } \
                if(strnum + flnum) \
                { \
                        if(args != "") { notif.nent_args = strzone(Process_Notif_Args(1, args, strtoupper(#type), #name)); } \