From: Mario Date: Mon, 20 Feb 2017 14:08:24 +0000 (+1000) Subject: If viewlocation has no ending target, consider it non-sidescrolling (scrolling depend... X-Git-Tag: xonotic-v0.8.2~192 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f4813c297a26e083f4421110cb028a13768b406b;p=xonotic%2Fxonotic-data.pk3dir.git If viewlocation has no ending target, consider it non-sidescrolling (scrolling depends on there being a start and end target, when end doesn't exist revert to free aiming and movement) --- diff --git a/qcsrc/common/viewloc.qc b/qcsrc/common/viewloc.qc index 300aed4fc..90da2662f 100644 --- a/qcsrc/common/viewloc.qc +++ b/qcsrc/common/viewloc.qc @@ -14,6 +14,9 @@ void viewloc_PlayerPhysics(entity this) { if(this.viewloc) { + if(this.viewloc.goalentity == this.viewloc.enemy) + return; // we can't side-scroll in this case + vector old_movement = this.movement; this.movement_x = old_movement_y; this.movement_y = 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); + } } }