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)
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 self.predraw = WarpZone_Fade_PreDraw;
85 void WarpZone_Camera_Read(float isnew)
88 warpzone_cameras_exist = 1;
89 self.classname = "func_warpzone_camera";
94 self.origin_x = ReadCoord();
95 self.origin_y = ReadCoord();
96 self.origin_z = ReadCoord();
99 self.origin = '0 0 0';
100 self.modelindex = ReadShort();
101 self.mins_x = ReadCoord();
102 self.mins_y = ReadCoord();
103 self.mins_z = ReadCoord();
104 self.maxs_x = ReadCoord();
105 self.maxs_y = ReadCoord();
106 self.maxs_z = ReadCoord();
107 self.scale = ReadByte() / 16;
108 self.oldorigin_x = ReadCoord();
109 self.oldorigin_y = ReadCoord();
110 self.oldorigin_z = ReadCoord();
111 self.avelocity_x = ReadCoord();
112 self.avelocity_y = ReadCoord();
113 self.avelocity_z = ReadCoord();
117 self.warpzone_fadestart = ReadShort();
118 self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort());
122 self.warpzone_fadestart = 0;
123 self.warpzone_fadeend = 0;
127 WarpZone_Camera_SetUp(self, self.oldorigin, self.avelocity);
129 // engine currently wants this
130 self.drawmask = MASK_NORMAL;
133 //setmodel(self, self.model);
134 setorigin(self, self.origin);
135 setsize(self, self.mins, self.maxs);
138 // engine currently wants this
139 self.predraw = WarpZone_Fade_PreDraw;
142 void CL_RotateMoves(vector ang) = #638;
143 void WarpZone_Teleported_Read(float isnew)
146 self.classname = "warpzone_teleported";
152 self.warpzone_transform = v;
153 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(self, getpropertyvec(VF_CL_VIEWANGLES)));
154 if(checkextension("DP_CSQC_ROTATEMOVES"))
156 //CL_RotateMoves('0 90 0');
159 float warpzone_fixingview;
160 float warpzone_fixingview_drawexteriormodel;
161 float autocvar_chase_active;
163 void WarpZone_View_Outside()
165 if(!warpzone_fixingview)
167 warpzone_fixingview = 0;
168 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
171 void WarpZone_View_Inside()
173 if(autocvar_chase_active)
175 WarpZone_View_Outside();
178 if(warpzone_fixingview)
180 warpzone_fixingview = 1;
181 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
182 cvar_set("r_drawexteriormodel", "0");
185 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
191 mi_x = min(o_x, c0_x, c1_x, c2_x, c3_x);
192 ma_x = max(o_x, c0_x, c1_x, c2_x, c3_x);
193 mi_y = min(o_y, c0_y, c1_y, c2_y, c3_y);
194 ma_y = max(o_y, c0_y, c1_y, c2_y, c3_y);
195 mi_z = min(o_z, c0_z, c1_z, c2_z, c3_z);
196 ma_z = max(o_z, c0_z, c1_z, c2_z, c3_z);
198 e = WarpZone_Find(mi, ma);
201 if(WarpZone_PlaneDist(e, o) < 0)
203 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
205 WarpZone_PlaneDist(e, c0),
206 WarpZone_PlaneDist(e, c1),
207 WarpZone_PlaneDist(e, c2),
208 WarpZone_PlaneDist(e, c3)
211 return e.warpzone_forward * -pd;
217 void WarpZone_FixPMove()
220 e = WarpZone_Find(pmove_org, pmove_org);
223 pmove_org = WarpZone_TransformOrigin(e, pmove_org);
224 input_angles = WarpZone_TransformVAngles(e, input_angles);
229 var float autocvar_cl_rollkillspeed = 10;
231 void WarpZone_FixView()
234 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
237 warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
238 warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
240 e = WarpZone_Find(org, org);
243 org = WarpZone_TransformOrigin(e, org);
244 ang = WarpZone_TransformVAngles(e, ang);
245 WarpZone_View_Inside();
248 WarpZone_View_Outside();
252 if(autocvar_cl_rollkillspeed)
253 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
257 rick = getproperty(VF_CL_VIEWANGLES_Z);
259 setproperty(VF_CL_VIEWANGLES_Z, rick);
263 setproperty(VF_ORIGIN, org);
264 setproperty(VF_ANGLES, ang);
266 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
267 corner0 = cs_unproject('0 0 0' + nearclip);
268 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
269 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
270 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
271 o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
273 setproperty(VF_ORIGIN, org + o);
280 void WarpZone_Shutdown()
282 WarpZone_View_Outside();