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

28{
30 {
31 cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has warpzones
32 cvar_settemp("r_water_resolutionmultiplier", "1"); // HACK for DarkPlaces: enforce full quality so entities can be seen clearly through warpzones
33 }
35 if (!this.enemy)
36 {
37 this.enemy = new(warpzone_from);
38 }
39 this.classname = "trigger_warpzone";
40
41 if(isnew)
42 IL_PUSH(g_warpzones, this);
43
44 int f = ReadByte();
45 this.warpzone_isboxy = (f & 1);
46 if(f & 4)
47 {
48 this.origin = ReadVector();
49 }
50 else
51 this.origin = '0 0 0';
52 this.modelindex = ReadShort();
53 this.mins = ReadVector();
54 this.maxs = ReadVector();
55 this.scale = ReadByte() / 16;
56 this.enemy.oldorigin = ReadVector();
57 this.enemy.avelocity = ReadVector();
58 this.oldorigin = ReadVector();
59 this.avelocity = ReadVector();
60
61 if(f & 2)
62 {
63 this.warpzone_fadestart = ReadShort();
64 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
65 }
66 else
67 {
68 this.warpzone_fadestart = 0;
69 this.warpzone_fadeend = 0;
70 }
71
72 // common stuff
73 WarpZone_SetUp(this, this.enemy.oldorigin, this.enemy.avelocity, this.oldorigin, this.avelocity);
74
75 // link me
76 //setmodel(this, this.model);
77 setorigin(this, this.origin);
78 setsize(this, this.mins, this.maxs);
79
80 // how to draw
81 // engine currently wants this
83
84 //settouch(this, WarpZone_Touch);
85 return true;
86}
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:350
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 88 of file client.qc.

89{
91 {
92 cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has cameras
93 cvar_settemp("r_water_resolutionmultiplier", "1"); // HACK for DarkPlaces: enforce full quality so entities can be seen clearly through warpzones
94 }
96 this.classname = "func_warpzone_camera";
97
98 int f = ReadByte();
99 if(f & 4)
100 {
101 this.origin = ReadVector();
102 }
103 else
104 this.origin = '0 0 0';
105 this.modelindex = ReadShort();
106 this.mins = ReadVector();
107 this.maxs = ReadVector();
108 this.scale = ReadByte() / 16;
109 this.oldorigin = ReadVector();
110 this.avelocity = ReadVector();
111
112 if(f & 2)
113 {
114 this.warpzone_fadestart = ReadShort();
115 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
116 }
117 else
118 {
119 this.warpzone_fadestart = 0;
120 this.warpzone_fadeend = 0;
121 }
122
123 // common stuff
124 WarpZone_Camera_SetUp(this, this.oldorigin, this.avelocity);
125
126 // engine currently wants this
127 this.drawmask = MASK_NORMAL;
128
129 // link me
130 //setmodel(this, this.model);
131 setorigin(this, this.origin);
132 setsize(this, this.mins, this.maxs);
133
134 // how to draw
135 // engine currently wants this
137 return true;
138}
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 141 of file client.qc.

142{
143 this.classname = "warpzone_teleported";
144 vector v = ReadVector();
145 return = true;
146 if (!isnew) return;
147 this.warpzone_transform = v;
148 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(this, getpropertyvec(VF_CL_VIEWANGLES)));
149 if(checkextension("DP_CSQC_ROTATEMOVES"))
151 //CL_RotateMoves('0 90 0');
152}
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 = getpropertyvec(VF_ORIGIN);
13 if(!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones
14 this.alpha = 0;
15 else if(this.warpzone_fadestart)
16 this.alpha = bound(0, (this.warpzone_fadeend - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.warpzone_fadeend - this.warpzone_fadestart), 1);
17 else
18 this.alpha = 1;
19 //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
20 if(this.alpha <= 0)
21 this.drawmask = 0;
22 else
23 this.drawmask = MASK_NORMAL;
24}
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 179 of file client.qc.

180{
181 vector mi, ma;
182 entity e;
183 float pd;
184
185 mi.x = min(o.x, c0_x, c1_x, c2_x, c3_x);
186 ma.x = max(o.x, c0_x, c1_x, c2_x, c3_x);
187 mi.y = min(o.y, c0_y, c1_y, c2_y, c3_y);
188 ma.y = max(o.y, c0_y, c1_y, c2_y, c3_y);
189 mi.z = min(o.z, c0_z, c1_z, c2_z, c3_z);
190 ma.z = max(o.z, c0_z, c1_z, c2_z, c3_z);
191
192 e = WarpZone_Find(mi, ma);
193 if(e)
194 {
195 if(WarpZone_PlaneDist(e, o) < 0)
196 return '0 0 0';
197 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
198 pd = min(
199 WarpZone_PlaneDist(e, c0),
200 WarpZone_PlaneDist(e, c1),
201 WarpZone_PlaneDist(e, c2),
202 WarpZone_PlaneDist(e, c3)
203 );
204 if(pd < 0)
205 return e.warpzone_forward * -pd;
206 }
207
208 return '0 0 0';
209}
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 211 of file client.qc.

212{
214 if(e)
215 {
218 }
219}
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 224 of file client.qc.

225{
226 entity e;
227 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
228
229 warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
230 warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
231
232 e = WarpZone_Find(org, org);
233 if(e)
234 {
238 }
239 else
241
242#ifndef KEEP_ROLL
243 float rick;
244 float f;
245 static float rollkill;
246 if (STAT(HEALTH) > 0 || STAT(HEALTH) == -666 || STAT(HEALTH) == -2342)
247 {
248 f = 0;
249 // reset roll when passing through a warpzone that change player's roll angle
252 if(rollkill)
253 rollkill = 0;
254 }
255 else
256 {
257 f = 1;
258 // roll the view when killed (v_deathtilt)
260 {
262 f = min(1, rollkill);
263 }
264 else if(rollkill)
265 rollkill = 0;
266 }
267
268 rick = getproperty(VF_CL_VIEWANGLES_Z);
269 rick *= f;
270 setproperty(VF_CL_VIEWANGLES_Z, rick);
271 ang.z *= f;
272#endif
273
274 setproperty(VF_ORIGIN, org);
275 setproperty(VF_ANGLES, ang);
276
277 vector width = '1 0 0' * cvar("vid_conwidth");
278 vector height = '0 1 0' * cvar("vid_conheight");
279 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
280 corner0 = cs_unproject('0 0 0' + nearclip);
281 corner1 = cs_unproject(width + nearclip);
282 corner2 = cs_unproject(height + nearclip);
283 corner3 = cs_unproject(width + height + nearclip);
284 o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
285 if(o != '0 0 0')
286 setproperty(VF_ORIGIN, org + o);
287}
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:157
vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
Definition client.qc:179
float autocvar_cl_rollkillspeed
Definition client.qc:222
void WarpZone_View_Inside()
Definition client.qc:165
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 289 of file client.qc.

290{
292}

References WarpZone_View_Outside().

Referenced by Shutdown().

◆ WarpZone_Touch()

void WarpZone_Touch ( entity this,
entity toucher )

Definition at line 183 of file server.qc.

184{
185 if(toucher.classname == "trigger_warpzone")
186 return;
187
188 if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
189 return;
190
191 // FIXME needs a better check to know what is safe to teleport and what not
192 if(toucher.move_movetype == MOVETYPE_NONE || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity)
193 return;
194
195 if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
196 return;
197
199
200 float f;
201 // number of frames we need to go back:
202 // dist = 16*sqrt(2) qu
203 // dist ~ 24 qu
204 // 24 qu = v*t
205 // 24 qu = v*frametime*n
206 // n = 24 qu/(v*frametime)
207 // for clients go only one frame though, may be too irritating otherwise
208 // but max 0.25 sec = 0.25/frametime frames
209 // 24/(0.25/frametime)
210 // 96*frametime
211 float d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
213 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
214 else
215 f = -1;
216 if(WarpZone_Teleport(this, toucher, f, 0))
217 {
218#ifdef SVQC
219 SUB_UseTargets_SkipTargets(this, toucher, toucher, BIT(1) | BIT(3)); // use toucher too?
220 SUB_UseTargets_SkipTargets(this.enemy, toucher, toucher, BIT(1) | BIT(2)); // use toucher too?
221#endif
222 }
223 else
224 {
225 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
226 }
227}
#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: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 165 of file client.qc.

166{
168 {
170 return;
171 }
173 return;
175 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
176 cvar_set("r_drawexteriormodel", "0");
177}
float warpzone_fixingview
Definition client.qc:154
float warpzone_fixingview_drawexteriormodel
Definition client.qc:155
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 157 of file client.qc.

158{
160 return;
162 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
163}
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 222 of file client.qc.

Referenced by WarpZone_FixView().

◆ warpzone_fixingview

float warpzone_fixingview

Definition at line 154 of file client.qc.

Referenced by WarpZone_View_Inside(), and WarpZone_View_Outside().

◆ warpzone_fixingview_drawexteriormodel

float warpzone_fixingview_drawexteriormodel

Definition at line 155 of file client.qc.

Referenced by WarpZone_View_Inside(), and WarpZone_View_Outside().