]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
bot_cmd sound: allow to specify channel, volume, attenuation
authorRudolf Polzer <divverent@xonotic.org>
Wed, 17 Oct 2012 14:36:22 +0000 (16:36 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 17 Oct 2012 14:36:22 +0000 (16:36 +0200)
qcsrc/server/bot/scripting.qc

index 7e29160cfa54caad2800cc7f6f295cfca6c3b6e4..1642133e11ea2c0d52104c795b6db4b6b6355172 100644 (file)
@@ -32,16 +32,22 @@ void bot_queuecommand(entity bot, string cmdstring)
                string cmdstr;
 
                sp = strstrofs(cmdstring, " ", 0);
-               if(sp < 0)
-               {
-                       parm = "";
-               }
-               else
+               if(sp >= 0)
                {
                        parm = substring(cmdstring, sp + 1, -1);
                        cmdstr = substring(cmdstring, 0, sp);
                        if(cmdstr == "sound")
+                       {
+                               // find the LAST word
+                               for(;;)
+                               {
+                                       sp = strstrofs(parm, " ", 0);
+                                       if(sp < 0)
+                                               break;
+                                       parm = substring(parm, sp + 1, -1);
+                               }
                                precache_sound(parm);
+                       }
                }
        }
 
@@ -1091,8 +1097,24 @@ float bot_cmd_sound()
        string f;
        f = bot_cmd.bot_cmd_parm_string;
 
+       float n = tokenizebyseparator(f, " ");
+
+       string sample = f;
+       float chan = CH_WEAPON_B;
+       float vol = VOL_BASE;
+       float atten = ATTN_MIN;
+
+       if(n >= 1)
+               sample = argv(n - 1);
+       if(n >= 2)
+               chan = stof(argv(0));
+       if(n >= 3)
+               vol = stof(argv(1));
+       if(n >= 4)
+               atten = stof(argv(1));
+
        precache_sound(f);
-       sound(self, CH_WEAPON_B, f, VOL_BASE, ATTN_MIN);
+       sound(self, chan, sample, vol, atten);
 
        return CMD_STATUS_FINISHED;
 }