]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/view.qc
Make precedence explicit in expressions where || and && are mixed (patch by martin-t)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / view.qc
index 7a8b5e705f7846bb7fecfc361a36cdb0ff0f2889..1f8eb8a69466a1d44c8a1be6972068cdd73125eb 100644 (file)
@@ -486,7 +486,7 @@ vector GetCurrentFov(float fov)
        else
                setsensitivityscale(1);
 
-       if(autocvar_cl_velocityzoom_enabled && autocvar_cl_velocityzoom_type) // _type = 0 disables velocity zoom too
+       if(autocvar_cl_velocityzoom_enabled && autocvar_cl_velocityzoom_type && !autocvar_cl_lockview) // _type = 0 disables velocity zoom too
        {
                if (intermission || (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2))
                        curspeed = 0;
@@ -1003,7 +1003,7 @@ vector crosshair_getcolor(entity this, float health_stat)
        vector wcross_color = '0 0 0';
        switch(autocvar_crosshair_color_special)
        {
-               case 1: // crosshair_color_per_weapon
+               case 1: // weapon color
                {
                        if(this != WEP_Null && hud == HUD_NORMAL)
                        {
@@ -1013,54 +1013,15 @@ vector crosshair_getcolor(entity this, float health_stat)
                        else { goto normalcolor; }
                }
 
-               case 2: // crosshair_color_by_health
+               case 2: // color based on health and armor
                {
                        vector v = healtharmor_maxdamage(health_stat, STAT(ARMOR), armorblockpercent, DEATH_WEAPON.m_id);
-                       float hp = floor(v.x + 1);
-
-                       //x = red
-                       //y = green
-                       //z = blue
-
-                       wcross_color.z = 0;
-
-                       if(hp > 200)
-                       {
-                               wcross_color.x = 0;
-                               wcross_color.y = 1;
-                       }
-                       else if(hp > 150)
-                       {
-                               wcross_color.x = 0.4 - (hp-150)*0.02 * 0.4;
-                               wcross_color.y = 0.9 + (hp-150)*0.02 * 0.1;
-                       }
-                       else if(hp > 100)
-                       {
-                               wcross_color.x = 1 - (hp-100)*0.02 * 0.6;
-                               wcross_color.y = 1 - (hp-100)*0.02 * 0.1;
-                               wcross_color.z = 1 - (hp-100)*0.02;
-                       }
-                       else if(hp > 50)
-                       {
-                               wcross_color.x = 1;
-                               wcross_color.y = 1;
-                               wcross_color.z = 0.2 + (hp-50)*0.02 * 0.8;
-                       }
-                       else if(hp > 20)
-                       {
-                               wcross_color.x = 1;
-                               wcross_color.y = (hp-20)*90/27/100;
-                               wcross_color.z = (hp-20)*90/27/100 * 0.2;
-                       }
-                       else
-                       {
-                               wcross_color.x = 1;
-                               wcross_color.y = 0;
-                       }
+                       float health_and_armor = floor(v.x + 1);
+                       wcross_color = HUD_Get_Num_Color(health_and_armor, 200, false);
                        break;
                }
 
-               case 3: // crosshair_color_rainbow
+               case 3: // rainbow/random color
                {
                        if(time >= rainbow_last_flicker)
                        {
@@ -1085,9 +1046,9 @@ void HUD_Crosshair(entity this)
 
        float f, i, j;
        vector v;
-       if(!scoreboard_active && !camera_active && intermission != 2 && !STAT(GAME_STOPPED) &&
-               spectatee_status != -1 && (!csqcplayer.viewloc || (!spectatee_status && (csqcplayer.viewloc.spawnflags & VIEWLOC_FREEAIM))) && !MUTATOR_CALLHOOK(DrawCrosshair) &&
-               !HUD_MinigameMenu_IsOpened() )
+       if(!scoreboard_active && !camera_active && intermission != 2 && !STAT(GAME_STOPPED) && !autocvar_cl_lockview
+               && spectatee_status != -1 && (!csqcplayer.viewloc || (!spectatee_status && (csqcplayer.viewloc.spawnflags & VIEWLOC_FREEAIM))) && !MUTATOR_CALLHOOK(DrawCrosshair)
+               && !HUD_MinigameMenu_IsOpened())
        {
                if (!autocvar_crosshair_enabled) // main toggle for crosshair rendering
                        return;
@@ -2044,16 +2005,20 @@ void View_PostProcessing()
 
 void View_Lock()
 {
-       if(autocvar_cl_lockview || (!autocvar_hud_cursormode && (autocvar__hud_configure && spectatee_status <= 0 || intermission > 1 || QuickMenu_IsOpened())))
-       {
+       int lock_type = (!autocvar_hud_cursormode && ((autocvar__hud_configure && spectatee_status <= 0) || intermission > 1 || QuickMenu_IsOpened()));
+       if (lock_type == 0)
+               lock_type = autocvar_cl_lockview;
+
+       // lock_type 1: lock origin and angles
+       // lock_type 2: lock only origin
+       if(lock_type >= 1)
                setproperty(VF_ORIGIN, freeze_org);
-               setproperty(VF_ANGLES, freeze_ang);
-       }
        else
-       {
                freeze_org = getpropertyvec(VF_ORIGIN);
+       if(lock_type == 1)
+               setproperty(VF_ANGLES, freeze_ang);
+       else
                freeze_ang = getpropertyvec(VF_ANGLES);
-       }
 }
 
 void View_DemoCamera()