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;
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}
26
28NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew)
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}
88
89NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew)
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}
140
142NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew)
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}
154
157
159{
161 return;
163 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
164}
165
167{
169 {
171 return;
172 }
174 return;
176 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
177 cvar_set("r_drawexteriormodel", "0");
178}
179
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}
211
221
222#ifndef KEEP_ROLL
224#endif
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}
289
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:811
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:367
int ReadByte()
#define STAT(...)
Definition stats.qh:82
void WarpZone_View_Outside()
Definition client.qc:158
float warpzone_fixingview
Definition client.qc:155
void WarpZone_Fade_PreDraw(entity this)
Definition client.qc:10
void WarpZone_FixPMove()
Definition client.qc:212
float warpzone_fixingview_drawexteriormodel
Definition client.qc:156
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
void CL_RotateMoves(vector ang)
void WarpZone_FixView()
Definition client.qc:225
void WarpZone_Shutdown()
Definition client.qc:290
void WarpZone_Touch(entity this, entity toucher)
Definition server.qc:184
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