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 float warpzone_fixingview;
145 float warpzone_fixingview_drawexteriormodel;
146 //float warpzone_fixingview_sidespeed;
147 //float warpzone_fixingview_forwardspeed;
148 void WarpZone_Inside()
150 if(warpzone_fixingview)
152 warpzone_fixingview = 1;
153 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
154 //warpzone_fixingview_sidespeed = cvar("cl_sidespeed");
155 //warpzone_fixingview_forwardspeed = cvar("cl_forwardspeed");
156 cvar_set("r_drawexteriormodel", "0");
157 //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed / 100)); // just keep a bit of it in case player gets stuck
158 //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed / 100)); // just keep a bit of it in case player gets stuck
161 void WarpZone_Outside()
163 if(!warpzone_fixingview)
165 warpzone_fixingview = 0;
166 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
167 //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed));
168 //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed));
171 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
177 mi_x = min5(o_x, c0_x, c1_x, c2_x, c3_x);
178 ma_x = max5(o_x, c0_x, c1_x, c2_x, c3_x);
179 mi_y = min5(o_y, c0_y, c1_y, c2_y, c3_y);
180 ma_y = max5(o_y, c0_y, c1_y, c2_y, c3_y);
181 mi_z = min5(o_z, c0_z, c1_z, c2_z, c3_z);
182 ma_z = max5(o_z, c0_z, c1_z, c2_z, c3_z);
184 e = WarpZone_Find(mi, ma);
187 if(WarpZone_PlaneDist(e, o) < 0)
189 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
191 WarpZone_PlaneDist(e, c0),
192 WarpZone_PlaneDist(e, c1),
193 WarpZone_PlaneDist(e, c2),
194 WarpZone_PlaneDist(e, c3)
197 return e.warpzone_forward * -pd;
203 float warpzone_saved;
204 vector warpzone_saved_origin;
205 vector warpzone_saved_angles;
206 vector warpzone_saved_cl_viewangles;
208 var float autocvar_cl_rollkillspeed = 10;
210 void WarpZone_FixView()
215 vector corner0, corner1, corner2, corner3, nearclip;
218 warpzone_saved_origin = warpzone_fixview_origin;
219 warpzone_saved_angles = warpzone_fixview_angles;
220 warpzone_saved_cl_viewangles = warpzone_fixview_cl_viewangles;
222 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
223 corner0 = cs_unproject('0 0 0' + nearclip);
224 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
225 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
226 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
229 if(warpzone_fixview_angles_z != 0 || warpzone_fixview_cl_viewangles_z != 0)
231 if(autocvar_cl_rollkillspeed)
232 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
235 warpzone_fixview_angles_z *= f;
236 warpzone_fixview_cl_viewangles_z *= f;
237 warpzone_saved_angles_z *= f; // PERMANENTLY apply that change!
238 warpzone_saved_cl_viewangles_z *= f; // PERMANENTLY apply that change!
240 R_SetView(VF_CL_VIEWANGLES_Z, warpzone_fixview_angles_z);
244 e = WarpZone_Find(warpzone_fixview_origin, warpzone_fixview_origin);
248 warpzone_fixview_origin = WarpZone_TransformOrigin(e, warpzone_fixview_origin);
249 corner0 = WarpZone_TransformOrigin(e, corner0);
250 corner1 = WarpZone_TransformOrigin(e, corner1);
251 corner2 = WarpZone_TransformOrigin(e, corner2);
252 corner3 = WarpZone_TransformOrigin(e, corner3);
253 warpzone_fixview_angles = WarpZone_TransformVAngles(e, warpzone_fixview_angles);
254 warpzone_fixview_cl_viewangles = WarpZone_TransformVAngles(e, warpzone_fixview_cl_viewangles);
260 // if we are near any warpzone planes - MOVE AWAY (work around nearclip)
261 o = WarpZone_FixNearClip(warpzone_fixview_origin, corner0, corner1, corner2, corner3);
265 warpzone_fixview_origin += o;
268 if(warpzone_saved == 1)
270 R_SetView(VF_ORIGIN, warpzone_fixview_origin);
271 R_SetView(VF_ANGLES, warpzone_fixview_cl_viewangles);
274 void WarpZone_UnFixView()
278 warpzone_fixview_origin = warpzone_saved_origin;
279 warpzone_fixview_angles = warpzone_saved_angles;
280 warpzone_fixview_cl_viewangles = warpzone_saved_cl_viewangles;
281 R_SetView(VF_ORIGIN, warpzone_fixview_origin);
282 R_SetView(VF_ANGLES, warpzone_fixview_angles);
283 R_SetView(VF_CL_VIEWANGLES, warpzone_fixview_cl_viewangles);
291 void WarpZone_Shutdown()