]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a free movement spawnflag to viewlocation to allow forward and backward travel...
authorMario <mario@smbclan.net>
Sat, 27 Jan 2018 11:21:21 +0000 (21:21 +1000)
committerMario <mario@smbclan.net>
Sat, 27 Jan 2018 11:21:21 +0000 (21:21 +1000)
qcsrc/common/triggers/trigger/viewloc.qh
qcsrc/common/viewloc.qc

index 3181e67b5dd592baacef6cdee10b801777dbfb78..69c6c821ed7f23cde5c765a3f8bb989f1c2de2c8 100644 (file)
@@ -4,6 +4,7 @@
 
 const int VIEWLOC_NOSIDESCROLL = BIT(0); // NOTE: currently unimplemented
 const int VIEWLOC_FREEAIM = BIT(1);
+const int VIEWLOC_FREEMOVE = BIT(2);
 
 #ifdef CSQC
 .entity goalentity;
index 5f5fe8b9fdd6f4bb512a66287b31acf76e949919..50565c95af61a33039ae0ae104af7ece67671cb7 100644 (file)
@@ -19,7 +19,10 @@ void viewloc_PlayerPhysics(entity this)
 
                vector old_movement = PHYS_CS(this).movement;
                PHYS_CS(this).movement_x = old_movement_y;
-               PHYS_CS(this).movement_y = 0;
+               if(this.viewloc.spawnflags & VIEWLOC_FREEMOVE)
+                       PHYS_CS(this).movement_y = old_movement_x;
+               else
+                       PHYS_CS(this).movement_y = 0;
 
                vector level_start, level_end;
                level_start = this.viewloc.enemy.origin;
@@ -27,6 +30,9 @@ void viewloc_PlayerPhysics(entity this)
                vector forward = vectoangles(normalize(level_end - level_start));
                vector backward = vectoangles(normalize(level_start - level_end));
 
+               if((this.viewloc.spawnflags & VIEWLOC_FREEMOVE) && this.angles_y < 0)
+                       PHYS_CS(this).movement_y = -PHYS_CS(this).movement_y;
+
                if(this.viewloc.spawnflags & VIEWLOC_FREEAIM)
                {
                        if(this.angles_y > 0)
@@ -44,6 +50,8 @@ void viewloc_PlayerPhysics(entity this)
                }
 
                //if(!PHYS_INPUT_BUTTON_CROUCH(this) && !IS_DUCKED(this))
+               if(!(this.viewloc.spawnflags & VIEWLOC_FREEMOVE))
+               {
 #ifdef SVQC
                        //PHYS_INPUT_BUTTON_CROUCH(this) = (old_movement_x < 0);
                        if (old_movement.x < 0)
@@ -56,6 +64,7 @@ void viewloc_PlayerPhysics(entity this)
                        }
                        //else { input_buttons &= ~16; this.flags &= ~FL_DUCKED; }
 #endif
+               }
        }
 }
 
@@ -172,10 +181,12 @@ void viewloc_SetViewLocation()
                                view_angle.y = avatar_facing_dir.y; // snap avatar to look on along the correct axis
 
                                // if (0 == input_movevalues.x) look straight ahead
-                               if (0 > input_movevalues.x) { // look up
-                                       view_angle.x = 50;
-                               } else if (0 < input_movevalues.x) { // look down
-                                       view_angle.x = -50;
+                               if (!(view.viewloc.spawnflags & VIEWLOC_FREEMOVE)) {
+                                       if (0 > input_movevalues.x) { // look up
+                                               view_angle.x = 50;
+                                       } else if (0 < input_movevalues.x) { // look down
+                                               view_angle.x = -50;
+                                       }
                                }
                        } else {
                                vector mpos = CursorToWorldCoord(viewloc_mousepos);