]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/View.qc
Whoops, forgot FL_SPECTATOR
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / View.qc
index 66d7dd31c4b1ae258043002bc381a81109d9ddfc..3362ce42231193210b22b6ad0fe52f5cf8cbd1bd 100644 (file)
@@ -57,9 +57,11 @@ void Porto_Draw()
                if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
                        return;
                if(portal_number == 1)
+               {
                        portal1_idx = idx;
-               if(portal_number >= 2)
-                       break;
+                       if(portal_number >= 2)
+                               break;
+               }
        }
 
        while(idx >= 2)
@@ -102,7 +104,7 @@ vector GetCurrentFov(float fov)
                zoomfactor = 2.5;
        zoomspeed = autocvar_cl_zoomspeed;
        if(zoomspeed >= 0)
-               if(zoomspeed < 0.5 || zoomspeed > 16)
+       if(zoomspeed < 0.5 || zoomspeed > 16)
                        zoomspeed = 3.5;
 
        zoomdir = button_zoom;
@@ -121,13 +123,20 @@ vector GetCurrentFov(float fov)
                // fteqcc failed twice here already, don't optimize this
        }
 
-       if(zoomdir)
-               zoomin_effect = 0;
+       if(zoomdir) { zoomin_effect = 0; }
 
-       if(zoomin_effect || camera_active)
+       if(camera_active)
        {
                current_viewzoom = min(1, current_viewzoom + drawframetime);
        }
+       else if(autocvar_cl_spawnzoom && zoomin_effect)
+       {
+               float spawnzoomfactor = bound(1, autocvar_cl_spawnzoom_factor, 16);
+               
+               current_viewzoom += (autocvar_cl_spawnzoom_speed * (spawnzoomfactor - current_viewzoom) * drawframetime); 
+               current_viewzoom = bound(1 / spawnzoomfactor, current_viewzoom, 1);
+               if(current_viewzoom == 1) { zoomin_effect = 0; }
+       }
        else
        {
                if(zoomspeed < 0) // instant zoom
@@ -240,7 +249,7 @@ float EnemyHitCheck()
        if(teamplay)
                if(t == myteam)
                        return SHOTTYPE_HITTEAM;
-       if(t == COLOR_SPECTATOR)
+       if(t == NUM_SPECTATOR)
                return SHOTTYPE_HITWORLD;
        return SHOTTYPE_HITENEMY;
 }
@@ -390,6 +399,13 @@ void CSQC_UpdateView(float w, float h)
 
        hud = getstati(STAT_HUD);
 
+       if(autocvar__hud_showbinds_reload) // menu can set this one
+       {
+               db_close(binddb);
+               binddb = db_create();
+               cvar_set("_hud_showbinds_reload", "0");
+       }
+
        if(checkextension("DP_CSQC_MINFPS_QUALITY"))
                view_quality = getproperty(VF_MINFPS_QUALITY);
        else
@@ -419,8 +435,8 @@ void CSQC_UpdateView(float w, float h)
        vid_width = vf_size_x;
        vid_height = vf_size_y;
 
-       vector reticle_pos, reticle_size;
-       vector splash_pos, splash_size;
+       vector reticle_pos = '0 0 0', reticle_size = '0 0 0';
+       vector splash_pos = '0 0 0', splash_size = '0 0 0';
 
        WaypointSprite_Load();
 
@@ -441,12 +457,12 @@ void CSQC_UpdateView(float w, float h)
                if(spectatee_status >= 0 && (autocvar_cl_eventchase_death && getstati(STAT_HEALTH) <= 0 && !intermission) || intermission)
                {
                        // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.)
-                       vector current_view_origin = getpropertyvec(VF_ORIGIN);
-                       
+                       vector current_view_origin = ((csqcplayer ? csqcplayer.origin : pmove_org) + autocvar_cl_eventchase_viewoffset);
+
                        // We must enable chase_active to get a third person view (weapon viewmodel hidden and own player model showing).
                        // Ideally, there should be another way to enable third person cameras, such as through setproperty()
-                       if(!autocvar_chase_active)
-                               cvar_set("chase_active", "-1"); // -1 enables chase_active while marking it as set by this code, and not by the user (which would be 1)
+                       // -1 enables chase_active while marking it as set by this code, and not by the user (which would be 1)
+                       if(!autocvar_chase_active) { cvar_set("chase_active", "-1"); }
 
                        // make the camera smooth back
                        if(autocvar_cl_eventchase_speed && eventchase_current_distance < autocvar_cl_eventchase_distance)
@@ -454,17 +470,20 @@ void CSQC_UpdateView(float w, float h)
                        else if(eventchase_current_distance != autocvar_cl_eventchase_distance)
                                eventchase_current_distance = autocvar_cl_eventchase_distance;
 
-                       vector eventchase_target_origin;
                        makevectors(view_angles);
-                       // pass 1, used to check where the camera would go and obtain the trace_fraction
-                       eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance;
-                       WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self);
-                       // pass 2, also multiplying view_forward with trace_fraction, to prevent the camera from going through walls
-                       // The 0.1 subtraction is to not limit the camera precisely at the wall surface, as that allows the view to poke through
-                       eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance * (trace_fraction - 0.1);
-                       WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self);
-
-                       setproperty(VF_ORIGIN, trace_endpos);
+
+                       vector eventchase_target_origin = (current_view_origin - (v_forward * eventchase_current_distance));
+                       WarpZone_TraceBox(current_view_origin, autocvar_cl_eventchase_mins, autocvar_cl_eventchase_maxs, eventchase_target_origin, MOVE_WORLDONLY, self);
+
+                       // If the boxtrace fails, revert back to line tracing.
+                       if(trace_startsolid)
+                       {
+                               eventchase_target_origin = (current_view_origin - (v_forward * eventchase_current_distance));
+                               WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self);
+                               setproperty(VF_ORIGIN, (trace_endpos - (v_forward * autocvar_cl_eventchase_mins_z)));
+                       }
+                       else { setproperty(VF_ORIGIN, trace_endpos); }
+
                        setproperty(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles));
                }
                else if(autocvar_chase_active < 0) // time to disable chase_active if it was set by this code
@@ -473,9 +492,16 @@ void CSQC_UpdateView(float w, float h)
                        eventchase_current_distance = 0; // start from 0 next time
                }
        }
-       
+       // workaround for camera stuck between player's legs when using chase_active 1
+       // because the engine stops updating the chase_active camera when the game ends
+       else if(intermission)
+       {
+               cvar_settemp("chase_active", "-1");
+               eventchase_current_distance = 0;
+       }
+
        // do lockview after event chase camera so that it still applies whenever necessary.
-       if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0) || intermission > 1)
+       if(autocvar_cl_lockview || (!autocvar_hud_cursormode && (autocvar__hud_configure && spectatee_status <= 0 || intermission > 1)))
        {
                setproperty(VF_ORIGIN, freeze_org);
                setproperty(VF_ANGLES, freeze_ang);
@@ -539,8 +565,8 @@ void CSQC_UpdateView(float w, float h)
                        calledhooks |= HOOK_END;
                }
        }
-       
-  Announcer();
+
+       Announcer();
 
        fov = autocvar_fov;
        if(fov <= 59.5)
@@ -773,7 +799,6 @@ void CSQC_UpdateView(float w, float h)
 
 
        // improved polyblend
-       vector rgb;
        if(autocvar_hud_contents)
        {
                float contentalpha_temp, incontent, liquidalpha, contentfadetime;
@@ -890,25 +915,22 @@ void CSQC_UpdateView(float w, float h)
                // pro: matches model better
                // contra: it's not red because blood is red, but because red is an alarming color, so red should stay
                // maybe different reddish pics?
-               if(autocvar_chase_active >= 0) // not while the event chase camera is active
+               if(autocvar_cl_gentle_damage || autocvar_cl_gentle)
                {
-                       if(autocvar_cl_gentle_damage || autocvar_cl_gentle)
+                       if(autocvar_cl_gentle_damage == 2)
                        {
-                               if(autocvar_cl_gentle_damage == 2)
+                               if(myhealth_flash < pain_threshold) // only randomize when the flash is gone
                                {
-                                       if(myhealth_flash < pain_threshold) // only randomize when the flash is gone
-                                       {
-                                               myhealth_gentlergb = eX * random() + eY * random() + eZ * random();
-                                       }
+                                       myhealth_gentlergb = eX * random() + eY * random() + eZ * random();
                                }
-                               else
-                                       myhealth_gentlergb = stov(autocvar_hud_damage_gentle_color);
-
-                               drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, myhealth_gentlergb, autocvar_hud_damage_gentle_alpha_multiplier * bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
                        }
                        else
-                               drawpic(splash_pos, "gfx/blood", splash_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
+                               myhealth_gentlergb = stov(autocvar_hud_damage_gentle_color);
+
+                       drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, myhealth_gentlergb, autocvar_hud_damage_gentle_alpha_multiplier * bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
                }
+               else
+                       drawpic(splash_pos, "gfx/blood", splash_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
 
                if(autocvar_hud_postprocessing) // we still need to set this anyway even when chase_active is set, this way it doesn't get stuck on.
                {
@@ -936,7 +958,7 @@ void CSQC_UpdateView(float w, float h)
                if(cvar("r_glsl_postprocess_uservec2_enable") != e2) { cvar_set("r_glsl_postprocess_uservec2_enable", ftos(e2)); }
 
                // blur postprocess handling done first (used by hud_damage and hud_contents)
-               if((damage_blurpostprocess_x || content_blurpostprocess_x) && autocvar_chase_active >= 0) // not while the event chase camera is active
+               if((damage_blurpostprocess_x || content_blurpostprocess_x))
                {
                        float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, autocvar_hud_postprocessing_maxblurradius);
                        float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, autocvar_hud_postprocessing_maxbluralpha);
@@ -955,13 +977,13 @@ void CSQC_UpdateView(float w, float h)
                }
 
                // edge detection postprocess handling done second (used by hud_powerup) 
-               float sharpen_intensity, strength_finished = getstatf(STAT_STRENGTH_FINISHED), invincible_finished = getstatf(STAT_INVINCIBLE_FINISHED);
+               float sharpen_intensity = 0, strength_finished = getstatf(STAT_STRENGTH_FINISHED), invincible_finished = getstatf(STAT_INVINCIBLE_FINISHED);
                if (strength_finished - time > 0) { sharpen_intensity += (strength_finished - time); }
                if (invincible_finished - time > 0) { sharpen_intensity += (invincible_finished - time); }
                
                sharpen_intensity = bound(0, ((getstati(STAT_HEALTH) > 0) ? sharpen_intensity : 0), 5); // Check to see if player is alive (if not, set 0) - also bound to fade out starting at 5 seconds.
                
-               if(autocvar_hud_powerup && sharpen_intensity > 0 && autocvar_chase_active >= 0) // not while the event chase camera is active
+               if(autocvar_hud_powerup && sharpen_intensity > 0)
                {
                        if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible
                        {
@@ -1076,8 +1098,8 @@ void CSQC_UpdateView(float w, float h)
                        else
                                shottype = SHOTTYPE_HITWORLD;
 
-                       vector wcross_color, wcross_size;
-                       string wcross_wep, wcross_name;
+                       vector wcross_color = '0 0 0', wcross_size = '0 0 0';
+                       string wcross_wep = "", wcross_name;
                        float wcross_scale, wcross_blur;
 
                        if (autocvar_crosshair_per_weapon || autocvar_crosshair_color_per_weapon) {
@@ -1183,7 +1205,8 @@ void CSQC_UpdateView(float w, float h)
 
                        if(autocvar_crosshair_hitindication)
                        {
-                               vector hitindication_color = stov(autocvar_crosshair_hitindication_color);
+                               vector hitindication_color = ((autocvar_crosshair_color_per_weapon) ? stov(autocvar_crosshair_hitindication_per_weapon_color) : stov(autocvar_crosshair_hitindication_color));
+                               
                                if(hitindication_crosshair_time < hit_time)
                                {
                                        if(time - hit_time < MAX_TIME_DIFF) // don't trigger the animation if it's too old
@@ -1264,9 +1287,9 @@ void CSQC_UpdateView(float w, float h)
                                if (autocvar_crosshair_ring || autocvar_crosshair_ring_reload)
                                {
                                        // declarations and stats
-                                       float ring_value, ring_scale, ring_alpha, ring_inner_value, ring_inner_alpha;
-                                       string ring_image, ring_inner_image;
-                                       vector ring_rgb, ring_inner_rgb;
+                                       float ring_value = 0, ring_scale = 0, ring_alpha = 0, ring_inner_value = 0, ring_inner_alpha = 0;
+                                       string ring_image = string_null, ring_inner_image = string_null;
+                                       vector ring_rgb = '0 0 0', ring_inner_rgb = '0 0 0';
 
                                        ring_scale = autocvar_crosshair_ring_size;
 
@@ -1468,6 +1491,8 @@ void CSQC_UpdateView(float w, float h)
             CSQC_RAPTOR_HUD();
         else if(hud == HUD_BUMBLEBEE)
             CSQC_BUMBLE_HUD();
+        else if(hud == HUD_BUMBLEBEE_GUN)
+            CSQC_BUMBLE_GUN_HUD();
     }
        
        cl_notice_run();
@@ -1480,25 +1505,8 @@ void CSQC_UpdateView(float w, float h)
 
 void CSQC_common_hud(void)
 {
-    // do some accuracy var caching
-    float i;
-    if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS))
-    {
-        if(autocvar_accuracy_color_levels != acc_color_levels)
-        {
-            if(acc_color_levels)
-                strunzone(acc_color_levels);
-            acc_color_levels = strzone(autocvar_accuracy_color_levels);
-            acc_levels = tokenize_console(acc_color_levels);
-            if (acc_levels > MAX_ACCURACY_LEVELS)
-                acc_levels = MAX_ACCURACY_LEVELS;
-
-            for (i = 0; i < acc_levels; ++i)
-                acc_lev[i] = stof(argv(i)) / 100.0;
-        }
-        // let know that acc_col[] needs to be loaded
-        acc_col[0] = '-1 0 0';
-    }
+       if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS))
+               Accuracy_LoadLevels();
 
     HUD_Main(); // always run these functions for alpha checks
     HUD_DrawScoreboard();