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 if(!warpzone_warpzones_exist)
32 cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has warpzones
33 warpzone_warpzones_exist = 1;
36 this.enemy = new(warpzone_from);
38 this.classname = "trigger_warpzone";
41 IL_PUSH(g_warpzones, this);
44 this.warpzone_isboxy = (f & 1);
47 this.origin = ReadVector();
50 this.origin = '0 0 0';
51 this.modelindex = ReadShort();
52 this.mins = ReadVector();
53 this.maxs = ReadVector();
54 this.scale = ReadByte() / 16;
55 this.enemy.oldorigin = ReadVector();
56 this.enemy.avelocity = ReadVector();
57 this.oldorigin = ReadVector();
58 this.avelocity = ReadVector();
62 this.warpzone_fadestart = ReadShort();
63 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
67 this.warpzone_fadestart = 0;
68 this.warpzone_fadeend = 0;
72 WarpZone_SetUp(this, this.enemy.oldorigin, this.enemy.avelocity, this.oldorigin, this.avelocity);
75 //setmodel(this, this.model);
76 setorigin(this, this.origin);
77 setsize(this, this.mins, this.maxs);
80 // engine currently wants this
81 setpredraw(this, WarpZone_Fade_PreDraw);
83 //settouch(this, WarpZone_Touch);
87 NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew)
89 if(!warpzone_cameras_exist)
90 cvar_settemp("r_water", "1"); // HACK for DarkPlaces: always enable reflections when a map has cameras
91 warpzone_cameras_exist = 1;
92 this.classname = "func_warpzone_camera";
97 this.origin = ReadVector();
100 this.origin = '0 0 0';
101 this.modelindex = ReadShort();
102 this.mins = ReadVector();
103 this.maxs = ReadVector();
104 this.scale = ReadByte() / 16;
105 this.oldorigin = ReadVector();
106 this.avelocity = ReadVector();
110 this.warpzone_fadestart = ReadShort();
111 this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort());
115 this.warpzone_fadestart = 0;
116 this.warpzone_fadeend = 0;
120 WarpZone_Camera_SetUp(this, this.oldorigin, this.avelocity);
122 // engine currently wants this
123 this.drawmask = MASK_NORMAL;
126 //setmodel(this, this.model);
127 setorigin(this, this.origin);
128 setsize(this, this.mins, this.maxs);
131 // engine currently wants this
132 setpredraw(this, WarpZone_Fade_PreDraw);
136 void CL_RotateMoves(vector ang) = #638;
137 NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew)
139 this.classname = "warpzone_teleported";
140 vector v = ReadVector();
143 this.warpzone_transform = v;
144 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(this, getpropertyvec(VF_CL_VIEWANGLES)));
145 if(checkextension("DP_CSQC_ROTATEMOVES"))
147 //CL_RotateMoves('0 90 0');
150 float warpzone_fixingview;
151 float warpzone_fixingview_drawexteriormodel;
153 void WarpZone_View_Outside()
155 if(!warpzone_fixingview)
157 warpzone_fixingview = 0;
158 cvar_set("r_drawexteriormodel", ftos(warpzone_fixingview_drawexteriormodel));
161 void WarpZone_View_Inside()
163 if(autocvar_chase_active)
165 WarpZone_View_Outside();
168 if(warpzone_fixingview)
170 warpzone_fixingview = 1;
171 warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
172 cvar_set("r_drawexteriormodel", "0");
175 vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
181 mi.x = min(o.x, c0_x, c1_x, c2_x, c3_x);
182 ma.x = max(o.x, c0_x, c1_x, c2_x, c3_x);
183 mi.y = min(o.y, c0_y, c1_y, c2_y, c3_y);
184 ma.y = max(o.y, c0_y, c1_y, c2_y, c3_y);
185 mi.z = min(o.z, c0_z, c1_z, c2_z, c3_z);
186 ma.z = max(o.z, c0_z, c1_z, c2_z, c3_z);
188 e = WarpZone_Find(mi, ma);
191 if(WarpZone_PlaneDist(e, o) < 0)
193 // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
195 WarpZone_PlaneDist(e, c0),
196 WarpZone_PlaneDist(e, c1),
197 WarpZone_PlaneDist(e, c2),
198 WarpZone_PlaneDist(e, c3)
201 return e.warpzone_forward * -pd;
207 void WarpZone_FixPMove()
209 entity e = WarpZone_Find(pmove_org, pmove_org);
212 pmove_org = WarpZone_TransformOrigin(e, pmove_org);
213 input_angles = WarpZone_TransformVAngles(e, input_angles);
218 float autocvar_cl_rollkillspeed = 10;
220 void WarpZone_FixView()
223 vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
225 warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
226 warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
228 e = WarpZone_Find(org, org);
231 org = WarpZone_TransformOrigin(e, org);
232 ang = WarpZone_TransformVAngles(e, ang);
233 WarpZone_View_Inside();
236 WarpZone_View_Outside();
241 static float rollkill;
242 if (STAT(HEALTH) > 0 || STAT(HEALTH) == -666 || STAT(HEALTH) == -2342)
245 // reset roll when passing through a warpzone that change player's roll angle
246 if(autocvar_cl_rollkillspeed)
247 f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
254 // roll the view when killed (v_deathtilt)
255 if(autocvar_cl_rollkillspeed)
257 rollkill += frametime * autocvar_cl_rollkillspeed;
258 f = min(1, rollkill);
264 rick = getproperty(VF_CL_VIEWANGLES_Z);
266 setproperty(VF_CL_VIEWANGLES_Z, rick);
270 setproperty(VF_ORIGIN, org);
271 setproperty(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 setproperty(VF_ORIGIN, org + o);
283 void WarpZone_Shutdown()
285 WarpZone_View_Outside();