From: Mario Date: Wed, 13 Jul 2016 11:35:44 +0000 (+1000) Subject: Add a volume parameter to GlobalSound, also muffle landing sounds while crouching X-Git-Tag: xonotic-v0.8.2~700^2~69 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b7d3af12c0f5d48a6f2a421c958f84079b9cbbdd;p=xonotic%2Fxonotic-data.pk3dir.git Add a volume parameter to GlobalSound, also muffle landing sounds while crouching --- diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index b9069705e..8c1ed1ca8 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -316,7 +316,7 @@ #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; @@ -334,9 +334,9 @@ 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; @@ -355,9 +355,9 @@ 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(); } @@ -390,9 +390,9 @@ ? 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) @@ -415,15 +415,15 @@ 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; } diff --git a/qcsrc/common/effects/qc/globalsound.qh b/qcsrc/common/effects/qc/globalsound.qh index 44925cd51..640d330f1 100644 --- a/qcsrc/common/effects/qc/globalsound.qh +++ b/qcsrc/common/effects/qc/globalsound.qh @@ -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 diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 795e0310a..005f128b9 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -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; } diff --git a/qcsrc/common/mutators/mutator/dodging/dodging.qc b/qcsrc/common/mutators/mutator/dodging/dodging.qc index 0d20ff7af..64312727e 100644 --- a/qcsrc/common/mutators/mutator/dodging/dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/dodging.qc @@ -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 diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 8ab8a1380..d68c26cea 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -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 } diff --git a/qcsrc/common/sounds/sound.qh b/qcsrc/common/sounds/sound.qh index 90b2758ac..b91506222 100644 --- a/qcsrc/common/sounds/sound.qh +++ b/qcsrc/common/sounds/sound.qh @@ -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. diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 957742be5..e0b7e116e 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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; } diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index ae823f7bd..50ceba310 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -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