1 void WarpZone_Read(float isnew)
3 ++warpzone_warpzones_exist;
7 self.enemy.classname = "warpzone_from";
9 self.classname = "trigger_warpzone";
11 self.warpzone_isboxy = ReadByte();
12 self.origin_x = ReadCoord();
13 self.origin_y = ReadCoord();
14 self.origin_z = ReadCoord();
15 self.modelindex = ReadShort();
16 self.mins_x = ReadCoord();
17 self.mins_y = ReadCoord();
18 self.mins_z = ReadCoord();
19 self.maxs_x = ReadCoord();
20 self.maxs_y = ReadCoord();
21 self.maxs_z = ReadCoord();
22 self.scale = ReadByte() / 16;
23 self.enemy.oldorigin_x = ReadCoord();
24 self.enemy.oldorigin_y = ReadCoord();
25 self.enemy.oldorigin_z = ReadCoord();
26 self.enemy.avelocity_x = ReadCoord();
27 self.enemy.avelocity_y = ReadCoord();
28 self.enemy.avelocity_z = ReadCoord();
29 self.oldorigin_x = ReadCoord();
30 self.oldorigin_y = ReadCoord();
31 self.oldorigin_z = ReadCoord();
32 self.avelocity_x = ReadCoord();
33 self.avelocity_y = ReadCoord();
34 self.avelocity_z = ReadCoord();
37 WarpZone_SetUp(self, self.enemy.oldorigin, self.enemy.avelocity, self.oldorigin, self.avelocity);
39 // engine currently wants this
40 self.drawmask = MASK_NORMAL;
43 //setmodel(self, self.model);
44 setorigin(self, self.origin);
45 setsize(self, self.mins, self.maxs);
48 void WarpZone_Camera_Read(float isnew)
50 ++warpzone_cameras_exist;
51 self.classname = "func_warpzone_camera";
52 self.origin_x = ReadCoord();
53 self.origin_y = ReadCoord();
54 self.origin_z = ReadCoord();
55 self.modelindex = ReadShort();
56 self.mins_x = ReadCoord();
57 self.mins_y = ReadCoord();
58 self.mins_z = ReadCoord();
59 self.maxs_x = ReadCoord();
60 self.maxs_y = ReadCoord();
61 self.maxs_z = ReadCoord();
62 self.scale = ReadByte() / 16;
63 self.oldorigin_x = ReadCoord();
64 self.oldorigin_y = ReadCoord();
65 self.oldorigin_z = ReadCoord();
66 self.avelocity_x = ReadCoord();
67 self.avelocity_y = ReadCoord();
68 self.avelocity_z = ReadCoord();
71 WarpZone_Camera_SetUp(self, self.oldorigin, self.avelocity);
73 // engine currently wants this
74 self.drawmask = MASK_NORMAL;
77 //setmodel(self, self.model);
78 setorigin(self, self.origin);
79 setsize(self, self.mins, self.maxs);
82 float warpzone_fixingview;
83 float warpzone_fixingview_drawexteriormodel;
84 //float warpzone_fixingview_sidespeed;
85 //float warpzone_fixingview_forwardspeed;
86 void WarpZone_Inside()
88 if(warpzone_fixingview)
90 warpzone_fixingview = 1;
91 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
92 //warpzone_fixingview_sidespeed = cvar("cl_sidespeed");
93 //warpzone_fixingview_forwardspeed = cvar("cl_forwardspeed");
94 cvar_set("r_drawexteriormodel", "0");
95 //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed / 100)); // just keep a bit of it in case player gets stuck
96 //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed / 100)); // just keep a bit of it in case player gets stuck
99 void WarpZone_Outside()
101 if(!warpzone_fixingview)
103 warpzone_fixingview = 0;
104 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
105 //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed));
106 //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed));
109 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
111 float nearclipdistance;
116 mi_x = min5(o_x, c0_x, c1_x, c2_x, c3_x);
117 ma_x = max5(o_x, c0_x, c1_x, c2_x, c3_x);
118 mi_y = min5(o_y, c0_y, c1_y, c2_y, c3_y);
119 ma_y = max5(o_y, c0_y, c1_y, c2_y, c3_y);
120 mi_z = min5(o_z, c0_z, c1_z, c2_z, c3_z);
121 ma_z = max5(o_z, c0_z, c1_z, c2_z, c3_z);
123 e = WarpZone_Find(mi, ma);
126 if(WarpZone_PlaneDist(e, o) < 0)
128 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
130 WarpZone_PlaneDist(e, c0),
131 WarpZone_PlaneDist(e, c1),
132 WarpZone_PlaneDist(e, c2),
133 WarpZone_PlaneDist(e, c3)
136 return e.warpzone_forward * -pd;
142 float warpzone_saved;
143 vector warpzone_saved_origin;
144 vector warpzone_saved_angles;
145 vector warpzone_saved_cl_viewangles;
147 var float autocvar_cl_rollkillspeed = 10;
149 void WarpZone_FixView()
154 vector corner0, corner1, corner2, corner3, nearclip;
157 warpzone_saved_origin = warpzone_fixview_origin;
158 warpzone_saved_angles = warpzone_fixview_angles;
159 warpzone_saved_cl_viewangles = warpzone_fixview_cl_viewangles;
161 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
162 corner0 = cs_unproject('0 0 0' + nearclip);
163 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
164 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
165 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
168 if(warpzone_fixview_angles_z != 0 || warpzone_fixview_cl_viewangles_z != 0)
170 if(autocvar_cl_rollkillspeed)
171 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
174 warpzone_fixview_angles_z *= f;
175 warpzone_fixview_cl_viewangles_z *= f;
176 warpzone_saved_angles_z *= f; // PERMANENTLY apply that change!
177 warpzone_saved_cl_viewangles_z *= f; // PERMANENTLY apply that change!
179 R_SetView(VF_CL_VIEWANGLES_Z, warpzone_fixview_angles_z);
183 e = WarpZone_Find(warpzone_fixview_origin, warpzone_fixview_origin);
187 warpzone_fixview_origin = WarpZone_TransformOrigin(e, warpzone_fixview_origin);
188 corner0 = WarpZone_TransformOrigin(e, corner0);
189 corner1 = WarpZone_TransformOrigin(e, corner1);
190 corner2 = WarpZone_TransformOrigin(e, corner2);
191 corner3 = WarpZone_TransformOrigin(e, corner3);
192 warpzone_fixview_angles = WarpZone_TransformVAngles(e, warpzone_fixview_angles);
193 warpzone_fixview_cl_viewangles = WarpZone_TransformVAngles(e, warpzone_fixview_cl_viewangles);
199 // if we are near any warpzone planes - MOVE AWAY (work around nearclip)
200 o = WarpZone_FixNearClip(warpzone_fixview_origin, corner0, corner1, corner2, corner3);
204 warpzone_fixview_origin += o;
207 if(warpzone_saved == 1)
209 R_SetView(VF_ORIGIN, warpzone_fixview_origin);
210 R_SetView(VF_ANGLES, warpzone_fixview_cl_viewangles);
213 void WarpZone_UnFixView()
217 warpzone_fixview_origin = warpzone_saved_origin;
218 warpzone_fixview_angles = warpzone_saved_angles;
219 warpzone_fixview_cl_viewangles = warpzone_saved_cl_viewangles;
220 R_SetView(VF_ORIGIN, warpzone_fixview_origin);
221 R_SetView(VF_ANGLES, warpzone_fixview_angles);
222 R_SetView(VF_CL_VIEWANGLES, warpzone_fixview_cl_viewangles);
230 void WarpZone_Shutdown()