clientside announcers, patch by Taoki with some minor tweaks
authorfruitiex <fruitiex@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Tue, 9 Feb 2010 13:37:45 +0000 (13:37 +0000)
committerfruitiex <fruitiex@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Tue, 9 Feb 2010 13:37:45 +0000 (13:37 +0000)
git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8627 f962a42d-fe04-0410-a3ab-8c8b0445ebaa

64 files changed:
data/defaultNexuiz.cfg
data/qcsrc/client/Defs.qc
data/qcsrc/client/Main.qc
data/qcsrc/client/View.qc
data/qcsrc/client/miscfunctions.qc
data/qcsrc/common/constants.qh
data/qcsrc/menu/menu.qc
data/qcsrc/server/arena.qc
data/qcsrc/server/cl_client.qc
data/qcsrc/server/clientcommands.qc
data/qcsrc/server/defs.qh
data/qcsrc/server/g_damage.qc
data/qcsrc/server/g_world.qc
data/qcsrc/server/miscfunctions.qc
data/qcsrc/server/portals.qc
data/qcsrc/server/t_items.qc
data/qcsrc/server/w_common.qc
data/qcsrc/server/w_electro.qc
data/qcsrc/server/w_grenadelauncher.qc
data/qcsrc/server/w_minstanex.qc
data/qcsrc/server/w_nex.qc
data/qcsrc/server/w_rocketlauncher.qc
data/sound/announcer/default/03kills.ogg [moved from data/sound/announcer/male/03kills.ogg with 100% similarity]
data/sound/announcer/default/05kills.ogg [moved from data/sound/announcer/male/05kills.ogg with 100% similarity]
data/sound/announcer/default/1.ogg [moved from data/sound/announcer/robotic/1.ogg with 100% similarity]
data/sound/announcer/default/10.ogg [moved from data/sound/announcer/robotic/10.ogg with 100% similarity]
data/sound/announcer/default/10kills.ogg [moved from data/sound/announcer/male/10kills.ogg with 100% similarity]
data/sound/announcer/default/15kills.ogg [moved from data/sound/announcer/male/15kills.ogg with 100% similarity]
data/sound/announcer/default/1fragleft.ogg [moved from data/sound/announcer/robotic/1fragleft.ogg with 100% similarity]
data/sound/announcer/default/1minuteremains.ogg [moved from data/sound/announcer/robotic/1minuteremains.ogg with 100% similarity]
data/sound/announcer/default/2.ogg [moved from data/sound/announcer/robotic/2.ogg with 100% similarity]
data/sound/announcer/default/20kills.ogg [moved from data/sound/announcer/male/20kills.ogg with 100% similarity]
data/sound/announcer/default/25kills.ogg [moved from data/sound/announcer/male/25kills.ogg with 100% similarity]
data/sound/announcer/default/2fragsleft.ogg [moved from data/sound/announcer/robotic/2fragsleft.ogg with 100% similarity]
data/sound/announcer/default/3.ogg [moved from data/sound/announcer/robotic/3.ogg with 100% similarity]
data/sound/announcer/default/30kills.ogg [moved from data/sound/announcer/male/30kills.ogg with 100% similarity]
data/sound/announcer/default/3fragsleft.ogg [moved from data/sound/announcer/robotic/3fragsleft.ogg with 100% similarity]
data/sound/announcer/default/4.ogg [moved from data/sound/announcer/robotic/4.ogg with 100% similarity]
data/sound/announcer/default/5.ogg [moved from data/sound/announcer/robotic/5.ogg with 100% similarity]
data/sound/announcer/default/5minutesremain.ogg [moved from data/sound/announcer/robotic/5minutesremain.ogg with 100% similarity]
data/sound/announcer/default/6.ogg [moved from data/sound/announcer/robotic/6.ogg with 100% similarity]
data/sound/announcer/default/7.ogg [moved from data/sound/announcer/robotic/7.ogg with 100% similarity]
data/sound/announcer/default/8.ogg [moved from data/sound/announcer/robotic/8.ogg with 100% similarity]
data/sound/announcer/default/9.ogg [moved from data/sound/announcer/robotic/9.ogg with 100% similarity]
data/sound/announcer/default/airshot.ogg [moved from data/sound/announcer/male/airshot.ogg with 100% similarity]
data/sound/announcer/default/amazing.ogg [moved from data/sound/announcer/male/amazing.ogg with 100% similarity]
data/sound/announcer/default/awesome.ogg [moved from data/sound/announcer/male/awesome.ogg with 100% similarity]
data/sound/announcer/default/begin.ogg [moved from data/sound/announcer/robotic/begin.ogg with 100% similarity]
data/sound/announcer/default/blueteamtakeslead.ogg [moved from data/sound/announcer/robotic/blueteamtakeslead.ogg with 100% similarity]
data/sound/announcer/default/botlike.ogg [moved from data/sound/announcer/male/botlike.ogg with 100% similarity]
data/sound/announcer/default/electrobitch.ogg [moved from data/sound/announcer/male/electrobitch.ogg with 100% similarity]
data/sound/announcer/default/headshot.ogg [moved from data/sound/announcer/male/headshot.ogg with 100% similarity]
data/sound/announcer/default/impressive.ogg [moved from data/sound/announcer/male/impressive.ogg with 100% similarity]
data/sound/announcer/default/lastsecond.ogg [moved from data/sound/announcer/robotic/lastsecond.ogg with 100% similarity]
data/sound/announcer/default/leadgained.ogg [moved from data/sound/announcer/robotic/leadgained.ogg with 100% similarity]
data/sound/announcer/default/leadlost.ogg [moved from data/sound/announcer/robotic/leadlost.ogg with 100% similarity]
data/sound/announcer/default/leadtied.ogg [moved from data/sound/announcer/robotic/leadtied.ogg with 100% similarity]
data/sound/announcer/default/narrowly.ogg [moved from data/sound/announcer/robotic/narrowly.ogg with 100% similarity]
data/sound/announcer/default/prepareforbattle.ogg [moved from data/sound/announcer/robotic/prepareforbattle.ogg with 100% similarity]
data/sound/announcer/default/redteamtakeslead.ogg [moved from data/sound/announcer/robotic/redteamtakeslead.ogg with 100% similarity]
data/sound/announcer/default/terminated.ogg [moved from data/sound/announcer/robotic/terminated.ogg with 100% similarity]
data/sound/announcer/default/timeoutcalled.ogg [moved from data/sound/announcer/robotic/timeoutcalled.ogg with 100% similarity]
data/sound/announcer/default/welcome.ogg [moved from data/sound/announcer/male/welcome.ogg with 100% similarity]
data/sound/announcer/default/yoda.ogg [moved from data/sound/announcer/male/yoda.ogg with 100% similarity]

index 01e460e..72ec433 100644 (file)
@@ -866,6 +866,7 @@ seta cl_sound_maptime_warning "1" "play announcer sound telling you the remainin
 seta cl_notify_carried_items "3" "notify you of carried items when you obtain them (e.g. flags in CTF) - 0: disabled, 1: notify of taken items, 2: notify of picking up dropped items, 3: notify of both"
 
 seta cl_hitsound 1 "play a hit notifier sound when you have hit an enemy"
+seta cl_announcer default "name of the announcer you wish to use from data/sound/announcer"
 
 // startmap_dm is used when running with the -listen or -dedicated commandline options
 set serverconfig server.cfg
index e726602..8020d1a 100644 (file)
@@ -178,6 +178,9 @@ float               sbar_currentammo;
 float vid_conwidth, vid_conheight;
 float binddb;
 
+//     Announcer
+string announce_snd;
+
 // QUALIFYING
 float race_checkpoint;
 float race_time;
index 8c7c711..53e12d9 100644 (file)
@@ -42,6 +42,7 @@ float __engine_check;
 #endif
 
 string forcefog;
+string cl_announcer_prev;
 void WaypointSprite_Load();
 void CSQC_Init(void)
 {
@@ -128,11 +129,17 @@ void CSQC_Init(void)
 
        WaypointSprite_Load();
 
+       // precaches
        Projectile_Precache();
        GibSplash_Precache();
        Casings_Precache();
        DamageInfo_Precache();
-       Announcer_Precache();
+       if(cvar_string("cl_announcer") != cl_announcer_prev) {
+               Announcer_Precache();
+               if(cl_announcer_prev)
+                       strunzone(cl_announcer_prev);
+               cl_announcer_prev = strzone(cvar_string("cl_announcer"));
+       }
        Tuba_Precache();
 
 #ifdef UID
@@ -1251,14 +1258,18 @@ float CSQC_Parse_TempEntity()
                        Net_VoteDialogReset();
                        bHandled = true;
                        break;
-        case TE_CSQC_LIGHTNINGARC:
-            Net_ReadLightningarc();
-            bHandled = true;
-            break;
-        case TE_CSQC_PINGPLREPORT:
-            Net_ReadPingPLReport();
-            bHandled = true;
-            break;
+               case TE_CSQC_LIGHTNINGARC:
+                       Net_ReadLightningarc();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_PINGPLREPORT:
+                       Net_ReadPingPLReport();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_ANNOUNCE:
+                       announce_snd = strzone(ReadString());
+                       bHandled = true;
+                       break;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
                        bHandled = false;
index 2916189..f404cec 100644 (file)
@@ -102,7 +102,7 @@ void CheckForGamestartChange() {
        if (previous_game_starttime != startTime) {
                if ((time + 5.0) < startTime) {
                        //if connecting to server while restart was active don't always play prepareforbattle
-                       sound(self, CHAN_VOICE, "announcer/robotic/prepareforbattle.wav", VOL_BASEVOICE, ATTN_NONE);
+                       sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/prepareforbattle.wav"), VOL_BASEVOICE, ATTN_NONE);
                }
                if (time < startTime) {
                        restartAnnouncer = spawn();
@@ -410,6 +410,7 @@ void CSQC_UpdateView(float w, float h)
                }
 
        CheckForGamestartChange();
+       serverAnnouncer();
        maptimeAnnouncer();
        carrierAnnouncer();
 
index d88af42..63f0faf 100644 (file)
@@ -3,6 +3,17 @@ var float(string text, float handleColors, vector fontSize) stringwidth;
 entity players;
 entity teams;
 
+void serverAnnouncer()
+{
+       // check for pending announcement, play it and remove it
+       if(announce_snd != "")
+       {
+               sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/", announce_snd, ".wav"), VOL_BASEVOICE, ATTN_NONE);
+               strunzone(announce_snd);
+               announce_snd = "";
+       }
+}
+
 void restartAnnouncer_Think() {
        float countdown_rounded, countdown;
        countdown = getstatf(STAT_GAMESTARTTIME) - time;
@@ -11,7 +22,7 @@ void restartAnnouncer_Think() {
                if (!spectatee_status) //do cprint only for players
                        centerprint("^1Begin!");
 
-               sound(self, CHAN_VOICE, "announcer/robotic/begin.wav", VOL_BASEVOICE, ATTN_NONE);
+               sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/begin.wav"), VOL_BASEVOICE, ATTN_NONE);
                //reset maptime announcers now as well
                announcer_5min = announcer_1min = FALSE;
 
@@ -23,7 +34,7 @@ void restartAnnouncer_Think() {
                        centerprint(strcat("^1Game starts in ", ftos(countdown_rounded), " seconds"));
 
                if(countdown_rounded <= 3 && countdown_rounded >= 1) {
-                       sound(self, CHAN_VOICE, strcat("announcer/robotic/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE);
+                       sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE);
                }
 
                self.nextthink = getstatf(STAT_GAMESTARTTIME) - (countdown - 1);
@@ -61,7 +72,7 @@ void maptimeAnnouncer() {
         if not (warmuplimit == -1 && warmup_stage) {
                        announcer_5min = TRUE;
                        //dprint("i will play the sound, I promise!\n");
-                       sound(self, CHAN_VOICE, "announcer/robotic/5minutesremain.wav", VOL_BASEVOICE, ATTN_NONE);
+                       sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/5minutesremain.wav"), VOL_BASEVOICE, ATTN_NONE);
                }
     }
 
@@ -76,7 +87,7 @@ void maptimeAnnouncer() {
        //if we're in warmup mode, check whether there's a warmup timelimit
        if not (warmuplimit == -1 && warmup_stage) {
                        announcer_1min = TRUE;
-                       sound(self, CHAN_VOICE, "announcer/robotic/1minuteremains.wav", VOL_BASEVOICE, ATTN_NONE);
+                       sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/1minuteremains.wav"), VOL_BASEVOICE, ATTN_NONE);
        }
        }
 }
@@ -125,18 +136,51 @@ void carrierAnnouncer() {
        redflag_prev = redflag;
 }
 
-/**
-  * Add all future announcer sounds precaches here.
-  * TODO: make all announcer sound() calls client-side in the end, to allow queues etc.
-  */
-
 /**
  * Add all future announcer sounds precaches here.
- * TODO: make all announcer sound() calls client-side in the end, to allow queues etc.
+ * TODO: announcer queues
  */
 void Announcer_Precache () {
-    precache_sound ("announcer/robotic/1minuteremains.wav");
-       precache_sound ("announcer/robotic/5minutesremain.wav");
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/1minuteremains.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/5minutesremain.wav"));
+
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/electrobitch.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/airshot.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/03kills.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/05kills.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/10kills.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/15kills.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/20kills.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/25kills.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/30kills.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/botlike.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/yoda.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/amazing.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/awesome.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/headshot.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/impressive.wav"));
+
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/prepareforbattle.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/begin.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/timeoutcalled.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/1fragleft.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/2fragsleft.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/3fragsleft.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/terminated.wav"));
+
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/1.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/2.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/3.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/4.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/5.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/6.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/7.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/8.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/9.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/10.wav"));
+
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/lastsecond.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/narrowly.wav"));
 }
 
 void AuditLists()
index 01e0de8..da59cbe 100644 (file)
@@ -55,6 +55,7 @@ const float TE_CSQC_TEAMNAGGER = 106;
 const float TE_CSQC_PINGPLREPORT = 107;
 const float TE_CSQC_VOTE = 108;
 const float TE_CSQC_VOTERESET = 109;
+const float TE_CSQC_ANNOUNCE = 110;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;
index e2a7f39..bec77b4 100644 (file)
@@ -554,7 +554,7 @@ void() m_draw =
                if(Menu_Active)
                if(!cvar("menu_video_played"))
                {
-                       localcmd("set menu_video_played 1; cd loop $menu_cdtrack; play sound/announcer/male/welcome.ogg\n");
+                       localcmd("set menu_video_played 1; cd loop $menu_cdtrack; play sound/announcer/default/welcome.ogg\n");
                        menuLogoAlpha = -0.8; // no idea why, but when I start this at zero, it jumps instead of fading
                }
        }
index 4e100eb..ff193f8 100644 (file)
@@ -215,13 +215,13 @@ void Arena_Warmup()
                        //centerprint(self, strcat("Round will start in ", ftos(f),"\n"));
                        roundStartTime_prev = f;
                        if(f == 5)
-                               play2all("announcer/robotic/prepareforbattle.wav");
+                               Announce("prepareforbattle");
                        else if(f == 3)
-                               play2all("announcer/robotic/3.wav");
+                               Announce("3");
                        else if(f == 2)
-                               play2all("announcer/robotic/2.wav");
+                               Announce("2");
                        else if(f == 1)
-                               play2all("announcer/robotic/1.wav");
+                               Announce("1");
 
                        centerprint(self, msg);
                }
@@ -240,7 +240,7 @@ void Arena_Warmup()
        else if(f > -1 && f != roundStartTime_prev)
        {
                roundStartTime_prev = f;
-               play2all("announcer/robotic/begin.wav");
+               Announce("begin");
                centerprint(self, "^1Begin!\n");        
 
                if(g_ca) {
index 1227e33..6b60833 100644 (file)
@@ -6,6 +6,19 @@ void send_CSQC_teamnagger() {
        WriteByte(0, TE_CSQC_TEAMNAGGER);
 }
 
+void Announce(string snd) {
+       WriteByte(MSG_ALL, SVC_TEMPENTITY);
+       WriteByte(MSG_ALL, TE_CSQC_ANNOUNCE);
+       WriteString(MSG_ALL, snd);
+}
+
+void AnnounceTo(entity e, string snd) {
+       msg_entity = e;
+       WriteByte(MSG_ONE, SVC_TEMPENTITY);
+       WriteByte(MSG_ONE, TE_CSQC_ANNOUNCE);
+       WriteString(MSG_ONE, snd);
+}
+
 float ClientData_Send(entity to, float sf)
 {
        if(to != self.owner)
@@ -1148,7 +1161,7 @@ void KillIndicator_Think()
                if(clienttype(self.owner) == CLIENTTYPE_REAL)
                {
                        if(self.cnt <= 10)
-                               announce(self.owner, strcat("announcer/robotic/", ftos(self.cnt), ".wav"));
+                               AnnounceTo(self.owner, strcat(ftos(self.cnt), ""));
                        if(self.owner.killindicator_teamchange)
                        {
                                if(self.owner.killindicator_teamchange == -1)
@@ -2197,7 +2210,7 @@ void ShowRespawnCountdown()
                {
                        self.respawn_countdown = number - 1;
                        if(ceil(self.death_time - (time + 0.5)) == number) // only say it if it is the same number even in 0.5s; to prevent overlapping sounds
-                               announce(self, strcat("announcer/robotic/", ftos(number), ".wav"));
+                               AnnounceTo(self, strcat(ftos(number), ""));
                }
        }
 }
@@ -2791,7 +2804,7 @@ void PlayerPostThink (void)
                if(timeleft <= 0)
                {
                        bprint("^3", self.netname, "^3 was kicked for idling.\n");
-                       announce(self, "announcer/robotic/terminated.wav");
+                       AnnounceTo(self, "terminated");
                        dropclient(self);
                        return;
                }
@@ -2800,7 +2813,7 @@ void PlayerPostThink (void)
                        if(timeleft != self.idlekick_lasttimeleft)
                        {
                                centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat("^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
-                               announce(self, strcat("announcer/robotic/", ftos(timeleft), ".wav"));
+                               AnnounceTo(self, strcat(ftos(timeleft), ""));
                        }
                }
                else
index 883e83f..46c912f 100644 (file)
@@ -585,7 +585,7 @@ void evaluateTimeout() {
        timeoutHandler.nextthink = time; //always let the entity think asap
 
        //inform all connected clients about the timeout call
-       play2all("announcer/robotic/timeoutcalled.wav");
+       Announce("timeoutcalled");
 }
 
 /**
index f18fcb9..b97fefd 100644 (file)
@@ -337,6 +337,9 @@ float sv_loddistance2;
 .float cvar_cl_gunalign;
 .float cvar_cl_noantilag;
 
+void Announce(string snd);
+void AnnounceTo(entity e, string snd);
+
 .float version_nagtime;
 
 .float modelindex_lod0;
index 4b5fa6c..e4779dd 100644 (file)
@@ -485,7 +485,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                                bprint (a,"^7 made a ^1TRIPLE SCORE\n");
                                        } else {
                                                bprint (a,"^7 made a ^1TRIPLE FRAG\n");
-                                               announce(attacker, "announcer/male/03kills.wav");
+                                               AnnounceTo(attacker, "03kills");
                                        }
                                }
                                else if (attacker.killcount == 5)
@@ -494,7 +494,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                                bprint (a,"^7 unleashes ^1SCORING RAGE\n");
                                        } else {
                                                bprint (a,"^7 unleashes ^1RAGE\n");
-                                               announce(attacker, "announcer/male/05kills.wav");
+                                               AnnounceTo(attacker, "05kills");
                                        }
                                }
                                else if (attacker.killcount == 10)
@@ -503,7 +503,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                                bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
                                        } else {
                                                bprint (a,"^7 starts the ^1MASSACRE!\n");
-                                               announce(attacker, "announcer/male/10kills.wav");
+                                               AnnounceTo(attacker, "10kills");
                                        }
                                }
                                else if (attacker.killcount == 15)
@@ -512,7 +512,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                                bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
                                        } else {
                                                bprint (a,"^7 executes ^1MAYHEM!\n");
-                                               announce(attacker, "announcer/male/15kills.wav");
+                                               AnnounceTo(attacker, "15kills");
                                        }
                                }
                                else if (attacker.killcount == 20)
@@ -521,7 +521,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                                bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
                                        } else {
                                                bprint (a,"^7 is a ^1BERSERKER!\n");
-                                               announce(attacker, "announcer/male/20kills.wav");
+                                               AnnounceTo(attacker, "20kills");
                                        }
                                }
                                else if (attacker.killcount == 25)
@@ -530,7 +530,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                                bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
                                        } else {
                                                bprint (a,"^7 inflicts ^1CARNAGE!\n");
-                                               announce(attacker, "announcer/male/25kills.wav");
+                                               AnnounceTo(attacker, "25kills");
                                        }
                                }
                                else if (attacker.killcount == 30)
@@ -539,7 +539,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                                bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
                                        } else {
                                                bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
-                                               announce(attacker, "announcer/male/30kills.wav");
+                                               AnnounceTo(attacker, "30kills");
                                        }
                                }
                        }
@@ -593,7 +593,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
                                        bprint ("^1",s, "^1 died\n");
                        GiveFrags(targ, targ, -1);
                        if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
-                               announce(targ, "announcer/male/botlike.wav");
+                               AnnounceTo(targ, "botlike");
                        }
 
                        if (targ.killcount > 2)
index 544f46d..1b79380 100644 (file)
@@ -140,7 +140,7 @@ void timeoutHandler_Think() {
                                }
                        }
                        if(remainingTimeoutTime == cvar("sv_timeout_resumetime")) { //play a warning sound when only <sv_timeout_resumetime> seconds are left
-                               play2all("announcer/robotic/prepareforbattle.wav");
+                               Announce("prepareforbattle");
                        }
                        remainingTimeoutTime -= 1;
                        self.nextthink = time + TIMEOUT_SLOWMO_VALUE;
@@ -1756,11 +1756,11 @@ float WinningCondition_Scores(float limit, float leadlimit)
 
                        if (limit)
                        if (leaderfrags == limit - 1)
-                               play2all("announcer/robotic/1fragleft.wav");
+                               Announce("1fragleft");
                        else if (leaderfrags == limit - 2)
-                               play2all("announcer/robotic/2fragsleft.wav");
+                               Announce("2fragsleft");
                        else if (leaderfrags == limit - 3)
-                               play2all("announcer/robotic/3fragsleft.wav");
+                               Announce("3fragsleft");
                }
        }
 
index 3a8cf78..c4d772e 100644 (file)
@@ -1509,27 +1509,16 @@ void play2(entity e, string filename)
     soundtoat(MSG_ONE, world, '0 0 0', CHAN_AUTO, filename, VOL_BASE, ATTN_NONE);
 }
 
-.float announcetime;
-float announce(entity player, string msg)
-{
-    if (time > player.announcetime)
-        if (clienttype(player) == CLIENTTYPE_REAL)
-        {
-            player.announcetime = time + 0.8;
-            play2(player, msg);
-            return TRUE;
-        }
-    return FALSE;
-}
 // use this one if you might be causing spam (e.g. from touch functions that might get called more than once per frame)
+.float spamtime;
 float spamsound(entity e, float chan, string samp, float vol, float atten)
 {
     if (!sound_allowed(MSG_BROADCAST, e))
         return FALSE;
 
-    if (time > e.announcetime)
+    if (time > e.spamtime)
     {
-        e.announcetime = time;
+        e.spamtime = time;
         sound(e, chan, samp, vol, atten);
         return TRUE;
     }
@@ -1692,37 +1681,6 @@ void precache()
     if (g_jetpack)
         precache_sound ("misc/jetpack_fly.wav");
 
-    // announcer sounds - male
-    precache_sound ("announcer/male/electrobitch.wav");
-    precache_sound ("announcer/male/airshot.wav");
-    precache_sound ("announcer/male/03kills.wav");
-    precache_sound ("announcer/male/05kills.wav");
-    precache_sound ("announcer/male/10kills.wav");
-    precache_sound ("announcer/male/15kills.wav");
-    precache_sound ("announcer/male/20kills.wav");
-    precache_sound ("announcer/male/25kills.wav");
-    precache_sound ("announcer/male/30kills.wav");
-    precache_sound ("announcer/male/botlike.wav");
-    precache_sound ("announcer/male/yoda.wav");
-    precache_sound ("announcer/male/amazing.wav");
-    precache_sound ("announcer/male/awesome.wav");
-    precache_sound ("announcer/male/headshot.wav");
-    precache_sound ("announcer/male/impressive.wav");
-
-    // announcer sounds - robotic
-    precache_sound ("announcer/robotic/prepareforbattle.wav");
-    precache_sound ("announcer/robotic/begin.wav");
-    precache_sound ("announcer/robotic/timeoutcalled.wav");
-    precache_sound ("announcer/robotic/1fragleft.wav");
-    precache_sound ("announcer/robotic/2fragsleft.wav");
-    precache_sound ("announcer/robotic/3fragsleft.wav");
-    precache_sound ("announcer/robotic/terminated.wav");
-    if (g_minstagib)
-    {
-        precache_sound ("announcer/robotic/lastsecond.wav");
-        precache_sound ("announcer/robotic/narrowly.wav");
-    }
-
     precache_model ("models/sprites/0.spr32");
     precache_model ("models/sprites/1.spr32");
     precache_model ("models/sprites/2.spr32");
@@ -1734,16 +1692,6 @@ void precache()
     precache_model ("models/sprites/8.spr32");
     precache_model ("models/sprites/9.spr32");
     precache_model ("models/sprites/10.spr32");
-    precache_sound ("announcer/robotic/1.wav");
-    precache_sound ("announcer/robotic/2.wav");
-    precache_sound ("announcer/robotic/3.wav");
-    precache_sound ("announcer/robotic/4.wav");
-    precache_sound ("announcer/robotic/5.wav");
-    precache_sound ("announcer/robotic/6.wav");
-    precache_sound ("announcer/robotic/7.wav");
-    precache_sound ("announcer/robotic/8.wav");
-    precache_sound ("announcer/robotic/9.wav");
-    precache_sound ("announcer/robotic/10.wav");
 
     // common weapon precaches
     precache_sound ("weapons/weapon_switch.wav");
index 96b6cb4..cedf344 100644 (file)
@@ -164,7 +164,7 @@ float Portal_TeleportPlayer(entity teleporter, entity player)
        {
                // telefrag within 1 second of portal creation = amazing
                if(time < teleporter.teleport_time + 1)
-                       announce(player, "announcer/male/amazing.wav");
+                       AnnounceTo(player, "amazing");
        }
 
        if not(teleporter.enemy)
index d4428c9..a1ec70f 100644 (file)
@@ -273,13 +273,13 @@ float Item_GiveTo(entity item, entity player)
                                if (clienttype(player) == CLIENTTYPE_REAL)
                                {
                                        if(player.health <= 5)
-                                               play2(player, "announcer/robotic/lastsecond.wav");
+                                               AnnounceTo(player, "lastsecond");
                                        else if(player.health < 50)
-                                               play2(player, "announcer/robotic/narrowly.wav");
+                                               AnnounceTo(player, "narrowly");
                                }
                                // sound not available
                                // else if(item.items == IT_CELLS)
-                               //      play2(player, "announce/robotic/ammo.wav");
+                               //      AnnounceTo(player, "ammo");
 
                                if (item.weapons & WEPBIT_MINSTANEX)
                                        W_GiveWeapon (player, WEP_MINSTANEX, "Nex");
@@ -293,7 +293,7 @@ float Item_GiveTo(entity item, entity player)
                        {
                                pickedup = TRUE;
                                // sound not available
-                               // play2(player, "announce/robotic/extra.ogg\nplay2 announce/robotic/_lives.wav");
+                               // AnnounceTo(player, "_lives");
                                player.armorvalue = player.armorvalue + cvar("g_minstagib_extralives");
                                sprint(player, "^3You picked up some extra lives\n");
                        }
@@ -303,7 +303,7 @@ float Item_GiveTo(entity item, entity player)
                        {
                                pickedup = TRUE;
                                // sound not available
-                               // play2(player, "announce/robotic/invisible.wav");
+                               // AnnounceTo(player, "invisible");
                                player.strength_finished = max(player.strength_finished, time) + cvar("g_balance_powerup_strength_time");
                        }
 
@@ -312,7 +312,7 @@ float Item_GiveTo(entity item, entity player)
                        {
                                pickedup = TRUE;
                                // sound not available
-                               // play2(player, "announce/robotic/speed.wav");
+                               // AnnounceTo(player, "speed");
                                player.invincible_finished = max(player.invincible_finished, time) + cvar("g_balance_powerup_strength_time");
                        }
 
index e0ba807..0f565ad 100644 (file)
@@ -190,9 +190,9 @@ void W_BallisticBullet_Hit (void)
                if(self.dmg_edge != 0)
                {
                        if(headshot)
-                               announce(self.owner, "announcer/male/headshot.wav");
+                               AnnounceTo(self.owner, "headshot");
                        if(yoda)
-                               announce(self.owner, "announcer/male/awesome.wav");
+                               AnnounceTo(self.owner, "awesome");
                }
 
                // calculate hits for ballistic weapons
index ff5446f..b8f5b28 100644 (file)
@@ -37,7 +37,7 @@ void W_Plasma_Explode (void)
                        if(IsDifferentTeam(self.owner, other))
                                if(other.deadflag == DEAD_NO)
                                        if(IsFlying(other))
-                                               announce(self.owner, "announcer/male/electrobitch.wav");
+                                               AnnounceTo(self.owner, "electrobitch");
 
        self.event_damage = SUB_Null;
        self.takedamage = DAMAGE_NO;
index 31fa998..a9e8a6b 100644 (file)
@@ -8,7 +8,7 @@ void W_Grenade_Explode (void)
                        if(IsDifferentTeam(self.owner, other))
                                if(other.deadflag == DEAD_NO)
                                        if(IsFlying(other))
-                                               announce(self.owner, "announcer/male/airshot.wav");
+                                               AnnounceTo(self.owner, "airshot");
 
        self.event_damage = SUB_Null;
        self.takedamage = DAMAGE_NO;
@@ -23,7 +23,7 @@ void W_Grenade_Explode2 (void)
                if(other.classname == "player")
                        if(IsDifferentTeam(self.owner, other))
                                if(IsFlying(other))
-                                       announce(self.owner, "announcer/male/airshot.wav");
+                                       AnnounceTo(self.owner, "airshot");
 
        self.event_damage = SUB_Null;
        self.takedamage = DAMAGE_NO;
index 089af24..52d099b 100644 (file)
@@ -18,20 +18,20 @@ void W_MinstaNex_Attack (void)
        if(g_minstagib)
        {
                if(yoda)
-                       announce(self, "announcer/male/yoda.wav");
+                       AnnounceTo(self, "yoda");
        }
        else
        {
                if(yoda && flying)
-                       announce(self, "announcer/male/yoda.wav");
+                       AnnounceTo(self, "yoda");
                if(headshot)
                {
-                       announce(self, "announcer/male/headshot.wav");
+                       AnnounceTo(self, "headshot");
                        print("h\n");
                }
                if(damage_goodhits && self.minstanex_lasthit)
                {
-                       if(announce(self, "announcer/male/impressive.wav"))
+                       if(AnnounceTo(self, "impressive"))
                                damage_goodhits = 0; // only every second time
                }
        }
@@ -100,68 +100,68 @@ void minstagib_ammocheck (void)
                {
                        centerprint(self, "you're dead now...\n");
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/terminated.wav");
+                       AnnounceTo(self, "terminated");
                }
                else if (self.health == 10)
                {
                        centerprint(self, "^11^7 second left to find some ammo\n");
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/1.wav");
+                       AnnounceTo(self, "1");
                }
                else if (self.health == 20)
                {
                        centerprint(self, "^12^7 seconds left to find some ammo\n");
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/2.wav");
+                       AnnounceTo(self, "2");
                }
                else if (self.health == 30)
                {
                        centerprint(self, "^13^7 seconds left to find some ammo\n");
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/3.wav");
+                       AnnounceTo(self, "3");
                }
                else if (self.health == 40)
                {
                        centerprint(self, "^14^7 seconds left to find some ammo\n");
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/4.wav");
+                       AnnounceTo(self, "4");
                }
                else if (self.health == 50)
                {
                        centerprint(self, "^15^7 seconds left to find some ammo\n");
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/5.wav");
+                       AnnounceTo(self, "5");
                }
                else if (self.health == 60)
                {
                        centerprint(self, "^36^7 seconds left to find some ammo\n");
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/6.wav");
+                       AnnounceTo(self, "6");
                }
                else if (self.health == 70)
                {
                        centerprint(self, "^37^7 seconds left to find some ammo\n");
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/7.wav");
+                       AnnounceTo(self, "7");
                }
                else if (self.health == 80)
                {
                        centerprint(self, "^38^7 seconds left to find some ammo\n");
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/8.wav");
+                       AnnounceTo(self, "8");
                }
                else if (self.health == 90)
                {
                        centerprint(self, "^39^7 seconds left to find some ammo\n");
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       announce(self, "announcer/robotic/9.wav");
+                       AnnounceTo(self, "9");
                }
                else if (self.health == 100)
                {
                        centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        if not(self.flags & FL_GODMODE)
-                               announce(self, "announcer/robotic/10.wav");
+                               AnnounceTo(self, "10");
                }
        }
        self.minstagib_nextthink = time + 1;
index 766fd62..eff82c3 100644 (file)
@@ -24,7 +24,7 @@ void W_Nex_Attack (void)
        FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, cvar("g_balance_nex_damage"), cvar("g_balance_nex_force"), cvar("g_balance_nex_damagefalloff_mindist"), cvar("g_balance_nex_damagefalloff_maxdist"), cvar("g_balance_nex_damagefalloff_halflife"), cvar("g_balance_nex_damagefalloff_forcehalflife"), WEP_NEX);
 
        if(yoda && flying)
-               announce(self, "announcer/male/yoda.wav");
+               AnnounceTo(self, "yoda");
 
        //beam and muzzle flash done on client
        SendCSQCNexBeamParticle();
index 97772e5..d43ad94 100644 (file)
@@ -21,7 +21,7 @@ void W_Rocket_Explode (void)
                if(other.classname == "player")
                        if(IsDifferentTeam(self.owner, other))
                                if(IsFlying(other))
-                                       announce(self.owner, "announcer/male/airshot.wav");
+                                       AnnounceTo(self.owner, "airshot");
 
        self.event_damage = SUB_Null;
        self.takedamage = DAMAGE_NO;