Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
client.qc
Go to the documentation of this file.
1#include "client.qh"
2#include "common.qh"
3
4#ifdef CSQC
6#endif
7
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}
23
25NET_HANDLE(ENT_CLIENT_WARPZONE, bool isNew)
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}
81
82NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isNew)
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}
131
133NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isNew)
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}
148
151
153{
155 return;
157 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
158}
159
161{
163 {
165 return;
166 }
168 return;
170 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
171 cvar_set("r_drawexteriormodel", "0");
172}
173
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}
202
212
213#ifndef KEEP_ROLL
215#endif
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}
279
float height
Definition bobbing.qc:3
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float alpha
Definition items.qc:13
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition util.qc:807
string classname
float drawmask
const float VF_CL_VIEWANGLES
vector input_angles
float modelindex
const float VF_ORIGIN
vector avelocity
float frametime
const float MASK_NORMAL
vector pmove_org
vector mins
float checkpvs(vector viewpos, entity viewee)
vector maxs
const float VF_ANGLES
vector origin
vector oldorigin
const float VF_CL_VIEWANGLES_Z
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define NET_HANDLE(id, param)
Definition net.qh:15
#define ReadVector()
Definition net.qh:349
int ReadByte()
#define STAT(...)
Definition stats.qh:94
void WarpZone_View_Outside()
Definition client.qc:152
float warpzone_fixingview
Definition client.qc:149
void WarpZone_Fade_PreDraw(entity this)
Definition client.qc:8
void WarpZone_FixPMove()
Definition client.qc:203
float warpzone_fixingview_drawexteriormodel
Definition client.qc:150
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
void CL_RotateMoves(vector ang)
void WarpZone_FixView()
Definition client.qc:216
void WarpZone_Shutdown()
Definition client.qc:280
void WarpZone_Touch(entity this, entity toucher)
Definition server.qc:181
vector warpzone_save_view_origin
Definition client.qh:8
vector warpzone_save_view_angles
Definition client.qh:9
void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, vector other_ang)
Definition common.qc:60
entity WarpZone_Find(vector mi, vector ma)
Definition common.qc:158
float WarpZone_PlaneDist(entity wz, vector v)
Definition common.qc:476
void WarpZone_Camera_SetUp(entity e, vector my_org, vector my_ang)
Definition common.qc:89
vector WarpZone_TransformVAngles(entity wz, vector ang)
Definition common.qc:501
vector WarpZone_TransformOrigin(entity wz, vector v)
Definition common.qc:486
float warpzone_fadestart
Definition common.qh:24
float warpzone_cameras_exist
Definition common.qh:13
vector warpzone_transform
Definition common.qh:23
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
void cvar_set(string name, string value)
float bound(float min, float value, float max)
float cvar(string name)
float vlen(vector v)
float min(float f,...)
float checkextension(string ext)
string ftos(float f)
float max(float f,...)
float scale
Definition projectile.qc:14
vector
Definition self.qh:96
vector org
Definition self.qh:96
entity entity toucher
Definition self.qh:76
#define setpredraw(e, f)
Definition self.qh:88
vector vector ang
Definition self.qh:96
entity enemy
Definition sv_ctf.qh:152
const vector eY
Definition vector.qh:44
const vector eZ
Definition vector.qh:45
const vector eX
Definition vector.qh:43
int autocvar_chase_active
Definition view.qh:17