]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a volume parameter to GlobalSound, also muffle landing sounds while crouching
authorMario <mario@smbclan.net>
Wed, 13 Jul 2016 11:35:44 +0000 (21:35 +1000)
committerMario <mario@smbclan.net>
Wed, 13 Jul 2016 11:35:44 +0000 (21:35 +1000)
qcsrc/common/effects/qc/globalsound.qc
qcsrc/common/effects/qc/globalsound.qh
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/dodging/dodging.qc
qcsrc/common/physics/player.qc
qcsrc/common/sounds/sound.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc

index b9069705e3b97657ab9163f5366067503b412c72..8c1ed1ca8305759ef85ee3a7cb691975c51ca7f7 100644 (file)
 
        #ifdef SVQC
 
-               void _GlobalSound(entity this, entity gs, entity ps, string sample, int chan, int voicetype, bool fake)
+               void _GlobalSound(entity this, entity gs, entity ps, string sample, int chan, float vol, int voicetype, bool fake)
                {
                        if (gs == NULL && ps == NULL && sample == "") return;
                        if(this.classname == "body") return;
                                                if (IS_REAL_CLIENT(msg_entity))
                                                {
                                                        float atten = (msg_entity.cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE;
-                                                       if (gs) globalsound(MSG_ONE, this, gs, r, chan, VOL_BASEVOICE, atten);
-                                                       else if (ps) playersound(MSG_ONE, this, ps, r, chan, VOL_BASEVOICE, atten);
-                                                       else soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten);
+                                                       if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten);
+                                                       else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten);
+                                                       else soundto(MSG_ONE, this, chan, sample, vol, atten);
                                                }
                                        }
                                        if (voicetype == VOICETYPE_LASTATTACKER_ONLY) break;
                                                MACRO_BEGIN \
                                                { \
                                                        float atten = (msg_entity.cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; \
-                                                       if (gs) globalsound(MSG_ONE, this, gs, r, chan, VOL_BASEVOICE, atten); \
-                                                       else if (ps) playersound(MSG_ONE, this, ps, r, chan, VOL_BASEVOICE, atten); \
-                                                       else soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten); \
+                                                       if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten); \
+                                                       else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten); \
+                                                       else soundto(MSG_ONE, this, chan, sample, vol, atten); \
                                                } MACRO_END
 
                                        if (fake) { msg_entity = this; X(); }
                                                                    ? bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, \
                                                                        ATTEN_MAX) \
                                                                        : ATTEN_NONE; \
-                                                               if (gs) globalsound(MSG_ONE, this, gs, r, chan, VOL_BASEVOICE, atten); \
-                                                               else if (ps) playersound(MSG_ONE, this, ps, r, chan, VOL_BASEVOICE, atten); \
-                                                               else soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten); \
+                                                               if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten); \
+                                                               else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten); \
+                                                               else soundto(MSG_ONE, this, chan, sample, vol, atten); \
                                                        } \
                                                } MACRO_END
                                        if (fake)
                                        msg_entity = this;
                                        if (fake)
                                        {
-                                               if (gs) globalsound(MSG_ONE, this, gs, r, chan, VOL_BASE, ATTEN_NORM);
-                                               else if (ps) playersound(MSG_ONE, this, ps, r, chan, VOL_BASE, ATTEN_NORM);
-                                               else soundto(MSG_ONE, this, chan, sample, VOL_BASE, ATTEN_NORM);
+                                               if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, ATTEN_NORM);
+                                               else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, ATTEN_NORM);
+                                               else soundto(MSG_ONE, this, chan, sample, vol, ATTEN_NORM);
                                        }
                                        else
                                        {
-                                               if (gs) globalsound(MSG_ALL, this, gs, r, chan, VOL_BASE, ATTEN_NORM);
-                                               else if (ps) playersound(MSG_ALL, this, ps, r, chan, VOL_BASE, ATTEN_NORM);
-                                               else _sound(this, chan, sample, VOL_BASE, ATTEN_NORM);
+                                               if (gs) globalsound(MSG_ALL, this, gs, r, chan, vol, ATTEN_NORM);
+                                               else if (ps) playersound(MSG_ALL, this, ps, r, chan, vol, ATTEN_NORM);
+                                               else _sound(this, chan, sample, vol, ATTEN_NORM);
                                        }
                                        break;
                                }
index 44925cd510cf81c71fe4018b792de9a2f46bda22..640d330f1c0cc139d46266e77b05115507c7cc9d 100644 (file)
@@ -122,10 +122,10 @@ entity GetVoiceMessage(string type);
 
 #ifdef SVQC
 
-       void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float voicetype, bool fake);
-       #define GlobalSound(this, def, chan, voicetype) _GlobalSound(this, def, NULL, string_null, chan, voicetype, false)
-       #define GlobalSound_string(this, def, chan, voicetype) _GlobalSound(this, NULL, NULL, def, chan, voicetype, false)
-       #define PlayerSound(this, def, chan, voicetype) _GlobalSound(this, NULL, def, string_null, chan, voicetype, false)
+       void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float vol, float voicetype, bool fake);
+       #define GlobalSound(this, def, chan, vol, voicetype) _GlobalSound(this, def, NULL, string_null, chan, vol, voicetype, false)
+       #define GlobalSound_string(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, NULL, def, chan, vol, voicetype, false)
+       #define PlayerSound(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, def, string_null, chan, vol, voicetype, false)
        #define VoiceMessage(this, def, msg) \
                MACRO_BEGIN \
                { \
@@ -137,7 +137,7 @@ entity GetVoiceMessage(string type);
                        if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
                        else if (flood > 0) fake = false; \
                        else break; \
-                       _GlobalSound(this, NULL, VM, string_null, CH_VOICE, voicetype, fake); \
+                       _GlobalSound(this, NULL, VM, string_null, CH_VOICE, VOL_BASEVOICE, voicetype, fake); \
                } MACRO_END
 
 #endif
index 795e0310a263f35fd922478f1e9a1ad1125ad47d..005f128b9b5a469451c98b5c7c60029b3f8632eb 100644 (file)
@@ -338,7 +338,7 @@ void Monster_Sound(entity this, .string samplefield, float sound_delay, float de
        if(delaytoo)
        if(time < this.msound_delay)
                return; // too early
-       GlobalSound_string(this, this.(samplefield), chan, VOICETYPE_PLAYERSOUND);
+       GlobalSound_string(this, this.(samplefield), chan, VOL_BASE, VOICETYPE_PLAYERSOUND);
 
        this.msound_delay = time + sound_delay;
 }
index 0d20ff7af895f831c7c11cd41c29798f3fbd8c6b..64312727e4e0cc682743643eefbb8e9af4d06f4b 100644 (file)
@@ -226,7 +226,7 @@ void PM_dodging(entity this)
 
 #ifdef SVQC
                if (autocvar_sv_dodging_sound)
-                       PlayerSound(this, playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                       PlayerSound(this, playersound_jump, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND);
 
                animdecide_setaction(this, ANIMACTION_JUMP, true);
 #endif
index 8ab8a13800ffeb0b1da44c46488be78a736aa94f..d68c26ceab9ec5fcd30108830dbf5ecc0d0c230a 100644 (file)
@@ -541,7 +541,7 @@ bool PlayerJump(entity this)
        animdecide_setaction(this, ANIMACTION_JUMP, true);
 
        if (autocvar_g_jump_grunt)
-               PlayerSound(this, playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+               PlayerSound(this, playersound_jump, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND);
 #endif
        return true;
 }
@@ -781,7 +781,8 @@ void PM_check_hitground(entity this)
     entity gs = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
        ? GS_FALL_METAL
        : GS_FALL;
-    GlobalSound(this, gs, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+    float vol = ((IS_DUCKED(this)) ? VOL_MUFFLED : VOL_BASE);
+    GlobalSound(this, gs, CH_PLAYER, vol, VOICETYPE_PLAYERSOUND);
 #endif
 }
 
@@ -801,7 +802,7 @@ void PM_Footsteps(entity this)
                entity gs = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
                        ? GS_STEP_METAL
                        : GS_STEP;
-               GlobalSound(this, gs, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+               GlobalSound(this, gs, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND);
        }
 #endif
 }
index 90b2758aca3569e841d6cfa185ca2a556847bd2d..b915062223918a81a7c0c8b90be3ac297054eca1 100644 (file)
@@ -35,6 +35,7 @@ const float ATTEN_MAX = 3.984375;
 
 const float VOL_BASE = 0.7;
 const float VOL_BASEVOICE = 1.0;
+const float VOL_MUFFLED = 0.35;
 
 // Play all sounds via sound7, for access to the extra channels.
 // Otherwise, channels 8 to 15 would be blocked for a weird QW feature.
index 957742be5741efe62f4c3172ee036822e4527cf0..e0b7e116eae253a3b6f85f3dc43e352b69774f99 100644 (file)
@@ -2379,13 +2379,13 @@ void PlayerPreThink (entity this)
                entity e = this.teamkill_soundsource;
                entity oldpusher = e.pusher;
                e.pusher = this;
-               PlayerSound(e, playersound_teamshoot, CH_VOICE, VOICETYPE_LASTATTACKER_ONLY);
+               PlayerSound(e, playersound_teamshoot, CH_VOICE, VOL_BASEVOICE, VOICETYPE_LASTATTACKER_ONLY);
                e.pusher = oldpusher;
        }
 
        if (this.taunt_soundtime && time > this.taunt_soundtime) {
                this.taunt_soundtime = 0;
-               PlayerSound(this, playersound_taunt, CH_VOICE, VOICETYPE_AUTOTAUNT);
+               PlayerSound(this, playersound_taunt, CH_VOICE, VOL_BASEVOICE, VOICETYPE_AUTOTAUNT);
        }
 
        target_voicescript_next(this);
@@ -2404,7 +2404,7 @@ void DrownPlayer(entity this)
        if (this.waterlevel != WATERLEVEL_SUBMERGED || this.vehicle)
        {
                if(this.air_finished < time)
-                       PlayerSound(this, playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                       PlayerSound(this, playersound_gasp, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND);
                this.air_finished = time + autocvar_g_balance_contents_drowndelay;
                this.dmg = 2;
        }
index ae823f7bdb99705ccccf33c273e37162df43dffe..50ceba31014316ea5cff9e7c0ee528c3d30f681c 100644 (file)
@@ -436,15 +436,15 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                                        // exclude pain sounds for laserjumps as long as you aren't REALLY low on health and would die of the next two
                                        {
                                                if(deathtype == DEATH_FALL.m_id)
-                                                       PlayerSound(this, playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(this, playersound_fall, CH_PAIN, VOL_BASE, VOICETYPE_PLAYERSOUND);
                                                else if(this.health > 75)
-                                                       PlayerSound(this, playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(this, playersound_pain100, CH_PAIN, VOL_BASE, VOICETYPE_PLAYERSOUND);
                                                else if(this.health > 50)
-                                                       PlayerSound(this, playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(this, playersound_pain75, CH_PAIN, VOL_BASE, VOICETYPE_PLAYERSOUND);
                                                else if(this.health > 25)
-                                                       PlayerSound(this, playersound_pain50, CH_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(this, playersound_pain50, CH_PAIN, VOL_BASE, VOICETYPE_PLAYERSOUND);
                                                else
-                                                       PlayerSound(this, playersound_pain25, CH_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(this, playersound_pain25, CH_PAIN, VOL_BASE, VOICETYPE_PLAYERSOUND);
                                        }
                                }
                        }
@@ -523,9 +523,9 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                if(sound_allowed(MSG_BROADCAST, attacker))
                {
                        if(deathtype == DEATH_DROWN.m_id)
-                               PlayerSound(this, playersound_drown, CH_PAIN, VOICETYPE_PLAYERSOUND);
+                               PlayerSound(this, playersound_drown, CH_PAIN, VOL_BASE, VOICETYPE_PLAYERSOUND);
                        else
-                               PlayerSound(this, playersound_death, CH_PAIN, VOICETYPE_PLAYERSOUND);
+                               PlayerSound(this, playersound_death, CH_PAIN, VOL_BASE, VOICETYPE_PLAYERSOUND);
                }
 
                // get rid of kill indicator