Alter sound settings per game mode - Printable Version +- Xonotic Forums (https://forums.xonotic.org) +-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3) +--- Forum: Xonotic - Configuration Tips (https://forums.xonotic.org/forumdisplay.php?fid=19) +--- Thread: Alter sound settings per game mode (/showthread.php?tid=2985) |
||||||||||||||||||||||||||||||||||||
Alter sound settings per game mode - W4RP1G - 05-04-2012 Ok, I figured I should post what I've done so people can get an idea of how to do this. Thanks to Mr. Bougo, Asy7um, and Spaceman for their help. Here is how one can alter their sound levels(specifically mute and unmute music and ambient noise) in specific game modes. Add these line(for example) to autoexec.cfg Code: alias cl_hook_gamestart_ctf "seta snd_channel8volume 0.100000; seta bgmvolume 0.100000; seta snd_channel9volume 0.100000; seta snd_staticvolume 0.100000" _______________________________________ Original message: Is there a way to make the game automatically mute the music during a certain gametype? I love the music, but it's a hindrance in a duel. And since I mostly duel, I often forget to turn it back on when changing gametypes. Also, is it possible to bind "exec insertcfgname.cfg" to a key? RE: Alter sound settings per game mode - asyyy - 05-04-2012 bind x "exec insertcfgname.cfg" in duel.cfg seta "snd_channel8volume" "0" //mute music seta "snd_channel9volume" "0" //mute ambient sounds RE: Alter sound settings per game mode - Spaceman - 05-04-2012 bind s "exec insertcfgname.cfg" Maybe add seta "snd_channel8volume" "1" //mute music seta "snd_channel9volume" "1" //mute ambient sounds to your autoexec.cfg which will restore your volume levels every time you start. RE: Alter sound settings per game mode - Mr. Bougo - 05-04-2012 Actually, there are cfg hooks called from CSQC just for that. From defaultXonotic.cfg: Code: alias cl_hook_gamestart_all As you can see, those hooks do nothing by default. You can alias them to whatever you like in your autoexec.cfg. For example: Code: alias cl_hook_ctf "echo This message appears every time a ctf game starts" Now I'm not sure what you mean by "duel" -- is that what young'uns call 1v1 these days? If so, there's no way currently to distinguish between multiplayer FFA dm and 1v1 dm, since it's the same gametype with a different player count. RE: Alter sound settings per game mode - W4RP1G - 05-04-2012 (05-04-2012, 05:06 PM)Mr. Bougo Wrote: Actually, there are cfg hooks called from CSQC just for that.Very interesting! Yeah, duel is 1v1. I forget that it's technically still dm, though I'm curious how xonotic stats can differentiate between a duel and dm. RE: Alter sound settings per game mode - Mr. Bougo - 05-05-2012 (05-04-2012, 07:13 PM)W4RP1G Wrote: Very interesting! Yeah, duel is 1v1. I forget that it's technically still dm, though I'm curious how xonotic stats can differentiate between a duel and dm. This is how: Code: # FIXME: if we have two players and game type is 'dm', I guess this makes some dm matches on public servers count as duels. A "real player" seems to be any player who played in the match and was playing when the match ended. Bots are included in the count. RE: Alter sound settings per game mode - W4RP1G - 05-05-2012 (05-05-2012, 02:35 AM)Mr. Bougo Wrote:(05-04-2012, 07:13 PM)W4RP1G Wrote: Very interesting! Yeah, duel is 1v1. I forget that it's technically still dm, though I'm curious how xonotic stats can differentiate between a duel and dm. I see. Would it be possible to throw an XPM setting in there as well, so that just any dm with 2 players isn't counted as a duel? I guess that might be getting kinda picky though. Also, have you successfully used the cl_hooks? I've tried and get nothing. I can't even get cl_hook_gameend "echo good game" to do anything when I endmatch. RE: Alter sound settings per game mode - Mr. Bougo - 05-05-2012 You're using hooks wrong. They are aliases, not commands or cvars. You need to alias them to a command. alias cl_hook_gameend "echo good game" Also, echo prints to your console, use say to send a message. RE: Alter sound settings per game mode - W4RP1G - 05-05-2012 (05-05-2012, 05:09 PM)Mr. Bougo Wrote: You're using hooks wrong. They are aliases, not commands or cvars. You need to alias them to a command. Well, I tried it with the alias, without it, with and without quotations, and nothing worked. Then I figured out that my autoexec.cfg was not loading. I have no idea why, but Xonotic did not recognize it. I made a new one and everything works fine. I have it set up to kill bgm and ambient sound when I start a dm, andto restart them when the other modes start. It should be noted that snd_channel8/9volume do not control the ambient sound or bgm, it's bgmvolume and snd_staticvolume. Once again, thanks for the help, Mr. Bougo. One more thing though, do you know what the "activeweapon" hook does? RE: Alter sound settings per game mode - Mr. Bougo - 05-06-2012 I didn't know, so I checked the source. It's actually pretty nifty, it's called when you switch weapons (be it manually or automatically, and spawning with a weapon counts as a switch), with the weapon's shortname as argument or "none" if you switch to no weapon (I think that happens in race mode sometimes when you cross an object-altering trigger that removes all your weapons). Current shortnames (in git at least):
(for the record: for w in $(sed -nr 's/.*"w_(.*).qc"/\1/p' w_all.qc); do grep -m1 "REGISTER_WEAPON(" w_$w.qc; done | sed -r 's/.*, "(.*?)", _\("(.*?)"\).*/\2,\1/' | column -ts,) EDIT: Here's one thing you can do to make weapon-specific aliases: Code: alias cl_hook_activeweapon "cl_hook_w_$1" RE: Alter sound settings per game mode - W4RP1G - 05-06-2012 Oh I see. That's pretty neat, but I can't think of a practical use for that. Any ideas? RE: Alter sound settings per game mode - Mr. Bougo - 05-06-2012 Weapon-specific binds. Want auto-crouch when zooming with the nex? You can rebind mouse2 in cl_hook_w_nex. And bind it back to normal when switching away (you figure that one out) RE: Alter sound settings per game mode - W4RP1G - 05-06-2012 I was messing around with weapon specific FOVs, which is cool but distracting. Another thing I was considering was making the minstanex alt-fire bound to my laser key, then making mouse 2 zoom. I always hated how the minstanex alt wasn't a zoom. RE: Alter sound settings per game mode - rocknroll237 - 05-06-2012 Cool stuff! Has anyone got a guide for all of these alias thingys? RE: Alter sound settings per game mode - W4RP1G - 05-06-2012 (05-06-2012, 03:34 PM)rocknroll237 Wrote: Cool stuff! Has anyone got a guide for all of these alias thingys? from what i can tell, alias are simple, it's just : alias WhateverTheAliasIs "whatTheAliasDoes" For example, here is my current weapon hooks: Code: alias cl_hook_activeweapon "cl_hook_w_$1" That essentially changes the binds for the minstanex, and decreases the fov when using the machine gun. For the minsta, it changes mouse2 to zoom, and mouse3(which is bound to BACKSLASH for me) into the alt-fire. Then everything goes back to normal when minsta is off by rebinding alt fire to mouse2 and laser to mouse3(BACKSLASH). The MG fov is pretty obvious. The fov is set at 90 for the mg, and 115 for everything else. I probably went a bit overboard adding the mouse2/backslash binds to all weapons, but I'm obsessive I guess. Also note that cl_hook_w_none will be activated from time to time when changing weapons. Not sure why. I added commands to it to stop the annoying message I got when it was left empty. Also, see my original post for the specific sounds settings for different gametypes. RE: Alter sound settings per game mode - Mr. Bougo - 05-06-2012 (05-06-2012, 03:34 PM)rocknroll237 Wrote: Cool stuff! Has anyone got a guide for all of these alias thingys? This is a general console guide. It's not complete yet and doesn't cover all the undocumented features of the game though: Console Tips & Tricks The only guide is the source code. (05-06-2012, 03:49 PM)W4RP1G Wrote: I probably went a bit overboard adding the mouse2/backslash binds to all weapons, but I'm obsessive I guess. To make things cleaner, you could do this: Code: alias _whook "alias cl_hook_w_$1 \"bind BACKSLASH $2; fov $3; bind MOUSE2 $4\"" (05-06-2012, 03:49 PM)W4RP1G Wrote: Also note that cl_hook_w_none will be activated from time to time when changing weapons. Not sure why. I added commands to it to stop the annoying message I got when it was left empty. Do you think you could investigate this? Perhaps it triggers "none" when you spectate or die? RE: Alter sound settings per game mode - W4RP1G - 05-07-2012 (05-06-2012, 11:34 PM)Mr. Bougo Wrote:(05-06-2012, 03:34 PM)rocknroll237 Wrote: Cool stuff! Has anyone got a guide for all of these alias thingys? I get the "unknown command cl_hook_w_none" error randomly when switching weapons, on respawn, and when going into spectator mode. Going into spectator mode makes sense, but I don't understand why I get it when respawning and switching weapons. RE: Alter sound settings per game mode - Mr. Bougo - 05-08-2012 That's because I forgot to make the cl_hook_w_none alias. Add alias cl_hook_w_none to the bunch. I guess you spawn without a weapon then get it given to you. I guess this should be reported to the bug tracker. "cl_hook_activeweapon none gets called on spawn". Care to do that? RE: Alter sound settings per game mode - W4RP1G - 05-09-2012 (05-08-2012, 01:42 AM)Mr. Bougo Wrote: That's because I forgot to make the cl_hook_w_none alias. Add alias cl_hook_w_none to the bunch. Done RE: Alter sound settings per game mode - Mr. Bougo - 05-09-2012 It seems you didn't understand what my aliases above do. The Xonotic hook system calls the cl_hook_activeweapon console command with as argument the name of the target weapon. My aliases above redirect this command to a set of aliases, one for each weapon: alias cl_hook_activeweapon "cl_hook_w_$1" This means that the command "cl_hook_activeweapon shotgun" will in turn call the command "cl_hook_w_shotgun". I simply forgot to define the "cl_hook_w_none" alias which gets called when the hook system calls "cl_hook_activeweapon none". Nevertheless, cl_hook_activeweapon none gets called when it shouldn't (from a player's standpoint at least), and that is the bug. I corrected the bug description accordingly. RE: Alter sound settings per game mode - W4RP1G - 05-09-2012 (05-09-2012, 02:22 PM)Mr. Bougo Wrote: It seems you didn't understand what my aliases above do. The Xonotic hook system calls the cl_hook_activeweapon console command with as argument the name of the target weapon. My aliases above redirect this command to a set of aliases, one for each weapon: Oh i see. Yeah I don't fully understand how this stuff works. Thanks for correcting that for me. RE: Alter sound settings per game mode - BlaXpirit - 05-11-2012 Sorry for the 'advertisement', but I talk on this topic and much more in this thread. RE: Alter sound settings per game mode - rocknroll237 - 05-12-2012 |