]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/master' into mirceakitsune/event_chasecam
authorSamual <samual@xonotic.org>
Fri, 29 Apr 2011 05:35:24 +0000 (01:35 -0400)
committerSamual <samual@xonotic.org>
Fri, 29 Apr 2011 05:35:24 +0000 (01:35 -0400)
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh

index 14c52f9227f992a0da3d0f9b0f5c6cc8d3f55023..546bbf4d064c1be624a935ebc6148030414a587c 100644 (file)
@@ -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 81a713c32456ee7d3b0d5034dacb31f9da1df228..8500cc58b67b5e36dcc6cb9b339d2d836bf23b43 100644 (file)
@@ -203,6 +203,10 @@ void CSQC_Shutdown(void)
        if(camera_active)
                cvar_set("chase_active",ftos(chase_active_backup));
 
+       // unset the event chasecam's chase_active
+       if(autocvar_chase_active < 0)
+               cvar_set("chase_active", "0");
+
        if not(isdemo())
        {
                if not(calledhooks & HOOK_START)
index 1a1c37624d4aa66ec0cdd25825e7c2c062e213d4..0da6406195bc955b32298dc81dd9c385e2fdebf3 100644 (file)
@@ -366,6 +366,8 @@ vector myhealth_gentlergb;
 float contentavgalpha, liquidalpha_prev;
 vector liquidcolor_prev;
 
+float eventchase_current_distance;
+
 float checkfail[16];
 
 void CSQC_UpdateView(float w, float h)
@@ -411,7 +413,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;
@@ -422,8 +424,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 - v_forward * eventchase_current_distance;
+
+                       traceline(pmove_org, 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 = pmove_org - v_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..6d157405b04653cadafb3933e162022de10aec41 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;
+var float autocvar_cl_eventchase_death = 1;
+var float autocvar_cl_eventchase_intermission = 1;
+var float autocvar_cl_eventchase_distance = 140;
+var float autocvar_cl_eventchase_speed = 1.3;