From f1ead602997113ae2cb58dbd08ce456e5c712b3b Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 2 Feb 2018 13:22:41 +1000 Subject: [PATCH] Something beautiful sounding (pitch-shift monster sounds based on their scale) --- qcsrc/common/effects/qc/globalsound.qc | 2 -- qcsrc/common/effects/qc/globalsound.qh | 2 ++ qcsrc/common/monsters/sv_monsters.qc | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index edf995a0f..874c64d53 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -11,8 +11,6 @@ REGISTER_NET_TEMP(globalsound) REGISTER_NET_TEMP(playersound) - string GlobalSound_sample(string pair, float r); - #ifdef SVQC /** * @param from the source entity, its position is sent diff --git a/qcsrc/common/effects/qc/globalsound.qh b/qcsrc/common/effects/qc/globalsound.qh index 1df0b1a42..8c6dd86dd 100644 --- a/qcsrc/common/effects/qc/globalsound.qh +++ b/qcsrc/common/effects/qc/globalsound.qh @@ -119,6 +119,8 @@ void PrecachePlayerSounds(string f); //#endif entity GetVoiceMessage(string type); +string GlobalSound_sample(string pair, float r); + #ifdef SVQC void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float vol, float voicetype, bool fake); diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index e6eb9b03d..15fba0134 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -336,7 +336,12 @@ void Monster_Sound(entity this, .string samplefield, float sound_delay, bool del if(delaytoo) if(time < this.msound_delay) return; // too early - GlobalSound_string(this, this.(samplefield), chan, VOL_BASE, VOICETYPE_PLAYERSOUND); + string sample = this.(samplefield); + if (sample != "") sample = GlobalSound_sample(sample, random()); + float myscale = ((this.scale) ? this.scale : 1); // safety net + float scale_inverse = 1 / myscale; + // TODO: change volume depending on size too? + sound7(this, chan, sample, VOL_BASE, ATTEN_NORM, scale_inverse * 100, 0); this.msound_delay = time + sound_delay; } -- 2.39.2