- 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(!(view.viewloc.spawnflags & VIEWLOC_FREEAIM))
- {
- 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);
- }
- else
- {
- //vector fpos = view.origin + view.view_ofs + forward * max_shot_distance;
- //vector bpos = view.origin + view.view_ofs + backward * max_shot_distance;
+ if (have_sidescroll) {
+ vector view_angle = view.angles;
+ if (!(view.viewloc.spawnflags & VIEWLOC_FREEAIM)) {
+ vector avatar_facing_dir;
+ // get the player's forward-facing direction, based on positions a and b
+ if (0 == input_movevalues.y) {
+ avatar_facing_dir = view_angle; // default to the previous values
+ } else if (0 > input_movevalues.y) { // left is forward
+ avatar_facing_dir = vectoangles(normalize(vec_to_max(position_b, position_a) - vec_to_min(position_b, position_a)));
+ } else { // right is forward
+ avatar_facing_dir = vectoangles(normalize(vec_to_min(position_b, position_a) - vec_to_max(position_b, position_a)));
+ }
+ 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;
+ }
+ } else {