v_deathtilt 0 // needed for spectators (who are dead to avoid prediction)
// these settings determine how much the view is affected by movement/damage
+cl_deathfade 0.03 // fade screen to dark red when dead, value represents how fast the fade is (higher is faster)
cl_smoothviewheight 0.05 // time of the averaging to the viewheight value so that it creates a smooth transition for crouching and such. 0 for instant transition
-cl_deathfade 1 // fade screen to dark red when dead, value represents how fast the fade is (higher is faster)
cl_bobcycle 0 // how long the cycle of up/down view movement takes (only works if cl_bob is not 0), default is 0.6
cl_bob 0.01 // how much view moves up/down when moving (does not move if cl_bobcycle is 0, but still enables cl_bobmodel), default is 0.02
cl_bob2cycle 0 // how long the cycle of left/right view movement takes (only works if cl_bob2 is not 0), default is 0.6
seta cl_hitsound 1 "play a hit notifier sound when you have hit an enemy"
set cl_hitsound_antispam_time 0.05 "don't play the hitsound more often than this"
+seta cl_eventchase_death 1 "camera goes into 3rd person mode when the player is dead"
+seta cl_eventchase_intermission 1 "camera goes into 3rd person mode when the match ends"
+seta cl_eventchase_distance 140 "final camera distance"
+seta cl_eventchase_speed 1.3 "how fast the camera slides back, 0 is instant"
+
//nifreks lockonrestart feature, used in team-based game modes, if set to 1 and all players readied up no other player can then join the game anymore, useful to block spectators from joining
set teamplay_lockonrestart 0 "it set to 1 in a team-based game, the teams are locked once all players readied up and the game restarted (no new players can join after restart unless using the server-command unlockteams)"
float contentavgalpha, liquidalpha_prev;
vector liquidcolor_prev;
+float eventchase_current_distance;
+
void CSQC_UpdateView(float w, float h)
{
entity e;
input_angles = warpzone_fixview_cl_viewangles;
view_angles = warpzone_fixview_angles;
- if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0))
+ if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0) || intermission > 1)
{
pmove_org = freeze_pmove_org;
input_angles = view_angles = freeze_input_angles;
freeze_pmove_org = pmove_org;
freeze_input_angles = input_angles;
+ // event chase camera
+ if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually, and this code is skipped
+ {
+ if(spectatee_status >= 0 && (autocvar_cl_eventchase_death && getstati(STAT_HEALTH) <= 0 && !intermission) || (autocvar_cl_eventchase_intermission && intermission))
+ {
+ // 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 R_SetView()
+ 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)
+
+ // make the camera smooth back
+ if(autocvar_cl_eventchase_speed && eventchase_current_distance < autocvar_cl_eventchase_distance)
+ eventchase_current_distance += autocvar_cl_eventchase_speed * (autocvar_cl_eventchase_distance - eventchase_current_distance) * frametime; // slow down the further we get
+ 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 = pmove_org - view_forward * eventchase_current_distance;
+
+ traceline(pmove_org, eventchase_target_origin, MOVE_NORMAL, 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 = pmove_org - view_forward * eventchase_current_distance * (trace_fraction - 0.1);
+
+ R_SetView(VF_ORIGIN, eventchase_target_origin);
+ }
+ else if(autocvar_chase_active < 0) // time to disable chase_active if it was set by this code
+ {
+ cvar_set("chase_active", "0");
+ eventchase_current_distance = 0; // start from 0 next time
+ }
+ }
+
// Render the Scene
- if(!intermission || !view_set)
+ if(!intermission || !view_set || (intermission && autocvar_cl_eventchase_intermission))
{
view_origin = pmove_org + vo;
view_angles = input_angles;