5 #include <client/autocvars.qh>
6 #include <lib/csqcmodel/cl_model.qh>
11 void WarpZone_Fade_PreDraw(entity this)
14 org = getpropertyvec(VF_ORIGIN);
15 if(!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones
17 else if(this.warpzone_fadestart)
18 this.alpha = bound(0, (this.warpzone_fadeend - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.warpzone_fadeend - this.warpzone_fadestart), 1);
21 //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
25 this.drawmask = MASK_NORMAL;
28 void WarpZone_Touch(entity this, entity toucher);
29 NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew)
31 warpzone_warpzones_exist = 1;
34 this.enemy = new(warpzone_from);
36 this.classname = "trigger_warpzone";
39 IL_PUSH(g_warpzones, this);
42 this.warpzone_isboxy = (f & 1);
45 this.origin = ReadVector();
48 this.origin = '0 0 0';
49 this.modelindex = ReadShort();
50 this.mins = ReadVector();
51 this.maxs = ReadVector();
52 this.scale = ReadByte() / 16;
53 this.enemy.oldorigin = ReadVector();
54 this.enemy.avelocity = ReadVector();
55 this.oldorigin = ReadVector();
56 this.avelocity = ReadVector();
60 this.warpzone_fadestart = ReadShort();
61 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
65 this.warpzone_fadestart = 0;
66 this.warpzone_fadeend = 0;
70 WarpZone_SetUp(this, this.enemy.oldorigin, this.enemy.avelocity, this.oldorigin, this.avelocity);
73 //setmodel(this, this.model);
74 setorigin(this, this.origin);
75 setsize(this, this.mins, this.maxs);
78 // engine currently wants this
79 setpredraw(this, WarpZone_Fade_PreDraw);
81 //settouch(this, WarpZone_Touch);
85 NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew)
87 warpzone_cameras_exist = 1;
88 this.classname = "func_warpzone_camera";
93 this.origin = ReadVector();
96 this.origin = '0 0 0';
97 this.modelindex = ReadShort();
98 this.mins = ReadVector();
99 this.maxs = ReadVector();
100 this.scale = ReadByte() / 16;
101 this.oldorigin = ReadVector();
102 this.avelocity = ReadVector();
106 this.warpzone_fadestart = ReadShort();
107 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
111 this.warpzone_fadestart = 0;
112 this.warpzone_fadeend = 0;
116 WarpZone_Camera_SetUp(this, this.oldorigin, this.avelocity);
118 // engine currently wants this
119 this.drawmask = MASK_NORMAL;
122 //setmodel(this, this.model);
123 setorigin(this, this.origin);
124 setsize(this, this.mins, this.maxs);
127 // engine currently wants this
128 setpredraw(this, WarpZone_Fade_PreDraw);
132 void CL_RotateMoves(vector ang) = #638;
133 NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew)
135 this.classname = "warpzone_teleported";
136 vector v = ReadVector();
139 this.warpzone_transform = v;
140 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(this, getpropertyvec(VF_CL_VIEWANGLES)));
141 if(checkextension("DP_CSQC_ROTATEMOVES"))
143 //CL_RotateMoves('0 90 0');
146 float warpzone_fixingview;
147 float warpzone_fixingview_drawexteriormodel;
149 void WarpZone_View_Outside()
151 if(!warpzone_fixingview)
153 warpzone_fixingview = 0;
154 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
157 void WarpZone_View_Inside()
159 if(autocvar_chase_active)
161 WarpZone_View_Outside();
164 if(warpzone_fixingview)
166 warpzone_fixingview = 1;
167 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
168 cvar_set("r_drawexteriormodel", "0");
171 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
177 mi.x = min(o.x, c0_x, c1_x, c2_x, c3_x);
178 ma.x = max(o.x, c0_x, c1_x, c2_x, c3_x);
179 mi.y = min(o.y, c0_y, c1_y, c2_y, c3_y);
180 ma.y = max(o.y, c0_y, c1_y, c2_y, c3_y);
181 mi.z = min(o.z, c0_z, c1_z, c2_z, c3_z);
182 ma.z = max(o.z, c0_z, c1_z, c2_z, c3_z);
184 e = WarpZone_Find(mi, ma);
187 if(WarpZone_PlaneDist(e, o) < 0)
189 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
191 WarpZone_PlaneDist(e, c0),
192 WarpZone_PlaneDist(e, c1),
193 WarpZone_PlaneDist(e, c2),
194 WarpZone_PlaneDist(e, c3)
197 return e.warpzone_forward * -pd;
203 void WarpZone_FixPMove()
205 entity e = WarpZone_Find(pmove_org, pmove_org);
208 pmove_org = WarpZone_TransformOrigin(e, pmove_org);
209 input_angles = WarpZone_TransformVAngles(e, input_angles);
214 float autocvar_cl_rollkillspeed = 10;
216 void WarpZone_FixView()
219 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
221 warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
222 warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
224 e = WarpZone_Find(org, org);
227 org = WarpZone_TransformOrigin(e, org);
228 ang = WarpZone_TransformVAngles(e, ang);
229 WarpZone_View_Inside();
232 WarpZone_View_Outside();
237 static float rollkill;
238 if (STAT(HEALTH) > 0 || STAT(HEALTH) == -666 || STAT(HEALTH) == -2342)
241 // reset roll when passing through a warpzone that change player's roll angle
242 if(autocvar_cl_rollkillspeed)
243 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
250 // roll the view when killed (v_deathtilt)
251 if(autocvar_cl_rollkillspeed)
253 rollkill += frametime * autocvar_cl_rollkillspeed;
254 f = min(1, rollkill);
260 rick = getproperty(VF_CL_VIEWANGLES_Z);
262 setproperty(VF_CL_VIEWANGLES_Z, rick);
266 setproperty(VF_ORIGIN, org);
267 setproperty(VF_ANGLES, ang);
269 nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
270 corner0 = cs_unproject('0 0 0' + nearclip);
271 corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
272 corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
273 corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
274 o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
276 setproperty(VF_ORIGIN, org + o);
279 void WarpZone_Shutdown()
281 WarpZone_View_Outside();