From: Mario Date: Sat, 27 Jan 2018 11:21:21 +0000 (+1000) Subject: Add a free movement spawnflag to viewlocation to allow forward and backward travel... X-Git-Tag: xonotic-v0.8.5~2368 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d0fe3aff3992f2ad4a914c63146ae54f70f5994c;p=xonotic%2Fxonotic-data.pk3dir.git Add a free movement spawnflag to viewlocation to allow forward and backward travel in side-scrolling mode (like brawlers) --- diff --git a/qcsrc/common/triggers/trigger/viewloc.qh b/qcsrc/common/triggers/trigger/viewloc.qh index 3181e67b5..69c6c821e 100644 --- a/qcsrc/common/triggers/trigger/viewloc.qh +++ b/qcsrc/common/triggers/trigger/viewloc.qh @@ -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; diff --git a/qcsrc/common/viewloc.qc b/qcsrc/common/viewloc.qc index 5f5fe8b9f..50565c95a 100644 --- a/qcsrc/common/viewloc.qc +++ b/qcsrc/common/viewloc.qc @@ -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);