1 void WarpZone_Fade_PreDraw()
4 org = getpropertyvec(VF_ORIGIN);
5 if(!checkpvs(org, self)) // this makes sense as long as we don't support recursive warpzones
7 else if(self.warpzone_fadestart)
8 self.alpha = bound(0, (self.warpzone_fadeend - vlen(org - self.origin - 0.5 * (self.mins + self.maxs))) / (self.warpzone_fadeend - self.warpzone_fadestart), 1);
11 //printf("%v <-> %v\n", view_origin, self.origin + 0.5 * (self.mins + self.maxs));
15 self.drawmask = MASK_NORMAL;
18 void WarpZone_Read(float isnew)
20 warpzone_warpzones_exist = 1;
24 self.enemy.classname = "warpzone_from";
26 self.classname = "trigger_warpzone";
29 self.warpzone_isboxy = (f & 1);
32 self.origin_x = ReadCoord();
33 self.origin_y = ReadCoord();
34 self.origin_z = ReadCoord();
37 self.origin = '0 0 0';
38 self.modelindex = ReadShort();
39 self.mins_x = ReadCoord();
40 self.mins_y = ReadCoord();
41 self.mins_z = ReadCoord();
42 self.maxs_x = ReadCoord();
43 self.maxs_y = ReadCoord();
44 self.maxs_z = ReadCoord();
45 self.scale = ReadByte() / 16;
46 self.enemy.oldorigin_x = ReadCoord();
47 self.enemy.oldorigin_y = ReadCoord();
48 self.enemy.oldorigin_z = ReadCoord();
49 self.enemy.avelocity_x = ReadCoord();
50 self.enemy.avelocity_y = ReadCoord();
51 self.enemy.avelocity_z = ReadCoord();
52 self.oldorigin_x = ReadCoord();
53 self.oldorigin_y = ReadCoord();
54 self.oldorigin_z = ReadCoord();
55 self.avelocity_x = ReadCoord();
56 self.avelocity_y = ReadCoord();
57 self.avelocity_z = ReadCoord();
61 self.warpzone_fadestart = ReadShort();
62 self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort());
66 self.warpzone_fadestart = 0;
67 self.warpzone_fadeend = 0;
71 WarpZone_SetUp(self, self.enemy.oldorigin, self.enemy.avelocity, self.oldorigin, self.avelocity);
74 //setmodel(self, self.model);
75 setorigin(self, self.origin);
76 setsize(self, self.mins, self.maxs);
79 // engine currently wants this
80 self.predraw = WarpZone_Fade_PreDraw;
83 void WarpZone_Camera_Read(float isnew)
85 warpzone_cameras_exist = 1;
86 self.classname = "func_warpzone_camera";
91 self.origin_x = ReadCoord();
92 self.origin_y = ReadCoord();
93 self.origin_z = ReadCoord();
96 self.origin = '0 0 0';
97 self.modelindex = ReadShort();
98 self.mins_x = ReadCoord();
99 self.mins_y = ReadCoord();
100 self.mins_z = ReadCoord();
101 self.maxs_x = ReadCoord();
102 self.maxs_y = ReadCoord();
103 self.maxs_z = ReadCoord();
104 self.scale = ReadByte() / 16;
105 self.oldorigin_x = ReadCoord();
106 self.oldorigin_y = ReadCoord();
107 self.oldorigin_z = ReadCoord();
108 self.avelocity_x = ReadCoord();
109 self.avelocity_y = ReadCoord();
110 self.avelocity_z = ReadCoord();
114 self.warpzone_fadestart = ReadShort();
115 self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort());
119 self.warpzone_fadestart = 0;
120 self.warpzone_fadeend = 0;
124 WarpZone_Camera_SetUp(self, self.oldorigin, self.avelocity);
126 // engine currently wants this
127 self.drawmask = MASK_NORMAL;
130 //setmodel(self, self.model);
131 setorigin(self, self.origin);
132 setsize(self, self.mins, self.maxs);
135 // engine currently wants this
136 self.predraw = WarpZone_Fade_PreDraw;
139 void CL_RotateMoves(vector ang) = #638;
140 void WarpZone_Teleported_Read(float isnew)
143 self.classname = "warpzone_teleported";
149 self.warpzone_transform = v;
150 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(self, 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;
158 float autocvar_chase_active;
160 void WarpZone_View_Outside()
162 if(!warpzone_fixingview)
164 warpzone_fixingview = 0;
165 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
168 void WarpZone_View_Inside()
170 if(autocvar_chase_active)
172 WarpZone_View_Outside();
175 if(warpzone_fixingview)
177 warpzone_fixingview = 1;
178 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
179 cvar_set("r_drawexteriormodel", "0");
182 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
188 mi_x = min(o_x, c0_x, c1_x, c2_x, c3_x);
189 ma_x = max(o_x, c0_x, c1_x, c2_x, c3_x);
190 mi_y = min(o_y, c0_y, c1_y, c2_y, c3_y);
191 ma_y = max(o_y, c0_y, c1_y, c2_y, c3_y);
192 mi_z = min(o_z, c0_z, c1_z, c2_z, c3_z);
193 ma_z = max(o_z, c0_z, c1_z, c2_z, c3_z);
195 e = WarpZone_Find(mi, ma);
198 if(WarpZone_PlaneDist(e, o) < 0)
200 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
202 WarpZone_PlaneDist(e, c0),
203 WarpZone_PlaneDist(e, c1),
204 WarpZone_PlaneDist(e, c2),
205 WarpZone_PlaneDist(e, c3)
208 return e.warpzone_forward * -pd;
214 void WarpZone_FixPMove()
217 e = WarpZone_Find(pmove_org, pmove_org);
220 pmove_org = WarpZone_TransformOrigin(e, pmove_org);
221 input_angles = WarpZone_TransformVAngles(e, input_angles);
226 var float autocvar_cl_rollkillspeed = 10;
228 void WarpZone_FixView()
231 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
234 warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
235 warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
237 e = WarpZone_Find(org, org);
240 org = WarpZone_TransformOrigin(e, org);
241 ang = WarpZone_TransformVAngles(e, ang);
242 WarpZone_View_Inside();
245 WarpZone_View_Outside();
249 if(autocvar_cl_rollkillspeed)
250 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
254 rick = getproperty(VF_CL_VIEWANGLES_Z);
256 setproperty(VF_CL_VIEWANGLES_Z, rick);
260 setproperty(VF_ORIGIN, org);
261 setproperty(VF_ANGLES, ang);
263 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
264 corner0 = cs_unproject('0 0 0' + nearclip);
265 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
266 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
267 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
268 o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
270 setproperty(VF_ORIGIN, org + o);
277 void WarpZone_Shutdown()
279 WarpZone_View_Outside();