Xonotic
viewloc.qc File Reference
#include "viewloc.qh"
+ Include dependency graph for viewloc.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void viewloc_PlayerPhysics (entity this)
 

Function Documentation

◆ viewloc_PlayerPhysics()

void viewloc_PlayerPhysics ( entity  this)

Definition at line 13 of file viewloc.qc.

References aim_vec(), angle_snap_f(), angle_snap_vec(), autocvar_vid_conheight, autocvar_vid_conwidth, BIT, CSQCModel_server2csqc(), entity(), entnum, findfloat(), flags, freeze_ang, freeze_org, input_buttons, input_movevalues, LOG_TRACE, max(), min(), MOVE_NOMONSTERS, normalize(), NULL, PHYS_INPUT_BUTTON_CROUCH, player_localentnum, spectatee_status, STATIC_INIT_LATE, trace_endpos, vec2, vec3, vec_bounds_in(), vec_to_max(), vec_to_min(), vectoangles(), vector(), VF_ANGLES, VF_CL_VIEWANGLES, VF_ORIGIN, viewloc, VIEWLOC_CAM_NOANGLE, VIEWLOC_CAM_SNAP_CLOSE, VIEWLOC_CAM_SNAP_HARD, VIEWLOC_CAM_SNAP_UNLOCK, VIEWLOC_CAM_TRACK, VIEWLOC_FREEAIM, VIEWLOC_FREEMOVE, viewloc_mousepos, and vtos().

Referenced by sys_phys_update().

14 {
15  if(this.viewloc)
16  {
17  if(this.viewloc.goalentity == this.viewloc.enemy)
18  return; // we can't side-scroll in this case
19 
20  vector old_movement = PHYS_CS(this).movement;
21  PHYS_CS(this).movement_x = old_movement_y;
22  if((this.viewloc.spawnflags & VIEWLOC_FREEMOVE) && !this.ladder_entity)
23  PHYS_CS(this).movement_y = old_movement_x;
24  else
25  PHYS_CS(this).movement_y = 0;
26 
27  vector level_start, level_end;
28  level_start = this.viewloc.enemy.origin;
29  level_end = this.viewloc.goalentity.origin;
30  vector forward = vectoangles(normalize(level_end - level_start));
31  vector backward = vectoangles(normalize(level_start - level_end));
32 
33  if((this.viewloc.spawnflags & VIEWLOC_FREEMOVE) && this.angles_y < 0 && !this.ladder_entity)
34  PHYS_CS(this).movement_y = -PHYS_CS(this).movement_y;
35 
36  if(this.viewloc.spawnflags & VIEWLOC_FREEAIM)
37  {
38  if(this.angles_y > 0)
39  PHYS_CS(this).movement_x = -PHYS_CS(this).movement_x;
40  }
41  else
42  {
43  if(PHYS_CS(this).movement_x < 0)
44  PHYS_CS(this).movement_x = -PHYS_CS(this).movement_x;
45 
46  if(PHYS_CS(this).movement_x < 0) // left
47  this.angles_y = backward.y;
48  if(PHYS_CS(this).movement_x > 0) // right
49  this.angles_y = forward.y;
50  }
51  #if 0
52  //if(!PHYS_INPUT_BUTTON_CROUCH(this) && !IS_DUCKED(this))
53  if(!(this.viewloc.spawnflags & VIEWLOC_FREEMOVE))
54  {
55 #ifdef SVQC
56  //PHYS_INPUT_BUTTON_CROUCH(this) = (old_movement_x < 0);
57  if (old_movement.x < 0)
58  PHYS_INPUT_BUTTON_CROUCH(this) = true;
59 #elif defined(CSQC)
60  if (old_movement.x < 0)
61  {
62  input_buttons |= BIT(4);
63  this.flags |= FL_DUCKED;
64  }
65  //else { input_buttons &= ~16; this.flags &= ~FL_DUCKED; }
66 #endif
67  }
68  #endif
69  }
70 }
#define PHYS_INPUT_BUTTON_CROUCH(s)
Definition: player.qh:150
float input_buttons
Definition: csprogsdefs.qc:62
const int VIEWLOC_FREEAIM
Definition: viewloc.qh:5
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
vector(float skel, float bonenum) _skel_get_boneabs_hidden
entity viewloc
Definition: viewloc.qh:13
float flags
Definition: csprogsdefs.qc:129
const int VIEWLOC_FREEMOVE
Definition: viewloc.qh:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function: