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#if defined(CSQC)
6#elif defined(MENUQC)
7#elif defined(SVQC)
8#endif
9
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}
25
27NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew)
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}
87
88NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew)
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}
139
141NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew)
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}
153
156
158{
160 return;
162 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
163}
164
166{
168 {
170 return;
171 }
173 return;
175 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
176 cvar_set("r_drawexteriormodel", "0");
177}
178
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}
210
220
221#ifndef KEEP_ROLL
223#endif
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}
288
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:350
int ReadByte()
#define STAT(...)
Definition stats.qh:82
void WarpZone_View_Outside()
Definition client.qc:157
float warpzone_fixingview
Definition client.qc:154
void WarpZone_Fade_PreDraw(entity this)
Definition client.qc:10
void WarpZone_FixPMove()
Definition client.qc:211
float warpzone_fixingview_drawexteriormodel
Definition client.qc:155
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
void CL_RotateMoves(vector ang)
void WarpZone_FixView()
Definition client.qc:224
void WarpZone_Shutdown()
Definition client.qc:289
void WarpZone_Touch(entity this, entity toucher)
Definition server.qc:183
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:64
entity WarpZone_Find(vector mi, vector ma)
Definition common.qc:167
float WarpZone_PlaneDist(entity wz, vector v)
Definition common.qc:499
void WarpZone_Camera_SetUp(entity e, vector my_org, vector my_ang)
Definition common.qc:93
vector WarpZone_TransformVAngles(entity wz, vector ang)
Definition common.qc:524
vector WarpZone_TransformOrigin(entity wz, vector v)
Definition common.qc:509
float warpzone_fadestart
Definition common.qh:21
float warpzone_cameras_exist
Definition common.qh:10
vector warpzone_transform
Definition common.qh:20
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
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:92
vector org
Definition self.qh:92
entity entity toucher
Definition self.qh:72
#define setpredraw(e, f)
Definition self.qh:84
vector vector ang
Definition self.qh:92
entity enemy
Definition sv_ctf.qh:153
int autocvar_chase_active
Definition view.qh:17