Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alter sound settings per game mode

#1
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"
alias cl_hook_gamestart_dm "seta snd_channel8volume 0; seta bgmvolume 0; seta snd_channel9volume 0; seta snd_staticvolume 0"
That will effectively turn music and ambient sounds on(at half volume) for ctf and off for dm. This can be done for all other gametypes as well.
_______________________________________

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?
Reply

#2
bind x "exec insertcfgname.cfg"

in duel.cfg
seta "snd_channel8volume" "0" //mute music
seta "snd_channel9volume" "0" //mute ambient sounds
Reply

#3
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.
Reply

#4
Actually, there are cfg hooks called from CSQC just for that.

From defaultXonotic.cfg:
Code:
alias cl_hook_gamestart_all
alias cl_hook_gamestart_nop  //is only called when CSQC unloads before knowing the gametype, very unlikely
alias cl_hook_gamestart_dm
alias cl_hook_gamestart_tdm
alias cl_hook_gamestart_dom
alias cl_hook_gamestart_ctf
alias cl_hook_gamestart_rune
alias cl_hook_gamestart_lms
alias cl_hook_gamestart_arena
alias cl_hook_gamestart_ca
alias cl_hook_gamestart_kh
alias cl_hook_gamestart_ons
alias cl_hook_gamestart_as
alias cl_hook_gamestart_rc
alias cl_hook_gamestart_nb
alias cl_hook_gamestart_cts
alias cl_hook_gamestart_ka
alias cl_hook_gamestart_ft
alias cl_hook_gameend
alias cl_hook_activeweapon

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.
Reply

#5
(05-04-2012, 05:06 PM)Mr. Bougo Wrote: Actually, there are cfg hooks called from CSQC just for that.

From defaultXonotic.cfg:
Code:
alias cl_hook_gamestart_all
alias cl_hook_gamestart_nop  //is only called when CSQC unloads before knowing the gametype, very unlikely
alias cl_hook_gamestart_dm
alias cl_hook_gamestart_tdm
alias cl_hook_gamestart_dom
alias cl_hook_gamestart_ctf
alias cl_hook_gamestart_rune
alias cl_hook_gamestart_lms
alias cl_hook_gamestart_arena
alias cl_hook_gamestart_ca
alias cl_hook_gamestart_kh
alias cl_hook_gamestart_ons
alias cl_hook_gamestart_as
alias cl_hook_gamestart_rc
alias cl_hook_gamestart_nb
alias cl_hook_gamestart_cts
alias cl_hook_gamestart_ka
alias cl_hook_gamestart_ft
alias cl_hook_gameend
alias cl_hook_activeweapon

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.
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.
Reply

#6
Wink 
(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',
# change this into a 'duel' gametype. This should be
# removed when the stats actually send 'duel' instead of 'dm'
if num_real_players(players, count_bots=True) == 2 and \
        game_meta['G'] == 'dm':
    game_meta['G'] = 'duel'

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.
Reply

#7
(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.

This is how:
Code:
# FIXME: if we have two players and game type is 'dm',
# change this into a 'duel' gametype. This should be
# removed when the stats actually send 'duel' instead of 'dm'
if num_real_players(players, count_bots=True) == 2 and \
        game_meta['G'] == 'dm':
    game_meta['G'] = 'duel'

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.

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.
Reply

#8
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.
Reply

#9
(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.

alias cl_hook_gameend "echo good game"

Also, echo prints to your console, use say to send a message.

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?
Reply

#10
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):
Laser laser
Shotgun shotgun
Machine Gun uzi
Mortar grenadelauncher
Mine Layer minelayer
Electro electro
Crylink crylink
Nex nex
Hagar hagar
Rocket Launcher rocketlauncher
Port-O-Launch porto
MinstaNex minstanex
Grappling Hook hook
Heavy Laser Assault Cannon hlac
@!#%'n Tuba tuba
Rifle rifle
Fireball fireball
T.A.G. Seeker seeker

(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"
alias cl_hook_w_laser
alias cl_hook_w_shotgun
alias cl_hook_w_uzi
alias cl_hook_w_grenadelauncher
alias cl_hook_w_minelayer
alias cl_hook_w_electro
alias cl_hook_w_crylink
alias cl_hook_w_nex
alias cl_hook_w_hagar
alias cl_hook_w_rocketlauncher
alias cl_hook_w_porto
alias cl_hook_w_minstanex
alias cl_hook_w_hook
alias cl_hook_w_hlac
alias cl_hook_w_tuba
alias cl_hook_w_rifle
alias cl_hook_w_fireball
alias cl_hook_w_seeker
Then use these empty aliases just like the other hooks, by aliasing them to whatever you want. You can then have weapon-specific binds, how awesome is that.
Reply

#11
Oh I see. That's pretty neat, but I can't think of a practical use for that. Any ideas?
Reply

#12
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)
Reply

#13
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.
Reply

#14
Cool stuff! Has anyone got a guide for all of these alias thingys?
Reply

#15
(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"
alias cl_hook_w_minstanex "bind BACKSLASH +fire2; fov 115; bind MOUSE2 +zoom"
alias cl_hook_w_shotgun "bind BACKSLASH weapon_group_1; fov 115; bind MOUSE2 +fire2"
alias cl_hook_w_uzi "bind BACKSLASH weapon_group_1; fov 90; bind MOUSE2 +fire2"
alias cl_hook_w_rocketlauncher "bind BACKSLASH weapon_group_1; fov 115; bind MOUSE2 +fire2"
alias cl_hook_w_grenadelauncher "bind BACKSLASH weapon_group_1; fov 115; bind MOUSE2 +fire2"
alias cl_hook_w_crylink "bind BACKSLASH weapon_group_1; fov 115; bind MOUSE2 +fire2"
alias cl_hook_w_electro "bind BACKSLASH weapon_group_1; fov 115; bind MOUSE2 +fire2"
alias cl_hook_w_nex "bind BACKSLASH weapon_group_1; fov 115; bind MOUSE2 +fire2"
alias cl_hook_w_hagar "bind BACKSLASH weapon_group_1; fov 115; bind MOUSE2 +fire2"
alias cl_hook_w_laser "fov 115; bind MOUSE2 +fire2"
alias cl_hook_w_none "bind BACKSLASH weapon_group_1; fov 115; bind MOUSE2 +fire2"

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.
Reply

#16
(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\""
//      weapon           BACKSLASH       fov  MOUSE2
_whook  minstanex        +fire2          115  +zoom
_whook  shotgun          weapon_group_1  115  +fire2
_whook  uzi              weapon_group_1  90   +fire2
_whook  rocketlauncher   weapon_group_1  115  +fire2
_whook  grenadelauncher  weapon_group_1  115  +fire2
_whook  crylink          weapon_group_1  115  +fire2
_whook  electro          weapon_group_1  115  +fire2
_whook  nex              weapon_group_1  115  +fire2
_whook  hagar            weapon_group_1  115  +fire2
_whook  laser            fov             115  +fire2
_whook  none             weapon_group_1  115  +fire2
unalias _whook


(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?
Reply

#17
(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?

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\""
//      weapon           BACKSLASH       fov  MOUSE2
_whook  minstanex        +fire2          115  +zoom
_whook  shotgun          weapon_group_1  115  +fire2
_whook  uzi              weapon_group_1  90   +fire2
_whook  rocketlauncher   weapon_group_1  115  +fire2
_whook  grenadelauncher  weapon_group_1  115  +fire2
_whook  crylink          weapon_group_1  115  +fire2
_whook  electro          weapon_group_1  115  +fire2
_whook  nex              weapon_group_1  115  +fire2
_whook  hagar            weapon_group_1  115  +fire2
_whook  laser            fov             115  +fire2
_whook  none             weapon_group_1  115  +fire2
unalias _whook


(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?

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.
Reply

#18
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?
Reply

#19
(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.

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?

Done
Reply

#20
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.
Reply

#21
(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:
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.

Oh i see. Yeah I don't fully understand how this stuff works. Thanks for correcting that for me.
Reply

#22
Sorry for the 'advertisement', but I talk on this topic and much more in this thread.
Reply

#23
[Image: thread-hijack.jpg]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Frames/Per/Second Linux 2022 Joff 3 1,384 01-16-2024, 02:34 AM
Last Post: Annata23
  [NEED HELP] StrafeHUD panel settings BuddyFriendGuy 0 1,647 11-30-2022, 04:19 AM
Last Post: BuddyFriendGuy
  [NEED HELP] How to add more players (bots) in single mode? fairking 2 2,642 09-19-2022, 09:05 AM
Last Post: fairking
  Understanding zoom settings. youIsMe 0 2,617 06-03-2020, 12:22 PM
Last Post: youIsMe
  in/cm per 360? KoalaBearScarf 37 47,850 10-08-2019, 04:35 PM
Last Post: _para
  Playing offline against bots with proper duel settings? Cynical 5 5,526 06-24-2019, 04:47 PM
Last Post: Aguaumreal
  Are there any Arc beam settings Aguaumreal 0 2,328 01-01-2019, 03:21 PM
Last Post: Aguaumreal
  How to include custom maps in Instant Action mode? Haisook 8 8,820 04-03-2013, 06:08 PM
Last Post: axe
  Best settings config for instagib voice 8 18,049 08-29-2012, 07:24 AM
Last Post: Lee_Stricklin
  Video Configurations in the Settings Menu .Danny. 4 7,109 03-07-2011, 10:48 PM
Last Post: The mysterious Mr. 4m

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-