r5019 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Nov 8 15:25:47 EST 2008
Author: div0
Date: 2008-11-08 15:25:46 -0500 (Sat, 08 Nov 2008)
New Revision: 5019
Modified:
trunk/data/qcsrc/server/cl_client.qc
trunk/data/qcsrc/server/defs.qh
trunk/data/qcsrc/server/g_triggers.qc
Log:
target_voicescript beginnign
Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc 2008-11-08 17:18:13 UTC (rev 5018)
+++ trunk/data/qcsrc/server/cl_client.qc 2008-11-08 20:25:46 UTC (rev 5019)
@@ -789,6 +789,8 @@
centerprint(self, "You are defending!\n");
}
+ target_voicescript_clear(self);
+
} else if(self.classname == "observer") {
PutObserverInServer ();
}
@@ -2251,6 +2253,8 @@
self.pusher = oldpusher;
self = oldself;
}
+
+ target_voicescript_next(self);
}
Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh 2008-11-08 17:18:13 UTC (rev 5018)
+++ trunk/data/qcsrc/server/defs.qh 2008-11-08 20:25:46 UTC (rev 5019)
@@ -499,3 +499,6 @@
// reset to 0 on weapon switch
// may be useful to all weapons
.float bulletcounter;
+
+void target_voicescript_next(entity pl);
+void target_voicescript_clear(entity pl);
Modified: trunk/data/qcsrc/server/g_triggers.qc
===================================================================
--- trunk/data/qcsrc/server/g_triggers.qc 2008-11-08 17:18:13 UTC (rev 5018)
+++ trunk/data/qcsrc/server/g_triggers.qc 2008-11-08 20:25:46 UTC (rev 5019)
@@ -1242,3 +1242,92 @@
{
InitializeEntity(self, follow_init, INITPRIO_FINDTARGET);
}
+
+
+
+
+.entity voicescript; // attached voice script
+.float voicescript_index; // index of next voice, or -1 to use the randomized ones
+.float voicescript_nextthink; // time to play next voice
+.float voicescript_voiceend; // time when this voice ends
+
+void target_voicescript_clear(entity pl)
+{
+ pl.voicescript = world;
+}
+
+void target_voicescript_use()
+{
+ if(activator.voicescript != self)
+ {
+ activator.voicescript = self;
+ activator.voicescript_index = 0;
+ activator.voicescript_nextthink = time;
+ }
+}
+
+void target_voicescript_next(entity pl)
+{
+ entity vs;
+ float i, n;
+
+ vs = pl.voicescript;
+ if(!vs)
+ return;
+ if(vs.message == "")
+ return;
+ if(pl.classname != "player")
+ return;
+ if(gameover)
+ return;
+
+ if(time >= pl.voicescript_voiceend)
+ {
+ if(time >= pl.voicescript_nextthink)
+ {
+ // get the next voice...
+ n = tokenize_sane(vs.message);
+
+ if(pl.voicescript_index < vs.cnt)
+ i = pl.voicescript_index * 2;
+ else if(n > vs.cnt * 2)
+ i = mod(pl.voicescript_index - vs.cnt, (n - vs.cnt * 2 - 1) / 2) * 2 + vs.cnt * 2 + 1;
+ else
+ i = -1;
+
+ if(i >= 0)
+ {
+ play2(pl, strcat(vs.netname, "/", argv(i), ".wav"));
+ pl.voicescript_voiceend = time + stof(argv(i + 1));
+ }
+ else
+ pl.voicescript = world;
+
+ pl.voicescript_index += 1;
+ pl.voicescript_nextthink = pl.voicescript_voiceend + vs.wait * (0.5 + random());
+ }
+ }
+}
+
+void spawnfunc_target_voicescript()
+{
+ // netname: directory of the sound files
+ // message: list of "sound file" duration "sound file" duration, a *, and again a list
+ // foo1 4.1 foo2 4.0 foo3 3.1 * fool1 1.1 fool2 7.1 fool3 9.1 fool4 3.7
+ // wait: average time between messages
+
+ float i, n;
+ self.use = target_voicescript_use;
+
+ n = tokenize_sane(self.message);
+ self.cnt = n / 2;
+ for(i = 0; i+1 < n; i += 2)
+ {
+ if(argv(i) == "*")
+ {
+ self.cnt = i / 2;
+ ++i;
+ }
+ precache_sound(strcat(self.netname, "/", argv(i), ".wav"));
+ }
+}
More information about the nexuiz-commits
mailing list