]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix hud shake being applied on respawn
authorterencehill <piuntn@gmail.com>
Wed, 6 Apr 2016 23:08:40 +0000 (01:08 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 6 Apr 2016 23:08:40 +0000 (01:08 +0200)
qcsrc/client/hud/hud.qc

index 49cf0a390df49568bf3ada7fc1e170efd70d1191..c87cb5a89cd853e3561826106d9b31fd2dd4ac2c 100644 (file)
@@ -450,12 +450,15 @@ void Hud_Dynamic_Frame()
                        hud_dynamic_shake_factor = 0;
                else
                {
-                       float health = STAT(HEALTH);
+                       static float old_health = 0;
+                       float health = max(-1, STAT(HEALTH));
                        float new_hud_dynamic_shake_factor = 0;
-                       if(prev_health - health >= autocvar_hud_dynamic_shake_damage_min && autocvar_hud_dynamic_shake_damage_max > autocvar_hud_dynamic_shake_damage_min)
+                       if (old_health - health >= autocvar_hud_dynamic_shake_damage_min
+                               && autocvar_hud_dynamic_shake_damage_max > autocvar_hud_dynamic_shake_damage_min
+                               && old_health > 0 && !intermission)
                        {
                                float m = max(autocvar_hud_dynamic_shake_damage_min, 1);
-                               new_hud_dynamic_shake_factor = (prev_health - health - m) / (autocvar_hud_dynamic_shake_damage_max - m);
+                               new_hud_dynamic_shake_factor = (old_health - health - m) / (autocvar_hud_dynamic_shake_damage_max - m);
                                if(new_hud_dynamic_shake_factor >= 1)
                                        new_hud_dynamic_shake_factor = 1;
                                if(new_hud_dynamic_shake_factor >= hud_dynamic_shake_factor)
@@ -464,6 +467,7 @@ void Hud_Dynamic_Frame()
                                        hud_dynamic_shake_time = time;
                                }
                        }
+                       old_health = health;
                        if(hud_dynamic_shake_factor)
                                if(!Hud_Shake_Update())
                                        hud_dynamic_shake_factor = 0;