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 28 of file client.qc.

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 cvar_settemp(string tmp_cvar, string tmp_value)
Definition util.qc:811
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:367
int ReadByte()
void WarpZone_Fade_PreDraw(entity this)
Definition client.qc:10
void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, vector other_ang)
Definition common.qc:64
float warpzone_fadestart
Definition common.qh:21
float warpzone_fadeend
Definition common.qh:22
float warpzone_isboxy
Definition common.qh:12
IntrusiveList g_warpzones
Definition common.qh:6
float warpzone_warpzones_exist
Definition common.qh:9
float max(float f,...)
float scale
Definition projectile.qc:14
#define setpredraw(e, f)
Definition self.qh:84
entity enemy
Definition sv_ctf.qh:153

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 89 of file client.qc.

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 drawmask
const float MASK_NORMAL
void WarpZone_Camera_SetUp(entity e, vector my_org, vector my_ang)
Definition common.qc:93
float warpzone_cameras_exist
Definition common.qh:10

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 142 of file client.qc.

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"))
152 //CL_RotateMoves('0 90 0');
153}
const float VF_CL_VIEWANGLES
void CL_RotateMoves(vector ang)
vector WarpZone_TransformVAngles(entity wz, vector ang)
Definition common.qc:524
vector warpzone_transform
Definition common.qh:20
float checkextension(string ext)
vector
Definition self.qh:92

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 10 of file client.qc.

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: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:92

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 180 of file client.qc.

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}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity WarpZone_Find(vector mi, vector ma)
Definition common.qc:167
float WarpZone_PlaneDist(entity wz, vector v)
Definition common.qc:499
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 212 of file client.qc.

213{
215 if(e)
216 {
219 }
220}
vector input_angles
vector pmove_org
vector WarpZone_TransformOrigin(entity wz, vector v)
Definition common.qc:509

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

◆ WarpZone_FixView()

void WarpZone_FixView ( )

Definition at line 225 of file client.qc.

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 {
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
253 if(rollkill)
254 rollkill = 0;
255 }
256 else
257 {
258 f = 1;
259 // roll the view when killed (v_deathtilt)
261 {
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}
float height
Definition bobbing.qc:3
float frametime
const float VF_ANGLES
const float VF_CL_VIEWANGLES_Z
#define STAT(...)
Definition stats.qh:82
void WarpZone_View_Outside()
Definition client.qc:158
vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
Definition client.qc:180
float autocvar_cl_rollkillspeed
Definition client.qc:223
void WarpZone_View_Inside()
Definition client.qc:166
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:92

References ang, autocvar_cl_rollkillspeed, cvar(), entity(), 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 290 of file client.qc.

291{
293}

References WarpZone_View_Outside().

Referenced by Shutdown().

◆ WarpZone_Touch()

void WarpZone_Touch ( entity this,
entity toucher )

Definition at line 184 of file server.qc.

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(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
197 return;
198
200
201 float f;
202 // number of frames we need to go back:
203 // dist = 16*sqrt(2) qu
204 // dist ~ 24 qu
205 // 24 qu = v*t
206 // 24 qu = v*frametime*n
207 // n = 24 qu/(v*frametime)
208 // for clients go only one frame though, may be too irritating otherwise
209 // but max 0.25 sec = 0.25/frametime frames
210 // 24/(0.25/frametime)
211 // 96*frametime
212 float d;
213 d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
215 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
216 else
217 f = -1;
218 if(WarpZone_Teleport(this, toucher, f, 0))
219 {
220#ifdef SVQC
221 SUB_UseTargets_SkipTargets(this, toucher, toucher, BIT(1) | BIT(3)); // use toucher too?
222 SUB_UseTargets_SkipTargets(this.enemy, toucher, toucher, BIT(1) | BIT(2)); // use toucher too?
223#endif
224 }
225 else
226 {
227 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
228 }
229}
#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:244
float time
#define EXACTTRIGGER_TOUCH(e, t)
Definition common.qh:115
#define LOG_TRACE(...)
Definition log.qh:76
const int MOVETYPE_NONE
Definition movetypes.qh:129
const int MOVETYPE_FOLLOW
Definition movetypes.qh:141
entity entity toucher
Definition self.qh:72
float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
Definition server.qc:82
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 166 of file client.qc.

167{
169 {
171 return;
172 }
174 return;
176 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
177 cvar_set("r_drawexteriormodel", "0");
178}
float warpzone_fixingview
Definition client.qc:155
float warpzone_fixingview_drawexteriormodel
Definition client.qc:156
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 158 of file client.qc.

159{
161 return;
163 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
164}
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 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().