]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/viewloc.qc
Made instagib powerups on par with vanilla ones.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / viewloc.qc
index 300aed4fc7f99a36b1367a90e09a991cbb2fc6b9..d6d7d9facfb2edc3f7f32c39138119723a47f5b0 100644 (file)
@@ -14,12 +14,15 @@ void viewloc_PlayerPhysics(entity this)
 {
        if(this.viewloc)
        {
-               vector old_movement = this.movement;
-               this.movement_x = old_movement_y;
-               this.movement_y = 0;
+               if(this.viewloc.goalentity == this.viewloc.enemy)
+                       return; // we can't side-scroll in this case
 
-               if(this.movement_x < 0)
-                       this.movement_x = -this.movement_x;
+               vector old_movement = PHYS_CS(this).movement;
+               PHYS_CS(this).movement_x = old_movement_y;
+               PHYS_CS(this).movement_y = 0;
+
+               if(PHYS_CS(this).movement_x < 0)
+                       PHYS_CS(this).movement_x = -PHYS_CS(this).movement_x;
 
                vector level_start, level_end;
                level_start = this.viewloc.enemy.origin;
@@ -28,9 +31,9 @@ void viewloc_PlayerPhysics(entity this)
                forward = vectoangles(normalize(level_end - level_start));
                backward = vectoangles(normalize(level_start - level_end));
 
-               if(this.movement_x < 0) // left
+               if(PHYS_CS(this).movement_x < 0) // left
                        this.angles_y = backward_y;
-               if(this.movement_x > 0) // right
+               if(PHYS_CS(this).movement_x > 0) // right
                        this.angles_y = forward_y;
 
                if(old_movement_x > 0)
@@ -86,6 +89,7 @@ void viewloc_SetViewLocation()
        //NOTE: the "cam_" cvars sould probably be changed out with a spawnflag or an entity key. I have it like this for my testing -- Player_2
        if(view.viewloc && !wasfreed(view.viewloc) && view.viewloc.enemy && view.viewloc.goalentity)
        {
+               bool have_sidescroll = (view.viewloc.enemy != view.viewloc.goalentity);
                vector position_a, position_b, camera_position, camera_angle = '0 0 0', forward, backward;
                //vector scratch;
 
@@ -105,7 +109,7 @@ void viewloc_SetViewLocation()
 
 
                // a tracking camera follows the player when it leaves the world box
-               if (autocvar_cam_track) {
+               if (autocvar_cam_track || !have_sidescroll) {
                        camera_angle = aim_vec (camera_position, view.origin);
                }
 
@@ -149,15 +153,18 @@ void viewloc_SetViewLocation()
                setproperty(VF_ORIGIN, camera_position);
                setproperty(VF_ANGLES, camera_angle);
 
-               forward = vectoangles(normalize(vec_to_min(position_b, position_a) - vec_to_max(position_b, position_a)));
-               backward = vectoangles(normalize(vec_to_max(position_b, position_a) - vec_to_min(position_b, position_a)));
+               if(have_sidescroll)
+               {
+                       forward = vectoangles(normalize(vec_to_min(position_b, position_a) - vec_to_max(position_b, position_a)));
+                       backward = vectoangles(normalize(vec_to_max(position_b, position_a) - vec_to_min(position_b, position_a)));
 
-               if(input_movevalues_y < 0) // left
-                       view.angles_y = backward_y;
-               if(input_movevalues_y > 0) // favour right
-                       view.angles_y = forward_y;
+                       if(input_movevalues_y < 0) // left
+                               view.angles_y = backward.y;
+                       if(input_movevalues_y > 0) // favour right
+                               view.angles_y = forward.y;
 
-               setproperty(VF_CL_VIEWANGLES, view.angles);
+                       setproperty(VF_CL_VIEWANGLES, view.angles);
+               }
        }
 }