1 void WarpZone_Fade_PreDraw()
3 if(self.warpzone_fadestart)
4 self.alpha = bound(0, (self.warpzone_fadeend - vlen(view_origin - self.origin - 0.5 * (self.mins + self.maxs))) / (self.warpzone_fadeend - self.warpzone_fadestart), 1);
7 //print(sprintf("%v <-> %v\n", view_origin, self.origin + 0.5 * (self.mins + self.maxs)));
11 self.drawmask = MASK_NORMAL;
14 void WarpZone_Read(float isnew)
18 warpzone_warpzones_exist = 1;
22 self.enemy.classname = "warpzone_from";
24 self.classname = "trigger_warpzone";
27 self.warpzone_isboxy = (f & 1);
30 self.origin_x = ReadCoord();
31 self.origin_y = ReadCoord();
32 self.origin_z = ReadCoord();
35 self.origin = '0 0 0';
36 self.modelindex = ReadShort();
37 self.mins_x = ReadCoord();
38 self.mins_y = ReadCoord();
39 self.mins_z = ReadCoord();
40 self.maxs_x = ReadCoord();
41 self.maxs_y = ReadCoord();
42 self.maxs_z = ReadCoord();
43 self.scale = ReadByte() / 16;
44 self.enemy.oldorigin_x = ReadCoord();
45 self.enemy.oldorigin_y = ReadCoord();
46 self.enemy.oldorigin_z = ReadCoord();
47 self.enemy.avelocity_x = ReadCoord();
48 self.enemy.avelocity_y = ReadCoord();
49 self.enemy.avelocity_z = ReadCoord();
50 self.oldorigin_x = ReadCoord();
51 self.oldorigin_y = ReadCoord();
52 self.oldorigin_z = ReadCoord();
53 self.avelocity_x = ReadCoord();
54 self.avelocity_y = ReadCoord();
55 self.avelocity_z = ReadCoord();
59 self.warpzone_fadestart = ReadShort();
60 self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort());
64 self.warpzone_fadestart = 0;
65 self.warpzone_fadeend = 0;
69 WarpZone_SetUp(self, self.enemy.oldorigin, self.enemy.avelocity, self.oldorigin, self.avelocity);
72 //setmodel(self, self.model);
73 setorigin(self, self.origin);
74 setsize(self, self.mins, self.maxs);
77 // engine currently wants this
78 if(self.warpzone_fadestart)
79 self.predraw = WarpZone_Fade_PreDraw;
81 self.drawmask = MASK_NORMAL;
84 void WarpZone_Camera_Read(float isnew)
87 warpzone_cameras_exist = 1;
88 self.classname = "func_warpzone_camera";
93 self.origin_x = ReadCoord();
94 self.origin_y = ReadCoord();
95 self.origin_z = ReadCoord();
98 self.origin = '0 0 0';
99 self.modelindex = ReadShort();
100 self.mins_x = ReadCoord();
101 self.mins_y = ReadCoord();
102 self.mins_z = ReadCoord();
103 self.maxs_x = ReadCoord();
104 self.maxs_y = ReadCoord();
105 self.maxs_z = ReadCoord();
106 self.scale = ReadByte() / 16;
107 self.oldorigin_x = ReadCoord();
108 self.oldorigin_y = ReadCoord();
109 self.oldorigin_z = ReadCoord();
110 self.avelocity_x = ReadCoord();
111 self.avelocity_y = ReadCoord();
112 self.avelocity_z = ReadCoord();
116 self.warpzone_fadestart = ReadShort();
117 self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort());
121 self.warpzone_fadestart = 0;
122 self.warpzone_fadeend = 0;
126 WarpZone_Camera_SetUp(self, self.oldorigin, self.avelocity);
128 // engine currently wants this
129 self.drawmask = MASK_NORMAL;
132 //setmodel(self, self.model);
133 setorigin(self, self.origin);
134 setsize(self, self.mins, self.maxs);
137 // engine currently wants this
138 if(self.warpzone_fadestart)
139 self.predraw = WarpZone_Fade_PreDraw;
141 self.drawmask = MASK_NORMAL;
144 void CL_RotateMoves(vector ang) = #638;
145 void WarpZone_Teleported_Read(float isnew)
148 self.classname = "warpzone_teleported";
154 self.warpzone_transform = v;
155 R_SetView3fv(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(self, R_SetView3fv(VF_CL_VIEWANGLES)));
156 if(checkextension("DP_CSQC_ROTATEMOVES"))
158 //CL_RotateMoves('0 90 0');
161 float warpzone_fixingview;
162 float warpzone_fixingview_drawexteriormodel;
163 //float warpzone_fixingview_sidespeed;
164 //float warpzone_fixingview_forwardspeed;
165 void WarpZone_Inside()
167 if(warpzone_fixingview)
169 warpzone_fixingview = 1;
170 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
171 //warpzone_fixingview_sidespeed = cvar("cl_sidespeed");
172 //warpzone_fixingview_forwardspeed = cvar("cl_forwardspeed");
173 cvar_set("r_drawexteriormodel", "0");
174 //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed / 100)); // just keep a bit of it in case player gets stuck
175 //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed / 100)); // just keep a bit of it in case player gets stuck
178 void WarpZone_Outside()
180 if(!warpzone_fixingview)
182 warpzone_fixingview = 0;
183 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
184 //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed));
185 //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed));
188 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
194 mi_x = min5(o_x, c0_x, c1_x, c2_x, c3_x);
195 ma_x = max5(o_x, c0_x, c1_x, c2_x, c3_x);
196 mi_y = min5(o_y, c0_y, c1_y, c2_y, c3_y);
197 ma_y = max5(o_y, c0_y, c1_y, c2_y, c3_y);
198 mi_z = min5(o_z, c0_z, c1_z, c2_z, c3_z);
199 ma_z = max5(o_z, c0_z, c1_z, c2_z, c3_z);
201 e = WarpZone_Find(mi, ma);
204 if(WarpZone_PlaneDist(e, o) < 0)
206 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
208 WarpZone_PlaneDist(e, c0),
209 WarpZone_PlaneDist(e, c1),
210 WarpZone_PlaneDist(e, c2),
211 WarpZone_PlaneDist(e, c3)
214 return e.warpzone_forward * -pd;
220 float warpzone_saved;
221 vector warpzone_saved_origin;
222 vector warpzone_saved_angles;
223 vector warpzone_saved_cl_viewangles;
225 var float autocvar_cl_rollkillspeed = 10;
227 void WarpZone_FixView()
232 vector corner0, corner1, corner2, corner3, nearclip;
235 warpzone_saved_origin = warpzone_fixview_origin;
236 warpzone_saved_angles = warpzone_fixview_angles;
237 warpzone_saved_cl_viewangles = warpzone_fixview_cl_viewangles;
239 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
240 corner0 = cs_unproject('0 0 0' + nearclip);
241 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
242 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
243 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
246 if(warpzone_fixview_angles_z != 0 || warpzone_fixview_cl_viewangles_z != 0)
248 if(autocvar_cl_rollkillspeed)
249 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
252 warpzone_fixview_angles_z *= f;
253 warpzone_fixview_cl_viewangles_z *= f;
254 warpzone_saved_angles_z *= f; // PERMANENTLY apply that change!
255 warpzone_saved_cl_viewangles_z *= f; // PERMANENTLY apply that change!
257 R_SetView(VF_CL_VIEWANGLES_Z, warpzone_fixview_angles_z);
261 e = WarpZone_Find(warpzone_fixview_origin, warpzone_fixview_origin);
265 warpzone_fixview_origin = WarpZone_TransformOrigin(e, warpzone_fixview_origin);
266 corner0 = WarpZone_TransformOrigin(e, corner0);
267 corner1 = WarpZone_TransformOrigin(e, corner1);
268 corner2 = WarpZone_TransformOrigin(e, corner2);
269 corner3 = WarpZone_TransformOrigin(e, corner3);
270 warpzone_fixview_angles = WarpZone_TransformVAngles(e, warpzone_fixview_angles);
271 warpzone_fixview_cl_viewangles = WarpZone_TransformVAngles(e, warpzone_fixview_cl_viewangles);
277 // if we are near any warpzone planes - MOVE AWAY (work around nearclip)
278 o = WarpZone_FixNearClip(warpzone_fixview_origin, corner0, corner1, corner2, corner3);
282 warpzone_fixview_origin += o;
285 if(warpzone_saved == 1)
287 R_SetView(VF_ORIGIN, warpzone_fixview_origin);
288 R_SetView(VF_ANGLES, warpzone_fixview_cl_viewangles);
291 void WarpZone_UnFixView()
295 warpzone_fixview_origin = warpzone_saved_origin;
296 warpzone_fixview_angles = warpzone_saved_angles;
297 warpzone_fixview_cl_viewangles = warpzone_saved_cl_viewangles;
298 R_SetView(VF_ORIGIN, warpzone_fixview_origin);
299 R_SetView(VF_ANGLES, warpzone_fixview_angles);
300 R_SetView(VF_CL_VIEWANGLES, warpzone_fixview_cl_viewangles);
308 void WarpZone_Shutdown()