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 if(!warpzone_warpzones_exist)
33 cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has warpzones
34 cvar_settemp("r_water_resolutionmultiplier", "1"); // HACK for DarkPlaces: enforce full quality so entities can be seen clearly through warpzones
36 warpzone_warpzones_exist = 1;
39 this.enemy = new(warpzone_from);
41 this.classname = "trigger_warpzone";
44 IL_PUSH(g_warpzones, this);
47 this.warpzone_isboxy = (f & 1);
50 this.origin = ReadVector();
53 this.origin = '0 0 0';
54 this.modelindex = ReadShort();
55 this.mins = ReadVector();
56 this.maxs = ReadVector();
57 this.scale = ReadByte() / 16;
58 this.enemy.oldorigin = ReadVector();
59 this.enemy.avelocity = ReadVector();
60 this.oldorigin = ReadVector();
61 this.avelocity = ReadVector();
65 this.warpzone_fadestart = ReadShort();
66 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
70 this.warpzone_fadestart = 0;
71 this.warpzone_fadeend = 0;
75 WarpZone_SetUp(this, this.enemy.oldorigin, this.enemy.avelocity, this.oldorigin, this.avelocity);
78 //setmodel(this, this.model);
79 setorigin(this, this.origin);
80 setsize(this, this.mins, this.maxs);
83 // engine currently wants this
84 setpredraw(this, WarpZone_Fade_PreDraw);
86 //settouch(this, WarpZone_Touch);
90 NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew)
92 if(!warpzone_cameras_exist)
94 cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has cameras
95 cvar_settemp("r_water_resolutionmultiplier", "1"); // HACK for DarkPlaces: enforce full quality so entities can be seen clearly through warpzones
97 warpzone_cameras_exist = 1;
98 this.classname = "func_warpzone_camera";
103 this.origin = ReadVector();
106 this.origin = '0 0 0';
107 this.modelindex = ReadShort();
108 this.mins = ReadVector();
109 this.maxs = ReadVector();
110 this.scale = ReadByte() / 16;
111 this.oldorigin = ReadVector();
112 this.avelocity = ReadVector();
116 this.warpzone_fadestart = ReadShort();
117 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
121 this.warpzone_fadestart = 0;
122 this.warpzone_fadeend = 0;
126 WarpZone_Camera_SetUp(this, this.oldorigin, this.avelocity);
128 // engine currently wants this
129 this.drawmask = MASK_NORMAL;
132 //setmodel(this, this.model);
133 setorigin(this, this.origin);
134 setsize(this, this.mins, this.maxs);
137 // engine currently wants this
138 setpredraw(this, WarpZone_Fade_PreDraw);
142 void CL_RotateMoves(vector ang) = #638;
143 NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew)
145 this.classname = "warpzone_teleported";
146 vector v = ReadVector();
149 this.warpzone_transform = v;
150 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(this, getpropertyvec(VF_CL_VIEWANGLES)));
151 if(checkextension("DP_CSQC_ROTATEMOVES"))
153 //CL_RotateMoves('0 90 0');
156 float warpzone_fixingview;
157 float warpzone_fixingview_drawexteriormodel;
159 void WarpZone_View_Outside()
161 if(!warpzone_fixingview)
163 warpzone_fixingview = 0;
164 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
167 void WarpZone_View_Inside()
169 if(autocvar_chase_active)
171 WarpZone_View_Outside();
174 if(warpzone_fixingview)
176 warpzone_fixingview = 1;
177 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
178 cvar_set("r_drawexteriormodel", "0");
181 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
187 mi.x = min(o.x, c0_x, c1_x, c2_x, c3_x);
188 ma.x = max(o.x, c0_x, c1_x, c2_x, c3_x);
189 mi.y = min(o.y, c0_y, c1_y, c2_y, c3_y);
190 ma.y = max(o.y, c0_y, c1_y, c2_y, c3_y);
191 mi.z = min(o.z, c0_z, c1_z, c2_z, c3_z);
192 ma.z = max(o.z, c0_z, c1_z, c2_z, c3_z);
194 e = WarpZone_Find(mi, ma);
197 if(WarpZone_PlaneDist(e, o) < 0)
199 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
201 WarpZone_PlaneDist(e, c0),
202 WarpZone_PlaneDist(e, c1),
203 WarpZone_PlaneDist(e, c2),
204 WarpZone_PlaneDist(e, c3)
207 return e.warpzone_forward * -pd;
213 void WarpZone_FixPMove()
215 entity e = WarpZone_Find(pmove_org, pmove_org);
218 pmove_org = WarpZone_TransformOrigin(e, pmove_org);
219 input_angles = WarpZone_TransformVAngles(e, input_angles);
224 float autocvar_cl_rollkillspeed = 10;
226 void WarpZone_FixView()
229 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
231 warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
232 warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
234 e = WarpZone_Find(org, org);
237 org = WarpZone_TransformOrigin(e, org);
238 ang = WarpZone_TransformVAngles(e, ang);
239 WarpZone_View_Inside();
242 WarpZone_View_Outside();
247 static float rollkill;
248 if (STAT(HEALTH) > 0 || STAT(HEALTH) == -666 || STAT(HEALTH) == -2342)
251 // reset roll when passing through a warpzone that change player's roll angle
252 if(autocvar_cl_rollkillspeed)
253 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
260 // roll the view when killed (v_deathtilt)
261 if(autocvar_cl_rollkillspeed)
263 rollkill += frametime * autocvar_cl_rollkillspeed;
264 f = min(1, rollkill);
270 rick = getproperty(VF_CL_VIEWANGLES_Z);
272 setproperty(VF_CL_VIEWANGLES_Z, rick);
276 setproperty(VF_ORIGIN, org);
277 setproperty(VF_ANGLES, ang);
279 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
280 corner0 = cs_unproject('0 0 0' + nearclip);
281 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
282 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
283 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
284 o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
286 setproperty(VF_ORIGIN, org + o);
289 void WarpZone_Shutdown()
291 WarpZone_View_Outside();