]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into mirceakitsune/event_chasecam
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 7 Apr 2011 21:40:46 +0000 (00:40 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 7 Apr 2011 21:40:46 +0000 (00:40 +0300)
defaultXonotic.cfg
qcsrc/client/View.qc
qcsrc/client/autocvars.qh

index bddddb12e409430f7dfa9a41e8dd8e470c1b3b39..6a5a8aeb358eced8a6d3ee9bb45db2778bd2cf81 100644 (file)
@@ -241,8 +241,8 @@ vid_conheight 600
 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
@@ -316,6 +316,11 @@ set sv_ready_restart_repeatable 0  "allows the players to restart the game as oft
 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)"
 
index 09ec96eabaaa9ece2608496c64c551d646d1b695..4a0d48686cdb68e37c3ea14badf1c2ae987ae820 100644 (file)
@@ -366,6 +366,8 @@ vector myhealth_gentlergb;
 float contentavgalpha, liquidalpha_prev;
 vector liquidcolor_prev;
 
+float eventchase_current_distance;
+
 void CSQC_UpdateView(float w, float h)
 {
        entity e;
@@ -401,7 +403,7 @@ void CSQC_UpdateView(float w, float h)
        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;
@@ -412,8 +414,43 @@ void CSQC_UpdateView(float w, float h)
        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;
index e11266ce0223324944413047fc647a5d95314ea2..bc5c16f2a27b375fc5edfcc12f453047620253cd 100644 (file)
@@ -305,3 +305,7 @@ float autocvar_viewsize;
 float autocvar_crosshair_color_by_health;
 float autocvar_cl_hitsound;
 float autocvar_cl_hitsound_antispam_time;
+float autocvar_cl_eventchase_death;
+float autocvar_cl_eventchase_intermission;
+float autocvar_cl_eventchase_distance;
+float autocvar_cl_eventchase_speed;