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 float autocvar_chase_active;
169 void WarpZone_View_Outside()
171 if(!warpzone_fixingview)
173 warpzone_fixingview = 0;
174 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
177 void WarpZone_View_Inside()
179 if(autocvar_chase_active)
181 WarpZone_View_Outside();
184 if(warpzone_fixingview)
186 warpzone_fixingview = 1;
187 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
188 cvar_set("r_drawexteriormodel", "0");
191 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
197 mi_x = min5(o_x, c0_x, c1_x, c2_x, c3_x);
198 ma_x = max5(o_x, c0_x, c1_x, c2_x, c3_x);
199 mi_y = min5(o_y, c0_y, c1_y, c2_y, c3_y);
200 ma_y = max5(o_y, c0_y, c1_y, c2_y, c3_y);
201 mi_z = min5(o_z, c0_z, c1_z, c2_z, c3_z);
202 ma_z = max5(o_z, c0_z, c1_z, c2_z, c3_z);
204 e = WarpZone_Find(mi, ma);
207 if(WarpZone_PlaneDist(e, o) < 0)
209 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
211 WarpZone_PlaneDist(e, c0),
212 WarpZone_PlaneDist(e, c1),
213 WarpZone_PlaneDist(e, c2),
214 WarpZone_PlaneDist(e, c3)
217 return e.warpzone_forward * -pd;
223 void WarpZone_FixPMove()
226 e = WarpZone_Find(pmove_org, pmove_org);
229 pmove_org = WarpZone_TransformOrigin(e, pmove_org);
230 input_angles = WarpZone_TransformVAngles(e, input_angles);
235 var float autocvar_cl_rollkillspeed = 10;
237 void WarpZone_FixView()
240 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
243 org = R_SetView3fv(VF_ORIGIN);
244 ang = R_SetView3fv(VF_ANGLES);
246 e = WarpZone_Find(org, org);
249 org = WarpZone_TransformOrigin(e, org);
250 ang = WarpZone_TransformVAngles(e, ang);
251 WarpZone_View_Inside();
254 WarpZone_View_Outside();
258 if(autocvar_cl_rollkillspeed)
259 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
263 rick = R_SetView(VF_CL_VIEWANGLES_Z);
265 R_SetView(VF_CL_VIEWANGLES_Z, rick);
270 R_SetView(VF_ORIGIN, org);
271 R_SetView(VF_ANGLES, ang);
273 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
274 corner0 = cs_unproject('0 0 0' + nearclip);
275 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
276 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
277 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
278 o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
280 R_SetView(VF_ORIGIN, org + o);
287 void WarpZone_Shutdown()
289 WarpZone_View_Outside();