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

Go to the source code of this file.

Macros

#define avg_factor(avg_time)   (1 - exp(-frametime / max(0.001, avg_time)))
 
#define highpass(value, frac, ref_store, ret)
 
#define highpass2(value, frac, ref_store, ref_out)
 
#define highpass2_limited(value, frac, limit, ref_store, ref_out)
 
#define highpass3(value, frac, ref_store, ref_out)
 
#define highpass_limited(value, frac, limit, ref_store, ret)
 
#define lowpass(value, frac, ref_store, ret)   ret = ref_store = ref_store * (1 - frac) + (value) * frac;
 
#define lowpass2(value, frac, ref_store, ref_out)
 
#define lowpass3(value, frac, ref_store, ref_out)
 
#define lowpass_limited(value, frac, limit, ref_store, ret)
 

Functions

vector bobmodel_ofs (entity view)
 
void calc_followmodel_ofs (entity view)
 
void CSQC_Demo_Camera ()
 
void CSQC_UpdateView (entity this, float w, float h)
 
void fpscounter_update ()
 
vector GetCurrentFov (float fov)
 
vector GetOrthoviewFOV (vector ov_worldmin, vector ov_worldmax, vector ov_mid, vector ov_org)
 
vector GetViewLocationFOV (float fov)
 
void HitSound ()
 
void HUD_Contents ()
 
void HUD_Cursor_Show ()
 
void HUD_Damage ()
 
void HUD_Draw (entity this)
 
void HUD_Mouse (entity player)
 
vector leanmodel_ofs (entity view)
 
vector project_3d_to_2d (vector vec)
 
bool projected_on_screen (vector screen_pos)
 
 STATIC_INIT (viewmodel)
 
 STATIC_INIT (fpscounter_init)
 
void update_mousepos ()
 
void UpdateDamage ()
 
void View_CheckButtonStatus ()
 
void View_DemoCamera ()
 
void View_EventChase (entity this)
 
void View_Lock ()
 
void View_NightVision ()
 
void View_Ortho ()
 
void View_PostProcessing ()
 
void View_UpdateFov ()
 
void ViewLocation_Mouse ()
 
void viewmodel_animate (entity this)
 
void viewmodel_draw (entity this)
 
int WantEventchase (entity this, bool want_vehiclechase)
 

Variables

bool autocvar_cl_bobmodel
 
float autocvar_cl_bobmodel_side
 
float autocvar_cl_bobmodel_speed
 
float autocvar_cl_bobmodel_up
 
float autocvar_cl_followmodel
 
float autocvar_cl_followmodel_highpass = 0.05
 
float autocvar_cl_followmodel_limit = 135
 
float autocvar_cl_followmodel_lowpass = 0.03
 
float autocvar_cl_followmodel_speed = 0.3
 
bool autocvar_cl_followmodel_velocity_absolute
 
float autocvar_cl_followmodel_velocity_lowpass = 0.05
 
float autocvar_cl_leanmodel
 
float autocvar_cl_leanmodel_highpass = 0.2
 
float autocvar_cl_leanmodel_highpass1 = 0.2
 
float autocvar_cl_leanmodel_limit = 30
 
float autocvar_cl_leanmodel_lowpass = 0.05
 
float autocvar_cl_leanmodel_speed = 0.3
 
float autocvar_cl_viewmodel_alpha = 1
 
float autocvar_cl_viewmodel_scale
 
float avgspeed
 
const float CAMERA_CHASE = 2
 
const float CAMERA_FREE = 1
 
float camera_mode
 
vector camera_offset
 
vector content_blurpostprocess
 
float contentavgalpha
 
vector current_angles
 
vector current_camera_offset
 
vector current_origin
 
vector current_position
 
vector damage_blurpostprocess
 
float eventchase_current_distance
 
float eventchase_running
 
vector freeze_ang
 
vector freeze_org
 
float liquidalpha_prev
 
vector liquidcolor_prev
 
bool minigame_wasactive
 
vector mouse_angles
 
float myhealth
 
float myhealth_flash
 
vector myhealth_gentlergb
 
float myhealth_prev
 
string name_last
 
string NextFrameCommand
 
entity nightvision_noise
 
entity nightvision_noise2
 
float old_bluralpha
 
float old_blurradius
 
float old_sharpen_intensity
 
float oldr_farclip_base
 
float oldr_farclip_world
 
float oldr_nearclip
 
float oldr_novis
 
float oldr_useinfinitefarclip
 
float oldr_useportalculling
 
bool ov_enabled
 
vector ov_mid = '0 0 0'
 
vector ov_org = '0 0 0'
 
vector ov_worldmax = '0 0 0'
 
vector ov_worldmin = '0 0 0'
 
int showfps_framecounter
 
float showfps_prevfps_time
 
vector viewmodel_angles
 
vector viewmodel_origin
 
float weapon_eta_last
 
float weapon_nextthink
 
float weapon_switchdelay
 

Macro Definition Documentation

◆ avg_factor

#define avg_factor (   avg_time)    (1 - exp(-frametime / max(0.001, avg_time)))

Definition at line 65 of file view.qc.

Referenced by calc_followmodel_ofs(), and leanmodel_ofs().

◆ highpass

#define highpass (   value,
  frac,
  ref_store,
  ret 
)
Value:
MACRO_BEGIN \
float __f = 0; lowpass(value, frac, ref_store, __f); \
ret = (value) - __f; \
MACRO_END
#define lowpass(value, frac, ref_store, ret)
Definition: view.qc:67

Definition at line 75 of file view.qc.

◆ highpass2

#define highpass2 (   value,
  frac,
  ref_store,
  ref_out 
)
Value:
highpass(value.x, frac, ref_store.x, ref_out.x); \
highpass(value.y, frac, ref_store.y, ref_out.y); \
MACRO_END
#define highpass(value, frac, ref_store, ret)
Definition: view.qc:75

Definition at line 90 of file view.qc.

Referenced by leanmodel_ofs().

◆ highpass2_limited

#define highpass2_limited (   value,
  frac,
  limit,
  ref_store,
  ref_out 
)
Value:
highpass_limited(value.x, frac, limit, ref_store.x, ref_out.x); \
highpass_limited(value.y, frac, limit, ref_store.y, ref_out.y); \
MACRO_END
#define highpass_limited(value, frac, limit, ref_store, ret)
Definition: view.qc:80

Definition at line 95 of file view.qc.

Referenced by leanmodel_ofs().

◆ highpass3

#define highpass3 (   value,
  frac,
  ref_store,
  ref_out 
)
Value:
highpass(value.x, frac, ref_store.x, ref_out.x); \
highpass(value.y, frac, ref_store.y, ref_out.y); \
highpass(value.z, frac, ref_store.z, ref_out.z); \
MACRO_END
#define highpass(value, frac, ref_store, ret)
Definition: view.qc:75

Definition at line 106 of file view.qc.

Referenced by calc_followmodel_ofs().

◆ highpass_limited

#define highpass_limited (   value,
  frac,
  limit,
  ref_store,
  ret 
)
Value:
MACRO_BEGIN \
float __f = 0; lowpass_limited(value, frac, limit, ref_store, __f); \
ret = (value) - __f; \
MACRO_END
#define lowpass_limited(value, frac, limit, ref_store, ret)
Definition: view.qc:70

Definition at line 80 of file view.qc.

◆ lowpass

#define lowpass (   value,
  frac,
  ref_store,
  ret 
)    ret = ref_store = ref_store * (1 - frac) + (value) * frac;

Definition at line 67 of file view.qc.

◆ lowpass2

#define lowpass2 (   value,
  frac,
  ref_store,
  ref_out 
)
Value:
lowpass(value.x, frac, ref_store.x, ref_out.x); \
lowpass(value.y, frac, ref_store.y, ref_out.y); \
MACRO_END
#define lowpass(value, frac, ref_store, ret)
Definition: view.qc:67

Definition at line 85 of file view.qc.

Referenced by leanmodel_ofs().

◆ lowpass3

#define lowpass3 (   value,
  frac,
  ref_store,
  ref_out 
)
Value:
lowpass(value.x, frac, ref_store.x, ref_out.x); \
lowpass(value.y, frac, ref_store.y, ref_out.y); \
lowpass(value.z, frac, ref_store.z, ref_out.z); \
MACRO_END
#define lowpass(value, frac, ref_store, ret)
Definition: view.qc:67

Definition at line 100 of file view.qc.

Referenced by calc_followmodel_ofs().

◆ lowpass_limited

#define lowpass_limited (   value,
  frac,
  limit,
  ref_store,
  ret 
)
Value:
MACRO_BEGIN \
float __ignore; lowpass(value, frac, ref_store, __ignore); \
ret = ref_store = bound((value) - (limit), ref_store, (value) + (limit)); \
MACRO_END
#define lowpass(value, frac, ref_store, ret)
Definition: view.qc:67

Definition at line 70 of file view.qc.

Function Documentation

◆ bobmodel_ofs()

vector bobmodel_ofs ( entity  view)

Definition at line 202 of file view.qc.

References ANIMIMPLICITSTATE_INAIR, autocvar_cl_bobmodel_side, autocvar_cl_bobmodel_speed, autocvar_cl_bobmodel_up, autocvar_cl_viewmodel_scale, bound(), cos(), frametime, max(), min(), sin(), time, vec2, vector(), and vlen().

Referenced by viewmodel_animate().

203 {
204  bool clonground = !(view.anim_implicit_state & ANIMIMPLICITSTATE_INAIR);
205  static bool oldonground;
206  static float hitgroundtime;
207  if (clonground)
208  {
209  float f = time; // cl.movecmd[0].time
210  if (!oldonground)
211  hitgroundtime = f;
212  }
213  oldonground = clonground;
214 
215  // calculate for swinging gun model
216  // the gun bobs when running on the ground, but doesn't bob when you're in the air.
217  vector gunorg = '0 0 0';
218  static float bobmodel_scale = 0;
219  static float time_ofs = 0; // makes the effect always restart in the same way
220  if (clonground)
221  {
222  if (time - hitgroundtime > 0.05)
223  bobmodel_scale = min(1, bobmodel_scale + frametime * 5);
224  }
225  else
226  bobmodel_scale = max(0, bobmodel_scale - frametime * 5);
227 
228  float xyspeed = bound(0, vlen(vec2(view.velocity)), 400);
229  if (bobmodel_scale && xyspeed)
230  {
231  float bspeed = xyspeed * 0.01 * autocvar_cl_viewmodel_scale * bobmodel_scale;
232  float s = (time - time_ofs) * autocvar_cl_bobmodel_speed;
233  gunorg.y = bspeed * autocvar_cl_bobmodel_side * sin(s);
234  gunorg.z = bspeed * autocvar_cl_bobmodel_up * cos(s * 2);
235  }
236  else
237  time_ofs = time;
238 
239  return gunorg;
240 }
float autocvar_cl_bobmodel_side
Definition: view.qc:47
float autocvar_cl_viewmodel_scale
Definition: view.qc:42
float autocvar_cl_bobmodel_up
Definition: view.qc:48
float frametime
Definition: csprogsdefs.qc:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const int ANIMIMPLICITSTATE_INAIR
Definition: animdecide.qh:132
float autocvar_cl_bobmodel_speed
Definition: view.qc:46
#define vec2(...)
Definition: vector.qh:90
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calc_followmodel_ofs()

void calc_followmodel_ofs ( entity  view)

Definition at line 112 of file view.qc.

References autocvar_cl_followmodel_highpass, autocvar_cl_followmodel_limit, autocvar_cl_followmodel_lowpass, autocvar_cl_followmodel_speed, autocvar_cl_followmodel_velocity_absolute, autocvar_cl_followmodel_velocity_lowpass, avg_factor, bound(), cl_followmodel_ofs, cl_followmodel_time, highpass3, lowpass3, time, vector(), and view_angles.

Referenced by Hud_Dynamic_Frame(), and viewmodel_animate().

113 {
115  return; // cl_followmodel_ofs already calculated for this frame
116 
117  float frac;
118  vector gunorg = '0 0 0';
119  static vector vel_average;
120  static vector gunorg_adjustment_highpass;
121  static vector gunorg_adjustment_lowpass;
122 
123  vector vel;
125  vel = view.velocity;
126  else
127  {
128  vector forward, right, up;
129  MAKE_VECTORS(view_angles, forward, right, up);
130  vel.x = view.velocity * forward;
131  vel.y = view.velocity * right * -1;
132  vel.z = view.velocity * up;
133  }
134 
135  vel.x = bound(vel_average.x - autocvar_cl_followmodel_limit, vel.x, vel_average.x + autocvar_cl_followmodel_limit);
136  vel.y = bound(vel_average.y - autocvar_cl_followmodel_limit, vel.y, vel_average.y + autocvar_cl_followmodel_limit);
137  vel.z = bound(vel_average.z - autocvar_cl_followmodel_limit, vel.z, vel_average.z + autocvar_cl_followmodel_limit);
138 
140  lowpass3(vel, frac, vel_average, gunorg);
141 
142  gunorg *= -autocvar_cl_followmodel_speed * 0.042;
143 
144  // perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
145  // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
147  highpass3(gunorg, frac, gunorg_adjustment_highpass, gunorg);
149  lowpass3(gunorg, frac, gunorg_adjustment_lowpass, gunorg);
150 
152  {
153  vector fixed_gunorg;
154  vector forward, right, up;
155  MAKE_VECTORS(view_angles, forward, right, up);
156  fixed_gunorg.x = gunorg * forward;
157  fixed_gunorg.y = gunorg * right * -1;
158  fixed_gunorg.z = gunorg * up;
159  gunorg = fixed_gunorg;
160  }
161 
162  cl_followmodel_ofs = gunorg;
164 }
float cl_followmodel_time
Definition: hud.qh:214
bool autocvar_cl_followmodel_velocity_absolute
Definition: view.qc:56
float autocvar_cl_followmodel_highpass
Definition: view.qc:54
float autocvar_cl_followmodel_lowpass
Definition: view.qc:55
#define lowpass3(value, frac, ref_store, ref_out)
Definition: view.qc:100
vector view_angles
Definition: csprogsdefs.qc:150
float autocvar_cl_followmodel_velocity_lowpass
Definition: view.qc:53
float autocvar_cl_followmodel_limit
Definition: view.qc:52
#define avg_factor(avg_time)
Definition: view.qc:65
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector cl_followmodel_ofs
Definition: hud.qh:213
#define highpass3(value, frac, ref_store, ref_out)
Definition: view.qc:106
float time
Definition: csprogsdefs.qc:16
float autocvar_cl_followmodel_speed
Definition: view.qc:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQC_Demo_Camera()

void CSQC_Demo_Camera ( )

Definition at line 1772 of file view.qc.

References autocvar_camera_chase_smoothly, autocvar_camera_forward_follows, autocvar_camera_free, autocvar_camera_look_attenuation, autocvar_camera_look_player, autocvar_camera_mouse_threshold, autocvar_camera_reset, autocvar_camera_speed_attenuation, autocvar_camera_speed_chase, autocvar_camera_speed_free, autocvar_camera_speed_roll, CAMERA_CHASE, camera_direction, CAMERA_FREE, camera_mode, camera_offset, camera_roll, cos(), current_angles, current_camera_offset, current_origin, current_position, cvar_set(), DEG2RAD, dir, getmousepos(), max(), mouse_angles, normalize(), sin(), speed, sqrt(), vdist, vectoangles(), vector(), VF_ANGLES, VF_ORIGIN, and view_origin.

Referenced by View_DemoCamera().

1773 {
1774  float speed, attenuation, dimensions;
1775  vector tmp, delta;
1776 
1778  {
1779  camera_offset = '0 0 0';
1780  current_angles = '0 0 0';
1781  camera_direction = '0 0 0';
1782  camera_offset.z += 30;
1783  camera_offset.x += 30 * -cos(current_angles.y * DEG2RAD);
1784  camera_offset.y += 30 * -sin(current_angles.y * DEG2RAD);
1787  cvar_set("camera_reset", "0");
1789  }
1790 
1791  // Camera angles
1792  if( camera_roll )
1794 
1796  {
1797  vector dir;
1798  float n;
1799 
1801  n = mouse_angles.z;
1802  mouse_angles = vectoangles(dir);
1803  mouse_angles.x = mouse_angles.x * -1;
1804  mouse_angles.z = n;
1805  }
1806  else
1807  {
1808  tmp = getmousepos() * 0.1;
1810  {
1811  mouse_angles.x += tmp.y * cos(mouse_angles.z * DEG2RAD) + (tmp.x * sin(mouse_angles.z * DEG2RAD));
1812  mouse_angles.y -= tmp.x * cos(mouse_angles.z * DEG2RAD) + (tmp.y * -sin(mouse_angles.z * DEG2RAD));
1813  }
1814  }
1815 
1816  while (mouse_angles.x < -180) mouse_angles.x = mouse_angles.x + 360;
1817  while (mouse_angles.x > 180) mouse_angles.x = mouse_angles.x - 360;
1818  while (mouse_angles.y < -180) mouse_angles.y = mouse_angles.y + 360;
1819  while (mouse_angles.y > 180) mouse_angles.y = mouse_angles.y - 360;
1820 
1821  // Fix difference when angles don't have the same sign
1822  delta = '0 0 0';
1823  if(mouse_angles.y < -60 && current_angles.y > 60)
1824  delta = '0 360 0';
1825  if(mouse_angles.y > 60 && current_angles.y < -60)
1826  delta = '0 -360 0';
1827 
1829  attenuation = autocvar_camera_look_attenuation;
1830  else
1831  attenuation = autocvar_camera_speed_attenuation;
1832 
1833  attenuation = 1 / max(1, attenuation);
1834  current_angles += (mouse_angles - current_angles + delta) * attenuation;
1835 
1836  while (current_angles.x < -180) current_angles.x = current_angles.x + 360;
1837  while (current_angles.x > 180) current_angles.x = current_angles.x - 360;
1838  while (current_angles.y < -180) current_angles.y = current_angles.y + 360;
1839  while (current_angles.y > 180) current_angles.y = current_angles.y - 360;
1840 
1841  // Camera position
1842  tmp = '0 0 0';
1843  dimensions = 0;
1844 
1845  if( camera_direction.x )
1846  {
1847  tmp.x = camera_direction.x * cos(current_angles.y * DEG2RAD);
1848  tmp.y = camera_direction.x * sin(current_angles.y * DEG2RAD);
1850  tmp.z = camera_direction.x * -sin(current_angles.x * DEG2RAD);
1851  ++dimensions;
1852  }
1853 
1854  if( camera_direction.y )
1855  {
1856  tmp.x += camera_direction.y * -sin(current_angles.y * DEG2RAD);
1858  tmp.z += camera_direction.y * sin(current_angles.z * DEG2RAD);
1859  ++dimensions;
1860  }
1861 
1862  if( camera_direction.z )
1863  {
1864  tmp.z += camera_direction.z * cos(current_angles.z * DEG2RAD);
1865  ++dimensions;
1866  }
1867 
1870  else
1872 
1873  if(dimensions)
1874  {
1875  speed = speed * sqrt(1 / dimensions);
1876  camera_offset += tmp * speed;
1877  }
1878 
1880 
1881  // Camera modes
1882  if( autocvar_camera_free )
1883  {
1884  if ( camera_mode == CAMERA_CHASE )
1885  {
1888  }
1889 
1892  }
1893  else
1894  {
1895  if ( camera_mode == CAMERA_FREE )
1896  {
1900  }
1901 
1903 
1905  current_origin += (view_origin - current_origin) * attenuation;
1906  else
1908 
1910  }
1911 
1912  setproperty(VF_ANGLES, current_angles);
1913  setproperty(VF_ORIGIN, current_position);
1914 }
float DEG2RAD
Definition: csprogsdefs.qc:961
float speed
Definition: subs.qh:41
vector current_camera_offset
Definition: view.qc:1771
vector camera_direction
Definition: main.qh:126
bool autocvar_camera_chase_smoothly
Definition: view.qh:5
bool autocvar_camera_reset
Definition: view.qh:12
vector current_angles
Definition: view.qc:1771
vector view_origin
Definition: main.qh:93
float autocvar_camera_speed_roll
Definition: view.qh:16
vector camera_offset
Definition: view.qc:1771
float autocvar_camera_look_player
Definition: view.qh:10
bool autocvar_camera_free
Definition: view.qh:8
bool autocvar_camera_forward_follows
Definition: view.qh:7
const float CAMERA_FREE
Definition: view.qc:570
vector mouse_angles
Definition: view.qc:1771
vector current_origin
Definition: view.qc:1771
vector current_position
Definition: view.qc:1771
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float autocvar_camera_speed_attenuation
Definition: view.qh:13
const float VF_ANGLES
Definition: csprogsdefs.qc:186
float autocvar_camera_look_attenuation
Definition: view.qh:9
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
float autocvar_camera_mouse_threshold
Definition: view.qh:11
const float CAMERA_CHASE
Definition: view.qc:571
float autocvar_camera_speed_chase
Definition: view.qh:14
int dir
Definition: impulse.qc:89
float autocvar_camera_speed_free
Definition: view.qh:15
const float VF_ORIGIN
Definition: csprogsdefs.qc:182
float camera_mode
Definition: view.qc:569
float camera_roll
Definition: main.qh:125
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQC_UpdateView()

void CSQC_UpdateView ( entity  this,
float  w,
float  h 
)

Definition at line 1532 of file view.qc.

References Announcer(), autocvar__hud_showbinds_reload, autocvar_chase_active, autocvar_cl_stripcolorcodes, autocvar_r_drawviewmodel, autocvar_vid_conheight, autocvar_vid_conwidth, autocvar_vid_pixelheight, binddb, bound(), button_attack2, button_zoom, calledhooks, checkextension(), ColorTranslateMode, cs_project_is_b0rked, CSQCModel_server2csqc(), csqcplayer, CSQCPlayer_SetCamera(), current_player, cvar_set(), db_close(), db_create(), Draw_ShowNames_All(), drawframetime, DrawReticle(), drawtime, entity(), execute_next_frame(), Fog_Force(), fpscounter_update(), framecount, ftos(), g_drawables, g_drawables_2d, game_stopped_time, HOOK_END, HOOK_START, hud, HUD_Contents(), HUD_Damage(), HUD_Draw(), HUD_Mouse(), HUD_Scale_Disable(), IL_EACH, IL_ENDFRAME(), intermission, intermission_time, isdemo(), localcmd, MASK_ENGINE, MASK_ENGINEVIEWMODELS, MASK_NORMAL, MAX_WEAPONSLOTS, maxclients, NextFrameCommand, PHYS_INPUT_BUTTON_ATCK2, PHYS_INPUT_BUTTON_ZOOM, player_localentnum, player_localnum, postinit, PostInit(), scoreboard_active, Scoreboard_WouldDraw(), string_null, TC, ticrate, time, vector(), VF_ANGLES, VF_DRAWCROSSHAIR, VF_DRAWENGINESBAR, VF_DRAWWORLD, VF_MIN, VF_MINFPS_QUALITY, VF_ORIGIN, VF_PERSPECTIVE, VF_SIZE, vid_conheight, vid_conwidth, vid_height, vid_pixelheight, vid_width, view_angles, View_CheckButtonStatus(), View_DemoCamera(), View_EventChase(), view_forward, View_Lock(), View_NightVision(), view_origin, View_Ortho(), View_PostProcessing(), view_quality, view_right, view_up, View_UpdateFov(), viewmodel_draw(), viewmodels, and WarpZone_FixView().

1533 {
1534  TC(int, w); TC(int, h);
1535 
1537 
1538  ++framecount;
1539 
1540  stats_get();
1541  hud = STAT(HUD);
1542 
1543  ReplicateVars(REPLICATEVARS_CHECK);
1544 
1546 
1547  if(autocvar__hud_showbinds_reload) // menu can set this one
1548  {
1549  db_close(binddb);
1550  binddb = db_create();
1551  cvar_set("_hud_showbinds_reload", "0");
1552  }
1553 
1554  if(checkextension("DP_CSQC_MINFPS_QUALITY"))
1555  view_quality = getproperty(VF_MINFPS_QUALITY);
1556  else
1557  view_quality = 1;
1558 
1561 
1562  vector vf_size = getpropertyvec(VF_SIZE);
1563  vector vf_min = getpropertyvec(VF_MIN);
1564  vid_width = vf_size.x;
1565  vid_height = vf_size.y;
1566 
1567  ticrate = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
1568 
1570  {
1571  // in first person view if r_drawviewmodel is off weapon isn't visible
1572  // and server doesn't throw any casing
1573  // switching to 3rd person view r_drawviewmodel is set to -1 to let know the server casings
1574  // can be thrown for self since own weapon model is visible
1575  if (autocvar_r_drawviewmodel == 0 && STAT(HEALTH) > 0)
1576  cvar_set("r_drawviewmodel", "-1");
1577  }
1578  else
1579  {
1580  if (autocvar_r_drawviewmodel < 0)
1581  cvar_set("r_drawviewmodel", "0");
1582  }
1583 
1584  WaypointSprite_Load();
1585 
1587 
1588  if(player_localentnum <= maxclients) // is it a client?
1590  else // then player_localentnum is the vehicle I'm driving
1592  myteam = entcs_GetTeam(current_player);
1593 
1594  // abused multiple places below
1596  if(!local_player)
1597  local_player = this; // fall back!
1598 
1599  View_EventChase(local_player);
1600 
1601  // do lockview after event chase camera so that it still applies whenever necessary.
1602  View_Lock();
1603 
1604  WarpZone_FixView();
1605  //WarpZone_FixPMove();
1606 
1607  View_Ortho();
1608 
1609  // run viewmodel_draw before updating view_angles to the angles calculated by WarpZone_FixView
1610  // viewmodel_draw needs to use the view_angles set by the engine on every CSQC_UpdateView call
1611  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
1612  viewmodel_draw(viewmodels[slot]);
1613 
1614  // Render the Scene
1615  view_origin = getpropertyvec(VF_ORIGIN);
1616  view_angles = getpropertyvec(VF_ANGLES);
1617  MAKE_VECTORS(view_angles, view_forward, view_right, view_up);
1618 
1619 #ifdef BLURTEST
1620  View_BlurTest();
1621 #endif
1622 
1623  TargetMusic_Advance();
1624  Fog_Force();
1626 
1627  if(drawtime == 0)
1628  drawframetime = 0.01666667; // when we don't know fps yet, we assume 60fps
1629  else
1630  drawframetime = bound(0.000001, time - drawtime, 1);
1631  drawtime = time;
1632 
1633  // watch for gametype changes here...
1634  // in ParseStuffCMD the cmd isn't executed yet :/
1635  // might even be better to add the gametype to TE_CSQC_INIT...?
1636  if(!postinit)
1637  PostInit();
1638 
1641 
1642  if(STAT(GAME_STOPPED) && !game_stopped_time)
1644  else if(game_stopped_time && !STAT(GAME_STOPPED))
1645  game_stopped_time = 0;
1646 
1647  if(intermission && !isdemo() && !(calledhooks & HOOK_END))
1648  {
1649  if(calledhooks & HOOK_START)
1650  {
1651  localcmd("\ncl_hook_gameend\n");
1652  calledhooks |= HOOK_END;
1653  }
1654  }
1655 
1656  Announcer();
1657 
1659 
1661 
1662  // ALWAYS Clear Current Scene First
1663  clearscene();
1664 
1665  setproperty(VF_ORIGIN, view_origin);
1666  setproperty(VF_ANGLES, view_angles);
1667 
1668  // FIXME engine bug? VF_SIZE and VF_MIN are not restored to sensible values by this
1669  setproperty(VF_SIZE, vf_size);
1670  setproperty(VF_MIN, vf_min);
1671 
1672  // Assign Standard Viewflags
1673  // Draw the World (and sky)
1674  setproperty(VF_DRAWWORLD, 1);
1675 
1676  // Set the console size vars
1680 
1681  View_UpdateFov();
1682 
1683  View_DemoCamera();
1684 
1685  // Draw the Crosshair
1686  setproperty(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden
1687 
1688  // Draw the Engine Status Bar (the default Quake HUD)
1689  setproperty(VF_DRAWENGINESBAR, 0);
1690 
1691  // Update the mouse position
1692  /*
1693  mousepos_x = vid_conwidth;
1694  mousepos_y = vid_conheight;
1695  mousepos = mousepos*0.5 + getmousepos();
1696  */
1697 
1698  IL_EACH(g_drawables, it.draw, it.draw(it));
1699 
1700  addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS); // TODO: .health is used in cl_deathfade (a feature we have turned off currently)
1701  renderscene();
1702 
1703  // Now the the scene has been rendered, begin with the 2D drawing functions
1704 
1705  View_NightVision();
1706  DrawReticle(local_player);
1707  HUD_Contents();
1708  HUD_Damage();
1710 
1711  // draw 2D entities
1712  IL_EACH(g_drawables_2d, it.draw2d, it.draw2d(it));
1714 #if ENABLE_DEBUGDRAW
1715  Debug_Draw();
1716 #endif
1717 
1719 
1720  HUD_Draw(this); // this parameter for deep vehicle function
1721 
1722  if(NextFrameCommand)
1723  {
1724  localcmd("\n", NextFrameCommand, "\n");
1726  }
1727 
1728  // we must do this check AFTER a frame was rendered, or it won't work
1729  if(cs_project_is_b0rked == 0)
1730  {
1731  string w0, h0;
1734  //setproperty(VF_VIEWPORT, '0 0 0', '640 480 0');
1735  //setproperty(VF_FOV, '90 90 0');
1736  setproperty(VF_ORIGIN, '0 0 0');
1737  setproperty(VF_ANGLES, '0 0 0');
1738  setproperty(VF_PERSPECTIVE, 1);
1739  vector forward, right, up;
1740  MAKE_VECTORS('0 0 0', forward, right, up);
1741  vector v1, v2;
1742  cvar_set("vid_conwidth", "800");
1743  cvar_set("vid_conheight", "600");
1744  v1 = cs_project(forward);
1745  cvar_set("vid_conwidth", "640");
1746  cvar_set("vid_conheight", "480");
1747  v2 = cs_project(forward);
1748  if(v1 == v2)
1750  else
1751  cs_project_is_b0rked = -1;
1752  cvar_set("vid_conwidth", w0);
1753  cvar_set("vid_conheight", h0);
1754  }
1755 
1756  HUD_Mouse(local_player);
1757 
1758  cl_notice_run();
1759  unpause_update();
1760  Net_Flush();
1761 
1762  // let's reset the view back to normal for the end
1763  setproperty(VF_MIN, '0 0 0');
1764  setproperty(VF_SIZE, '1 0 0' * w + '0 1 0' * h);
1765 
1766  IL_ENDFRAME();
1767 }
int binddb
Definition: main.qh:160
float vid_conheight
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition: player.qh:148
bool autocvar__hud_showbinds_reload
Definition: main.qh:18
#define IL_EACH(this, cond, body)
ERASEABLE int db_create()
Definition: map.qh:25
float current_player
Definition: hud.qh:182
string string_null
Definition: nil.qh:9
void View_PostProcessing()
Definition: view.qc:1203
entity CSQCModel_server2csqc(int i)
Definition: cl_model.qc:314
void View_CheckButtonStatus()
Definition: view.qc:1341
void View_DemoCamera()
Definition: view.qc:1290
int vid_height
Definition: main.qh:120
void View_EventChase(entity this)
Definition: view.qc:627
void DrawReticle(entity this)
Definition: crosshair.qc:678
bool scoreboard_active
Definition: scoreboard.qh:9
const float MASK_ENGINE
Definition: csprogsdefs.qc:162
void HUD_Draw(entity this)
Definition: view.qc:859
entity viewmodels[MAX_WEAPONSLOTS]
Definition: view.qh:104
entity() spawn
float game_stopped_time
Definition: view.qh:128
vector view_origin
Definition: main.qh:93
float intermission
Definition: csprogsdefs.qc:148
#define PHYS_INPUT_BUTTON_ZOOM(s)
Definition: player.qh:149
float intermission_time
Definition: view.qh:127
string NextFrameCommand
Definition: view.qc:572
ERASEABLE void db_close(int db)
Definition: map.qh:84
bool autocvar_cl_stripcolorcodes
Definition: view.qh:26
void HUD_Scale_Disable()
Definition: hud.qc:83
float maxclients
Definition: csprogsdefs.qc:21
vector view_forward
Definition: main.qh:93
const float VF_MINFPS_QUALITY
Definition: csprogsdefs.qc:910
void Announcer()
Definition: announcer.qc:166
float vid_conwidth
float drawtime
Definition: view.qh:115
int calledhooks
Definition: main.qh:134
vector view_angles
Definition: csprogsdefs.qc:150
vector view_up
Definition: main.qh:93
void Fog_Force()
Definition: main.qc:1006
ERASEABLE void IL_ENDFRAME()
void viewmodel_draw(entity this)
Definition: view.qc:279
bool button_attack2
Definition: main.qh:99
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
int ColorTranslateMode
Definition: string.qh:174
void WarpZone_FixView()
Definition: client.qc:225
const int HOOK_END
Definition: main.qh:136
#define TC(T, sym)
Definition: _all.inc:82
const int HOOK_START
Definition: main.qh:135
const float VF_PERSPECTIVE
Definition: csprogsdefs.qc:199
void HUD_Damage()
Definition: view.qc:1114
void CSQCPlayer_SetCamera()
Called once per CSQC_UpdateView()
Definition: cl_player.qc:554
vector view_right
Definition: main.qh:93
void View_Lock()
Definition: view.qc:1264
bool Scoreboard_WouldDraw()
Definition: scoreboard.qc:1187
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
float player_localentnum
Definition: csprogsdefs.qc:19
bool button_zoom
Definition: main.qh:97
void View_Ortho()
Definition: view.qc:1437
bool postinit
Definition: main.qh:29
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void PostInit()
Definition: main.qc:434
void HUD_Mouse(entity player)
Definition: view.qc:948
bool autocvar_r_drawviewmodel
Definition: view.qh:94
const float VF_ANGLES
Definition: csprogsdefs.qc:186
const float MASK_ENGINEVIEWMODELS
Definition: csprogsdefs.qc:163
float drawframetime
Definition: main.qh:92
float view_quality
Definition: main.qh:143
const float VF_DRAWWORLD
Definition: csprogsdefs.qc:190
float vid_pixelheight
Definition: main.qh:121
void View_NightVision()
Definition: view.qc:990
void View_UpdateFov()
Definition: view.qc:1519
int autocvar_vid_conwidth
Definition: view.qh:72
const float VF_DRAWENGINESBAR
Definition: csprogsdefs.qc:191
const float VF_DRAWCROSSHAIR
Definition: csprogsdefs.qc:192
void execute_next_frame()
Definition: util.qc:1612
entity csqcplayer
Definition: cl_player.qh:26
int autocvar_chase_active
Definition: view.qh:17
int vid_width
Definition: main.qh:120
int framecount
Definition: main.qh:149
int autocvar_vid_conheight
Definition: view.qh:71
const float VF_SIZE
Definition: csprogsdefs.qc:175
float time
Definition: csprogsdefs.qc:16
float autocvar_vid_pixelheight
Definition: view.qh:73
int cs_project_is_b0rked
Definition: main.qh:119
void fpscounter_update()
Definition: view.qc:389
float player_localnum
Definition: csprogsdefs.qc:20
IntrusiveList g_drawables
Definition: main.qh:77
void Draw_ShowNames_All()
Definition: shownames.qc:220
float ticrate
Definition: main.qh:182
IntrusiveList g_drawables_2d
Definition: main.qh:78
const float VF_ORIGIN
Definition: csprogsdefs.qc:182
int hud
Definition: main.qh:142
void HUD_Contents()
Definition: view.qc:1044
const float VF_MIN
Definition: csprogsdefs.qc:172
+ Here is the call graph for this function:

◆ fpscounter_update()

void fpscounter_update ( )

Definition at line 389 of file view.qc.

References bound(), gettime(), GETTIME_FRAMESTART, rint(), showfps_framecounter, showfps_prevfps_time, and WriteShort().

Referenced by CSQC_UpdateView().

390 {
391  if(!STAT(SHOWFPS))
392  return;
393 
394  float currentTime = gettime(GETTIME_FRAMESTART);
395 
397  if(currentTime - showfps_prevfps_time > STAT(SHOWFPS))
398  {
399  float fps = showfps_framecounter / (currentTime - showfps_prevfps_time);
401  showfps_prevfps_time = currentTime;
402 
403  int channel = MSG_C2S;
404  WriteHeader(channel, fpsreport);
405  WriteShort(channel, bound(0, rint(fps), 32767)); // prevent insane fps values
406  }
407 }
int showfps_framecounter
Definition: view.qc:387
float GETTIME_FRAMESTART
float showfps_prevfps_time
Definition: view.qc:386
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCurrentFov()

vector GetCurrentFov ( float  fov)

Definition at line 416 of file view.qc.

References almost_equals(), autocvar_cl_lockview, autocvar_cl_spawnzoom, autocvar_cl_spawnzoom_factor, autocvar_cl_spawnzoom_speed, autocvar_cl_velocityzoom_enabled, autocvar_cl_velocityzoom_factor, autocvar_cl_velocityzoom_speed, autocvar_cl_velocityzoom_time, autocvar_cl_velocityzoom_type, autocvar_cl_zoomfactor, autocvar_cl_zoomsensitivity, autocvar_cl_zoomspeed, avgspeed, bound(), button_zoom, camera_active, csqcplayer, current_viewzoom, current_zoomfraction, drawframetime, entity(), exp(), float2range11(), hud, intermission, isdemo(), M_PI, max(), MAX_WEAPONSLOTS, min(), pmove_vel, spectatee_status, spectatorbutton_zoom, v, vector(), vid_height, vid_pixelheight, vid_width, view_angles, viewmodels, vlen(), and zoomin_effect.

Referenced by View_UpdateFov().

417 {
418  float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
419  float velocityzoom, curspeed;
420  vector v;
421 
422  zoomsensitivity = autocvar_cl_zoomsensitivity;
423  zoomfactor = autocvar_cl_zoomfactor;
424  if(zoomfactor < 1 || zoomfactor > 30)
425  zoomfactor = 2.5;
426  zoomspeed = autocvar_cl_zoomspeed;
427  if (zoomspeed >= 0 && (zoomspeed < 0.5 || zoomspeed > 16))
428  zoomspeed = 3.5;
429 
430  zoomdir = button_zoom;
431 
432  if(hud == HUD_NORMAL && !spectatee_status)
433  {
434  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
435  {
436  entity wepent = viewmodels[slot];
437  if(wepent.switchweapon != wepent.activeweapon)
438  continue;
439  Weapon wep = wepent.activeweapon;
440  if(wep != WEP_Null && wep.wr_zoomdir)
441  {
442  bool do_zoom = wep.wr_zoomdir(wep); // TODO: merge this with wr_zoom?
443  zoomdir += do_zoom;
444  }
445  }
446  }
447  if(spectatee_status > 0 || isdemo())
448  {
450  {
451  if(zoomdir)
452  zoomdir = 0;
453  else
454  zoomdir = 1;
455  }
456  // fteqcc failed twice here already, don't optimize this
457  }
458 
459  if(zoomdir) { zoomin_effect = 0; }
460 
461  if (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2)
462  {
463  current_viewzoom = 1;
464  }
465  else if (camera_active)
466  {
468  }
470  {
471  float spawnzoomfactor = bound(1, autocvar_cl_spawnzoom_factor, 30);
472 
474  current_viewzoom = bound(1 / spawnzoomfactor, current_viewzoom, 1);
475  if(current_viewzoom == 1) { zoomin_effect = 0; }
476  }
477  else
478  {
479  if(zoomspeed < 0) // instant zoom
480  {
481  if(zoomdir)
482  current_viewzoom = 1 / zoomfactor;
483  else
484  current_viewzoom = 1;
485  }
486  else
487  {
488  if(zoomdir)
489  current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
490  else
491  current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
492  }
493  }
494 
497  else if(almost_equals(current_viewzoom, 1/zoomfactor))
499  else
500  current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1);
501 
502  if(zoomsensitivity < 1)
503  setsensitivityscale(current_viewzoom ** (1 - zoomsensitivity));
504  else
505  setsensitivityscale(1);
506 
507  if(autocvar_cl_velocityzoom_enabled && autocvar_cl_velocityzoom_type && !autocvar_cl_lockview) // _type = 0 disables velocity zoom too
508  {
509  if (intermission || (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2))
510  curspeed = 0;
511  else
512  {
513  vector forward, right, up;
514  MAKE_VECTORS(view_angles, forward, right, up);
515  v = pmove_vel;
516  if(csqcplayer)
517  v = csqcplayer.velocity;
518 
520  {
521  case 3: curspeed = max(0, forward * v); break;
522  case 2: curspeed = (forward * v); break;
523  case 1: default: curspeed = vlen(v); break;
524  }
525  }
526 
527  velocityzoom = bound(0, drawframetime / max(0.000000001, autocvar_cl_velocityzoom_time), 1); // speed at which the zoom adapts to player velocity
528  avgspeed = avgspeed * (1 - velocityzoom) + (curspeed / autocvar_cl_velocityzoom_speed) * velocityzoom;
529  velocityzoom = exp(float2range11(avgspeed * -autocvar_cl_velocityzoom_factor / 1) * 1);
530 
531  //print(ftos(avgspeed), " avgspeed, ", ftos(curspeed), " curspeed, ", ftos(velocityzoom), " return\n"); // for debugging
532  }
533  else
534  velocityzoom = 1;
535 
536  float frustumx, frustumy, fovx, fovy;
537  frustumy = tan(fov * M_PI / 360.0) * 0.75 * current_viewzoom * velocityzoom;
538  frustumx = frustumy * vid_width / vid_height / vid_pixelheight;
539  fovx = atan2(frustumx, 1) / M_PI * 360.0;
540  fovy = atan2(frustumy, 1) / M_PI * 360.0;
541 
542  return '1 0 0' * fovx + '0 1 0' * fovy;
543 }
float autocvar_cl_zoomspeed
Definition: view.qh:34
ERASEABLE float float2range11(float f)
continuous function mapping all reals into -1..1
Definition: math.qh:203
int autocvar_cl_velocityzoom_type
Definition: view.qh:29
float autocvar_cl_zoomfactor
Definition: view.qh:32
int vid_height
Definition: main.qh:120
entity viewmodels[MAX_WEAPONSLOTS]
Definition: view.qh:104
entity() spawn
float intermission
Definition: csprogsdefs.qc:148
float current_viewzoom
Definition: main.qh:101
vector pmove_vel
Definition: csprogsdefs.qc:55
ERASEABLE float almost_equals(float a, float b)
Definition: math.qh:222
float autocvar_cl_velocityzoom_time
Definition: view.qh:31
bool autocvar_cl_lockview
Definition: view.qh:20
float exp(float e)
Definition: mathlib.qc:73
vector view_angles
Definition: csprogsdefs.qc:150
float autocvar_cl_spawnzoom_speed
Definition: view.qh:24
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
float current_zoomfraction
Definition: main.qh:117
float autocvar_cl_velocityzoom_speed
Definition: view.qh:30
bool button_zoom
Definition: main.qh:97
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const float M_PI
Definition: csprogsdefs.qc:269
float autocvar_cl_zoomsensitivity
Definition: view.qh:33
vector v
Definition: ent_cs.qc:116
float spectatee_status
Definition: main.qh:166
float camera_active
Definition: main.qh:123
float drawframetime
Definition: main.qh:92
float vid_pixelheight
Definition: main.qh:121
float autocvar_cl_spawnzoom_factor
Definition: view.qh:25
bool autocvar_cl_velocityzoom_enabled
Definition: view.qh:27
entity csqcplayer
Definition: cl_player.qh:26
int vid_width
Definition: main.qh:120
float autocvar_cl_velocityzoom_factor
Definition: view.qh:28
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
float zoomin_effect
Definition: main.qh:102
bool autocvar_cl_spawnzoom
Definition: view.qh:23
bool spectatorbutton_zoom
Definition: main.qh:98
float avgspeed
Definition: view.qc:415
int hud
Definition: main.qh:142
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetOrthoviewFOV()

vector GetOrthoviewFOV ( vector  ov_worldmin,
vector  ov_worldmax,
vector  ov_mid,
vector  ov_org 
)

Definition at line 554 of file view.qc.

References height, M_PI, and vlen().

Referenced by View_UpdateFov().

555 {
556  float fovx, fovy;
557  float width = (ov_worldmax.x - ov_worldmin.x);
558  float height = (ov_worldmax.y - ov_worldmin.y);
559  float distance_to_middle_of_world = vlen(ov_mid - ov_org);
560  fovx = atan2(width/2, distance_to_middle_of_world) / M_PI * 360.0;
561  fovy = atan2(height/2, distance_to_middle_of_world) / M_PI * 360.0;
562  return '1 0 0' * fovx + '0 1 0' * fovy;
563 }
vector ov_worldmax
Definition: view.qc:1435
float height
Definition: jumppads.qh:12
vector ov_org
Definition: view.qc:1432
const float M_PI
Definition: csprogsdefs.qc:269
vector ov_worldmin
Definition: view.qc:1434
vector ov_mid
Definition: view.qc:1433
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetViewLocationFOV()

vector GetViewLocationFOV ( float  fov)

Definition at line 545 of file view.qc.

References M_PI, vid_height, vid_pixelheight, and vid_width.

Referenced by View_UpdateFov().

546 {
547  float frustumy = tan(fov * M_PI / 360.0) * 0.75;
548  float frustumx = frustumy * vid_width / vid_height / vid_pixelheight;
549  float fovx = atan2(frustumx, 1) / M_PI * 360.0;
550  float fovy = atan2(frustumy, 1) / M_PI * 360.0;
551  return '1 0 0' * fovx + '0 1 0' * fovy;
552 }
int vid_height
Definition: main.qh:120
const float M_PI
Definition: csprogsdefs.qc:269
float vid_pixelheight
Definition: main.qh:121
int vid_width
Definition: main.qh:120
+ Here is the caller graph for this function:

◆ HitSound()

void HitSound ( )

Definition at line 793 of file view.qc.

References ATTN_NONE, autocvar_cl_hitsound, autocvar_cl_hitsound_antispam_time, autocvar_cl_hitsound_max_pitch, autocvar_cl_hitsound_min_pitch, autocvar_cl_hitsound_nom_damage, CH_INFO, COMPARE_INCREASING, entity(), MAX_WEAPONSLOTS, NULL, SND, sound, time, unaccounted_damage, viewmodels, and VOL_BASE.

794 {
795  // varying sound pitch
796 
797  bool have_arc = false;
798  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
799  {
800  entity wepent = viewmodels[slot];
801 
802  if(wepent.activeweapon == WEP_ARC)
803  have_arc = true;
804  }
805 
806  static float hitsound_time_prev = 0;
807  // HACK: the only way to get the arc to sound consistent with pitch shift is to ignore cl_hitsound_antispam_time
808  bool arc_hack = have_arc && autocvar_cl_hitsound >= 2;
809  if (arc_hack || COMPARE_INCREASING(time, hitsound_time_prev) > autocvar_cl_hitsound_antispam_time)
810  {
811  if (autocvar_cl_hitsound && unaccounted_damage)
812  {
813  float pitch_shift = 1;
814  if (autocvar_cl_hitsound == 2 || autocvar_cl_hitsound == 3)
815  {
816  // customizable gradient function that crosses (0,a), (c,1) and asymptotically approaches b
820  float d = unaccounted_damage;
821  pitch_shift = (b*d*(a-1) + a*c*(1-b)) / (d*(a-1) + c*(1-b));
822 
823  // if pitch shift is reversed, mirror in (max-min)/2 + min
824  if (autocvar_cl_hitsound == 3)
825  {
826  float mirror_value = (a-b)/2 + b;
827  pitch_shift = mirror_value + (mirror_value - pitch_shift);
828  }
829  }
830 
831  //LOG_TRACE("dmg total (dmg): ", ftos(unaccounted_damage), " , pitch shift: ", ftos(pitch_shift));
832 
833  // todo: avoid very long and very short sounds from wave stretching using different sound files? seems unnecessary
834  // todo: normalize sound pressure levels? seems unnecessary
835 
836  sound7(NULL, CH_INFO, SND(HIT), VOL_BASE, ATTN_NONE, pitch_shift * 100, 0);
837  }
838  unaccounted_damage = 0;
839  hitsound_time_prev = time;
840  }
841 
842  static float typehit_time_prev = 0;
843  float typehit_time = STAT(TYPEHIT_TIME);
844  if (COMPARE_INCREASING(typehit_time, typehit_time_prev) > autocvar_cl_hitsound_antispam_time)
845  {
846  sound(NULL, CH_INFO, SND_TYPEHIT, VOL_BASE, ATTN_NONE);
847  typehit_time_prev = typehit_time;
848  }
849 
850  static float kill_time_prev = 0;
851  float kill_time = STAT(KILL_TIME);
852  if (COMPARE_INCREASING(kill_time, kill_time_prev) > autocvar_cl_hitsound_antispam_time)
853  {
854  sound(NULL, CH_INFO, SND_KILL, VOL_BASE, ATTN_NONE);
855  kill_time_prev = kill_time;
856  }
857 }
#define SND(id)
Definition: all.qh:35
const float ATTN_NONE
Definition: csprogsdefs.qc:225
float autocvar_cl_hitsound_nom_damage
Definition: view.qh:81
entity viewmodels[MAX_WEAPONSLOTS]
Definition: view.qh:104
float autocvar_cl_hitsound_antispam_time
Definition: view.qh:82
entity() spawn
const int CH_INFO
Definition: sound.qh:6
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
#define NULL
Definition: post.qh:17
const float VOL_BASE
Definition: sound.qh:36
float autocvar_cl_hitsound_max_pitch
Definition: view.qh:80
#define COMPARE_INCREASING(to, from)
Definition: util.qh:228
float unaccounted_damage
Definition: view.qh:116
float autocvar_cl_hitsound_min_pitch
Definition: view.qh:79
int autocvar_cl_hitsound
Definition: view.qh:78
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ HUD_Contents()

void HUD_Contents ( )

Definition at line 1044 of file view.qc.

References autocvar_hud_contents, autocvar_hud_contents_blur, autocvar_hud_contents_blur_alpha, autocvar_hud_contents_fadeintime, autocvar_hud_contents_fadeouttime, autocvar_hud_contents_lava_alpha, autocvar_hud_contents_lava_color, autocvar_hud_contents_slime_alpha, autocvar_hud_contents_slime_color, autocvar_hud_contents_water_alpha, autocvar_hud_contents_water_color, autocvar_hud_postprocessing, bound(), content_blurpostprocess, CONTENT_LAVA, CONTENT_SLIME, CONTENT_WATER, contentavgalpha, drawfill(), DRAWFLAG_NORMAL, drawframetime, liquidalpha_prev, liquidcolor_prev, max(), MUTATOR_CALLHOOK, stov(), vec2, vector(), vid_conheight, vid_conwidth, and view_origin.

Referenced by CSQC_UpdateView().

1045 {
1047  return;
1048 
1049  // improved polyblend
1050  float contentalpha_temp, incontent, liquidalpha, contentfadetime;
1051  vector liquidcolor;
1052 
1053  switch(pointcontents(view_origin))
1054  {
1055  case CONTENT_WATER:
1056  liquidalpha = autocvar_hud_contents_water_alpha;
1057  liquidcolor = stov(autocvar_hud_contents_water_color);
1058  incontent = 1;
1059  break;
1060 
1061  case CONTENT_LAVA:
1062  liquidalpha = autocvar_hud_contents_lava_alpha;
1063  liquidcolor = stov(autocvar_hud_contents_lava_color);
1064  incontent = 1;
1065  break;
1066 
1067  case CONTENT_SLIME:
1068  liquidalpha = autocvar_hud_contents_slime_alpha;
1069  liquidcolor = stov(autocvar_hud_contents_slime_color);
1070  incontent = 1;
1071  break;
1072 
1073  default:
1074  liquidalpha = 0;
1075  liquidcolor = '0 0 0';
1076  incontent = 0;
1077  break;
1078  }
1079 
1080  if(incontent) // fade in/out at different speeds so you can do e.g. instant fade when entering water and slow when leaving it.
1081  { // also lets delcare previous values for blending properties, this way it isn't reset until after you have entered a different content
1082  contentfadetime = autocvar_hud_contents_fadeintime;
1083  liquidalpha_prev = liquidalpha;
1084  liquidcolor_prev = liquidcolor;
1085  }
1086  else
1087  contentfadetime = autocvar_hud_contents_fadeouttime;
1088 
1089  contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1);
1090  contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp;
1091 
1092  if(contentavgalpha)
1094 
1096  {
1098  {
1102  }
1103  else
1104  {
1108  }
1109  }
1110 }
float vid_conheight
const float CONTENT_LAVA
Definition: csprogsdefs.qc:240
vector liquidcolor_prev
Definition: view.qc:586
vector content_blurpostprocess
Definition: view.qc:767
bool autocvar_hud_contents
Definition: view.qh:37
float autocvar_hud_contents_fadeintime
Definition: view.qh:40
vector view_origin
Definition: main.qh:93
float vid_conwidth
float autocvar_hud_contents_blur_alpha
Definition: view.qh:39
string autocvar_hud_contents_water_color
Definition: view.qh:47
float autocvar_hud_contents_lava_alpha
Definition: view.qh:42
const float CONTENT_SLIME
Definition: csprogsdefs.qc:239
float autocvar_hud_contents_fadeouttime
Definition: view.qh:41
const float CONTENT_WATER
Definition: csprogsdefs.qc:238
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
string autocvar_hud_contents_lava_color
Definition: view.qh:43
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float autocvar_hud_contents_water_alpha
Definition: view.qh:46
float autocvar_hud_contents_slime_alpha
Definition: view.qh:44
float autocvar_hud_contents_blur
Definition: view.qh:38
float contentavgalpha
Definition: view.qc:585
float drawframetime
Definition: main.qh:92
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
#define vec2(...)
Definition: vector.qh:90
string autocvar_hud_contents_slime_color
Definition: view.qh:45
float liquidalpha_prev
Definition: view.qc:585
void HUD_Contents()
Definition: view.qc:1044
bool autocvar_hud_postprocessing
Definition: view.qh:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HUD_Cursor_Show()

void HUD_Cursor_Show ( )

Definition at line 935 of file view.qc.

References autocvar__menu_alpha, CURSOR_MOVE, CURSOR_NORMAL, CURSOR_RESIZE, CURSOR_RESIZE2, cursor_type, draw_cursor(), draw_cursor_normal(), and mousepos.

Referenced by HUD_Mouse().

936 {
937  float cursor_alpha = 1 - autocvar__menu_alpha;
939  draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
940  else if(cursor_type == CURSOR_MOVE)
941  draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
942  else if(cursor_type == CURSOR_RESIZE)
943  draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
944  else if(cursor_type == CURSOR_RESIZE2)
945  draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
946 }
void draw_cursor_normal(vector pos, vector col, float a)
Definition: hud.qc:37
float autocvar__menu_alpha
Definition: hud.qh:184
const int CURSOR_RESIZE
Definition: view.qh:112
vector mousepos
Definition: hud.qh:102
const int CURSOR_NORMAL
Definition: view.qh:110
const int CURSOR_RESIZE2
Definition: view.qh:113
void draw_cursor(vector pos, vector ofs, string img, vector col, float a)
Definition: hud.qc:31
const int CURSOR_MOVE
Definition: view.qh:111
int cursor_type
Definition: view.qh:109
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HUD_Damage()

void HUD_Damage ( )

Definition at line 1114 of file view.qc.

References autocvar_cl_gentle_damage, autocvar_hud_damage, autocvar_hud_damage_blur, autocvar_hud_damage_blur_alpha, autocvar_hud_damage_color, autocvar_hud_damage_factor, autocvar_hud_damage_fade_rate, autocvar_hud_damage_gentle_alpha_multiplier, autocvar_hud_damage_gentle_color, autocvar_hud_damage_maxalpha, autocvar_hud_damage_pain_threshold, autocvar_hud_damage_pain_threshold_lower, autocvar_hud_damage_pain_threshold_lower_health, autocvar_hud_damage_pain_threshold_pulsating_min, autocvar_hud_damage_pain_threshold_pulsating_period, autocvar_hud_postprocessing, bound(), damage_blurpostprocess, dmg_take, drawfill(), DRAWFLAG_NORMAL, drawpic(), fabs(), frametime, intermission, M_PI, max(), myhealth, myhealth_flash, myhealth_gentlergb, myhealth_prev, randomvec(), sin(), spectatee_status, stov(), time, vec2, vector(), vid_conheight, and vid_conwidth.

Referenced by CSQC_UpdateView().

1115 {
1116  if(!autocvar_hud_damage || STAT(FROZEN))
1117  return;
1118 
1119  vector splash_pos = '0 0 0', splash_size = '0 0 0';
1120  splash_size.x = max(vid_conwidth, vid_conheight);
1121  splash_size.y = max(vid_conwidth, vid_conheight);
1122  splash_pos.x = (vid_conwidth - splash_size.x) / 2;
1123  splash_pos.y = (vid_conheight - splash_size.y) / 2;
1124 
1125  float myhealth_flash_temp;
1126  myhealth = STAT(HEALTH);
1127 
1128  // fade out
1130  // add new damage
1132 
1133  float pain_threshold, pain_threshold_lower, pain_threshold_lower_health;
1134  pain_threshold = autocvar_hud_damage_pain_threshold;
1135  pain_threshold_lower = autocvar_hud_damage_pain_threshold_lower;
1136  pain_threshold_lower_health = autocvar_hud_damage_pain_threshold_lower_health;
1137 
1138  if(pain_threshold_lower && myhealth < pain_threshold_lower_health)
1139  {
1140  pain_threshold = pain_threshold - max(autocvar_hud_damage_pain_threshold_pulsating_min, fabs(sin(M_PI * time / autocvar_hud_damage_pain_threshold_pulsating_period))) * pain_threshold_lower * (1 - max(0, myhealth)/pain_threshold_lower_health);
1141  }
1142 
1143  myhealth_flash_temp = bound(0, myhealth_flash - pain_threshold, 1);
1144 
1145  if(myhealth_prev < 1)
1146  {
1147  if(myhealth >= 1)
1148  {
1149  myhealth_flash = 0; // just spawned, clear the flash immediately
1150  myhealth_flash_temp = 0;
1151  }
1152  else
1153  {
1155  }
1156  }
1157 
1158  if(spectatee_status == -1 || intermission)
1159  {
1160  myhealth_flash = 0; // observing, or match ended
1161  myhealth_flash_temp = 0;
1162  }
1163 
1165 
1166  // IDEA: change damage color/picture based on player model for robot/alien species?
1167  // pro: matches model better
1168  // contra: it's not red because blood is red, but because red is an alarming color, so red should stay
1169  // maybe different reddish pics?
1170  if(autocvar_cl_gentle_damage || autocvar_cl_gentle)
1171  {
1172  if(autocvar_cl_gentle_damage == 2)
1173  {
1174  if(myhealth_flash < pain_threshold) // only randomize when the flash is gone
1176  }
1177  else
1179 
1180  if(myhealth_flash_temp > 0)
1182  }
1183  else if(myhealth_flash_temp > 0)
1184  drawpic(splash_pos, "gfx/blood", splash_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
1185 
1186  if(autocvar_hud_postprocessing) // we still need to set this anyway even when chase_active is set, this way it doesn't get stuck on.
1187  {
1188  if(autocvar_hud_damage_blur && myhealth_flash_temp)
1189  {
1190  damage_blurpostprocess.x = 1;
1191  damage_blurpostprocess.y = bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage_blur;
1192  damage_blurpostprocess.z = bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage_blur_alpha;
1193  }
1194  else
1195  {
1196  damage_blurpostprocess.x = 0;
1197  damage_blurpostprocess.y = 0;
1198  damage_blurpostprocess.z = 0;
1199  }
1200  }
1201 }
float vid_conheight
float autocvar_hud_damage_factor
Definition: view.qh:52
vector damage_blurpostprocess
Definition: view.qc:767
float autocvar_hud_damage_gentle_alpha_multiplier
Definition: view.qh:54
float dmg_take
Definition: view.qh:119
float autocvar_hud_damage_fade_rate
Definition: view.qh:53
string autocvar_hud_damage_color
Definition: view.qh:51
float autocvar_hud_damage_pain_threshold_lower
Definition: view.qh:58
string autocvar_hud_damage_gentle_color
Definition: view.qh:55
bool autocvar_hud_damage
Definition: view.qh:48
float intermission
Definition: csprogsdefs.qc:148
float autocvar_hud_damage_pain_threshold_pulsating_period
Definition: view.qh:61
vector myhealth_gentlergb
Definition: view.qc:583
float autocvar_hud_damage_pain_threshold_pulsating_min
Definition: view.qh:60
float vid_conwidth
float autocvar_hud_damage_pain_threshold
Definition: view.qh:57
int autocvar_cl_gentle_damage
Definition: view.qh:19
float myhealth_prev
Definition: view.qc:577
float autocvar_hud_damage_blur_alpha
Definition: view.qh:50
float frametime
Definition: csprogsdefs.qc:17
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
float myhealth_flash
Definition: view.qc:578
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const float M_PI
Definition: csprogsdefs.qc:269
float spectatee_status
Definition: main.qh:166
float autocvar_hud_damage_pain_threshold_lower_health
Definition: view.qh:59
float myhealth
Definition: view.qc:577
#define vec2(...)
Definition: vector.qh:90
float autocvar_hud_damage_maxalpha
Definition: view.qh:56
float time
Definition: csprogsdefs.qc:16
float autocvar_hud_damage_blur
Definition: view.qh:49
bool autocvar_hud_postprocessing
Definition: view.qh:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HUD_Draw()

void HUD_Draw ( entity  this)

Definition at line 859 of file view.qc.

References autocvar_cl_nade_timer, autocvar_hud_colorflash_alpha, DrawCircleClippedPic(), drawfill(), DRAWFLAG_ADDITIVE, drawstring_aspect(), eY, gametype, Hud_Dynamic_Frame(), HUD_Scale_Enable(), intermission, M_ARGV, max(), MUTATOR_CALLHOOK, vec2, vec3, vector(), vid_conheight, and vid_conwidth.

Referenced by CSQC_UpdateView().

860 {
861  // if we don't know gametype and scores yet avoid drawing the scoreboard
862  // also in the very first frames, player state may be inconsistent so avoid drawing the hud at all
863  // e.g. since initial player's health is 0 hud would display the hud_damage effect,
864  // cl_deathscoreboard would show the scoreboard and so on
865  if(!gametype)
866  return;
867 
869 
870  if(!intermission)
871  if (MUTATOR_CALLHOOK(HUD_Draw_overlay))
872  {
874  }
875  else if(STAT(FROZEN))
876  {
877  vector col = '0.25 0.90 1';
878  float col_fade = max(0, STAT(REVIVE_PROGRESS) * 2 - 1);
879  float alpha_fade = 0.3 + 0.7 * (1 - max(0, STAT(REVIVE_PROGRESS) * 4 - 3));
880  if(col_fade)
881  col += vec3(col_fade, -col_fade, -col_fade);
883  }
884 
886  if(!intermission)
887  if(STAT(NADE_TIMER) && autocvar_cl_nade_timer) // give nade top priority, as it's a matter of life and death
888  {
889  vector col = '0.25 0.90 1' + vec3(STAT(NADE_TIMER), -STAT(NADE_TIMER), -STAT(NADE_TIMER));
890  DrawCircleClippedPic(vec2(0.5 * vid_conwidth, 0.6 * vid_conheight), 0.1 * vid_conheight, "gfx/crosshair_ring", STAT(NADE_TIMER), col, autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
891  drawstring_aspect(eY * 0.64 * vid_conheight, ((autocvar_cl_nade_timer == 2) ? _("Nade timer") : ""), vec2(vid_conwidth, 0.025 * vid_conheight), '1 1 1', 1, DRAWFLAG_NORMAL);
892  }
893  else if(STAT(CAPTURE_PROGRESS))
894  {
895  DrawCircleClippedPic(vec2(0.5 * vid_conwidth, 0.6 * vid_conheight), 0.1 * vid_conheight, "gfx/crosshair_ring", STAT(CAPTURE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
896  drawstring_aspect(eY * 0.64 * vid_conheight, _("Capture progress"), vec2(vid_conwidth, 0.025 * vid_conheight), '1 1 1', 1, DRAWFLAG_NORMAL);
897  }
898  else if(STAT(REVIVE_PROGRESS))
899  {
900  DrawCircleClippedPic(vec2(0.5 * vid_conwidth, 0.6 * vid_conheight), 0.1 * vid_conheight, "gfx/crosshair_ring", STAT(REVIVE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
901  drawstring_aspect(eY * 0.64 * vid_conheight, _("Revival progress"), vec2(vid_conwidth, 0.025 * vid_conheight), '1 1 1', 1, DRAWFLAG_NORMAL);
902  }
904 
905  if(autocvar_r_letterbox == 0)
906  if(autocvar_viewsize < 120)
907  {
908  if(!MUTATOR_CALLHOOK(DrawScoreboardAccuracy))
910 
911  HUD_Main();
913  }
914 
915  // crosshair goes VERY LAST
916  UpdateDamage();
917  HUD_Crosshair(this);
918  HitSound();
919 }
float vid_conheight
int autocvar_cl_nade_timer
Definition: view.qh:93
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
Definition: draw.qc:102
float autocvar_r_letterbox
Definition: view.qh:69
const vector eY
Definition: vector.qh:45
#define vec3(_x, _y, _z)
Definition: vector.qh:95
float intermission
Definition: csprogsdefs.qc:148
void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag)
Definition: draw.qc:182
void UpdateDamage()
Definition: view.qc:769
void HUD_Scale_Disable()
Definition: hud.qc:83
float vid_conwidth
const float DRAWFLAG_ADDITIVE
Definition: csprogsdefs.qc:318
void HitSound()
Definition: view.qc:793
void HUD_Scale_Enable()
Definition: hud.qc:90
void Hud_Dynamic_Frame()
Definition: hud.qc:595
float autocvar_viewsize
Definition: view.qh:74
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
entity gametype
Definition: main.qh:30
#define M_ARGV(x, type)
Definition: events.qh:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float autocvar_hud_colorflash_alpha
Definition: view.qh:36
void HUD_Crosshair(entity this)
Definition: crosshair.qc:226
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
#define vec2(...)
Definition: vector.qh:90
void Accuracy_LoadLevels()
Definition: weapons.qc:38
void HUD_Main()
Definition: hud.qc:689
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HUD_Mouse()

void HUD_Mouse ( entity  player)

Definition at line 948 of file view.qc.

References autocvar__hud_configure, autocvar__menu_alpha, autocvar_hud_cursormode, cursor_active, CURSOR_NORMAL, cursor_type, HUD_Cursor_Show(), HUD_Minigame_Mouse(), HUD_MinigameMenu_IsOpened(), HUD_Panel_Mouse(), HUD_Radar_Clickable(), HUD_Radar_Mouse(), mouseClicked, prevMouseClicked, QuickMenu_IsOpened(), QuickMenu_Mouse(), update_mousepos(), VIEWLOC_FREEAIM, and ViewLocation_Mouse().

Referenced by CSQC_UpdateView().

949 {
950  if(autocvar__menu_alpha == 1)
951  return;
952 
953  if(!cursor_active)
954  {
955  if(player.viewloc && (player.viewloc.spawnflags & VIEWLOC_FREEAIM))
956  ViewLocation_Mouse(); // NOTE: doesn't use cursormode
957  return;
958  }
959 
960  if (cursor_active == -1) // starting to display the cursor
961  {
962  // since HUD_Mouse is called by CSQC_UpdateView before CSQC_InputEvent,
963  // in the first frame mousepos is the mouse position of the last time
964  // the cursor was displayed, thus we ignore it to avoid a glictch
965  cursor_active = 1;
966  return;
967  }
968 
970  update_mousepos();
971 
974  HUD_Panel_Mouse();
975  else
976  {
979  if (QuickMenu_IsOpened())
980  QuickMenu_Mouse();
981  if (HUD_Radar_Clickable())
982  HUD_Radar_Mouse();
983  }
984 
986 
987  HUD_Cursor_Show();
988 }
void ViewLocation_Mouse()
Definition: view.qc:921
int prevMouseClicked
Definition: hud_config.qh:13
bool HUD_MinigameMenu_IsOpened()
bool autocvar__hud_configure
Definition: hud_config.qh:3
const int VIEWLOC_FREEAIM
Definition: viewloc.qh:5
void HUD_Panel_Mouse()
Definition: hud_config.qc:946
void HUD_Cursor_Show()
Definition: view.qc:935
void update_mousepos()
Definition: view.qc:379
int mouseClicked
Definition: hud_config.qh:12
bool HUD_Radar_Clickable()
Definition: radar.qc:25
float autocvar__menu_alpha
Definition: hud.qh:184
int cursor_active
Definition: view.qh:108
void HUD_Minigame_Mouse()
bool QuickMenu_IsOpened()
Definition: quickmenu.qc:244
const int CURSOR_NORMAL
Definition: view.qh:110
void HUD_Radar_Mouse()
Definition: radar.qc:134
void QuickMenu_Mouse()
Definition: quickmenu.qc:497
int cursor_type
Definition: view.qh:109
bool autocvar_hud_cursormode
Definition: hud.qh:188
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ leanmodel_ofs()

vector leanmodel_ofs ( entity  view)

Definition at line 166 of file view.qc.

References autocvar_cl_leanmodel_highpass, autocvar_cl_leanmodel_highpass1, autocvar_cl_leanmodel_limit, autocvar_cl_leanmodel_lowpass, autocvar_cl_leanmodel_speed, avg_factor, floor(), highpass2, highpass2_limited, lowpass2, PITCH, ROLL, vector(), view_angles, and YAW.

Referenced by viewmodel_animate().

167 {
168  float frac;
169  vector gunangles = '0 0 0';
170  static vector gunangles_prev = '0 0 0';
171  static vector gunangles_highpass = '0 0 0';
172  static vector gunangles_adjustment_highpass;
173  static vector gunangles_adjustment_lowpass;
174 
175  if (view.csqcmodel_teleported)
176  gunangles_prev = view_angles;
177 
178  // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
179  gunangles_highpass += gunangles_prev;
180  PITCH(gunangles_highpass) += 360 * floor((PITCH(view_angles) - PITCH(gunangles_highpass)) / 360 + 0.5);
181  YAW(gunangles_highpass) += 360 * floor((YAW(view_angles) - YAW(gunangles_highpass)) / 360 + 0.5);
182  ROLL(gunangles_highpass) += 360 * floor((ROLL(view_angles) - ROLL(gunangles_highpass)) / 360 + 0.5);
184  highpass2_limited(view_angles, frac, autocvar_cl_leanmodel_limit, gunangles_highpass, gunangles);
185  gunangles_prev = view_angles;
186  gunangles_highpass -= gunangles_prev;
187 
188  PITCH(gunangles) *= -autocvar_cl_leanmodel_speed;
189  YAW(gunangles) *= -autocvar_cl_leanmodel_speed;
190 
191  // we assume here: PITCH = 0, YAW = 1, ROLL = 2
193  highpass2(gunangles, frac, gunangles_adjustment_highpass, gunangles);
195  lowpass2(gunangles, frac, gunangles_adjustment_lowpass, gunangles);
196 
197  gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
198 
199  return gunangles;
200 }
#define lowpass2(value, frac, ref_store, ref_out)
Definition: view.qc:85
#define PITCH(v)
Definition: vector.qh:81
#define highpass2(value, frac, ref_store, ref_out)
Definition: view.qc:90
#define ROLL(v)
Definition: vector.qh:83
float autocvar_cl_leanmodel_lowpass
Definition: view.qc:63
float autocvar_cl_leanmodel_speed
Definition: view.qc:59
vector view_angles
Definition: csprogsdefs.qc:150
#define avg_factor(avg_time)
Definition: view.qc:65
float autocvar_cl_leanmodel_highpass
Definition: view.qc:62
float autocvar_cl_leanmodel_limit
Definition: view.qc:60
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define YAW(v)
Definition: vector.qh:82
float autocvar_cl_leanmodel_highpass1
Definition: view.qc:61
#define highpass2_limited(value, frac, limit, ref_store, ref_out)
Definition: view.qc:95
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ project_3d_to_2d()

vector project_3d_to_2d ( vector  vec)

Definition at line 359 of file view.qc.

References cs_project_is_b0rked, vid_conheight, vid_conwidth, vid_height, and vid_width.

Referenced by AuxiliaryXhair_Draw2D(), DamageText::DamageText_draw2d(), Draw_ShowNames(), EnemyHitCheck(), GENERIC_COMMAND(), HUD_Crosshair(), NET_HANDLE(), and turret_draw2d().

360 {
361  vec = cs_project(vec);
362  if(cs_project_is_b0rked > 0)
363  {
364  vec.x *= vid_conwidth / vid_width;
365  vec.y *= vid_conheight / vid_height;
366  }
367  return vec;
368 }
float vid_conheight
int vid_height
Definition: main.qh:120
float vid_conwidth
int vid_width
Definition: main.qh:120
int cs_project_is_b0rked
Definition: main.qh:119
+ Here is the caller graph for this function:

◆ projected_on_screen()

bool projected_on_screen ( vector  screen_pos)

Definition at line 370 of file view.qc.

References vid_conheight, and vid_conwidth.

Referenced by NET_HANDLE().

371 {
372  return screen_pos.z >= 0
373  && screen_pos.x >= 0
374  && screen_pos.y >= 0
375  && screen_pos.x < vid_conwidth
376  && screen_pos.y < vid_conheight;
377 }
float vid_conheight
float vid_conwidth
+ Here is the caller graph for this function:

◆ STATIC_INIT() [1/2]

STATIC_INIT ( viewmodel  )

Definition at line 354 of file view.qc.

References MAX_WEAPONSLOTS, and viewmodels.

354  {
355  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
356  viewmodels[slot] = new(viewmodel);
357 }
entity viewmodels[MAX_WEAPONSLOTS]
Definition: view.qh:104
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13

◆ STATIC_INIT() [2/2]

STATIC_INIT ( fpscounter_init  )

Definition at line 409 of file view.qc.

References gettime(), GETTIME_FRAMESTART, and showfps_prevfps_time.

410 {
411  float currentTime = gettime(GETTIME_FRAMESTART);
412  showfps_prevfps_time = currentTime; // we must initialize it to avoid an instant low frame sending
413 }
float GETTIME_FRAMESTART
float showfps_prevfps_time
Definition: view.qc:386
+ Here is the call graph for this function:

◆ update_mousepos()

void update_mousepos ( )

Definition at line 379 of file view.qc.

References autocvar_menu_mouse_speed, bound(), getmousepos(), mousepos, vid_conheight, and vid_conwidth.

Referenced by HUD_Mouse().

380 {
382  mousepos.x = bound(0, mousepos.x, vid_conwidth);
384 }
float vid_conheight
float autocvar_menu_mouse_speed
Definition: view.qh:66
float vid_conwidth
vector mousepos
Definition: hud.qh:102
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateDamage()

void UpdateDamage ( )

Definition at line 769 of file view.qc.

References COMPARE_INCREASING, spectatee_status, and unaccounted_damage.

770 {
771  // accumulate damage with each stat update
772  static float damage_total_prev = 0;
773  float damage_total = STAT(HITSOUND_DAMAGE_DEALT_TOTAL);
774  float unaccounted_damage_new = COMPARE_INCREASING(damage_total, damage_total_prev);
775  damage_total_prev = damage_total;
776 
777  static float damage_dealt_time_prev = 0;
778  float damage_dealt_time = STAT(HIT_TIME);
779  if (damage_dealt_time != damage_dealt_time_prev)
780  {
781  unaccounted_damage += unaccounted_damage_new;
782  //LOG_TRACE("dmg total: ", ftos(unaccounted_damage), " (+", ftos(unaccounted_damage_new), ")");
783  }
784  damage_dealt_time_prev = damage_dealt_time;
785 
786  // prevent hitsound when switching spectatee
787  static float spectatee_status_prev = 0;
788  if (spectatee_status != spectatee_status_prev)
789  unaccounted_damage = 0;
790  spectatee_status_prev = spectatee_status;
791 }
#define COMPARE_INCREASING(to, from)
Definition: util.qh:228
float spectatee_status
Definition: main.qh:166
float unaccounted_damage
Definition: view.qh:116

◆ View_CheckButtonStatus()

void View_CheckButtonStatus ( )

Definition at line 1341 of file view.qc.

References active_minigame, autocvar__togglezoom, autocvar_cl_unpress_attack_on_weapon_switch, autocvar_cl_unpress_zoom_on_death, autocvar_cl_unpress_zoom_on_weapon_switch, autocvar_fov, button_attack2, button_zoom, entity(), HUD_MinigameMenu_IsOpened(), intermission, isdemo(), localcmd, MAX_WEAPONSLOTS, minigame_wasactive, spectatee_status, strcat(), time, viewmodels, weapontime, and zoomscript_caught.

Referenced by CSQC_UpdateView().

1342 {
1343  float is_dead = (STAT(HEALTH) <= 0);
1344 
1345  // FIXME do we need this hack?
1346  if(isdemo())
1347  {
1348  // in demos, input_buttons do not work
1349  button_zoom = (autocvar__togglezoom == "-");
1350  }
1351  else if(button_zoom
1353  && (spectatee_status >= 0)
1354  && (is_dead || intermission))
1355  {
1356  // no zoom while dead or in intermission please
1357  localcmd("-zoom\n");
1358  button_zoom = false;
1359  }
1360 
1361  if(autocvar_fov <= 59.5)
1362  {
1363  if(!zoomscript_caught)
1364  {
1365  localcmd("+button9\n");
1366  zoomscript_caught = 1;
1367  }
1368  }
1369  else
1370  {
1371  if(zoomscript_caught)
1372  {
1373  localcmd("-button9\n");
1374  zoomscript_caught = 0;
1375  }
1376  }
1377 
1379  {
1380  if(!minigame_wasactive)
1381  {
1382  localcmd("+button12\n");
1383  minigame_wasactive = true;
1384  }
1385  }
1386  else if(minigame_wasactive)
1387  {
1388  localcmd("-button12\n");
1389  minigame_wasactive = false;
1390  }
1391 
1392  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
1393  {
1394  entity wepent = viewmodels[slot];
1395 
1396  if(wepent.last_switchweapon != wepent.switchweapon)
1397  {
1398  weapontime = time;
1399  wepent.last_switchweapon = wepent.switchweapon;
1401  {
1402  localcmd("-zoom\n");
1403  button_zoom = false;
1404  }
1406  {
1407  localcmd("-fire\n");
1408  localcmd("-fire2\n");
1409  button_attack2 = false;
1410  }
1411  }
1412  if(wepent.last_activeweapon != wepent.activeweapon)
1413  {
1414  wepent.last_activeweapon = wepent.activeweapon;
1415 
1416  entity e = wepent.activeweapon;
1417  if(e.netname != "")
1418  localcmd(strcat("\ncl_hook_activeweapon ", e.netname), "\n");
1419  else if(slot == 0)
1420  localcmd("\ncl_hook_activeweapon none\n");
1421  }
1422  }
1423 }
float zoomscript_caught
Definition: view.qh:117
bool HUD_MinigameMenu_IsOpened()
float weapontime
Definition: hud.qh:121
entity viewmodels[MAX_WEAPONSLOTS]
Definition: view.qh:104
entity() spawn
float intermission
Definition: csprogsdefs.qc:148
float autocvar_fov
Definition: view.qh:35
entity active_minigame
Definition: cl_minigames.qh:85
bool button_attack2
Definition: main.qh:99
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
bool button_zoom
Definition: main.qh:97
bool autocvar_cl_unpress_attack_on_weapon_switch
Definition: main.qh:15
bool autocvar_cl_unpress_zoom_on_death
Definition: main.qh:13
string autocvar__togglezoom
Definition: view.qh:92
float spectatee_status
Definition: main.qh:166
bool autocvar_cl_unpress_zoom_on_weapon_switch
Definition: main.qh:14
float time
Definition: csprogsdefs.qc:16
bool minigame_wasactive
Definition: view.qc:567
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ View_DemoCamera()

void View_DemoCamera ( )

Definition at line 1290 of file view.qc.

References autocvar_camera_enable, autocvar_chase_active, camera_active, camera_mode, chase_active_backup, CSQC_Demo_Camera(), cvar_set(), ftos(), isdemo(), strcat(), and time.

Referenced by CSQC_UpdateView().

1291 {
1292  if(camera_active) // Camera for demo playback
1293  {
1295  CSQC_Demo_Camera();
1296  else
1297  {
1298  cvar_set("chase_active", ftos(chase_active_backup));
1299  cvar_set("cl_demo_mousegrab", "0");
1300  camera_active = false;
1301  }
1302  }
1303  else
1304  {
1305 #ifdef CAMERATEST
1307 #else
1309 #endif
1310  {
1311  // Enable required Darkplaces cvars
1313  cvar_set("chase_active", "2");
1314  cvar_set("cl_demo_mousegrab", "1");
1315  camera_active = true;
1316  camera_mode = false;
1317  }
1318  }
1319 }
void CSQC_Demo_Camera()
Definition: view.qc:1772
float chase_active_backup
Definition: main.qh:124
bool autocvar_camera_enable
Definition: view.qh:6
float camera_active
Definition: main.qh:123
int autocvar_chase_active
Definition: view.qh:17
float camera_mode
Definition: view.qc:569
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ View_EventChase()

void View_EventChase ( entity  this)

Definition at line 627 of file view.qc.

References autocvar_chase_active, autocvar_cl_eventchase_distance, autocvar_cl_eventchase_maxs, autocvar_cl_eventchase_mins, autocvar_cl_eventchase_speed, autocvar_cl_eventchase_vehicle, autocvar_cl_eventchase_vehicle_distance, autocvar_cl_eventchase_vehicle_viewoffset, autocvar_cl_eventchase_viewoffset, csqcplayer, cvar_set(), cvar_settemp(), eventchase_current_distance, eventchase_running, frametime, Vehicle::height, hud, intermission, M_ARGV, max(), MOVE_WORLDONLY, MUTATOR_CALLHOOK, pmove_org, REGISTRY_GET, spectatee_status, trace_endpos, trace_fraction, trace_startsolid, vector(), VF_ANGLES, VF_ORIGIN, view_angles, Vehicle::view_ofs, viewloc, WantEventchase(), WarpZone_trace_transform, WarpZone_TraceBox(), WarpZone_TraceLine(), and WarpZone_TransformVAngles().

Referenced by CSQC_UpdateView().

628 {
629  // event chase camera
630  if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually, and this code is skipped
631  {
632  if(STAT(CAMERA_SPECTATOR))
633  {
634  if(spectatee_status > 0)
635  {
637  {
638  cvar_set("chase_active", "-2");
639  return;
640  }
641  }
642  else if(autocvar_chase_active == -2)
643  cvar_set("chase_active", "0");
644 
645  if(autocvar_chase_active == -2)
646  return;
647  }
648  else if(autocvar_chase_active == -2)
649  cvar_set("chase_active", "0");
650 
651  bool vehicle_chase = (hud != HUD_NORMAL && (autocvar_cl_eventchase_vehicle || spectatee_status > 0));
652 
653  float vehicle_viewdist = 0;
654  vector vehicle_viewofs = '0 0 0';
655 
656  if(vehicle_chase)
657  {
658  if(hud != HUD_BUMBLEBEE_GUN)
659  {
660  Vehicle info = REGISTRY_GET(Vehicles, hud);
661  vehicle_viewdist = info.height;
662  vehicle_viewofs = info.view_ofs;
663  if(vehicle_viewdist < 0) // when set below 0, this vehicle doesn't use third person view (gunner slots)
664  vehicle_chase = false;
665  }
666  else
667  vehicle_chase = false;
668  }
669 
670  int eventchase = WantEventchase(this, vehicle_chase);
671  if (eventchase)
672  {
673  vector current_view_origin_override = '0 0 0';
674  vector view_offset_override = '0 0 0';
675  float chase_distance_override = 0;
676  bool custom_eventchase = MUTATOR_CALLHOOK(CustomizeEventchase, this);
677  if(custom_eventchase)
678  {
679  current_view_origin_override = M_ARGV(0, vector);
680  view_offset_override = M_ARGV(1, vector);
681  chase_distance_override = M_ARGV(0, float);
682  }
683  eventchase_running = true;
684 
685  // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.)
686  vector current_view_origin = (csqcplayer ? csqcplayer.origin : pmove_org);
687  if (custom_eventchase)
688  current_view_origin = current_view_origin_override;
689 
690  // detect maximum viewoffset and use it
692  if(vehicle_chase)
693  {
694  if(vehicle_viewofs)
695  view_offset = vehicle_viewofs;
696  else
698  }
699  if (custom_eventchase)
700  view_offset = view_offset_override;
701 
702  if(view_offset)
703  {
704  WarpZone_TraceLine(current_view_origin, current_view_origin + view_offset + ('0 0 1' * autocvar_cl_eventchase_maxs.z), MOVE_WORLDONLY, this);
705  if(trace_fraction == 1) { current_view_origin += view_offset; }
706  else { current_view_origin.z += max(0, (trace_endpos.z - current_view_origin.z) - autocvar_cl_eventchase_maxs.z); }
707  }
708 
709  // We must enable chase_active to get a third person view (weapon viewmodel hidden and own player model showing).
710  // Ideally, there should be another way to enable third person cameras, such as through setproperty()
711  // -1 enables chase_active while marking it as set by this code, and not by the user (which would be 1)
712  if(!autocvar_chase_active) { cvar_set("chase_active", "-1"); }
713 
714  // make the camera smooth back
715  float chase_distance = autocvar_cl_eventchase_distance;
716  if(vehicle_chase)
717  {
718  if(vehicle_viewofs)
719  chase_distance = vehicle_viewdist;
720  else
722  }
723  if (custom_eventchase)
724  chase_distance = chase_distance_override;
725 
727  eventchase_current_distance += autocvar_cl_eventchase_speed * (chase_distance - eventchase_current_distance) * frametime; // slow down the further we get
728  else if(eventchase_current_distance != chase_distance)
729  eventchase_current_distance = chase_distance;
730 
731  vector forward, right, up;
732  MAKE_VECTORS(view_angles, forward, right, up);
733 
734  vector eventchase_target_origin = (current_view_origin - (forward * eventchase_current_distance));
735  WarpZone_TraceBox(current_view_origin, autocvar_cl_eventchase_mins, autocvar_cl_eventchase_maxs, eventchase_target_origin, MOVE_WORLDONLY, this);
736 
737  // If the boxtrace fails, revert back to line tracing.
738  if(!this.viewloc)
739  if(trace_startsolid)
740  {
741  eventchase_target_origin = (current_view_origin - (forward * eventchase_current_distance));
742  WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, this);
743  setproperty(VF_ORIGIN, (trace_endpos - (forward * autocvar_cl_eventchase_mins.z)));
744  }
745  else { setproperty(VF_ORIGIN, trace_endpos); }
746 
747  if(!this.viewloc)
749  }
750 
751  if (eventchase <= 0 && autocvar_chase_active < 0) // time to disable chase_active if it was set by this code
752  {
753  eventchase_running = false;
754  cvar_set("chase_active", "0");
755  eventchase_current_distance = 0; // start from 0 next time
756  }
757  }
758  // workaround for camera stuck between player's legs when using chase_active 1
759  // because the engine stops updating the chase_active camera when the game ends
760  else if(intermission)
761  {
762  cvar_settemp("chase_active", "-1");
764  }
765 }
vector pmove_org
Definition: csprogsdefs.qc:54
float autocvar_cl_eventchase_distance
Definition: view.qh:86
vector autocvar_cl_eventchase_mins
Definition: view.qh:90
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition: util.qc:696
float height
vehicle 3rd person view distance
Definition: vehicle.qh:36
void WarpZone_TraceBox(vector org, vector mi, vector ma, vector end, float nomonsters, entity forent)
Definition: common.qc:333
#define REGISTRY_GET(id, i)
Definition: registry.qh:43
float intermission
Definition: csprogsdefs.qc:148
int WantEventchase(entity this, bool want_vehiclechase)
Definition: view.qc:590
vector autocvar_cl_eventchase_vehicle_viewoffset
Definition: view.qh:76
vector autocvar_cl_eventchase_maxs
Definition: view.qh:89
vector view_angles
Definition: csprogsdefs.qc:150
bool autocvar_cl_eventchase_vehicle
Definition: view.qh:75
vector WarpZone_TransformVAngles(entity wz, vector ang)
Definition: common.qc:514
float frametime
Definition: csprogsdefs.qc:17
vector trace_endpos
Definition: csprogsdefs.qc:37
#define M_ARGV(x, type)
Definition: events.qh:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float autocvar_cl_eventchase_speed
Definition: view.qh:88
entity WarpZone_trace_transform
Definition: common.qh:37
entity viewloc
Definition: viewloc.qh:13
vector autocvar_cl_eventchase_viewoffset
Definition: view.qh:91
float spectatee_status
Definition: main.qh:166
const float VF_ANGLES
Definition: csprogsdefs.qc:186
void WarpZone_TraceLine(vector org, vector end, float nomonsters, entity forent)
Definition: common.qc:338
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
float eventchase_current_distance
Definition: view.qc:588
entity csqcplayer
Definition: cl_player.qh:26
float trace_startsolid
Definition: csprogsdefs.qc:35
int autocvar_chase_active
Definition: view.qh:17
vector view_ofs
vehicle 3rd person view offset
Definition: vehicle.qh:34
float MOVE_WORLDONLY
float trace_fraction
Definition: csprogsdefs.qc:36
float eventchase_running
Definition: view.qc:589
float autocvar_cl_eventchase_vehicle_distance
Definition: view.qh:77
const float VF_ORIGIN
Definition: csprogsdefs.qc:182
int hud
Definition: main.qh:142
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ View_Lock()

void View_Lock ( )

Definition at line 1264 of file view.qc.

References autocvar__hud_configure, autocvar_cl_lockview, autocvar_hud_cursormode, freeze_ang, freeze_org, HUD_MinigameMenu_IsOpened(), HUD_Radar_Clickable(), intermission, QuickMenu_IsOpened(), spectatee_status, VF_ANGLES, and VF_ORIGIN.

Referenced by CSQC_UpdateView().

1265 {
1266  int lock_type = autocvar_cl_lockview;
1267 
1270  || intermission > 1
1271  || HUD_Radar_Clickable()
1273  || QuickMenu_IsOpened()
1274  )
1275  )
1276  lock_type = 1;
1277 
1278  // lock_type 1: lock origin and angles
1279  // lock_type 2: lock only origin
1280  if(lock_type >= 1)
1281  setproperty(VF_ORIGIN, freeze_org);
1282  else
1283  freeze_org = getpropertyvec(VF_ORIGIN);
1284  if(lock_type == 1)
1285  setproperty(VF_ANGLES, freeze_ang);
1286  else
1287  freeze_ang = getpropertyvec(VF_ANGLES);
1288 }
bool HUD_MinigameMenu_IsOpened()
bool autocvar__hud_configure
Definition: hud_config.qh:3
vector freeze_ang
Definition: view.qc:574
float intermission
Definition: csprogsdefs.qc:148
bool autocvar_cl_lockview
Definition: view.qh:20
vector freeze_org
Definition: view.qc:574
bool HUD_Radar_Clickable()
Definition: radar.qc:25
float spectatee_status
Definition: main.qh:166
bool QuickMenu_IsOpened()
Definition: quickmenu.qc:244
const float VF_ANGLES
Definition: csprogsdefs.qc:186
bool autocvar_hud_cursormode
Definition: hud.qh:188
const float VF_ORIGIN
Definition: csprogsdefs.qc:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ View_NightVision()

void View_NightVision ( )

Definition at line 990 of file view.qc.

References autocvar_r_fakelight, autocvar_r_fullbright, autocvar_vid_conheight, autocvar_vid_conwidth, cos(), drawfill(), DRAWFLAG_ADDITIVE, DRAWFLAG_MODULATE, frametime, nightvision_noise, nightvision_noise2, Noise_Pink(), Noise_White(), SERVERFLAG_ALLOW_FULLBRIGHT, serverflags, sin(), time, and vector().

Referenced by CSQC_UpdateView().

991 {
993  return;
994 
995  // apply night vision effect
996  vector tc_00, tc_01, tc_10, tc_11;
997  vector rgb = '0 0 0';
998  float a;
999 
1000  if(!nightvision_noise)
1001  {
1003  }
1004  if(!nightvision_noise2)
1005  {
1007  }
1008 
1009  // color tint in yellow
1010  drawfill('0 0 0', autocvar_vid_conwidth * '1 0 0' + autocvar_vid_conheight * '0 1 0', '0.5 1 0.3', 1, DRAWFLAG_MODULATE);
1011 
1012  // draw BG
1013  a = Noise_Pink(nightvision_noise, frametime * 1.5) * 0.05 + 0.15;
1014  rgb = '1 1 1';
1015  tc_00 = '0 0 0' + '0.2 0 0' * sin(time * 0.3) + '0 0.3 0' * cos(time * 0.7);
1016  tc_01 = '0 2.25 0' + '0.6 0 0' * cos(time * 1.2) - '0 0.3 0' * sin(time * 2.2);
1017  tc_10 = '1.5 0 0' - '0.2 0 0' * sin(time * 0.5) + '0 0.5 0' * cos(time * 1.7);
1018  //tc_11 = '1 1 0' + '0.6 0 0' * sin(time * 0.6) + '0 0.3 0' * cos(time * 0.1);
1019  tc_11 = tc_01 + tc_10 - tc_00;
1020  R_BeginPolygon("gfx/nightvision-bg", DRAWFLAG_ADDITIVE, true);
1021  R_PolygonVertex('0 0 0', tc_00, rgb, a);
1022  R_PolygonVertex(autocvar_vid_conwidth * '1 0 0', tc_10, rgb, a);
1023  R_PolygonVertex(autocvar_vid_conwidth * '1 0 0' + autocvar_vid_conheight * '0 1 0', tc_11, rgb, a);
1024  R_PolygonVertex(autocvar_vid_conheight * '0 1 0', tc_01, rgb, a);
1025  R_EndPolygon();
1026 
1027  // draw FG
1028  a = Noise_Pink(nightvision_noise2, frametime * 0.1) * 0.05 + 0.12;
1029  rgb = '0.3 0.6 0.4' + '0.1 0.4 0.2' * Noise_White(nightvision_noise2, frametime);
1030  tc_00 = '0 0 0' + '1 0 0' * Noise_White(nightvision_noise2, frametime) + '0 1 0' * Noise_White(nightvision_noise2, frametime);
1031  tc_01 = tc_00 + '0 3 0' * (1 + Noise_White(nightvision_noise2, frametime) * 0.2);
1032  tc_10 = tc_00 + '2 0 0' * (1 + Noise_White(nightvision_noise2, frametime) * 0.3);
1033  tc_11 = tc_01 + tc_10 - tc_00;
1034  R_BeginPolygon("gfx/nightvision-fg", DRAWFLAG_ADDITIVE, true);
1035  R_PolygonVertex('0 0 0', tc_00, rgb, a);
1036  R_PolygonVertex(autocvar_vid_conwidth * '1 0 0', tc_10, rgb, a);
1037  R_PolygonVertex(autocvar_vid_conwidth * '1 0 0' + autocvar_vid_conheight * '0 1 0', tc_11, rgb, a);
1038  R_PolygonVertex(autocvar_vid_conheight * '0 1 0', tc_01, rgb, a);
1039  R_EndPolygon();
1040 }
entity nightvision_noise2
Definition: view.qc:575
int serverflags
Definition: main.qh:184
int autocvar_r_fakelight
Definition: view.qh:67
entity nightvision_noise
Definition: view.qc:575
const int SERVERFLAG_ALLOW_FULLBRIGHT
Definition: constants.qh:15
const float DRAWFLAG_ADDITIVE
Definition: csprogsdefs.qc:318
float frametime
Definition: csprogsdefs.qc:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const float DRAWFLAG_MODULATE
Definition: csprogsdefs.qc:319
ERASEABLE float Noise_White(entity e, float dt)
Definition: noise.qh:29
int autocvar_vid_conwidth
Definition: view.qh:72
bool autocvar_r_fullbright
Definition: view.qh:68
ERASEABLE float Noise_Pink(entity e, float dt)
Definition: noise.qh:18
int autocvar_vid_conheight
Definition: view.qh:71
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ View_Ortho()

void View_Ortho ( )

Definition at line 1437 of file view.qc.

References autocvar_cl_orthoview, bound(), cvar(), cvar_set(), cvar_settemp(), ftos(), LOG_INFOF, max(), oldr_farclip_base, oldr_farclip_world, oldr_nearclip, oldr_novis, oldr_useinfinitefarclip, oldr_useportalculling, ov_enabled, ov_mid, ov_org, ov_worldmax, ov_worldmin, vdist, vec3, VF_ANGLES, VF_ORIGIN, vid_height, vid_width, vlen(), and vtos().

Referenced by CSQC_UpdateView().

1438 {
1439  ov_org = '0 0 0';
1440  ov_mid = '0 0 0';
1441  ov_worldmin = '0 0 0';
1442  ov_worldmax = '0 0 0';
1444  {
1445  ov_worldmin = mi_picmin;
1446  ov_worldmax = mi_picmax;
1447 
1448  float ov_width = (ov_worldmax.x - ov_worldmin.x);
1449  float ov_height = (ov_worldmax.y - ov_worldmin.y);
1450  float ov_distance = (max(vid_width, vid_height) * max(ov_width, ov_height));
1451 
1452  ov_mid = ((ov_worldmax + ov_worldmin) * 0.5);
1453  ov_org = vec3(ov_mid.x, ov_mid.y, (ov_mid.z + ov_distance));
1454 
1455  float ov_nearest = vlen(ov_org - vec3(
1459  ));
1460 
1461  float ov_furthest = 0;
1462  float dist = 0;
1463 
1464  if((dist = vdist((vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
1465  if((dist = vdist((vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
1466  if((dist = vdist((vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
1467  if((dist = vdist((vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
1468  if((dist = vdist((vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
1469  if((dist = vdist((vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
1470  if((dist = vdist((vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
1471  if((dist = vdist((vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
1472 
1473  if(!ov_enabled)
1474  {
1475  oldr_nearclip = cvar("r_nearclip");
1476  oldr_farclip_base = cvar("r_farclip_base");
1477  oldr_farclip_world = cvar("r_farclip_world");
1478  oldr_novis = cvar("r_novis");
1479  oldr_useportalculling = cvar("r_useportalculling");
1480  oldr_useinfinitefarclip = cvar("r_useinfinitefarclip");
1481  }
1482 
1483  cvar_settemp("r_nearclip", ftos(ov_nearest));
1484  cvar_settemp("r_farclip_base", ftos(ov_furthest));
1485  cvar_settemp("r_farclip_world", "0");
1486  cvar_settemp("r_novis", "1");
1487  cvar_settemp("r_useportalculling", "0");
1488  cvar_settemp("r_useinfinitefarclip", "0");
1489 
1490  setproperty(VF_ORIGIN, ov_org);
1491  setproperty(VF_ANGLES, '90 0 0');
1492 
1493  ov_enabled = true;
1494 
1495  #if 0
1496  LOG_INFOF("OrthoView: org = %s, angles = %s, distance = %f, nearest = %f, furthest = %f",
1497  vtos(ov_org),
1498  vtos(getpropertyvec(VF_ANGLES)),
1499  ov_distance,
1500  ov_nearest,
1501  ov_furthest);
1502  #endif
1503  }
1504  else
1505  {
1506  if(ov_enabled)
1507  {
1508  cvar_set("r_nearclip", ftos(oldr_nearclip));
1509  cvar_set("r_farclip_base", ftos(oldr_farclip_base));
1510  cvar_set("r_farclip_world", ftos(oldr_farclip_world));
1511  cvar_set("r_novis", ftos(oldr_novis));
1512  cvar_set("r_useportalculling", ftos(oldr_useportalculling));
1513  cvar_set("r_useinfinitefarclip", ftos(oldr_useinfinitefarclip));
1514  }
1515  ov_enabled = false;
1516  }
1517 }
int vid_height
Definition: main.qh:120
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition: util.qc:696
#define vec3(_x, _y, _z)
Definition: vector.qh:95
vector ov_worldmax
Definition: view.qc:1435
bool ov_enabled
Definition: view.qc:1425
#define LOG_INFOF(...)
Definition: log.qh:71
bool autocvar_cl_orthoview
Definition: view.qh:21
float oldr_nearclip
Definition: view.qc:1426
vector ov_org
Definition: view.qc:1432
float oldr_useinfinitefarclip
Definition: view.qc:1431
float oldr_farclip_base
Definition: view.qc:1427
float oldr_useportalculling
Definition: view.qc:1430
const float VF_ANGLES
Definition: csprogsdefs.qc:186
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
float oldr_farclip_world
Definition: view.qc:1428
int vid_width
Definition: main.qh:120
float oldr_novis
Definition: view.qc:1429
vector ov_worldmin
Definition: view.qc:1434
vector ov_mid
Definition: view.qc:1433
const float VF_ORIGIN
Definition: csprogsdefs.qc:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ View_PostProcessing()

void View_PostProcessing ( )

Definition at line 1203 of file view.qc.

References autocvar_hud_postprocessing, autocvar_hud_postprocessing_maxbluralpha, autocvar_hud_postprocessing_maxblurradius, autocvar_hud_powerup, bound(), content_blurpostprocess, cvar(), cvar_set(), cvar_string(), damage_blurpostprocess, FOREACH, ftos(), old_bluralpha, old_blurradius, old_sharpen_intensity, and strcat().

Referenced by CSQC_UpdateView().

1204 {
1205  float e1 = (autocvar_hud_postprocessing_maxbluralpha != 0);
1206  float e2 = (autocvar_hud_powerup != 0);
1207  if(autocvar_hud_postprocessing && (e1 || e2)) // TODO: Remove this code and re-do the postprocess handling in the engine, where it properly belongs.
1208  {
1209  // enable or disable rendering types if they are used or not
1210  if(cvar("r_glsl_postprocess_uservec1_enable") != e1) { cvar_set("r_glsl_postprocess_uservec1_enable", ftos(e1)); }
1211  if(cvar("r_glsl_postprocess_uservec2_enable") != e2) { cvar_set("r_glsl_postprocess_uservec2_enable", ftos(e2)); }
1212 
1213  // blur postprocess handling done first (used by hud_damage and hud_contents)
1215  {
1218  if(blurradius != old_blurradius || bluralpha != old_bluralpha) // reduce cvar_set spam as much as possible
1219  {
1220  cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0"));
1221  old_blurradius = blurradius;
1222  old_bluralpha = bluralpha;
1223  }
1224  }
1225  else if(cvar_string("r_glsl_postprocess_uservec1") != "0 0 0 0") // reduce cvar_set spam as much as possible
1226  {
1227  cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
1228  old_blurradius = 0;
1229  old_bluralpha = 0;
1230  }
1231 
1232  // edge detection postprocess handling done second (used by hud_powerup)
1233  float sharpen_intensity = 0;
1234  FOREACH(StatusEffect, it.instanceOfPowerups,
1235  {
1236  float powerup_finished = StatusEffects_gettime(it, g_statuseffects) - time;
1237  if(powerup_finished > 0)
1238  sharpen_intensity += powerup_finished;
1239  });
1240 
1241  sharpen_intensity = bound(0, ((STAT(HEALTH) > 0) ? sharpen_intensity : 0), 5); // Check to see if player is alive (if not, set 0) - also bound to fade out starting at 5 seconds.
1242 
1243  if(autocvar_hud_powerup && sharpen_intensity > 0)
1244  {
1245  if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible
1246  {
1247  cvar_set("r_glsl_postprocess_uservec2", strcat(ftos((sharpen_intensity / 5) * autocvar_hud_powerup), " ", ftos(-sharpen_intensity * autocvar_hud_powerup), " 0 0"));
1248  old_sharpen_intensity = sharpen_intensity;
1249  }
1250  }
1251  else if(cvar_string("r_glsl_postprocess_uservec2") != "0 0 0 0") // reduce cvar_set spam as much as possible
1252  {
1253  cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");
1255  }
1256 
1257  if(cvar("r_glsl_postprocess") == 0)
1258  cvar_set("r_glsl_postprocess", "2");
1259  }
1260  else if(cvar("r_glsl_postprocess") == 2)
1261  cvar_set("r_glsl_postprocess", "0");
1262 }
vector damage_blurpostprocess
Definition: view.qc:767
vector content_blurpostprocess
Definition: view.qc:767
float old_bluralpha
Definition: view.qc:580
bool autocvar_hud_powerup
Definition: view.qh:62
float autocvar_hud_postprocessing_maxblurradius
Definition: view.qh:65
float old_blurradius
Definition: view.qc:580
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
float autocvar_hud_postprocessing_maxbluralpha
Definition: view.qh:64
float old_sharpen_intensity
Definition: view.qc:581
#define FOREACH(list, cond, body)
Definition: iter.qh:19
bool autocvar_hud_postprocessing
Definition: view.qh:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ View_UpdateFov()

void View_UpdateFov ( )

Definition at line 1519 of file view.qc.

References autocvar_cl_orthoview, autocvar_fov, csqcplayer, GetCurrentFov(), GetOrthoviewFOV(), GetViewLocationFOV(), ov_mid, ov_org, ov_worldmax, ov_worldmin, vector(), and VF_FOV.

Referenced by CSQC_UpdateView().

1520 {
1521  vector fov;
1524  else if(csqcplayer.viewloc)
1525  fov = GetViewLocationFOV(110); // enforce 110 fov, so things don't look odd
1526  else
1527  fov = GetCurrentFov(autocvar_fov);
1528 
1529  setproperty(VF_FOV, fov);
1530 }
vector GetOrthoviewFOV(vector ov_worldmin, vector ov_worldmax, vector ov_mid, vector ov_org)
Definition: view.qc:554
vector ov_worldmax
Definition: view.qc:1435
float autocvar_fov
Definition: view.qh:35
bool autocvar_cl_orthoview
Definition: view.qh:21
vector ov_org
Definition: view.qc:1432
vector GetCurrentFov(float fov)
Definition: view.qc:416
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector GetViewLocationFOV(float fov)
Definition: view.qc:545
const float VF_FOV
Definition: csprogsdefs.qc:179
entity csqcplayer
Definition: cl_player.qh:26
vector ov_worldmin
Definition: view.qc:1434
vector ov_mid
Definition: view.qc:1433
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ViewLocation_Mouse()

void ViewLocation_Mouse ( )

Definition at line 921 of file view.qc.

References autocvar_menu_mouse_speed, bound(), getmousepos(), spectatee_status, vid_conheight, vid_conwidth, and viewloc_mousepos.

Referenced by HUD_Mouse().

922 {
923  if(spectatee_status)
924  return; // don't draw it as spectator!
925 
929 
930  //float cursor_alpha = 1 - autocvar__menu_alpha;
931  //cursor_type = CURSOR_NORMAL;
932  //draw_cursor(viewloc_mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
933 }
float vid_conheight
float autocvar_menu_mouse_speed
Definition: view.qh:66
float vid_conwidth
vector viewloc_mousepos
Definition: view.qh:106
float spectatee_status
Definition: main.qh:166
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ viewmodel_animate()

void viewmodel_animate ( entity  this)

Definition at line 242 of file view.qc.

References angles, autocvar_chase_active, autocvar_cl_bobmodel, autocvar_cl_followmodel, autocvar_cl_leanmodel, bobmodel_ofs(), calc_followmodel_ofs(), cl_followmodel_ofs, CSQCModel_server2csqc(), entity(), leanmodel_ofs(), origin, and player_localentnum.

Referenced by viewmodel_draw().

243 {
244  if (autocvar_chase_active || STAT(HEALTH) <= 0) return;
245 
247 
249  {
250  calc_followmodel_ofs(view);
251  this.origin += cl_followmodel_ofs;
252  }
253 
255  this.angles += leanmodel_ofs(view);
256 
257  // vertical view bobbing code
258  // TODO: cl_bob
259 
260  // horizontal view bobbing code
261  // TODO: cl_bob2
262 
263  // fall bobbing code
264  // causes the view to swing down and back up when touching the ground
265  // TODO: cl_bobfall
266 
267  // gun model bobbing code
269  this.origin += bobmodel_ofs(view);
270 }
vector leanmodel_ofs(entity view)
Definition: view.qc:166
entity CSQCModel_server2csqc(int i)
Definition: cl_model.qc:314
entity() spawn
vector bobmodel_ofs(entity view)
Definition: view.qc:202
origin
Definition: ent_cs.qc:114
float autocvar_cl_leanmodel
Definition: view.qc:58
void calc_followmodel_ofs(entity view)
Definition: view.qc:112
float player_localentnum
Definition: csprogsdefs.qc:19
vector cl_followmodel_ofs
Definition: hud.qh:213
bool autocvar_cl_bobmodel
Definition: view.qc:45
vector angles
Definition: csprogsdefs.qc:104
int autocvar_chase_active
Definition: view.qh:17
float autocvar_cl_followmodel
Definition: view.qc:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ viewmodel_draw()

void viewmodel_draw ( entity  this)

Definition at line 279 of file view.qc.

References angles, anim_set(), anim_update(), animstate_endtime, animstate_looping, animstate_override, autocvar_chase_active, autocvar_cl_viewmodel_alpha, autocvar_r_drawviewmodel, bound(), CSQCModel_Effects_Apply(), CSQCModel_server2csqc(), current_player, EF_FULLBRIGHT, EF_NODEPTHTEST, entity(), intermission, m_alpha, MASK_NORMAL, max(), maxclients, Weapon::mdl, MUTATOR_CALLHOOK, name, name_last, NULL, origin, player_localentnum, setorigin(), state, time, vector(), viewmodel_angles, viewmodel_animate(), viewmodel_origin, weapon_eta_last, weapon_nextthink, weapon_switchdelay, WS_CLEAR, WS_DROP, and WS_RAISE.

Referenced by CSQC_UpdateView().

280 {
281  if(!this.activeweapon || !autocvar_r_drawviewmodel)
282  return;
283  int mask = (intermission || (STAT(HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL;
285  int wepskin = this.m_skin;
286  bool invehicle = player_localentnum > maxclients;
287  if (invehicle) a = -1;
288  Weapon wep = this.activeweapon;
289  int c = entcs_GetClientColors(current_player);
290  vector g = weaponentity_glowmod(wep, NULL, c, this);
292  int fx = ((me.csqcmodel_effects & EFMASK_CHEAP)
293  | EF_NODEPTHTEST)
294  &~ (EF_FULLBRIGHT); // can mask team color, so get rid of it
295  for (entity e = this; e; e = e.weaponchild)
296  {
297  e.drawmask = mask;
298  e.alpha = a;
299  e.skin = wepskin;
300  e.colormap = 256 + c; // colormap == 0 is black, c == 0 is white
301  e.glowmod = g;
302  e.csqcmodel_effects = fx;
304  }
305  if(a >= 0)
306  {
307  string name = wep.mdl;
308  string newname = wep.wr_viewmodel(wep, this);
309  if(newname)
310  name = newname;
311  bool swap = name != this.name_last;
312  // if (swap)
313  {
314  this.name_last = name;
315  CL_WeaponEntity_SetModel(this, name, swap);
316  this.viewmodel_origin = this.origin;
317  this.viewmodel_angles = this.angles;
318  }
319  anim_update(this);
320  if ((!this.animstate_override && !this.animstate_looping) || time > this.animstate_endtime)
321  anim_set(this, this.anim_idle, true, false, false);
322  }
323  float f = 0; // 0..1; 0: fully active
324  float rate = STAT(WEAPONRATEFACTOR);
325  float eta = rate ? ((this.weapon_nextthink - time) / rate) : 0;
326  if (eta <= 0) f = this.weapon_eta_last;
327  else switch (this.state)
328  {
329  case WS_RAISE:
330  {
331  f = eta / max(eta, this.weapon_switchdelay);
332  break;
333  }
334  case WS_DROP:
335  {
336  f = 1 - eta / max(eta, this.weapon_switchdelay);
337  break;
338  }
339  case WS_CLEAR:
340  {
341  f = 1;
342  break;
343  }
344  }
345  this.weapon_eta_last = f;
346  this.origin = this.viewmodel_origin;
347  this.angles = this.viewmodel_angles;
348  this.angles_x = (-90 * f * f);
349  viewmodel_animate(this);
350  MUTATOR_CALLHOOK(DrawViewModel, this);
351  setorigin(this, this.origin);
352 }
float state
Definition: subs.qh:32
vector viewmodel_origin
Definition: view.qc:272
void CSQCModel_Effects_Apply(entity this)
float current_player
Definition: hud.qh:182
float animstate_endtime
Definition: anim.qh:38
const int WS_RAISE
raise frame
Definition: weapon.qh:32
entity CSQCModel_server2csqc(int i)
Definition: cl_model.qc:314
bool animstate_override
true for one cycle, then changed to false
Definition: anim.qh:42
string name_last
Definition: view.qc:277
const int WS_CLEAR
no weapon selected
Definition: weapon.qh:30
entity() spawn
float autocvar_cl_viewmodel_alpha
Definition: view.qc:43
float intermission
Definition: csprogsdefs.qc:148
float maxclients
Definition: csprogsdefs.qc:21
void anim_set(entity e, vector anim, bool looping, bool override, bool restart)
Definition: anim.qc:6
origin
Definition: ent_cs.qc:114
void anim_update(entity e)
Update e.frame based on its animstate relative to time.
Definition: anim.qc:36
const int WS_DROP
deselecting frame
Definition: weapon.qh:34
const float EF_NODEPTHTEST
Definition: csprogsdefs.qc:304
float weapon_switchdelay
Definition: view.qc:275
float m_alpha
Definition: weaponsystem.qc:74
float weapon_nextthink
Definition: view.qc:273
float weapon_eta_last
Definition: view.qc:274
const float EF_FULLBRIGHT
Definition: csprogsdefs.qc:303
#define NULL
Definition: post.qh:17
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
float player_localentnum
Definition: csprogsdefs.qc:19
vector(float skel, float bonenum) _skel_get_boneabs_hidden
bool autocvar_r_drawviewmodel
Definition: view.qh:94
vector viewmodel_angles
Definition: view.qc:272
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
bool animstate_looping
whether to repeat
Definition: anim.qh:40
setorigin(ent, v)
vector angles
Definition: csprogsdefs.qc:104
int autocvar_chase_active
Definition: view.qh:17
void viewmodel_animate(entity this)
Definition: view.qc:242
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
float time
Definition: csprogsdefs.qc:16
string mdl
M: modelname : name of model (without g_ v_ or h_ prefixes)
Definition: weapon.qh:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WantEventchase()

int WantEventchase ( entity  this,
bool  want_vehiclechase 
)

Definition at line 590 of file view.qc.

References autocvar_cl_eventchase_death, autocvar_cl_eventchase_frozen, autocvar_cl_eventchase_spectated_change, autocvar_cl_eventchase_spectated_change_time, autocvar_cl_orthoview, eventchase_running, intermission, min(), MUTATOR_CALLHOOK, spectatee_status, spectatee_status_changed_time, time, velocity, and viewloc.

Referenced by View_EventChase().

591 {
593  return 0;
594  if(STAT(GAME_STOPPED) || intermission)
595  return 1;
596  if(this.viewloc)
597  return 1;
598  if(spectatee_status >= 0)
599  {
600  if(want_vehiclechase)
601  return 1;
603  return 1;
604  if(autocvar_cl_eventchase_frozen && STAT(FROZEN))
605  return 1;
606  if(autocvar_cl_eventchase_death && (STAT(HEALTH) <= 0))
607  {
609  {
610  // don't stop eventchase once it's started (even if velocity changes afterwards)
611  if(this.velocity == '0 0 0' || eventchase_running)
612  return 1;
613  }
614  else return 1;
615  }
617  {
619  return 1;
620  else if (eventchase_running)
621  return -1; // disable chase_active while eventchase is still enabled so to avoid a glicth
622  }
623  }
624  return 0;
625 }
bool autocvar_cl_eventchase_spectated_change
Definition: view.qh:83
float intermission
Definition: csprogsdefs.qc:148
int WantEventchase(entity this, bool want_vehiclechase)
Definition: view.qc:590
int autocvar_cl_eventchase_death
Definition: view.qh:85
bool autocvar_cl_orthoview
Definition: view.qh:21
float autocvar_cl_eventchase_spectated_change_time
Definition: view.qh:84
entity viewloc
Definition: viewloc.qh:13
float spectatee_status
Definition: main.qh:166
bool autocvar_cl_eventchase_frozen
Definition: view.qh:87
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
float spectatee_status_changed_time
Definition: main.qh:167
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
float eventchase_running
Definition: view.qc:589
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_cl_bobmodel

bool autocvar_cl_bobmodel

Definition at line 45 of file view.qc.

Referenced by viewmodel_animate().

◆ autocvar_cl_bobmodel_side

float autocvar_cl_bobmodel_side

Definition at line 47 of file view.qc.

Referenced by bobmodel_ofs().

◆ autocvar_cl_bobmodel_speed

float autocvar_cl_bobmodel_speed

Definition at line 46 of file view.qc.

Referenced by bobmodel_ofs().

◆ autocvar_cl_bobmodel_up

float autocvar_cl_bobmodel_up

Definition at line 48 of file view.qc.

Referenced by bobmodel_ofs().

◆ autocvar_cl_followmodel

float autocvar_cl_followmodel

Definition at line 50 of file view.qc.

Referenced by viewmodel_animate().

◆ autocvar_cl_followmodel_highpass

float autocvar_cl_followmodel_highpass = 0.05

Definition at line 54 of file view.qc.

Referenced by calc_followmodel_ofs().

◆ autocvar_cl_followmodel_limit

float autocvar_cl_followmodel_limit = 135

Definition at line 52 of file view.qc.

Referenced by calc_followmodel_ofs().

◆ autocvar_cl_followmodel_lowpass

float autocvar_cl_followmodel_lowpass = 0.03

Definition at line 55 of file view.qc.

Referenced by calc_followmodel_ofs().

◆ autocvar_cl_followmodel_speed

float autocvar_cl_followmodel_speed = 0.3

Definition at line 51 of file view.qc.

Referenced by calc_followmodel_ofs().

◆ autocvar_cl_followmodel_velocity_absolute

bool autocvar_cl_followmodel_velocity_absolute

Definition at line 56 of file view.qc.

Referenced by calc_followmodel_ofs().

◆ autocvar_cl_followmodel_velocity_lowpass

float autocvar_cl_followmodel_velocity_lowpass = 0.05

Definition at line 53 of file view.qc.

Referenced by calc_followmodel_ofs().

◆ autocvar_cl_leanmodel

float autocvar_cl_leanmodel

Definition at line 58 of file view.qc.

Referenced by viewmodel_animate().

◆ autocvar_cl_leanmodel_highpass

float autocvar_cl_leanmodel_highpass = 0.2

Definition at line 62 of file view.qc.

Referenced by leanmodel_ofs().

◆ autocvar_cl_leanmodel_highpass1

float autocvar_cl_leanmodel_highpass1 = 0.2

Definition at line 61 of file view.qc.

Referenced by leanmodel_ofs().

◆ autocvar_cl_leanmodel_limit

float autocvar_cl_leanmodel_limit = 30

Definition at line 60 of file view.qc.

Referenced by leanmodel_ofs().

◆ autocvar_cl_leanmodel_lowpass

float autocvar_cl_leanmodel_lowpass = 0.05

Definition at line 63 of file view.qc.

Referenced by leanmodel_ofs().

◆ autocvar_cl_leanmodel_speed

float autocvar_cl_leanmodel_speed = 0.3

Definition at line 59 of file view.qc.

Referenced by leanmodel_ofs().

◆ autocvar_cl_viewmodel_alpha

float autocvar_cl_viewmodel_alpha = 1

Definition at line 43 of file view.qc.

Referenced by viewmodel_draw().

◆ autocvar_cl_viewmodel_scale

float autocvar_cl_viewmodel_scale

Definition at line 42 of file view.qc.

Referenced by bobmodel_ofs().

◆ avgspeed

float avgspeed

Definition at line 415 of file view.qc.

Referenced by GetCurrentFov().

◆ CAMERA_CHASE

const float CAMERA_CHASE = 2

Definition at line 571 of file view.qc.

Referenced by CSQC_Demo_Camera().

◆ CAMERA_FREE

const float CAMERA_FREE = 1

Definition at line 570 of file view.qc.

Referenced by CSQC_Demo_Camera().

◆ camera_mode

float camera_mode

Definition at line 569 of file view.qc.

Referenced by CSQC_Demo_Camera(), and View_DemoCamera().

◆ camera_offset

vector camera_offset

Definition at line 1771 of file view.qc.

Referenced by CSQC_Demo_Camera().

◆ content_blurpostprocess

vector content_blurpostprocess

Definition at line 767 of file view.qc.

Referenced by HUD_Contents(), and View_PostProcessing().

◆ contentavgalpha

float contentavgalpha

Definition at line 585 of file view.qc.

Referenced by HUD_Contents().

◆ current_angles

vector current_angles

Definition at line 1771 of file view.qc.

Referenced by CSQC_Demo_Camera().

◆ current_camera_offset

vector current_camera_offset

Definition at line 1771 of file view.qc.

Referenced by CSQC_Demo_Camera().

◆ current_origin

vector current_origin

Definition at line 1771 of file view.qc.

Referenced by CSQC_Demo_Camera().

◆ current_position

vector current_position

Definition at line 1771 of file view.qc.

Referenced by CSQC_Demo_Camera().

◆ damage_blurpostprocess

vector damage_blurpostprocess

Definition at line 767 of file view.qc.

Referenced by HUD_Damage(), and View_PostProcessing().

◆ eventchase_current_distance

float eventchase_current_distance

Definition at line 588 of file view.qc.

Referenced by View_EventChase().

◆ eventchase_running

float eventchase_running

Definition at line 589 of file view.qc.

Referenced by View_EventChase(), and WantEventchase().

◆ freeze_ang

vector freeze_ang

Definition at line 574 of file view.qc.

Referenced by View_Lock(), and viewloc_PlayerPhysics().

◆ freeze_org

vector freeze_org

Definition at line 574 of file view.qc.

Referenced by View_Lock(), and viewloc_PlayerPhysics().

◆ liquidalpha_prev

float liquidalpha_prev

Definition at line 585 of file view.qc.

Referenced by HUD_Contents().

◆ liquidcolor_prev

vector liquidcolor_prev

Definition at line 586 of file view.qc.

Referenced by HUD_Contents().

◆ minigame_wasactive

bool minigame_wasactive

Definition at line 567 of file view.qc.

Referenced by View_CheckButtonStatus().

◆ mouse_angles

vector mouse_angles

Definition at line 1771 of file view.qc.

Referenced by CSQC_Demo_Camera().

◆ myhealth

float myhealth

Definition at line 577 of file view.qc.

Referenced by HUD_Damage(), PlayerHealth(), and vehicles_painframe().

◆ myhealth_flash

float myhealth_flash

Definition at line 578 of file view.qc.

Referenced by HUD_Damage().

◆ myhealth_gentlergb

vector myhealth_gentlergb

Definition at line 583 of file view.qc.

Referenced by HUD_Damage().

◆ myhealth_prev

float myhealth_prev

Definition at line 577 of file view.qc.

Referenced by HUD_Damage().

◆ name_last

string name_last

Definition at line 277 of file view.qc.

Referenced by viewmodel_draw().

◆ NextFrameCommand

string NextFrameCommand

Definition at line 572 of file view.qc.

Referenced by CSQC_UpdateView().

◆ nightvision_noise

entity nightvision_noise

Definition at line 575 of file view.qc.

Referenced by View_NightVision().

◆ nightvision_noise2

entity nightvision_noise2

Definition at line 575 of file view.qc.

Referenced by View_NightVision().

◆ old_bluralpha

float old_bluralpha

Definition at line 580 of file view.qc.

Referenced by View_PostProcessing().

◆ old_blurradius

float old_blurradius

Definition at line 580 of file view.qc.

Referenced by View_PostProcessing().

◆ old_sharpen_intensity

float old_sharpen_intensity

Definition at line 581 of file view.qc.

Referenced by View_PostProcessing().

◆ oldr_farclip_base

float oldr_farclip_base

Definition at line 1427 of file view.qc.

Referenced by View_Ortho().

◆ oldr_farclip_world

float oldr_farclip_world

Definition at line 1428 of file view.qc.

Referenced by View_Ortho().

◆ oldr_nearclip

float oldr_nearclip

Definition at line 1426 of file view.qc.

Referenced by View_Ortho().

◆ oldr_novis

float oldr_novis

Definition at line 1429 of file view.qc.

Referenced by View_Ortho().

◆ oldr_useinfinitefarclip

float oldr_useinfinitefarclip

Definition at line 1431 of file view.qc.

Referenced by View_Ortho().

◆ oldr_useportalculling

float oldr_useportalculling

Definition at line 1430 of file view.qc.

Referenced by View_Ortho().

◆ ov_enabled

bool ov_enabled

Definition at line 1425 of file view.qc.

Referenced by View_Ortho().

◆ ov_mid

vector ov_mid = '0 0 0'

Definition at line 1433 of file view.qc.

Referenced by View_Ortho(), and View_UpdateFov().

◆ ov_org

vector ov_org = '0 0 0'

Definition at line 1432 of file view.qc.

Referenced by View_Ortho(), and View_UpdateFov().

◆ ov_worldmax

vector ov_worldmax = '0 0 0'

Definition at line 1435 of file view.qc.

Referenced by View_Ortho(), and View_UpdateFov().

◆ ov_worldmin

vector ov_worldmin = '0 0 0'

Definition at line 1434 of file view.qc.

Referenced by View_Ortho(), and View_UpdateFov().

◆ showfps_framecounter

int showfps_framecounter

Definition at line 387 of file view.qc.

Referenced by fpscounter_update().

◆ showfps_prevfps_time

float showfps_prevfps_time

Definition at line 386 of file view.qc.

Referenced by fpscounter_update(), and STATIC_INIT().

◆ viewmodel_angles

vector viewmodel_angles

Definition at line 272 of file view.qc.

Referenced by viewmodel_draw().

◆ viewmodel_origin

vector viewmodel_origin

Definition at line 272 of file view.qc.

Referenced by viewmodel_draw().

◆ weapon_eta_last

float weapon_eta_last

Definition at line 274 of file view.qc.

Referenced by viewmodel_draw().

◆ weapon_nextthink

float weapon_nextthink

Definition at line 273 of file view.qc.

Referenced by viewmodel_draw(), W_WeaponFrame(), and weapon_thinkf().

◆ weapon_switchdelay

float weapon_switchdelay

Definition at line 275 of file view.qc.

Referenced by viewmodel_draw().