1 void WarpZone_Fade_PreDraw()
3 if(self.warpzone_fadestart)
6 org = R_SetView3fv(VF_ORIGIN);
7 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 //print(sprintf("%v <-> %v\n", view_origin, self.origin + 0.5 * (self.mins + self.maxs)));
15 self.drawmask = MASK_NORMAL;
18 void WarpZone_Read(float isnew)
22 warpzone_warpzones_exist = 1;
26 self.enemy.classname = "warpzone_from";
28 self.classname = "trigger_warpzone";
31 self.warpzone_isboxy = (f & 1);
34 self.origin_x = ReadCoord();
35 self.origin_y = ReadCoord();
36 self.origin_z = ReadCoord();
39 self.origin = '0 0 0';
40 self.modelindex = ReadShort();
41 self.mins_x = ReadCoord();
42 self.mins_y = ReadCoord();
43 self.mins_z = ReadCoord();
44 self.maxs_x = ReadCoord();
45 self.maxs_y = ReadCoord();
46 self.maxs_z = ReadCoord();
47 self.scale = ReadByte() / 16;
48 self.enemy.oldorigin_x = ReadCoord();
49 self.enemy.oldorigin_y = ReadCoord();
50 self.enemy.oldorigin_z = ReadCoord();
51 self.enemy.avelocity_x = ReadCoord();
52 self.enemy.avelocity_y = ReadCoord();
53 self.enemy.avelocity_z = ReadCoord();
54 self.oldorigin_x = ReadCoord();
55 self.oldorigin_y = ReadCoord();
56 self.oldorigin_z = ReadCoord();
57 self.avelocity_x = ReadCoord();
58 self.avelocity_y = ReadCoord();
59 self.avelocity_z = ReadCoord();
63 self.warpzone_fadestart = ReadShort();
64 self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort());
68 self.warpzone_fadestart = 0;
69 self.warpzone_fadeend = 0;
73 WarpZone_SetUp(self, self.enemy.oldorigin, self.enemy.avelocity, self.oldorigin, self.avelocity);
76 //setmodel(self, self.model);
77 setorigin(self, self.origin);
78 setsize(self, self.mins, self.maxs);
81 // engine currently wants this
82 if(self.warpzone_fadestart)
83 self.predraw = WarpZone_Fade_PreDraw;
85 self.drawmask = MASK_NORMAL;
88 void WarpZone_Camera_Read(float isnew)
91 warpzone_cameras_exist = 1;
92 self.classname = "func_warpzone_camera";
97 self.origin_x = ReadCoord();
98 self.origin_y = ReadCoord();
99 self.origin_z = ReadCoord();
102 self.origin = '0 0 0';
103 self.modelindex = ReadShort();
104 self.mins_x = ReadCoord();
105 self.mins_y = ReadCoord();
106 self.mins_z = ReadCoord();
107 self.maxs_x = ReadCoord();
108 self.maxs_y = ReadCoord();
109 self.maxs_z = ReadCoord();
110 self.scale = ReadByte() / 16;
111 self.oldorigin_x = ReadCoord();
112 self.oldorigin_y = ReadCoord();
113 self.oldorigin_z = ReadCoord();
114 self.avelocity_x = ReadCoord();
115 self.avelocity_y = ReadCoord();
116 self.avelocity_z = ReadCoord();
120 self.warpzone_fadestart = ReadShort();
121 self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort());
125 self.warpzone_fadestart = 0;
126 self.warpzone_fadeend = 0;
130 WarpZone_Camera_SetUp(self, self.oldorigin, self.avelocity);
132 // engine currently wants this
133 self.drawmask = MASK_NORMAL;
136 //setmodel(self, self.model);
137 setorigin(self, self.origin);
138 setsize(self, self.mins, self.maxs);
141 // engine currently wants this
142 if(self.warpzone_fadestart)
143 self.predraw = WarpZone_Fade_PreDraw;
145 self.drawmask = MASK_NORMAL;
148 void CL_RotateMoves(vector ang) = #638;
149 void WarpZone_Teleported_Read(float isnew)
152 self.classname = "warpzone_teleported";
158 self.warpzone_transform = v;
159 R_SetView3fv(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(self, R_SetView3fv(VF_CL_VIEWANGLES)));
160 if(checkextension("DP_CSQC_ROTATEMOVES"))
162 //CL_RotateMoves('0 90 0');
165 float warpzone_fixingview;
166 float warpzone_fixingview_drawexteriormodel;
167 void WarpZone_View_Inside()
169 if(warpzone_fixingview)
171 warpzone_fixingview = 1;
172 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
173 cvar_set("r_drawexteriormodel", "0");
176 void WarpZone_View_Outside()
178 if(!warpzone_fixingview)
180 warpzone_fixingview = 0;
181 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
182 //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed));
183 //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed));
186 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
192 mi_x = min5(o_x, c0_x, c1_x, c2_x, c3_x);
193 ma_x = max5(o_x, c0_x, c1_x, c2_x, c3_x);
194 mi_y = min5(o_y, c0_y, c1_y, c2_y, c3_y);
195 ma_y = max5(o_y, c0_y, c1_y, c2_y, c3_y);
196 mi_z = min5(o_z, c0_z, c1_z, c2_z, c3_z);
197 ma_z = max5(o_z, c0_z, c1_z, c2_z, c3_z);
199 e = WarpZone_Find(mi, ma);
202 if(WarpZone_PlaneDist(e, o) < 0)
204 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
206 WarpZone_PlaneDist(e, c0),
207 WarpZone_PlaneDist(e, c1),
208 WarpZone_PlaneDist(e, c2),
209 WarpZone_PlaneDist(e, c3)
212 return e.warpzone_forward * -pd;
218 void WarpZone_FixPMove()
221 e = WarpZone_Find(pmove_org, pmove_org);
224 pmove_org = WarpZone_TransformOrigin(e, pmove_org);
225 input_angles = WarpZone_TransformVAngles(e, input_angles);
230 var float autocvar_cl_rollkillspeed = 10;
232 void WarpZone_FixView()
235 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
238 org = R_SetView3fv(VF_ORIGIN);
239 ang = R_SetView3fv(VF_ANGLES);
241 e = WarpZone_Find(org, org);
244 org = WarpZone_TransformOrigin(e, org);
245 ang = WarpZone_TransformVAngles(e, ang);
246 WarpZone_View_Inside();
249 WarpZone_View_Outside();
253 if(autocvar_cl_rollkillspeed)
254 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
258 rick = R_SetView(VF_CL_VIEWANGLES_Z);
260 R_SetView(VF_CL_VIEWANGLES_Z, rick);
265 R_SetView(VF_ORIGIN, org);
266 R_SetView(VF_ANGLES, ang);
268 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
269 corner0 = cs_unproject('0 0 0' + nearclip);
270 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
271 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
272 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
273 o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
275 R_SetView(VF_ORIGIN, org + o);
282 void WarpZone_Shutdown()
284 WarpZone_View_Outside();