+ // event chase cam
+ if(spectatee_status >= 0 && (autocvar_cl_chase_death || autocvar_cl_chase_intermission))
+ if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually
+ {
+ if((autocvar_cl_chase_death && getstati(STAT_HEALTH) <= 0 && !intermission) || (autocvar_cl_chase_intermission && intermission) && intermission <= 1) // not during the map voting screen
+ {
+ // We must set chase_active in order to get a third person view (1st person weapon model hidden and own player model showing).
+ // Ideally, there should be another way to enable third person mode, such as an R_SetView() function specifically for this purpose.
+
+ if(!autocvar_chase_active)
+ cvar_set("chase_active", "-1"); // -1 enables chase_active as well as marking it as set by this code, and not by the user (which would be 1)
+
+ // make the camera smooth back
+ if(autocvar_cl_chase_speed && chase_current_distance < autocvar_cl_chase_distance)
+ chase_current_distance += autocvar_cl_chase_speed * (autocvar_cl_chase_distance - chase_current_distance) * frametime; // slow down smoothly
+ else if(chase_current_distance != autocvar_cl_chase_distance)
+ chase_current_distance = autocvar_cl_chase_distance;
+
+ vector chase_target_origin;
+ makevectors(view_angles);
+ chase_target_origin = pmove_org - view_forward * chase_current_distance;
+
+ // don't allow the camera to go through walls
+ traceline(pmove_org, chase_target_origin, MOVE_NORMAL, self);
+ if(trace_fraction == 1)
+ {
+ R_SetView(VF_ORIGIN, chase_target_origin);
+ chase_old_origin = chase_target_origin;
+ }
+ else
+ R_SetView(VF_ORIGIN, chase_old_origin);
+ }
+ else if(autocvar_chase_active < 0)
+ {
+ cvar_set("chase_active", "0");
+ chase_current_distance = 0; // start from 0
+ }
+ }
+