Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
client.qc File Reference
#include "client.qh"
#include "common.qh"
#include <lib/csqcmodel/cl_model.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)

References ang, and vector.

Referenced by NET_HANDLE().

◆ NET_HANDLE() [1/3]

NET_HANDLE ( ENT_CLIENT_WARPZONE ,
bool isNew )

Definition at line 25 of file client.qc.

26{
28 {
29 cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has warpzones
30 cvar_settemp("r_water_resolutionmultiplier", "1"); // HACK for DarkPlaces: enforce full quality so entities can be seen clearly through warpzones
31 }
33 if (!this.enemy)
34 this.enemy = new(warpzone_from);
35 this.classname = "trigger_warpzone";
36
37 if (isNew)
38 IL_PUSH(g_warpzones, this);
39
40 int sf = ReadByte();
41 this.warpzone_isboxy = (sf & 1);
42 if (sf & 4)
43 this.origin = ReadVector();
44 else
45 this.origin = '0 0 0';
46 this.modelindex = ReadShort();
47 this.mins = ReadVector();
48 this.maxs = ReadVector();
49 this.scale = ReadByte() / 16;
50 this.enemy.oldorigin = ReadVector();
51 this.enemy.avelocity = ReadVector();
52 this.oldorigin = ReadVector();
53 this.avelocity = ReadVector();
54
55 if (sf & 2)
56 {
57 this.warpzone_fadestart = ReadShort();
58 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
59 }
60 else
61 {
62 this.warpzone_fadestart = 0;
63 this.warpzone_fadeend = 0;
64 }
65
66 // common stuff
67 WarpZone_SetUp(this, this.enemy.oldorigin, this.enemy.avelocity, this.oldorigin, this.avelocity);
68
69 // link me
70 //setmodel(this, this.model);
71 setorigin(this, this.origin);
72 setsize(this, this.mins, this.maxs);
73
74 // how to draw
75 // engine currently wants this
77
78 //settouch(this, WarpZone_Touch);
79 return true;
80}
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition util.qc:807
string classname
float modelindex
vector avelocity
vector mins
vector maxs
vector origin
vector oldorigin
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define ReadVector()
Definition net.qh:349
int ReadByte()
void WarpZone_Fade_PreDraw(entity this)
Definition client.qc:8
void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, vector other_ang)
Definition common.qc:60
float warpzone_fadestart
Definition common.qh:24
float warpzone_fadeend
Definition common.qh:25
float warpzone_isboxy
Definition common.qh:15
IntrusiveList g_warpzones
Definition common.qh:6
float warpzone_warpzones_exist
Definition common.qh:12
float max(float f,...)
float scale
Definition projectile.qc:14
#define setpredraw(e, f)
Definition self.qh:88
entity enemy
Definition sv_ctf.qh:152

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

◆ NET_HANDLE() [2/3]

NET_HANDLE ( ENT_CLIENT_WARPZONE_CAMERA ,
bool isNew )

Definition at line 82 of file client.qc.

83{
85 {
86 cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has cameras
87 cvar_settemp("r_water_resolutionmultiplier", "1"); // HACK for DarkPlaces: enforce full quality so entities can be seen clearly through warpzones
88 }
90 this.classname = "func_warpzone_camera";
91
92 int sf = ReadByte();
93 if (sf & 4)
94 this.origin = ReadVector();
95 else
96 this.origin = '0 0 0';
97 this.modelindex = ReadShort();
98 this.mins = ReadVector();
99 this.maxs = ReadVector();
100 this.scale = ReadByte() / 16;
101 this.oldorigin = ReadVector();
102 this.avelocity = ReadVector();
103
104 if (sf & 2)
105 {
106 this.warpzone_fadestart = ReadShort();
107 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
108 }
109 else
110 {
111 this.warpzone_fadestart = 0;
112 this.warpzone_fadeend = 0;
113 }
114
115 // common stuff
116 WarpZone_Camera_SetUp(this, this.oldorigin, this.avelocity);
117
118 // engine currently wants this
119 this.drawmask = MASK_NORMAL;
120
121 // link me
122 //setmodel(this, this.model);
123 setorigin(this, this.origin);
124 setsize(this, this.mins, this.maxs);
125
126 // how to draw
127 // engine currently wants this
129 return true;
130}
float drawmask
const float MASK_NORMAL
void WarpZone_Camera_SetUp(entity e, vector my_org, vector my_ang)
Definition common.qc:89
float warpzone_cameras_exist
Definition common.qh:13

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

◆ NET_HANDLE() [3/3]

NET_HANDLE ( ENT_CLIENT_WARPZONE_TELEPORTED ,
bool isNew )

Definition at line 133 of file client.qc.

134{
135 this.classname = "warpzone_teleported";
136 vector v = ReadVector();
137 return = true;
138 if (!isNew)
139 return;
140 this.warpzone_transform = v;
141 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(this, getpropertyvec(VF_CL_VIEWANGLES)));
142 if (checkextension("DP_CSQC_ROTATEMOVES"))
143 {
145 //CL_RotateMoves('0 90 0');
146 }
147}
const float VF_CL_VIEWANGLES
void CL_RotateMoves(vector ang)
vector WarpZone_TransformVAngles(entity wz, vector ang)
Definition common.qc:501
vector warpzone_transform
Definition common.qh:23
float checkextension(string ext)
vector
Definition self.qh:96

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

◆ WarpZone_Fade_PreDraw()

void WarpZone_Fade_PreDraw ( entity this)

Definition at line 8 of file client.qc.

9{
10 vector org = getpropertyvec(VF_ORIGIN);
11 if (!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones
12 this.alpha = 0;
13 else if (this.warpzone_fadestart)
14 this.alpha = bound(0, (this.warpzone_fadeend - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.warpzone_fadeend - this.warpzone_fadestart), 1);
15 else
16 this.alpha = 1;
17 //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
18 if (this.alpha <= 0)
19 this.drawmask = 0;
20 else
21 this.drawmask = MASK_NORMAL;
22}
float alpha
Definition items.qc:13
const float VF_ORIGIN
float checkpvs(vector viewpos, entity viewee)
float bound(float min, float value, float max)
float vlen(vector v)
vector org
Definition self.qh:96

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

Referenced by NET_HANDLE(), and NET_HANDLE().

◆ WarpZone_FixNearClip()

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

Definition at line 174 of file client.qc.

175{
176 vector mi, ma;
177 mi.x = min(o.x, c0.x, c1.x, c2.x, c3.x);
178 ma.x = max(o.x, c0.x, c1.x, c2.x, c3.x);
179 mi.y = min(o.y, c0.y, c1.y, c2.y, c3.y);
180 ma.y = max(o.y, c0.y, c1.y, c2.y, c3.y);
181 mi.z = min(o.z, c0.z, c1.z, c2.z, c3.z);
182 ma.z = max(o.z, c0.z, c1.z, c2.z, c3.z);
183
184 entity e = WarpZone_Find(mi, ma);
185 if (e)
186 {
187 if (WarpZone_PlaneDist(e, o) < 0)
188 return '0 0 0';
189 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
190 float pd = min(
191 WarpZone_PlaneDist(e, c0),
192 WarpZone_PlaneDist(e, c1),
193 WarpZone_PlaneDist(e, c2),
194 WarpZone_PlaneDist(e, c3)
195 );
196 if (pd < 0)
197 return e.warpzone_forward * -pd;
198 }
199
200 return '0 0 0';
201}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity WarpZone_Find(vector mi, vector ma)
Definition common.qc:158
float WarpZone_PlaneDist(entity wz, vector v)
Definition common.qc:476
float min(float f,...)

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

Referenced by WarpZone_FixView().

◆ WarpZone_FixPMove()

void WarpZone_FixPMove ( )

Definition at line 203 of file client.qc.

204{
206 if (e)
207 {
210 }
211}
vector input_angles
vector pmove_org
vector WarpZone_TransformOrigin(entity wz, vector v)
Definition common.qc:486

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

◆ WarpZone_FixView()

void WarpZone_FixView ( )

Definition at line 216 of file client.qc.

217{
218 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
219
220 warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
221 warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
222
224 if (e)
225 {
229 }
230 else
232
233#ifndef KEEP_ROLL
234 float rick;
235 float f;
236 static float rollkill;
237 if (STAT(HEALTH) > 0 || STAT(HEALTH) == -666 || STAT(HEALTH) == -2342)
238 {
239 f = 0;
240 // reset roll when passing through a warpzone that change player's roll angle
243 if (rollkill)
244 rollkill = 0;
245 }
246 else
247 {
248 f = 1;
249 // roll the view when killed (v_deathtilt)
251 {
253 f = min(1, rollkill);
254 }
255 else if (rollkill)
256 rollkill = 0;
257 }
258
259 rick = getproperty(VF_CL_VIEWANGLES_Z);
260 rick *= f;
261 setproperty(VF_CL_VIEWANGLES_Z, rick);
262 ang.z *= f;
263#endif
264
265 setproperty(VF_ORIGIN, org);
266 setproperty(VF_ANGLES, ang);
267
268 vector width = eX * cvar("vid_conwidth");
269 vector height = eY * cvar("vid_conheight");
270 nearclip = eZ * (cvar("r_nearclip") * 1.125);
271 corner0 = cs_unproject('0 0 0' + nearclip);
272 corner1 = cs_unproject(width + nearclip);
273 corner2 = cs_unproject(height + nearclip);
274 corner3 = cs_unproject(width + height + nearclip);
275 o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
276 if (o != '0 0 0')
277 setproperty(VF_ORIGIN, org + o);
278}
float height
Definition bobbing.qc:3
float frametime
const float VF_ANGLES
const float VF_CL_VIEWANGLES_Z
#define STAT(...)
Definition stats.qh:94
void WarpZone_View_Outside()
Definition client.qc:152
vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
Definition client.qc:174
float autocvar_cl_rollkillspeed
Definition client.qc:214
void WarpZone_View_Inside()
Definition client.qc:160
vector warpzone_save_view_origin
Definition client.qh:8
vector warpzone_save_view_angles
Definition client.qh:9
float cvar(string name)
vector vector ang
Definition self.qh:96
const vector eY
Definition vector.qh:44
const vector eZ
Definition vector.qh:45
const vector eX
Definition vector.qh:43

References ang, autocvar_cl_rollkillspeed, cvar(), entity(), eX, eY, eZ, frametime, height, max(), min(), org, STAT, 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().

◆ WarpZone_Shutdown()

void WarpZone_Shutdown ( )

Definition at line 280 of file client.qc.

281{
283}

References WarpZone_View_Outside().

Referenced by Shutdown().

◆ WarpZone_Touch()

void WarpZone_Touch ( entity this,
entity toucher )

Definition at line 181 of file server.qc.

182{
183 if (toucher.classname == "trigger_warpzone")
184 return;
185
186 if (time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
187 return;
188
189 // FIXME needs a better check to know what is safe to teleport and what not
190 if (toucher.move_movetype == MOVETYPE_NONE || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity)
191 return;
192
193 if (WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
194 return;
195
197
198 float f;
199 // number of frames we need to go back:
200 // dist = 16*sqrt(2) qu
201 // dist ~ 24 qu
202 // 24 qu = v*t
203 // 24 qu = v*frametime*n
204 // n = 24 qu/(v*frametime)
205 // for clients go only one frame though, may be too irritating otherwise
206 // but max 0.25 sec = 0.25/frametime frames
207 // 24/(0.25/frametime)
208 // 96*frametime
209 float d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
211 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
212 else
213 f = -1;
214 if (WarpZone_Teleport(this, toucher, f, 0))
215 {
216#ifdef SVQC
217 SUB_UseTargets_SkipTargets(this, toucher, toucher, BIT(1) | BIT(3)); // use toucher too?
218 SUB_UseTargets_SkipTargets(this.enemy, toucher, toucher, BIT(1) | BIT(2)); // use toucher too?
219#endif
220 }
221 else
222 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
223}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
#define IS_NOT_A_CLIENT(s)
Definition player.qh:243
float time
#define EXACTTRIGGER_TOUCH(e, t)
Definition common.qh:118
#define LOG_TRACE(...)
Definition log.qh:74
const int MOVETYPE_NONE
Definition movetypes.qh:129
const int MOVETYPE_FOLLOW
Definition movetypes.qh:141
entity entity toucher
Definition self.qh:76
float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
Definition server.qc:80
void SUB_UseTargets_SkipTargets(entity this, entity actor, entity trigger, int skiptargets)
Definition triggers.qc:346

References BIT, bound(), enemy, entity(), EXACTTRIGGER_TOUCH, frametime, IS_NOT_A_CLIENT, LOG_TRACE, max(), MOVETYPE_FOLLOW, MOVETYPE_NONE, SUB_UseTargets_SkipTargets(), time, toucher, vlen(), WarpZone_PlaneDist(), and WarpZone_Teleport().

Referenced by WarpZone_InitStep_FinalizeTransform().

◆ WarpZone_View_Inside()

void WarpZone_View_Inside ( )

Definition at line 160 of file client.qc.

161{
163 {
165 return;
166 }
168 return;
170 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
171 cvar_set("r_drawexteriormodel", "0");
172}
float warpzone_fixingview
Definition client.qc:149
float warpzone_fixingview_drawexteriormodel
Definition client.qc:150
void cvar_set(string name, string value)
int autocvar_chase_active
Definition view.qh:17

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

Referenced by WarpZone_FixView().

◆ WarpZone_View_Outside()

void WarpZone_View_Outside ( )

Definition at line 152 of file client.qc.

153{
155 return;
157 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
158}
string ftos(float f)

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

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

Variable Documentation

◆ autocvar_cl_rollkillspeed

float autocvar_cl_rollkillspeed = 10

Definition at line 214 of file client.qc.

Referenced by WarpZone_FixView().

◆ warpzone_fixingview

float warpzone_fixingview

Definition at line 149 of file client.qc.

Referenced by WarpZone_View_Inside(), and WarpZone_View_Outside().

◆ warpzone_fixingview_drawexteriormodel

float warpzone_fixingview_drawexteriormodel

Definition at line 150 of file client.qc.

Referenced by WarpZone_View_Inside(), and WarpZone_View_Outside().