]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/cl_player.qc
Don't regurgitate fully digested prey silently by default
[voretournament/voretournament.git] / data / qcsrc / server / cl_player.qc
index e7bfb2d488a6d177fb1ba5452879d08bc66d2a72..e953ff7d4b41ecebbd10724d7ab70dc218112e67 100644 (file)
@@ -1221,11 +1221,12 @@ void UpdatePlayerSounds()
        LoadPlayerSounds(strcat(self.model, ".sounds"), 0);\r
 }\r
 \r
-void GlobalSound(string sample, float chan, float voicetype)\r
+void GlobalSound(string sample, float chan, float voicetype, float vol)\r
 {\r
        float n;\r
        float tauntrand;\r
-       float vol, vol_apply;\r
+       float vol_scale, vol_prey, vol_apply;\r
+       float pitch;\r
 \r
        if(sample == "")\r
                return;\r
@@ -1238,12 +1239,15 @@ void GlobalSound(string sample, float chan, float voicetype)
                sample = strcat(argv(0), ".wav"); // randomization\r
 \r
        // modified volume, used for attenuated (non-radio) voices\r
-       vol = VOL_BASEVOICE;\r
-       if(self.stat_eaten && cvar("g_vore_soundocclusion")) // reduce sound volume for prey, to simulate stomach culling\r
-               vol *= cvar("g_vore_soundocclusion");\r
+       vol_scale = vol_prey = 1;\r
        if(cvar("g_healthsize") && cvar("g_healthsize_soundfactor")) // amplify or reduce sound volume based on the size of the player\r
-               vol *= pow(self.scale, cvar("g_healthsize_soundfactor"));\r
-       vol = bound(0, vol, 1);\r
+               vol_scale *= bound(0, pow(self.scale, cvar("g_healthsize_soundfactor")), 1);\r
+       if(self.stat_eaten && cvar("g_vore_soundocclusion")) // reduce sound volume for prey, to simulate stomach culling\r
+               vol_prey *= bound(0, cvar("g_vore_soundocclusion"), 1);\r
+\r
+       // modified sound pitch, based on player scale\r
+       if(cvar("g_healthsize") && cvar("g_healthsize_pitch"))\r
+               pitch = pow(self.scale, -cvar("g_healthsize_pitch"));\r
 \r
        switch(voicetype)\r
        {\r
@@ -1256,11 +1260,12 @@ void GlobalSound(string sample, float chan, float voicetype)
                                        {\r
                                                if(msg_entity.cvar_cl_voice_directional == 1)\r
                                                {\r
-                                                       vol_apply = (self.predator != msg_entity.predator && self != msg_entity) ? vol : VOL_BASEVOICE;\r
-                                                       soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN);\r
+                                                       vol_apply = vol;\r
+                                                       vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale;\r
+                                                       soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN, pitch);\r
                                                }\r
                                                else\r
-                                                       soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);\r
+                                                       soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, pitch);\r
                                        }\r
                                }\r
                        break;\r
@@ -1273,15 +1278,16 @@ void GlobalSound(string sample, float chan, float voicetype)
                                        {\r
                                                if(msg_entity.cvar_cl_voice_directional == 1)\r
                                                {\r
-                                                       vol_apply = (self.predator != msg_entity.predator && self != msg_entity) ? vol : VOL_BASEVOICE;\r
-                                                       soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN);\r
+                                                       vol_apply = vol;\r
+                                                       vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale;\r
+                                                       soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN, pitch);\r
                                                }\r
                                                else\r
-                                                       soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);\r
+                                                       soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, pitch);\r
                                        }\r
                                        msg_entity = self;\r
                                        if(clienttype(msg_entity) == CLIENTTYPE_REAL)\r
-                                               soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTN_NONE);\r
+                                               soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTN_NONE, pitch);\r
                                }\r
                        break;\r
                case VOICETYPE_TEAMRADIO:\r
@@ -1290,11 +1296,12 @@ void GlobalSound(string sample, float chan, float voicetype)
                                {\r
                                        if(msg_entity.cvar_cl_voice_directional == 1)\r
                                        {\r
-                                               vol_apply = (self.predator != msg_entity.predator && self != msg_entity) ? vol : VOL_BASEVOICE;\r
-                                               soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN);\r
+                                               vol_apply = vol;\r
+                                               vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale;\r
+                                               soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN, pitch);\r
                                        }\r
                                        else\r
-                                               soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);\r
+                                               soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, pitch);\r
                                }\r
                        break;\r
                case VOICETYPE_AUTOTAUNT:\r
@@ -1310,11 +1317,12 @@ void GlobalSound(string sample, float chan, float voicetype)
                                {\r
                                        if (msg_entity.cvar_cl_voice_directional >= 1)\r
                                        {\r
-                                               vol_apply = (self.predator != msg_entity.predator && self != msg_entity) ? vol : VOL_BASEVOICE;\r
-                                               soundto(MSG_ONE, self, chan, sample, vol_apply, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX));\r
+                                               vol_apply = vol;\r
+                                               vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale;\r
+                                               soundto(MSG_ONE, self, chan, sample, vol_apply, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX), pitch);\r
                                        }\r
                                        else\r
-                                               soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);\r
+                                               soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, pitch);\r
                                }\r
                        break;\r
                case VOICETYPE_TAUNT:\r
@@ -1329,22 +1337,25 @@ void GlobalSound(string sample, float chan, float voicetype)
                        {\r
                                if (msg_entity.cvar_cl_voice_directional >= 1)\r
                                {\r
-                                       vol_apply = (self.predator != msg_entity.predator && self != msg_entity) ? vol : VOL_BASEVOICE;\r
-                                       soundto(MSG_ONE, self, chan, sample, vol_apply, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX));\r
+                                       vol_apply = vol;\r
+                                       vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale;\r
+                                       soundto(MSG_ONE, self, chan, sample, vol_apply, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX), pitch);\r
                                }\r
                                else\r
-                                       soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_NONE);\r
+                                       soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, pitch);\r
                        }\r
                case VOICETYPE_PLAYERSOUND:\r
                        FOR_EACH_REALCLIENT(msg_entity)\r
                        {\r
-                               vol_apply = (self.predator != msg_entity.predator && self != msg_entity) ? vol : VOL_BASEVOICE;\r
-                               soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_NORM);\r
+                               vol_apply = vol;\r
+                               vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale;\r
+                               soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_NORM, pitch);\r
                        }\r
                        break;\r
                case VOICETYPE_GURGLE:\r
+                       // since players can't be prey and predators at the same time, we don't use the prey modifier for the gurgle sound volume\r
                        if(self.stomach_load)\r
-                               sound(self, chan, sample, bound(0, vol * (self.stomach_load / self.stomach_maxload), 1), ATTN_NORM);\r
+                               sound7(self, chan, sample, bound(0, vol_scale * (self.stomach_load / self.stomach_maxload), 1), ATTN_NORM, pitch * 100, 0);\r
                        else\r
                                stopsound(self, chan);\r
                        break;\r
@@ -1362,7 +1373,7 @@ void PlayerSound(entity player, .string samplefield, float chan, float voicetype
        oldself = self;\r
        self = player;\r
        sample = self.samplefield;\r
-       GlobalSound(sample, chan, voicetype);\r
+       GlobalSound(sample, chan, voicetype, VOL_BASEVOICE);\r
        self = oldself;\r
 }\r
 \r