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

Go to the source code of this file.

Functions

void CL_RotateMoves (vector ang)
 
 NET_HANDLE (ENT_CLIENT_WARPZONE, bool isnew)
 
 NET_HANDLE (ENT_CLIENT_WARPZONE_CAMERA, bool isnew)
 
 NET_HANDLE (ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew)
 
void WarpZone_Fade_PreDraw (entity this)
 
vector WarpZone_FixNearClip (vector o, vector c0, vector c1, vector c2, vector c3)
 
void WarpZone_FixPMove ()
 
void WarpZone_FixView ()
 
void WarpZone_Shutdown ()
 
void WarpZone_Touch (entity this, entity toucher)
 
void WarpZone_View_Inside ()
 
void WarpZone_View_Outside ()
 

Variables

float autocvar_cl_rollkillspeed = 10
 
float warpzone_fixingview
 
float warpzone_fixingview_drawexteriormodel
 

Function Documentation

◆ CL_RotateMoves()

void CL_RotateMoves ( vector  ang)

Referenced by NET_HANDLE().

+ Here is the caller graph for this function:

◆ NET_HANDLE() [1/3]

NET_HANDLE ( ENT_CLIENT_WARPZONE  ,
bool  isnew 
)

Definition at line 28 of file client.qc.

References avelocity, classname, cvar_settemp(), enemy, g_warpzones, IL_PUSH(), max(), maxs, mins, modelindex, oldorigin, origin, scale, setorigin(), setpredraw, WarpZone_Fade_PreDraw(), warpzone_fadeend, warpzone_fadestart, warpzone_isboxy, WarpZone_SetUp(), and warpzone_warpzones_exist.

29 {
31  {
32  cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has warpzones
33  cvar_settemp("r_water_resolutionmultiplier", "1"); // HACK for DarkPlaces: enforce full quality so entities can be seen clearly through warpzones
34  }
36  if (!this.enemy)
37  {
38  this.enemy = new(warpzone_from);
39  }
40  this.classname = "trigger_warpzone";
41 
42  if(isnew)
43  IL_PUSH(g_warpzones, this);
44 
45  int f = ReadByte();
46  this.warpzone_isboxy = (f & 1);
47  if(f & 4)
48  {
49  this.origin = ReadVector();
50  }
51  else
52  this.origin = '0 0 0';
53  this.modelindex = ReadShort();
54  this.mins = ReadVector();
55  this.maxs = ReadVector();
56  this.scale = ReadByte() / 16;
57  this.enemy.oldorigin = ReadVector();
58  this.enemy.avelocity = ReadVector();
59  this.oldorigin = ReadVector();
60  this.avelocity = ReadVector();
61 
62  if(f & 2)
63  {
64  this.warpzone_fadestart = ReadShort();
65  this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
66  }
67  else
68  {
69  this.warpzone_fadestart = 0;
70  this.warpzone_fadeend = 0;
71  }
72 
73  // common stuff
74  WarpZone_SetUp(this, this.enemy.oldorigin, this.enemy.avelocity, this.oldorigin, this.avelocity);
75 
76  // link me
77  //setmodel(this, this.model);
78  setorigin(this, this.origin);
79  setsize(this, this.mins, this.maxs);
80 
81  // how to draw
82  // engine currently wants this
84 
85  //settouch(this, WarpZone_Touch);
86  return true;
87 }
float warpzone_fadestart
Definition: common.qh:21
float modelindex
Definition: csprogsdefs.qc:91
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition: util.qc:696
vector oldorigin
Definition: csprogsdefs.qc:102
vector maxs
Definition: csprogsdefs.qc:113
#define setpredraw(e, f)
Definition: self.qh:84
origin
Definition: ent_cs.qc:114
string classname
Definition: csprogsdefs.qc:107
vector avelocity
Definition: csprogsdefs.qc:105
float warpzone_warpzones_exist
Definition: common.qh:9
float warpzone_fadeend
Definition: common.qh:22
entity enemy
Definition: sv_ctf.qh:143
vector mins
Definition: csprogsdefs.qc:113
void WarpZone_Fade_PreDraw(entity this)
Definition: client.qc:10
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, vector other_ang)
Definition: common.qc:66
float scale
Definition: projectile.qc:14
IntrusiveList g_warpzones
Definition: common.qh:6
float warpzone_isboxy
Definition: common.qh:12
setorigin(ent, v)
+ Here is the call graph for this function:

◆ NET_HANDLE() [2/3]

NET_HANDLE ( ENT_CLIENT_WARPZONE_CAMERA  ,
bool  isnew 
)

Definition at line 89 of file client.qc.

References avelocity, CL_RotateMoves(), classname, cvar_settemp(), drawmask, MASK_NORMAL, max(), maxs, mins, modelindex, oldorigin, origin, scale, setorigin(), setpredraw, vector(), WarpZone_Camera_SetUp(), warpzone_cameras_exist, WarpZone_Fade_PreDraw(), warpzone_fadeend, and warpzone_fadestart.

90 {
92  {
93  cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has cameras
94  cvar_settemp("r_water_resolutionmultiplier", "1"); // HACK for DarkPlaces: enforce full quality so entities can be seen clearly through warpzones
95  }
97  this.classname = "func_warpzone_camera";
98 
99  int f = ReadByte();
100  if(f & 4)
101  {
102  this.origin = ReadVector();
103  }
104  else
105  this.origin = '0 0 0';
106  this.modelindex = ReadShort();
107  this.mins = ReadVector();
108  this.maxs = ReadVector();
109  this.scale = ReadByte() / 16;
110  this.oldorigin = ReadVector();
111  this.avelocity = ReadVector();
112 
113  if(f & 2)
114  {
115  this.warpzone_fadestart = ReadShort();
116  this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
117  }
118  else
119  {
120  this.warpzone_fadestart = 0;
121  this.warpzone_fadeend = 0;
122  }
123 
124  // common stuff
125  WarpZone_Camera_SetUp(this, this.oldorigin, this.avelocity);
126 
127  // engine currently wants this
128  this.drawmask = MASK_NORMAL;
129 
130  // link me
131  //setmodel(this, this.model);
132  setorigin(this, this.origin);
133  setsize(this, this.mins, this.maxs);
134 
135  // how to draw
136  // engine currently wants this
138  return true;
139 }
float warpzone_fadestart
Definition: common.qh:21
float modelindex
Definition: csprogsdefs.qc:91
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition: util.qc:696
vector oldorigin
Definition: csprogsdefs.qc:102
vector maxs
Definition: csprogsdefs.qc:113
#define setpredraw(e, f)
Definition: self.qh:84
origin
Definition: ent_cs.qc:114
string classname
Definition: csprogsdefs.qc:107
vector avelocity
Definition: csprogsdefs.qc:105
float warpzone_fadeend
Definition: common.qh:22
vector mins
Definition: csprogsdefs.qc:113
void WarpZone_Fade_PreDraw(entity this)
Definition: client.qc:10
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
float drawmask
Definition: csprogsdefs.qc:95
float scale
Definition: projectile.qc:14
void WarpZone_Camera_SetUp(entity e, vector my_org, vector my_ang)
Definition: common.qc:95
float warpzone_cameras_exist
Definition: common.qh:10
setorigin(ent, v)
+ Here is the call graph for this function:

◆ NET_HANDLE() [3/3]

NET_HANDLE ( ENT_CLIENT_WARPZONE_TELEPORTED  ,
bool  isnew 
)

Definition at line 142 of file client.qc.

References checkextension(), CL_RotateMoves(), classname, v, vector(), VF_CL_VIEWANGLES, warpzone_transform, and WarpZone_TransformVAngles().

143 {
144  this.classname = "warpzone_teleported";
145  vector v = ReadVector();
146  return = true;
147  if (!isnew) return;
148  this.warpzone_transform = v;
149  setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(this, getpropertyvec(VF_CL_VIEWANGLES)));
150  if(checkextension("DP_CSQC_ROTATEMOVES"))
151  CL_RotateMoves(v);
152  //CL_RotateMoves('0 90 0');
153 }
void CL_RotateMoves(vector ang)
const float VF_CL_VIEWANGLES
Definition: csprogsdefs.qc:194
vector warpzone_transform
Definition: common.qh:20
string classname
Definition: csprogsdefs.qc:107
vector WarpZone_TransformVAngles(entity wz, vector ang)
Definition: common.qc:514
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:

◆ WarpZone_Fade_PreDraw()

void WarpZone_Fade_PreDraw ( entity  this)

Definition at line 10 of file client.qc.

References alpha, bound(), checkpvs(), drawmask, entity(), MASK_NORMAL, maxs, mins, origin, vector(), VF_ORIGIN, vlen(), warpzone_fadeend, warpzone_fadestart, and WarpZone_Touch().

Referenced by NET_HANDLE().

11 {
12  vector org;
13  org = getpropertyvec(VF_ORIGIN);
14  if(!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones
15  this.alpha = 0;
16  else if(this.warpzone_fadestart)
17  this.alpha = bound(0, (this.warpzone_fadeend - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.warpzone_fadeend - this.warpzone_fadestart), 1);
18  else
19  this.alpha = 1;
20  //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
21  if(this.alpha <= 0)
22  this.drawmask = 0;
23  else
24  this.drawmask = MASK_NORMAL;
25 }
float alpha
Definition: items.qc:14
float warpzone_fadestart
Definition: common.qh:21
vector maxs
Definition: csprogsdefs.qc:113
float checkpvs(vector viewpos, entity viewee)
origin
Definition: ent_cs.qc:114
float warpzone_fadeend
Definition: common.qh:22
vector mins
Definition: csprogsdefs.qc:113
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
float drawmask
Definition: csprogsdefs.qc:95
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const float VF_ORIGIN
Definition: csprogsdefs.qc:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WarpZone_FixNearClip()

vector WarpZone_FixNearClip ( vector  o,
vector  c0,
vector  c1,
vector  c2,
vector  c3 
)

Definition at line 180 of file client.qc.

References entity(), max(), min(), vector(), WarpZone_Find(), and WarpZone_PlaneDist().

Referenced by WarpZone_FixView().

181 {
182  vector mi, ma;
183  entity e;
184  float pd;
185 
186  mi.x = min(o.x, c0_x, c1_x, c2_x, c3_x);
187  ma.x = max(o.x, c0_x, c1_x, c2_x, c3_x);
188  mi.y = min(o.y, c0_y, c1_y, c2_y, c3_y);
189  ma.y = max(o.y, c0_y, c1_y, c2_y, c3_y);
190  mi.z = min(o.z, c0_z, c1_z, c2_z, c3_z);
191  ma.z = max(o.z, c0_z, c1_z, c2_z, c3_z);
192 
193  e = WarpZone_Find(mi, ma);
194  if(e)
195  {
196  if(WarpZone_PlaneDist(e, o) < 0)
197  return '0 0 0';
198  // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
199  pd = min(
200  WarpZone_PlaneDist(e, c0),
201  WarpZone_PlaneDist(e, c1),
202  WarpZone_PlaneDist(e, c2),
203  WarpZone_PlaneDist(e, c3)
204  );
205  if(pd < 0)
206  return e.warpzone_forward * -pd;
207  }
208 
209  return '0 0 0';
210 }
entity() spawn
float WarpZone_PlaneDist(entity wz, vector v)
Definition: common.qc:489
entity WarpZone_Find(vector mi, vector ma)
Definition: common.qc:157
vector(float skel, float bonenum) _skel_get_boneabs_hidden
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WarpZone_FixPMove()

void WarpZone_FixPMove ( )

Definition at line 212 of file client.qc.

References entity(), input_angles, pmove_org, WarpZone_Find(), WarpZone_TransformOrigin(), and WarpZone_TransformVAngles().

213 {
215  if(e)
216  {
219  }
220 }
vector pmove_org
Definition: csprogsdefs.qc:54
entity() spawn
vector WarpZone_TransformOrigin(entity wz, vector v)
Definition: common.qc:499
vector input_angles
Definition: csprogsdefs.qc:60
vector WarpZone_TransformVAngles(entity wz, vector ang)
Definition: common.qc:514
entity WarpZone_Find(vector mi, vector ma)
Definition: common.qc:157
+ Here is the call graph for this function:

◆ WarpZone_FixView()

void WarpZone_FixView ( )

Definition at line 225 of file client.qc.

References autocvar_cl_rollkillspeed, cvar(), entity(), frametime, height, max(), min(), vector(), VF_ANGLES, VF_CL_VIEWANGLES_Z, VF_ORIGIN, WarpZone_Find(), WarpZone_FixNearClip(), warpzone_save_view_angles, warpzone_save_view_origin, WarpZone_TransformOrigin(), WarpZone_TransformVAngles(), WarpZone_View_Inside(), and WarpZone_View_Outside().

Referenced by CSQC_UpdateView().

226 {
227  entity e;
228  vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
229 
230  warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
231  warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
232 
233  e = WarpZone_Find(org, org);
234  if(e)
235  {
236  org = WarpZone_TransformOrigin(e, org);
237  ang = WarpZone_TransformVAngles(e, ang);
239  }
240  else
242 
243 #ifndef KEEP_ROLL
244  float rick;
245  float f;
246  static float rollkill;
247  if (STAT(HEALTH) > 0 || STAT(HEALTH) == -666 || STAT(HEALTH) == -2342)
248  {
249  f = 0;
250  // reset roll when passing through a warpzone that change player's roll angle
252  f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
253  if(rollkill)
254  rollkill = 0;
255  }
256  else
257  {
258  f = 1;
259  // roll the view when killed (v_deathtilt)
261  {
262  rollkill += frametime * autocvar_cl_rollkillspeed;
263  f = min(1, rollkill);
264  }
265  else if(rollkill)
266  rollkill = 0;
267  }
268 
269  rick = getproperty(VF_CL_VIEWANGLES_Z);
270  rick *= f;
271  setproperty(VF_CL_VIEWANGLES_Z, rick);
272  ang.z *= f;
273 #endif
274 
275  setproperty(VF_ORIGIN, org);
276  setproperty(VF_ANGLES, ang);
277 
278  vector width = '1 0 0' * cvar("vid_conwidth");
279  vector height = '0 1 0' * cvar("vid_conheight");
280  nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
281  corner0 = cs_unproject('0 0 0' + nearclip);
282  corner1 = cs_unproject(width + nearclip);
283  corner2 = cs_unproject(height + nearclip);
284  corner3 = cs_unproject(width + height + nearclip);
285  o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
286  if(o != '0 0 0')
287  setproperty(VF_ORIGIN, org + o);
288 }
vector warpzone_save_view_angles
Definition: client.qh:9
entity() spawn
vector WarpZone_TransformOrigin(entity wz, vector v)
Definition: common.qc:499
void WarpZone_View_Inside()
Definition: client.qc:166
vector warpzone_save_view_origin
Definition: client.qh:8
void WarpZone_View_Outside()
Definition: client.qc:158
const float VF_CL_VIEWANGLES_Z
Definition: csprogsdefs.qc:197
vector WarpZone_TransformVAngles(entity wz, vector ang)
Definition: common.qc:514
entity WarpZone_Find(vector mi, vector ma)
Definition: common.qc:157
float height
Definition: jumppads.qh:12
float frametime
Definition: csprogsdefs.qc:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
Definition: client.qc:180
const float VF_ANGLES
Definition: csprogsdefs.qc:186
float autocvar_cl_rollkillspeed
Definition: client.qc:223
const float VF_ORIGIN
Definition: csprogsdefs.qc:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WarpZone_Shutdown()

void WarpZone_Shutdown ( )

Definition at line 290 of file client.qc.

References WarpZone_View_Outside().

Referenced by Shutdown().

291 {
293 }
void WarpZone_View_Outside()
Definition: client.qc:158
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WarpZone_Touch()

void WarpZone_Touch ( entity  this,
entity  toucher 
)

Definition at line 184 of file server.qc.

References BIT, BITSET_ASSIGN, bound(), enemy, entity(), frametime, IS_NOT_A_CLIENT, LOG_INFO, LOG_TRACE, max(), maxs, mins, modelindex, MOVETYPE_FOLLOW, MOVETYPE_NONE, origin, scale, sendflags, setorigin(), SUB_UseTargets_SkipTargets(), time, to, vector(), vlen(), vtos(), warpzone_angles, warpzone_fadeend, warpzone_fadestart, WarpZone_Find(), warpzone_isboxy, warpzone_origin, WarpZone_PlaneDist(), warpzone_targetangles, warpzone_targetorigin, WarpZone_Teleport(), WarpZoneLib_ExactTrigger_Touch(), WriteByte(), WriteCoord(), and WriteShort().

Referenced by WarpZone_Fade_PreDraw(), and WarpZone_Projectile_Touch().

185 {
186  if(toucher.classname == "trigger_warpzone")
187  return;
188 
189  if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
190  return;
191 
192  // FIXME needs a better check to know what is safe to teleport and what not
193  if(toucher.move_movetype == MOVETYPE_NONE || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity)
194  return;
195 
196  if(WarpZoneLib_ExactTrigger_Touch(this, toucher))
197  return;
198 
199  if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
200  return;
201 
202  float f;
203  // number of frames we need to go back:
204  // dist = 16*sqrt(2) qu
205  // dist ~ 24 qu
206  // 24 qu = v*t
207  // 24 qu = v*frametime*n
208  // n = 24 qu/(v*frametime)
209  // for clients go only one frame though, may be too irritating otherwise
210  // but max 0.25 sec = 0.25/frametime frames
211  // 24/(0.25/frametime)
212  // 96*frametime
213  float d;
214  d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
215  if(IS_NOT_A_CLIENT(toucher))
216  f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
217  else
218  f = -1;
219  if(WarpZone_Teleport(this, toucher, f, 0))
220  {
221 #ifdef SVQC
222  SUB_UseTargets_SkipTargets(this, toucher, toucher, BIT(1) | BIT(3)); // use toucher too?
223  SUB_UseTargets_SkipTargets(this.enemy, toucher, toucher, BIT(1) | BIT(2)); // use toucher too?
224 #endif
225  }
226  else
227  {
228  LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
229  }
230 }
float MOVETYPE_NONE
Definition: progsdefs.qc:246
float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
Definition: server.qc:82
bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
Definition: common.qc:798
void SUB_UseTargets_SkipTargets(entity this, entity actor, entity trigger, int skiptargets)
Definition: triggers.qc:368
float WarpZone_PlaneDist(entity wz, vector v)
Definition: common.qc:489
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
entity enemy
Definition: sv_ctf.qh:143
float frametime
Definition: csprogsdefs.qc:17
#define IS_NOT_A_CLIENT(v)
was: (clienttype(v) == CLIENTTYPE_NOTACLIENT)
Definition: utils.qh:19
float MOVETYPE_FOLLOW
#define LOG_TRACE(...)
Definition: log.qh:81
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WarpZone_View_Inside()

void WarpZone_View_Inside ( )

Definition at line 166 of file client.qc.

References autocvar_chase_active, cvar(), cvar_set(), warpzone_fixingview, warpzone_fixingview_drawexteriormodel, and WarpZone_View_Outside().

Referenced by WarpZone_FixView().

167 {
169  {
171  return;
172  }
174  return;
176  warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
177  cvar_set("r_drawexteriormodel", "0");
178 }
void WarpZone_View_Outside()
Definition: client.qc:158
float warpzone_fixingview_drawexteriormodel
Definition: client.qc:156
float warpzone_fixingview
Definition: client.qc:155
int autocvar_chase_active
Definition: view.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WarpZone_View_Outside()

void WarpZone_View_Outside ( )

Definition at line 158 of file client.qc.

References cvar_set(), ftos(), warpzone_fixingview, and warpzone_fixingview_drawexteriormodel.

Referenced by WarpZone_FixView(), WarpZone_Shutdown(), and WarpZone_View_Inside().

159 {
161  return;
163  cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
164 }
float warpzone_fixingview_drawexteriormodel
Definition: client.qc:156
float warpzone_fixingview
Definition: client.qc:155
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_cl_rollkillspeed

float autocvar_cl_rollkillspeed = 10

Definition at line 223 of file client.qc.

Referenced by WarpZone_FixView().

◆ warpzone_fixingview

float warpzone_fixingview

Definition at line 155 of file client.qc.

Referenced by WarpZone_View_Inside(), and WarpZone_View_Outside().

◆ warpzone_fixingview_drawexteriormodel

float warpzone_fixingview_drawexteriormodel

Definition at line 156 of file client.qc.

Referenced by WarpZone_View_Inside(), and WarpZone_View_Outside().