]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/notifications/all.qh
Merge branch 'Mario/infinite_ammo_start' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications / all.qh
index 17d2047dcb767523f932ed258da2976ededd1946..e56658a682e124e33f4018109e22b7922a313224 100644 (file)
@@ -52,6 +52,7 @@ ENUMCLASS(CPID)
        CASE(CPID, STALEMATE)
        CASE(CPID, NADES)
        CASE(CPID, IDLING)
+       CASE(CPID, REMOVE)
        CASE(CPID, ITEM)
        CASE(CPID, PREVENT_JOIN)
        CASE(CPID, KEEPAWAY)
@@ -62,14 +63,13 @@ ENUMCLASS(CPID)
        CASE(CPID, MISSING_TEAMS)
        CASE(CPID, MISSING_PLAYERS)
        CASE(CPID, INSTAGIB_FINDAMMO)
-       CASE(CPID, CAMPAIGN_MESSAGE)
-       CASE(CPID, MOTD)
        CASE(CPID, NIX)
        CASE(CPID, ONSLAUGHT)
        CASE(CPID, ONS_CAPSHIELD)
        CASE(CPID, OVERTIME)
        CASE(CPID, POWERUP)
        CASE(CPID, RACE_FINISHLAP)
+       CASE(CPID, SURVIVAL)
        CASE(CPID, TEAMCHANGE)
        CASE(CPID, TIMEOUT)
        CASE(CPID, TIMEIN)
@@ -125,7 +125,8 @@ void Create_Notification_Entity_Annce(entity notif,
                                                                                float channel,
                                                                                string snd,
                                                                                float vol,
-                                                                               float position);
+                                                                               float position,
+                                                                               float queuetime);
 
 void Create_Notification_Entity_InfoCenter(entity notif,
                                                                                        float var_cvar,
@@ -351,21 +352,23 @@ float autocvar_notification_show_sprees_center_specialonly = true;
        s2loc: s2 string of locations of deaths or other events
        s3loc: s3 string of locations of deaths or other events
        f1-f4: float arguments expanded into strings to be swapped into sprintf
-       f1p2dec: f1 float to string with 2 decimal places
-       f2p2dec: f2 float to string with 2 decimal places
+       f1dtime: f1 float to string with 2 decimal places
+       f2dtime: f2 float to string with 2 decimal places
        f2primsec: f2 float primary or secondary selection for weapons
        f3primsec: f3 float primary or secondary selection for weapons
        f1secs: count_seconds of f1
        f1points: point or points depending on f1
        f1ord: count_ordinal of f1
        f1time: process_time of f1
-       f1race_time: mmssss of f1
-       f2race_time: mmssss of f2
+       f1race_time: TIME_ENCODED_TOSTRING of f1
+       f2race_time: TIME_ENCODED_TOSTRING of f2
+       f3race_time: TIME_ENCODED_TOSTRING of f3
        race_col: color of race time/position (i.e. good or bad)
        race_diff: show time difference between f2 and f3
        missing_teams: show which teams still need players
        pass_key: find the keybind for "passing" or "dropping" in CTF game mode
        nade_key: find the keybind for nade throwing
+       join_key: find the keybind for joining the game
        frag_ping: show the ping of a player
        frag_stats: show health/armor/ping of a player
        frag_pos: show score status and position in the match of a player
@@ -376,7 +379,8 @@ float autocvar_notification_show_sprees_center_specialonly = true;
        item_wepname: return full name of a weapon from weaponid
        item_wepammo: ammo display for weapon from f1 and f2
        item_centime: amount of time to display weapon message in centerprint
-       item_buffname: return full name of a buff from buffid
+       item_buffname: return full name of a buff from buffid f1
+       f3buffname: return full name of a buff from buffid f3
        death_team: show the full name of the team a player is switching from
        minigame1_name: return human readable name of a minigame from its id(s1)
        minigame1_d: return descriptor name of a minigame from its id(s1)
@@ -386,6 +390,18 @@ const float NOTIF_MAX_ARGS = 7;
 const float NOTIF_MAX_HUDARGS = 2;
 const float NOTIF_MAX_DURCNT = 2;
 
+#ifdef CSQC
+const int NOTIF_QUEUE_MAX = 10;
+entity notif_queue_entity[NOTIF_QUEUE_MAX];
+MSG notif_queue_type[NOTIF_QUEUE_MAX];
+float notif_queue_time[NOTIF_QUEUE_MAX];
+
+float notif_queue_next_time;
+int notif_queue_length;
+
+void Local_Notification_Queue_Process();
+#endif
+
 string arg_slot[NOTIF_MAX_ARGS];
 
 const float ARG_CS_SV_HA = 1; // enabled on CSQC, SVQC, and Hudargs
@@ -416,14 +432,14 @@ string BUFF_NAME(int i);
        ARG_CASE(ARG_CS,        "f2primsec",     (f2 ? _("secondary") : _("primary"))) \
        ARG_CASE(ARG_CS,        "f3primsec",     (f3 ? _("secondary") : _("primary"))) \
        ARG_CASE(ARG_CS,        "f1secs",        count_seconds(f1)) \
-       ARG_CASE(ARG_CS,        "f1points",      (f1 == 1 ? _("point") : _("points"))) \
+       ARG_CASE(ARG_CS,        "f1points",      (f1 == 1 ? _("1 point") : sprintf(_("%d points"), f1))) \
        ARG_CASE(ARG_CS_SV,     "f1ord",         count_ordinal(f1)) \
        ARG_CASE(ARG_CS_SV,     "f1time",        process_time(2, f1)) \
-       ARG_CASE(ARG_CS_SV_HA,  "f1race_time",   mmssss(f1)) \
-       ARG_CASE(ARG_CS_SV_HA,  "f2race_time",   mmssss(f2)) \
-       ARG_CASE(ARG_CS_SV_HA,  "f3race_time",   mmssss(f3)) \
-       ARG_CASE(ARG_CS_SV,     "race_col",      CCR(((f1 == 1) ? "^F1" : "^F2"))) \
-       ARG_CASE(ARG_CS_SV,     "race_diff",     ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssss(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssss(f3 - f2)))) \
+       ARG_CASE(ARG_CS_SV_HA,  "f1race_time",   TIME_ENCODED_TOSTRING(f1, true)) \
+       ARG_CASE(ARG_CS_SV_HA,  "f2race_time",   TIME_ENCODED_TOSTRING(f2, true)) \
+       ARG_CASE(ARG_CS_SV_HA,  "f3race_time",   TIME_ENCODED_TOSTRING(f3, true)) \
+       ARG_CASE(ARG_CS_SV,     "race_col",      CCR((f1 == 1) ? "^F1" : "^F2")) \
+       ARG_CASE(ARG_CS_SV,     "race_diff",     ((f2 > f3) ? sprintf("^1[+%s]", TIME_ENCODED_TOSTRING(f2 - f3, true)) : sprintf("^2[-%s]", TIME_ENCODED_TOSTRING(f3 - f2, true)))) \
        ARG_CASE(ARG_CS,        "missing_teams", notif_arg_missing_teams(f1)) \
        ARG_CASE(ARG_CS,        "pass_key",      getcommandkey(_("drop flag"), "+use")) \
        ARG_CASE(ARG_CS,        "nade_key",      getcommandkey(_("throw nade"), "dropweapon")) \
@@ -452,13 +468,13 @@ MACRO_END
 #define NOTIF_HIT_UNKNOWN(token,funcname) { backtrace(sprintf("%s: Hit unknown token in selected string! '%s'\n", funcname, selected)); break; }
 
 #define KILL_SPREE_LIST \
-       SPREE_ITEM(3, 03, _("TRIPLE FRAG! "), _("%s^K1 made a TRIPLE FRAG! %s^BG"), _("%s^K1 made a TRIPLE SCORE! %s^BG")) \
-       SPREE_ITEM(5, 05, _("RAGE! "), _("%s^K1 unlocked RAGE! %s^BG"), _("%s^K1 made FIVE SCORES IN A ROW! %s^BG")) \
-       SPREE_ITEM(10, 10, _("MASSACRE! "), _("%s^K1 started a MASSACRE! %s^BG"), _("%s^K1 made TEN SCORES IN A ROW! %s^BG")) \
-       SPREE_ITEM(15, 15, _("MAYHEM! "), _("%s^K1 executed MAYHEM! %s^BG"), _("%s^K1 made FIFTEEN SCORES IN A ROW! %s^BG")) \
-       SPREE_ITEM(20, 20, _("BERSERKER! "), _("%s^K1 is a BERSERKER! %s^BG"), _("%s^K1 made TWENTY SCORES IN A ROW! %s^BG")) \
-       SPREE_ITEM(25, 25, _("CARNAGE! "), _("%s^K1 inflicts CARNAGE! %s^BG"), _("%s^K1 made TWENTY FIVE SCORES IN A ROW! %s^BG")) \
-       SPREE_ITEM(30, 30, _("ARMAGEDDON! "), _("%s^K1 unleashes ARMAGEDDON! %s^BG"), _("%s^K1 made THIRTY SCORES IN A ROW! %s^BG"))
+       SPREE_ITEM(3,  03, _("TRIPLE FRAG!"), _("%s^K1 made a TRIPLE FRAG!"),   _("%s^K1 made a TRIPLE SCORE!")) \
+       SPREE_ITEM(5,  05, _("RAGE!"),        _("%s^K1 unlocked RAGE!"),        _("%s^K1 made FIVE SCORES IN A ROW!")) \
+       SPREE_ITEM(10, 10, _("MASSACRE!"),    _("%s^K1 started a MASSACRE!"),   _("%s^K1 made TEN SCORES IN A ROW!")) \
+       SPREE_ITEM(15, 15, _("MAYHEM!"),      _("%s^K1 executed MAYHEM!"),      _("%s^K1 made FIFTEEN SCORES IN A ROW!")) \
+       SPREE_ITEM(20, 20, _("BERSERKER!"),   _("%s^K1 is a BERSERKER!"),       _("%s^K1 made TWENTY SCORES IN A ROW!")) \
+       SPREE_ITEM(25, 25, _("CARNAGE!"),     _("%s^K1 inflicts CARNAGE!"),     _("%s^K1 made TWENTY FIVE SCORES IN A ROW!")) \
+       SPREE_ITEM(30, 30, _("ARMAGEDDON!"),  _("%s^K1 unleashes ARMAGEDDON!"), _("%s^K1 made THIRTY SCORES IN A ROW!"))
 
 #ifdef CSQC
 string notif_arg_frag_ping(bool newline, float fping)
@@ -497,7 +513,8 @@ string notif_arg_spree_cen(float spree)
                if(spree > 1)
                {
                        #define SPREE_ITEM(counta,countb,center,normal,gentle) \
-                               case counta: { return normal_or_gentle(center, sprintf(_("%d score spree! "), spree)); }
+                               case counta: \
+                                       return strcat(normal_or_gentle(center, sprintf(_("%d score spree!"), spree)), " ");
 
                        switch(spree)
                        {
@@ -508,10 +525,10 @@ string notif_arg_spree_cen(float spree)
                                        {
                                                return
                                                        sprintf(
-                                                               normal_or_gentle(
-                                                                       _("%d frag spree! "),
-                                                                       _("%d score spree! ")
-                                                               ),
+                                                               strcat(normal_or_gentle(
+                                                                       _("%d frag spree!"),
+                                                                       _("%d score spree!")
+                                                                       ), " "),
                                                                spree);
                                        }
                                        else { return ""; } // don't show spree information if it isn't an achievement
@@ -522,11 +539,11 @@ string notif_arg_spree_cen(float spree)
                }
                else if(spree == -1) // first blood
                {
-                       return normal_or_gentle(_("First blood! "), _("First score! "));
+                       return strcat(normal_or_gentle(_("First blood!"), _("First score!")), " ");
                }
                else if(spree == -2) // first victim
                {
-                       return normal_or_gentle(_("First victim! "), _("First casualty! "));
+                       return strcat(normal_or_gentle(_("First victim!"), _("First casualty!")), " ");
                }
        }
        return "";
@@ -555,7 +572,9 @@ string notif_arg_spree_inf(float type, string input, string player, float spree)
                                if(spree > 1)
                                {
                                        #define SPREE_ITEM(counta,countb,center,normal,gentle) \
-                                               case counta: { return sprintf(CCR(normal_or_gentle(normal, gentle)), player, spree_newline); }
+                                               case counta: \
+                                                       return sprintf(CCR(strcat(normal_or_gentle(normal, gentle), " %s^BG")), \
+                                                               player, spree_newline);
 
                                        switch(spree)
                                        {
@@ -566,10 +585,10 @@ string notif_arg_spree_inf(float type, string input, string player, float spree)
                                                        {
                                                                return
                                                                        sprintf(
-                                                                               CCR(normal_or_gentle(
-                                                                                       _("%s^K1 has %d frags in a row! %s^BG"),
-                                                                                       _("%s^K1 made %d scores in a row! %s^BG")
-                                                                               )),
+                                                                               CCR(strcat(normal_or_gentle(
+                                                                                       _("%s^K1 has %d frags in a row!"),
+                                                                                       _("%s^K1 made %d scores in a row!")
+                                                                                       ), " %s^BG")),
                                                                                player,
                                                                                spree,
                                                                                spree_newline
@@ -585,10 +604,10 @@ string notif_arg_spree_inf(float type, string input, string player, float spree)
                                {
                                        return
                                                sprintf(
-                                                       CCR(normal_or_gentle(
-                                                               _("%s^K1 drew first blood! %s^BG"),
-                                                               _("%s^K1 got the first score! %s^BG")
-                                                       )),
+                                                       CCR(strcat(normal_or_gentle(
+                                                               _("%s^K1 drew first blood!"),
+                                                               _("%s^K1 got the first score!")
+                                                               ), " %s^BG")),
                                                        player,
                                                        spree_newline
                                                );
@@ -632,20 +651,11 @@ string notif_arg_spree_inf(float type, string input, string player, float spree)
 
 string notif_arg_item_wepammo(float f1, float f2)
 {
-       string ammoitems = "";
        Weapon wep = REGISTRY_GET(Weapons, f1);
-       // TODO: registry handles
-       switch (wep.ammo_type)
-       {
-               case RES_SHELLS:  ammoitems = ITEM_Shells.m_name;      break;
-               case RES_BULLETS: ammoitems = ITEM_Bullets.m_name;     break;
-               case RES_ROCKETS: ammoitems = ITEM_Rockets.m_name;     break;
-               case RES_CELLS:   ammoitems = ITEM_Cells.m_name;       break;
-               case RES_PLASMA:  ammoitems = ITEM_Plasma.m_name;      break;
-               case RES_FUEL:    ammoitems = ITEM_JetpackFuel.m_name; break;
-               default: return ""; // doesn't use ammo
-       }
-       return sprintf(_(" with %d %s"), f2, ammoitems);
+       if(wep.ammo_type == RES_NONE)
+               return ""; // doesn't use ammo
+       // example for translators: You dropped the Vortex with 5 cells
+       return sprintf(_(" with %d %s"), f2, strtolower(wep.ammo_type.m_name));
 }
 
 
@@ -667,6 +677,7 @@ string notif_arg_item_wepammo(float f1, float f2)
 .string nent_snd;
 .float nent_vol;
 .float nent_position;
+.float nent_queuetime;
 
 // MSG_INFO and MSG_CENTER entity values
 .string nent_args; // used by both
@@ -701,7 +712,7 @@ string notif_arg_item_wepammo(float f1, float f2)
 
 REGISTRY(Notifications, BITS(11))
 REGISTER_REGISTRY(Notifications)
-REGISTRY_SORT(Notifications);
+REGISTRY_SORT(Notifications)
 
 REGISTRY_DEFINE_GET(Notifications, NULL)
 STATIC_INIT(Notifications) { FOREACH(Notifications, true, it.m_id = i); }
@@ -745,21 +756,22 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
        return it;
 }
 
-#define MSG_ANNCE_NOTIF_TEAM(teamnum, name, cvarname, defaultvalue, sound, channel, volume, position) \
-       MSG_ANNCE_NOTIF_(teamnum, ANNCE_##name, ANNCE_##cvarname, defaultvalue, sound, channel, volume, position)
+#define MSG_ANNCE_NOTIF_TEAM(teamnum, name, cvarname, defaultvalue, sound, channel, volume, position, queuetime) \
+       MSG_ANNCE_NOTIF_(teamnum, ANNCE_##name, ANNCE_##cvarname, defaultvalue, sound, channel, volume, position, queuetime)
 
-#define MSG_ANNCE_NOTIF(name, defaultvalue, sound, channel, volume, position) \
+#define MSG_ANNCE_NOTIF(name, defaultvalue, sound, channel, volume, position, queuetime) \
        NOTIF_ADD_AUTOCVAR(ANNCE_##name, defaultvalue) \
-       MSG_ANNCE_NOTIF_(0, ANNCE_##name, ANNCE_##name, defaultvalue, sound, channel, volume, position)
+       MSG_ANNCE_NOTIF_(0, ANNCE_##name, ANNCE_##name, defaultvalue, sound, channel, volume, position, queuetime)
 
-#define MSG_ANNCE_NOTIF_(teamnum, name, cvarname, defaultvalue, sound, channel, volume, position) \
+#define MSG_ANNCE_NOTIF_(teamnum, name, cvarname, defaultvalue, sound, channel, volume, position, queuetime) \
        REGISTER(Notifications, name, m_id, new_pure(msg_annce_notification)) { \
                Create_Notification_Entity      (this, defaultvalue, ACVNN(cvarname), MSG_ANNCE, strtoupper(#name), teamnum); \
                Create_Notification_Entity_Annce(this, ACVNN(cvarname), strtoupper(#name), \
-                       channel,   /* channel  */ \
-                       sound,     /* snd      */ \
-                       volume,    /* vol      */ \
-                       position); /* position */ \
+                       channel,    /* channel   */ \
+                       sound,      /* snd       */ \
+                       volume,     /* vol       */ \
+                       position,   /* position  */ \
+                       queuetime); /* queuetime */ \
        }
 
 #define MSG_INFO_NOTIF_TEAM(teamnum, name, cvarname, defaultvalue, strnum, flnum, args, hudargs, icon, normal, gentle) \