]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Default cl_hitsound to 1 (fixed sound) if it isn't set to a standard value (0 1 2 3)
authorterencehill <piuntn@gmail.com>
Tue, 15 Dec 2020 13:48:44 +0000 (14:48 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 15 Dec 2020 13:48:44 +0000 (14:48 +0100)
qcsrc/client/view.qc

index f39dbbefc5dc77b1f716016b60bbfeca8c4aaf32..8b13146633c81e10c3b42712f0ecf3cb13eb22b3 100644 (file)
@@ -809,22 +809,22 @@ void HitSound()
        {
                if (autocvar_cl_hitsound && unaccounted_damage)
                {
-                       // customizable gradient function that crosses (0,a), (c,1) and asymptotically approaches b
-                       float a = autocvar_cl_hitsound_max_pitch;
-                       float b = autocvar_cl_hitsound_min_pitch;
-                       float c = autocvar_cl_hitsound_nom_damage;
-                       float d = unaccounted_damage;
-                       float pitch_shift = (b*d*(a-1) + a*c*(1-b)) / (d*(a-1) + c*(1-b));
-
-                       // if sound variation is disabled, set pitch_shift to 1
-                       if (autocvar_cl_hitsound == 1)
-                               pitch_shift = 1;
-
-                       // if pitch shift is reversed, mirror in (max-min)/2 + min
-                       if (autocvar_cl_hitsound == 3)
+                       float pitch_shift = 1;
+                       if (autocvar_cl_hitsound == 2 || autocvar_cl_hitsound == 3)
                        {
-                               float mirror_value = (a-b)/2 + b;
-                               pitch_shift = mirror_value + (mirror_value - pitch_shift);
+                               // customizable gradient function that crosses (0,a), (c,1) and asymptotically approaches b
+                               float a = autocvar_cl_hitsound_max_pitch;
+                               float b = autocvar_cl_hitsound_min_pitch;
+                               float c = autocvar_cl_hitsound_nom_damage;
+                               float d = unaccounted_damage;
+                               pitch_shift = (b*d*(a-1) + a*c*(1-b)) / (d*(a-1) + c*(1-b));
+
+                               // if pitch shift is reversed, mirror in (max-min)/2 + min
+                               if (autocvar_cl_hitsound == 3)
+                               {
+                                       float mirror_value = (a-b)/2 + b;
+                                       pitch_shift = mirror_value + (mirror_value - pitch_shift);
+                               }
                        }
 
                        //LOG_TRACE("dmg total (dmg): ", ftos(unaccounted_damage), " , pitch shift: ", ftos(pitch_shift));