]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/View.qc
Make a comment more descriptive
[voretournament/voretournament.git] / data / qcsrc / client / View.qc
index a0a337b0ce31dfaafb5d5f131f309e1fedcb5947..3aa7f7c98c376d27893f7a8eb2ce4bf1188b9ce3 100644 (file)
@@ -260,6 +260,7 @@ float old_blurradius, old_bluralpha, old_sharpen_intensity;
 float stomachsplash_alpha, stomachsplash_remove_at_respawn;\r
 float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2;\r
 float volume_modify_changed_1, volume_modify_changed_2;\r
+float eventchase_current_distance;\r
 vector myhealth_gentlergb;\r
 vector liquidcolor_prev;\r
 vector damage_blurpostprocess, content_blurpostprocess;\r
@@ -294,6 +295,42 @@ void CSQC_UpdateView(float w, float h)
        pmove_org = warpzone_fixview_origin - vo;\r
        input_angles = warpzone_fixview_angles;\r
 \r
+       // event chase camera\r
+       if(cvar("chase_active") <= 0) // greater than 0 means it's enabled manually, and this code is skipped\r
+       {\r
+               if(!getstati(STAT_VORE_EATEN) && spectatee_status >= 0 && (cvar("cl_eventchase_death") && getstati(STAT_HEALTH) <= 0 && !intermission))\r
+               {\r
+                       // We must enable chase_active to get a third person view (weapon viewmodel hidden and own player model showing).\r
+                       // Ideally, there should be another way to enable third person cameras, such as through R_SetView()\r
+                       if(!cvar("chase_active"))\r
+                               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)\r
+\r
+                       // make the camera smooth back\r
+                       if(cvar("cl_eventchase_speed") && eventchase_current_distance < cvar("cl_eventchase_distance"))\r
+                               eventchase_current_distance += cvar("cl_eventchase_speed") * (cvar("cl_eventchase_distance") - eventchase_current_distance) * frametime; // slow down the further we get\r
+                       else if(eventchase_current_distance != cvar("cl_eventchase_distance"))\r
+                               eventchase_current_distance = cvar("cl_eventchase_distance");\r
+\r
+                       vector eventchase_target_origin;\r
+                       makevectors(view_angles);\r
+                       // pass 1, used to check where the camera would go and obtain the trace_fraction\r
+                       eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance;\r
+\r
+                       traceline(pmove_org, eventchase_target_origin, MOVE_WORLDONLY, self);\r
+                       // pass 2, also multiplying view_forward with trace_fraction, to prevent the camera from going through walls\r
+                       // The 0.1 subtraction is to not limit the camera precisely at the wall surface, as that allows the view to poke through\r
+                       eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance * (trace_fraction - 0.1);\r
+\r
+                       R_SetView(VF_ORIGIN, eventchase_target_origin);\r
+                       R_SetView(VF_ANGLES, view_angles);\r
+               }\r
+               else if(cvar("chase_active") < 0) // time to disable chase_active if it was set by this code\r
+               {\r
+                       cvar_set("chase_active", "0");\r
+                       eventchase_current_distance = 0; // start from 0 next time\r
+               }\r
+       }\r
+\r
        // Render the Scene\r
        if(!intermission || !view_set)\r
        {\r
@@ -711,7 +748,7 @@ void CSQC_UpdateView(float w, float h)
                        cvar_set("r_glsl_postprocess_uservec2_enable", ftos(cvar("hud_powerup") != 0));\r
 \r
                // lets apply the postprocess effects from the previous two functions if needed\r
-               if(damage_blurpostprocess_x || content_blurpostprocess_x)\r
+               if((damage_blurpostprocess_x || content_blurpostprocess_x) && cvar("chase_active") >= 0) // not while the event chase camera is active\r
                {\r
                        float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, cvar("hud_postprocessing_maxblurradius"));\r
                        float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, cvar("hud_postprocessing_maxbluralpha"));\r
@@ -735,7 +772,7 @@ void CSQC_UpdateView(float w, float h)
                if (getstatf(STAT_INVINCIBLE_FINISHED) - time > 0)\r
                        sharpen_intensity += (getstatf(STAT_INVINCIBLE_FINISHED) - time);\r
 \r
-               if(cvar("hud_powerup") && sharpen_intensity > 0)\r
+               if(cvar("hud_powerup") && sharpen_intensity > 0 && cvar("chase_active") >= 0) // not while the event chase camera is active\r
                {\r
                        sharpen_intensity = bound(0, sharpen_intensity, 5); // powerup warning time is 5 seconds, so fade the effect from there\r
 \r