#include "voicescript.qh"
#ifdef SVQC
-.entity voicescript; // attached voice script
-.float voicescript_index; // index of next voice, or -1 to use the randomized ones
+.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
+.float voicescript_voiceend; // time when this voice ends
void target_voicescript_clear(entity pl)
{
void target_voicescript_use(entity this, entity actor, entity trigger)
{
- if(actor.voicescript != this)
- {
+ if (actor.voicescript != this) {
actor.voicescript = this;
actor.voicescript_index = 0;
actor.voicescript_nextthink = time + this.delay;
float i, n, dt;
vs = pl.voicescript;
- if(!vs)
+ if (!vs) {
return;
- if(vs.message == "")
+ }
+ if (vs.message == "") {
return;
- if (!IS_PLAYER(pl))
+ }
+ if (!IS_PLAYER(pl)) {
return;
- if(game_stopped)
+ }
+ if (game_stopped) {
return;
+ }
- if(time >= pl.voicescript_voiceend)
- {
- if(time >= pl.voicescript_nextthink)
- {
+ if (time >= pl.voicescript_voiceend) {
+ if (time >= pl.voicescript_nextthink) {
// get the next voice...
n = tokenize_console(vs.message);
- if(pl.voicescript_index < vs.cnt)
+ if (pl.voicescript_index < vs.cnt) {
i = pl.voicescript_index * 2;
- else if(n > vs.cnt * 2)
+ } else if (n > vs.cnt * 2) {
i = ((pl.voicescript_index - vs.cnt) % ((n - vs.cnt * 2 - 1) / 2)) * 2 + vs.cnt * 2 + 1;
- else
+ } else {
i = -1;
+ }
- if(i >= 0)
- {
+ if (i >= 0) {
play2(pl, strcat(vs.netname, "/", argv(i), ".wav"));
dt = stof(argv(i + 1));
- if(dt >= 0)
- {
+ if (dt >= 0) {
pl.voicescript_voiceend = time + dt;
pl.voicescript_nextthink = pl.voicescript_voiceend + vs.wait * (0.5 + random());
- }
- else
- {
+ } else {
pl.voicescript_voiceend = time - dt;
pl.voicescript_nextthink = pl.voicescript_voiceend;
}
pl.voicescript_index += 1;
- }
- else
- {
+ } else {
pl.voicescript = NULL; // stop trying then
}
}
n = tokenize_console(this.message);
this.cnt = n / 2;
- for(i = 0; i+1 < n; i += 2)
- {
- if(argv(i) == "*")
- {
+ for (i = 0; i + 1 < n; i += 2) {
+ if (argv(i) == "*") {
this.cnt = i / 2;
++i;
}