]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/target/voicescript.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / target / voicescript.qc
index 6dfb568a8b5bbddfbfc1d3c5f7e8f93e68de2a4b..bb836a92e7ff3074213fcccb7225b02286117ee5 100644 (file)
@@ -1,9 +1,9 @@
 #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)
 {
@@ -12,8 +12,7 @@ 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;
@@ -26,48 +25,45 @@ void target_voicescript_next(entity pl)
        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
                        }
                }
@@ -89,10 +85,8 @@ spawnfunc(target_voicescript)
 
        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;
                }