5 #include <client/autocvars.qh>
6 #include <lib/csqcmodel/cl_model.qh>
11 void WarpZone_Fade_PreDraw(entity this)
14 org = getpropertyvec(VF_ORIGIN);
15 if(!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones
17 else if(this.warpzone_fadestart)
18 this.alpha = bound(0, (this.warpzone_fadeend - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.warpzone_fadeend - this.warpzone_fadestart), 1);
21 //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
25 this.drawmask = MASK_NORMAL;
28 void WarpZone_Touch(entity this, entity toucher);
29 NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew)
31 warpzone_warpzones_exist = 1;
34 this.enemy = new(warpzone_from);
36 this.classname = "trigger_warpzone";
39 this.warpzone_isboxy = (f & 1);
42 this.origin_x = ReadCoord();
43 this.origin_y = ReadCoord();
44 this.origin_z = ReadCoord();
47 this.origin = '0 0 0';
48 this.modelindex = ReadShort();
49 this.mins_x = ReadCoord();
50 this.mins_y = ReadCoord();
51 this.mins_z = ReadCoord();
52 this.maxs_x = ReadCoord();
53 this.maxs_y = ReadCoord();
54 this.maxs_z = ReadCoord();
55 this.scale = ReadByte() / 16;
56 this.enemy.oldorigin_x = ReadCoord();
57 this.enemy.oldorigin_y = ReadCoord();
58 this.enemy.oldorigin_z = ReadCoord();
59 this.enemy.avelocity_x = ReadCoord();
60 this.enemy.avelocity_y = ReadCoord();
61 this.enemy.avelocity_z = ReadCoord();
62 this.oldorigin_x = ReadCoord();
63 this.oldorigin_y = ReadCoord();
64 this.oldorigin_z = ReadCoord();
65 this.avelocity_x = ReadCoord();
66 this.avelocity_y = ReadCoord();
67 this.avelocity_z = ReadCoord();
71 this.warpzone_fadestart = ReadShort();
72 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
76 this.warpzone_fadestart = 0;
77 this.warpzone_fadeend = 0;
81 WarpZone_SetUp(this, this.enemy.oldorigin, this.enemy.avelocity, this.oldorigin, this.avelocity);
84 //setmodel(this, this.model);
85 setorigin(this, this.origin);
86 setsize(this, this.mins, this.maxs);
89 // engine currently wants this
90 setpredraw(this, WarpZone_Fade_PreDraw);
92 //settouch(this, WarpZone_Touch);
96 NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew)
98 warpzone_cameras_exist = 1;
99 this.classname = "func_warpzone_camera";
104 this.origin_x = ReadCoord();
105 this.origin_y = ReadCoord();
106 this.origin_z = ReadCoord();
109 this.origin = '0 0 0';
110 this.modelindex = ReadShort();
111 this.mins_x = ReadCoord();
112 this.mins_y = ReadCoord();
113 this.mins_z = ReadCoord();
114 this.maxs_x = ReadCoord();
115 this.maxs_y = ReadCoord();
116 this.maxs_z = ReadCoord();
117 this.scale = ReadByte() / 16;
118 this.oldorigin_x = ReadCoord();
119 this.oldorigin_y = ReadCoord();
120 this.oldorigin_z = ReadCoord();
121 this.avelocity_x = ReadCoord();
122 this.avelocity_y = ReadCoord();
123 this.avelocity_z = ReadCoord();
127 this.warpzone_fadestart = ReadShort();
128 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
132 this.warpzone_fadestart = 0;
133 this.warpzone_fadeend = 0;
137 WarpZone_Camera_SetUp(this, this.oldorigin, this.avelocity);
139 // engine currently wants this
140 this.drawmask = MASK_NORMAL;
143 //setmodel(this, this.model);
144 setorigin(this, this.origin);
145 setsize(this, this.mins, this.maxs);
148 // engine currently wants this
149 setpredraw(this, WarpZone_Fade_PreDraw);
153 void CL_RotateMoves(vector ang) = #638;
154 NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew)
156 this.classname = "warpzone_teleported";
163 this.warpzone_transform = v;
164 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(this, getpropertyvec(VF_CL_VIEWANGLES)));
165 if(checkextension("DP_CSQC_ROTATEMOVES"))
167 //CL_RotateMoves('0 90 0');
170 float warpzone_fixingview;
171 float warpzone_fixingview_drawexteriormodel;
173 void WarpZone_View_Outside()
175 if(!warpzone_fixingview)
177 warpzone_fixingview = 0;
178 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
181 void WarpZone_View_Inside()
183 if(autocvar_chase_active)
185 WarpZone_View_Outside();
188 if(warpzone_fixingview)
190 warpzone_fixingview = 1;
191 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
192 cvar_set("r_drawexteriormodel", "0");
195 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
201 mi.x = min(o.x, c0_x, c1_x, c2_x, c3_x);
202 ma.x = max(o.x, c0_x, c1_x, c2_x, c3_x);
203 mi.y = min(o.y, c0_y, c1_y, c2_y, c3_y);
204 ma.y = max(o.y, c0_y, c1_y, c2_y, c3_y);
205 mi.z = min(o.z, c0_z, c1_z, c2_z, c3_z);
206 ma.z = max(o.z, c0_z, c1_z, c2_z, c3_z);
208 e = WarpZone_Find(mi, ma);
211 if(WarpZone_PlaneDist(e, o) < 0)
213 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
215 WarpZone_PlaneDist(e, c0),
216 WarpZone_PlaneDist(e, c1),
217 WarpZone_PlaneDist(e, c2),
218 WarpZone_PlaneDist(e, c3)
221 return e.warpzone_forward * -pd;
227 void WarpZone_FixPMove()
229 entity e = WarpZone_Find(pmove_org, pmove_org);
232 pmove_org = WarpZone_TransformOrigin(e, pmove_org);
233 input_angles = WarpZone_TransformVAngles(e, input_angles);
238 float autocvar_cl_rollkillspeed = 10;
240 void WarpZone_FixView()
243 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
245 warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
246 warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
248 e = WarpZone_Find(org, org);
251 org = WarpZone_TransformOrigin(e, org);
252 ang = WarpZone_TransformVAngles(e, ang);
253 WarpZone_View_Inside();
256 WarpZone_View_Outside();
261 static float rollkill;
262 if (STAT(HEALTH) > 0 || STAT(HEALTH) == -666 || STAT(HEALTH) == -2342)
265 // reset roll when passing through a warpzone that change player's roll angle
266 if(autocvar_cl_rollkillspeed)
267 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
274 // roll the view when killed (v_deathtilt)
275 if(autocvar_cl_rollkillspeed)
277 rollkill += frametime * autocvar_cl_rollkillspeed;
278 f = min(1, rollkill);
284 rick = getproperty(VF_CL_VIEWANGLES_Z);
286 setproperty(VF_CL_VIEWANGLES_Z, rick);
290 setproperty(VF_ORIGIN, org);
291 setproperty(VF_ANGLES, ang);
293 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
294 corner0 = cs_unproject('0 0 0' + nearclip);
295 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
296 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
297 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
298 o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
300 setproperty(VF_ORIGIN, org + o);
303 void WarpZone_Shutdown()
305 WarpZone_View_Outside();