From: Rudolf Polzer Date: Wed, 17 Oct 2012 14:36:22 +0000 (+0200) Subject: bot_cmd sound: allow to specify channel, volume, attenuation X-Git-Tag: xonotic-v0.7.0~204 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=95f2eea059f30c207155434630dd671fb8a7f296;p=xonotic%2Fxonotic-data.pk3dir.git bot_cmd sound: allow to specify channel, volume, attenuation --- diff --git a/qcsrc/server/bot/scripting.qc b/qcsrc/server/bot/scripting.qc index 7e29160cf..1642133e1 100644 --- a/qcsrc/server/bot/scripting.qc +++ b/qcsrc/server/bot/scripting.qc @@ -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; }