1 void WarpZone_Read(float isnew)
6 self.enemy.classname = "warpzone_from";
8 self.classname = "trigger_warpzone";
9 self.origin_x = ReadCoord();
10 self.origin_y = ReadCoord();
11 self.origin_z = ReadCoord();
12 self.modelindex = ReadShort();
13 self.mins_x = ReadCoord();
14 self.mins_y = ReadCoord();
15 self.mins_z = ReadCoord();
16 self.maxs_x = ReadCoord();
17 self.maxs_y = ReadCoord();
18 self.maxs_z = ReadCoord();
19 self.scale = ReadByte() / 16;
20 self.enemy.oldorigin_x = ReadCoord();
21 self.enemy.oldorigin_y = ReadCoord();
22 self.enemy.oldorigin_z = ReadCoord();
23 self.enemy.avelocity_x = ReadCoord();
24 self.enemy.avelocity_y = ReadCoord();
25 self.enemy.avelocity_z = ReadCoord();
26 self.oldorigin_x = ReadCoord();
27 self.oldorigin_y = ReadCoord();
28 self.oldorigin_z = ReadCoord();
29 self.avelocity_x = ReadCoord();
30 self.avelocity_y = ReadCoord();
31 self.avelocity_z = ReadCoord();
34 WarpZone_SetUp(self, self.enemy.oldorigin, self.enemy.avelocity, self.oldorigin, self.avelocity);
36 // engine currently wants this
37 self.drawmask = MASK_NORMAL;
40 //setmodel(self, self.model);
41 setorigin(self, self.origin);
42 setsize(self, self.mins, self.maxs);
45 void WarpZone_Camera_Read(float isnew)
47 self.classname = "func_warpzone_camera";
48 self.origin_x = ReadCoord();
49 self.origin_y = ReadCoord();
50 self.origin_z = ReadCoord();
51 self.modelindex = ReadShort();
52 self.mins_x = ReadCoord();
53 self.mins_y = ReadCoord();
54 self.mins_z = ReadCoord();
55 self.maxs_x = ReadCoord();
56 self.maxs_y = ReadCoord();
57 self.maxs_z = ReadCoord();
58 self.scale = ReadByte() / 16;
59 self.oldorigin_x = ReadCoord();
60 self.oldorigin_y = ReadCoord();
61 self.oldorigin_z = ReadCoord();
62 self.avelocity_x = ReadCoord();
63 self.avelocity_y = ReadCoord();
64 self.avelocity_z = ReadCoord();
67 WarpZone_Camera_SetUp(self, self.oldorigin, self.avelocity);
69 // engine currently wants this
70 self.drawmask = MASK_NORMAL;
73 //setmodel(self, self.model);
74 setorigin(self, self.origin);
75 setsize(self, self.mins, self.maxs);
78 float warpzone_fixingview;
79 float warpzone_fixingview_drawexteriormodel;
80 //float warpzone_fixingview_sidespeed;
81 //float warpzone_fixingview_forwardspeed;
82 void WarpZone_Inside()
84 if(warpzone_fixingview)
86 warpzone_fixingview = 1;
87 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
88 //warpzone_fixingview_sidespeed = cvar("cl_sidespeed");
89 //warpzone_fixingview_forwardspeed = cvar("cl_forwardspeed");
90 cvar_set("r_drawexteriormodel", "0");
91 //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed / 100)); // just keep a bit of it in case player gets stuck
92 //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed / 100)); // just keep a bit of it in case player gets stuck
95 void WarpZone_Outside()
97 if(!warpzone_fixingview)
99 warpzone_fixingview = 0;
100 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
101 //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed));
102 //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed));
105 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
107 float nearclipdistance;
112 mi_x = min5(o_x, c0_x, c1_x, c2_x, c3_x);
113 ma_x = max5(o_x, c0_x, c1_x, c2_x, c3_x);
114 mi_y = min5(o_y, c0_y, c1_y, c2_y, c3_y);
115 ma_y = max5(o_y, c0_y, c1_y, c2_y, c3_y);
116 mi_z = min5(o_z, c0_z, c1_z, c2_z, c3_z);
117 ma_z = max5(o_z, c0_z, c1_z, c2_z, c3_z);
119 e = WarpZone_Find(mi, ma);
122 if(WarpZone_PlaneDist(e, o) < 0)
124 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
126 WarpZone_PlaneDist(e, c0),
127 WarpZone_PlaneDist(e, c1),
128 WarpZone_PlaneDist(e, c2),
129 WarpZone_PlaneDist(e, c3)
132 return e.warpzone_forward * -pd;
138 float warpzone_saved;
139 vector warpzone_saved_origin;
140 vector warpzone_saved_angles;
141 vector warpzone_saved_cl_viewangles;
143 var float autocvar_cl_rollkillspeed = 10;
145 void WarpZone_FixView()
150 vector corner0, corner1, corner2, corner3, nearclip;
153 warpzone_saved_origin = warpzone_fixview_origin;
154 warpzone_saved_angles = warpzone_fixview_angles;
155 warpzone_saved_cl_viewangles = warpzone_fixview_cl_viewangles;
157 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
158 corner0 = cs_unproject('0 0 0' + nearclip);
159 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
160 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
161 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
164 if(warpzone_fixview_angles_z != 0 || warpzone_fixview_cl_viewangles_z != 0)
166 if(autocvar_cl_rollkillspeed)
167 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
170 warpzone_fixview_angles_z *= f;
171 warpzone_fixview_cl_viewangles_z *= f;
172 warpzone_saved_angles_z *= f; // PERMANENTLY apply that change!
173 warpzone_saved_cl_viewangles_z *= f; // PERMANENTLY apply that change!
175 R_SetView(VF_CL_VIEWANGLES_Z, warpzone_fixview_angles_z);
179 e = WarpZone_Find(warpzone_fixview_origin, warpzone_fixview_origin);
183 warpzone_fixview_origin = WarpZone_TransformOrigin(e, warpzone_fixview_origin);
184 corner0 = WarpZone_TransformOrigin(e, corner0);
185 corner1 = WarpZone_TransformOrigin(e, corner1);
186 corner2 = WarpZone_TransformOrigin(e, corner2);
187 corner3 = WarpZone_TransformOrigin(e, corner3);
188 warpzone_fixview_angles = WarpZone_TransformVAngles(e, warpzone_fixview_angles);
189 warpzone_fixview_cl_viewangles = WarpZone_TransformVAngles(e, warpzone_fixview_cl_viewangles);
195 // if we are near any warpzone planes - MOVE AWAY (work around nearclip)
196 o = WarpZone_FixNearClip(warpzone_fixview_origin, corner0, corner1, corner2, corner3);
200 warpzone_fixview_origin += o;
203 if(warpzone_saved == 1)
205 R_SetView(VF_ORIGIN, warpzone_fixview_origin);
206 R_SetView(VF_ANGLES, warpzone_fixview_cl_viewangles);
209 void WarpZone_UnFixView()
213 warpzone_fixview_origin = warpzone_saved_origin;
214 warpzone_fixview_angles = warpzone_saved_angles;
215 warpzone_fixview_cl_viewangles = warpzone_saved_cl_viewangles;
216 R_SetView(VF_ORIGIN, warpzone_fixview_origin);
217 R_SetView(VF_ANGLES, warpzone_fixview_angles);
218 R_SetView(VF_CL_VIEWANGLES, warpzone_fixview_cl_viewangles);
226 void WarpZone_Shutdown()