1 vector angles_held[24];
\r
2 void Net_ReadHoldAngles()
\r
8 angles_held_status[wpn] = ReadByte();
\r
9 if(angles_held_status[wpn])
\r
14 angles_held[wpn] = v;
\r
19 vector polyline[16];
\r
20 float trace_dphitcontents;
\r
21 float Q3SURFACEFLAG_SLICK = 2; // low friction surface
\r
22 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
\r
25 vector p, dir, ang, q, nextdir;
\r
26 float idx, portal_number, portal1_idx;
\r
28 if(activeweapon != WEP_PORTO)
\r
33 if(angles_held_status[WEP_PORTO-1])
\r
35 makevectors(angles_held[WEP_PORTO-1]);
\r
49 traceline(p, p + 65536 * dir, TRUE, world);
\r
50 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
\r
52 nextdir = dir - 2 * (dir * trace_plane_normal) * trace_plane_normal; // mirror dir at trace_plane_normal
\r
58 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
\r
61 ang = vectoangles2(trace_plane_normal, dir);
\r
64 if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
\r
66 if(portal_number == 1)
\r
68 if(portal_number >= 2)
\r
74 p = polyline[idx-2];
\r
75 q = polyline[idx-1];
\r
77 p = p - view_up * 16;
\r
78 if(idx-1 >= portal1_idx)
\r
80 Draw_CylindricLine(p, q, 4, "", 1, 0, '0 0 1', 0.5, DRAWFLAG_NORMAL);
\r
84 Draw_CylindricLine(p, q, 4, "", 1, 0, '1 0 0', 0.5, DRAWFLAG_NORMAL);
\r
90 float DPCONTENTS_SOLID = 1; // hit a bmodel, not a bounding box
\r
91 float DPCONTENTS_BODY = 32; // hit a bounding box, not a bmodel
\r
95 porto.classname = "porto";
\r
96 porto.draw = Porto_Draw;
\r
97 porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
\r
104 return sin(x) / cos(x);
\r
106 float atan2(float y, float x)
\r
109 v = '1 0 0' * x + '0 1 0' * y;
\r
110 v = vectoangles(v);
\r
111 return v_y * 0.01745329251994329576;
\r
114 vector GetCurrentFov(float fov)
\r
116 float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
\r
118 zoomsensitivity = cvar("cl_zoomsensitivity");
\r
119 zoomfactor = cvar("cl_zoomfactor");
\r
120 if(zoomfactor < 1 || zoomfactor > 16)
\r
122 zoomspeed = cvar("cl_zoomspeed");
\r
124 if(zoomspeed < 0.5 || zoomspeed > 16)
\r
127 zoomdir = button_zoom;
\r
128 if(getstati(STAT_ACTIVEWEAPON) == WEP_NEX) // do NOT use switchweapon here
\r
129 zoomdir += button_attack2;
\r
130 if(spectatee_status > 0 || isdemo())
\r
132 if(spectatorbutton_zoom)
\r
133 zoomdir = 0 + !zoomdir;
\r
134 // do not even THINK about removing this 0
\r
135 // _I_ know what I am doing
\r
144 current_viewzoom = min(1, current_viewzoom + drawframetime);
\r
148 if(zoomspeed < 0) // instant zoom
\r
151 current_viewzoom = 1 / zoomfactor;
\r
153 current_viewzoom = 1;
\r
158 current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
\r
160 current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
\r
164 current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1);
\r
166 if(zoomsensitivity < 1)
\r
167 setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
\r
169 setsensitivityscale(1);
\r
171 float frustumx, frustumy, fovx, fovy;
\r
172 frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom;
\r
173 frustumx = frustumy * vid_width / vid_height / cvar("vid_pixelheight");
\r
174 fovx = atan2(frustumx, 1) / 0.00872664625997164788;
\r
175 fovy = atan2(frustumy, 1) / 0.00872664625997164788;
\r
177 return '1 0 0' * fovx + '0 1 0' * fovy;
\r
180 void CSQC_common_hud(void);
\r
182 void CSQC_kh_hud(void);
\r
183 void CSQC_ctf_hud(void);
\r
184 void PostInit(void);
\r
185 float Sbar_WouldDrawScoreboard ();
\r
186 float zoomscript_caught;
\r
187 void CSQC_UpdateView(void)
\r
192 WaypointSprite_Load();
\r
194 // Render the Scene
\r
195 view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
\r
196 view_angles = input_angles;
\r
197 makevectors(view_angles);
\r
198 view_forward = v_forward;
\r
199 view_right = v_right;
\r
203 if(cs_project_is_b0rked)
\r
206 vid_width = cvar("vid_width");
\r
207 vid_height = cvar("vid_height");
\r
212 // THIS IS BROKEN if you had just shot (kicktime)
\r
214 v = cs_project(view_origin + 1024 * view_forward);
\r
215 vid_width = floor(v_x * 2 + 0.5);
\r
216 vid_height = floor(v_y * 2 + 0.5);
\r
222 drawframetime = max(0.000001, time - drawtime);
\r
225 // watch for gametype changes here...
\r
226 // in ParseStuffCMD the cmd isn't executed yet :/
\r
227 // might even be better to add the gametype to TE_CSQC_INIT...?
\r
232 if(button_zoom || fov <= 59.5)
\r
234 if(!zoomscript_caught)
\r
236 localcmd("+button4\n");
\r
237 zoomscript_caught = 1;
\r
238 ignore_plus_zoom += 1;
\r
243 if(zoomscript_caught)
\r
245 localcmd("-button4\n");
\r
246 zoomscript_caught = 0;
\r
247 ignore_minus_zoom += 1;
\r
251 sbar_alpha_fg = cvar("sbar_alpha_fg" );
\r
252 sbar_hudselector = cvar("sbar_hudselector");
\r
253 activeweapon = getstati(STAT_SWITCHWEAPON);
\r
254 teamplay = cvar("teamplay");
\r
256 if(last_weapon != activeweapon) {
\r
258 last_weapon = activeweapon;
\r
261 // ALWAYS Clear Current Scene First
\r
264 // Assign Standard Viewflags
\r
265 // Draw the World (and sky)
\r
266 R_SetView(VF_DRAWWORLD, 1);
\r
268 R_SetView(VF_FOV, GetCurrentFov(fov));
\r
270 // Draw the Crosshair
\r
271 float scoreboard_active;
\r
272 scoreboard_active = Sbar_WouldDrawScoreboard();
\r
273 R_SetView(VF_DRAWCROSSHAIR, !scoreboard_active);
\r
275 // Draw the Engine Status Bar (the default Quake HUD)
\r
276 R_SetView(VF_DRAWENGINESBAR, 0);
\r
278 // Set the console size vars
\r
279 vid_conwidth = cvar("vid_conwidth");
\r
280 vid_conheight = cvar("vid_conheight");
\r
282 // fetch this one only once per frame
\r
283 sbar_showbinds = cvar("sbar_showbinds");
\r
284 sbar_showbinds_limit = cvar("sbar_showbinds_limit");
\r
286 // Update the mouse position
\r
288 mousepos_x = vid_conwidth;
\r
289 mousepos_y = vid_conheight;
\r
290 mousepos = mousepos*0.5 + getmousepos();
\r
293 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
\r
296 for(self = world; (self = nextent(self)); )
\r
302 // now switch to 2D drawing mode by calling a 2D drawing function
\r
303 // then polygon drawing will draw as 2D stuff, and NOT get queued until the
\r
304 // next R_RenderScene call
\r
305 drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);
\r
307 // Draw the mouse cursor
\r
308 // NOTE: drawpic must happen after R_RenderScene for some reason
\r
309 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
\r
310 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
\r
311 //self = edict_num(player_localnum);
\r
312 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
\r
313 //drawstring('0 8', strcat("ORG: ", vtos(self.origin), " state: ", ftos(self.ctf_state), " HP: ", ftos(self.health)), '8 8 0', '1 1 1', 1, 0);
\r
314 // as long as the ctf part isn't in, this is useless
\r
318 /*if(gametype == GAME_CTF)
\r
323 // draw 2D entities
\r
325 for(self = world; (self = nextent(self)); )
\r
331 if(gametype == GAME_ONSLAUGHT)
\r
333 if(cvar("cl_teamradar") >= 2)
\r
335 if(!scoreboard_active)
\r
340 //drawstring('0 0', minimapname, '8 8 0', '1 1 1', 1, 0);
\r
341 //drawsetcliparea(0,0,800,600);
\r
342 //drawresetcliparea();
\r
346 //if(cvar("cl_teamradar") >= 1) // TODO change it back to this
\r
347 if(cvar_string("cl_teamradar") != "0") // (so it is on by default)
\r
348 if(!scoreboard_active)
\r
353 if(cvar("r_letterbox") == 0)
\r
354 if(cvar("viewsize") < 120)
\r
359 void CSQC_common_hud(void)
\r
361 // Sbar_SortFrags(); done in Sbar_Draw
\r
365 // KeyHunt HUD by victim
\r
366 void CSQC_kh_hud(void)
\r
368 // HUD 0 has the weapons on the right hand side - temporarily shown when needed
\r
369 // HUD 1 has the weapons on the bottom - permanently
\r
371 // use the following two binds to check the icons move correctly
\r
372 // bind g "toggle sbar_flagstatus_right; echo Menu right $sbar_flagstatus_right" // move the icons
\r
373 // bind h "toggle sbar_hudselector; echo HUD $sbar_hudselector" // change the HUD
\r
375 float kh_keys, kh_keys_status, kh_teams_set;
\r
376 float kh_margin_x, kh_margin_y, kh_key_box;
\r
377 string kh_carrying, kh_outline;
\r
378 vector red_pos, blue_pos, yellow_pos, pink_pos, kh_size;
\r
379 vector red, blue, yellow, pink;
\r
381 kh_keys = getstati(STAT_KH_KEYS);
\r
382 kh_keys_status = kh_keys / 256;
\r
383 kh_teams_set = cvar("_teams_available"); // set in keyhunt.qc
\r
386 kh_margin_x = (cvar("sbar_flagstatus_right") * sbar_hudselector * (vid_conwidth - 67)) + 10;
\r
387 // sbar_flagstatus_right 0/1; sbar_hudselector 0/1; screen width - key width + margin
\r
389 red_pos_x = blue_pos_x = yellow_pos_x = pink_pos_x = kh_margin_x;
\r
393 pink_pos_y = kh_margin_y + 0; // top
\r
394 yellow_pos_y = kh_margin_y + kh_key_box;
\r
395 blue_pos_y = kh_margin_y + kh_key_box * 2;
\r
396 red_pos_y = kh_margin_y + kh_key_box * 3; //bottom
\r
403 kh_size = '0 0 0'; // don't resize the image
\r
405 kh_carrying = "gfx/sb_kh_full";
\r
406 kh_outline = "gfx/sb_kh_outline";
\r
408 // drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
\r
409 // vector position = '0 0'; // 'x y' 0 0 (the origin) is the top left. X 0 - 799, Y 0 - 599
\r
411 // vector size = '0 0'; // 'x y' changes the x & y dimensions. '0 0' gives the default pic size
\r
412 // vector rgb = '0 0 0'; // 'r g b' range 0 - 1
\r
414 if (kh_keys_status & 1) // red
\r
415 drawpic (red_pos, kh_carrying, kh_size, red, 0.2, 0); // show 20% alpha key
\r
417 drawpic (red_pos, kh_outline, kh_size, red, 0.4, 0); // show key outline 40% alpha
\r
420 drawpic (red_pos, kh_carrying, kh_size, red, 1.0, 0); // show solid key 100% alpha
\r
423 if (kh_keys_status & 2) // blue
\r
424 drawpic (blue_pos, kh_carrying, kh_size, blue, 0.2, 0);
\r
426 drawpic (blue_pos, kh_outline, kh_size, blue, 0.4, 0);
\r
429 drawpic (blue_pos, kh_carrying, kh_size, blue, 1.0, 0);
\r
432 if (kh_teams_set & 4) // yellow
\r
434 if (kh_keys_status & 4)
\r
435 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 0.2, 0);
\r
437 drawpic (yellow_pos, kh_outline, kh_size, yellow, 0.4, 0);
\r
440 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 1.0, 0);
\r
444 if (kh_teams_set & 8) // pink
\r
446 if (kh_keys_status & 8)
\r
447 drawpic (pink_pos, kh_carrying, kh_size, pink, 0.2, 0);
\r
449 drawpic (pink_pos, kh_outline, kh_size, pink, 0.4, 0);
\r
452 drawpic (pink_pos, kh_carrying, kh_size, pink, 1.0, 0);
\r