3 float trace_dphitcontents;
\r
4 float Q3SURFACEFLAG_SLICK = 2; // low friction surface
\r
5 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
\r
8 vector p, dir, ang, q, nextdir;
\r
9 float idx, portal_number, portal1_idx;
\r
11 if(activeweapon != WEP_PORTO)
\r
16 if(angles_held_status)
\r
18 makevectors(angles_held);
\r
32 traceline(p, p + 65536 * dir, TRUE, world);
\r
33 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
\r
35 nextdir = dir - 2 * (dir * trace_plane_normal) * trace_plane_normal; // mirror dir at trace_plane_normal
\r
41 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
\r
44 ang = vectoangles2(trace_plane_normal, dir);
\r
47 if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
\r
49 if(portal_number == 1)
\r
51 if(portal_number >= 2)
\r
57 p = polyline[idx-2];
\r
58 q = polyline[idx-1];
\r
60 p = p - view_up * 16;
\r
61 if(idx-1 >= portal1_idx)
\r
63 Draw_CylindricLine(p, q, 4, "", 1, 0, '0 0 1', 0.5, DRAWFLAG_NORMAL);
\r
67 Draw_CylindricLine(p, q, 4, "", 1, 0, '1 0 0', 0.5, DRAWFLAG_NORMAL);
\r
73 float DPCONTENTS_SOLID = 1; // hit a bmodel, not a bounding box
\r
74 float DPCONTENTS_BODY = 32; // hit a bounding box, not a bmodel
\r
78 porto.classname = "porto";
\r
79 porto.draw = Porto_Draw;
\r
80 porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
\r
87 return sin(x) / cos(x);
\r
89 float atan2(float y, float x)
\r
92 v = '1 0 0' * x + '0 1 0' * y;
\r
94 return v_y * 0.01745329251994329576;
\r
97 float camera_active;
\r
98 vector GetCurrentFov(float fov)
\r
100 float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
\r
102 zoomsensitivity = cvar("cl_zoomsensitivity");
\r
103 zoomfactor = cvar("cl_zoomfactor");
\r
104 if(zoomfactor < 1 || zoomfactor > 16)
\r
106 zoomspeed = cvar("cl_zoomspeed");
\r
108 if(zoomspeed < 0.5 || zoomspeed > 16)
\r
111 zoomdir = button_zoom;
\r
112 if(getstati(STAT_ACTIVEWEAPON) == WEP_NEX) // do NOT use switchweapon here
\r
113 zoomdir += button_attack2;
\r
114 if(spectatee_status > 0 || isdemo())
\r
116 if(spectatorbutton_zoom)
\r
117 zoomdir = 0 + !zoomdir;
\r
118 // do not even THINK about removing this 0
\r
119 // _I_ know what I am doing
\r
126 if(zoomin_effect || camera_active)
\r
128 current_viewzoom = min(1, current_viewzoom + drawframetime);
\r
132 if(zoomspeed < 0) // instant zoom
\r
135 current_viewzoom = 1 / zoomfactor;
\r
137 current_viewzoom = 1;
\r
142 current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
\r
144 current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
\r
148 if(almost_equals(current_viewzoom, 1))
\r
149 current_zoomfraction = 0;
\r
150 else if(almost_equals(current_viewzoom, 1/zoomfactor))
\r
151 current_zoomfraction = 1;
\r
153 current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1);
\r
155 if(zoomsensitivity < 1)
\r
156 setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
\r
158 setsensitivityscale(1);
\r
160 float frustumx, frustumy, fovx, fovy;
\r
161 frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom;
\r
162 frustumx = frustumy * vid_width / vid_height / vid_pixelheight;
\r
163 fovx = atan2(frustumx, 1) / 0.00872664625997164788;
\r
164 fovy = atan2(frustumy, 1) / 0.00872664625997164788;
\r
166 return '1 0 0' * fovx + '0 1 0' * fovy;
\r
169 void CSQC_common_hud(void);
\r
171 void CSQC_kh_hud(void);
\r
172 void CSQC_ctf_hud(void);
\r
173 void PostInit(void);
\r
174 float Sbar_WouldDrawScoreboard ();
\r
175 float zoomscript_caught;
\r
178 vector camera_offset, current_origin, mouse_angles, current_camera_offset, new_angles;
\r
179 void CSQC_UpdateView(float w, float h)
\r
184 vector v1, v2, delta;
\r
187 WaypointSprite_Load();
\r
189 ticrate = getstatf(STAT_SYS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
\r
191 // Render the Scene
\r
192 if(!intermission || !view_set)
\r
194 view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
\r
195 view_angles = input_angles;
\r
196 makevectors(view_angles);
\r
197 view_forward = v_forward;
\r
198 view_right = v_right;
\r
203 f = floor(cvar("v_flipped"));
\r
204 cvar_set("v_flipped", ftos(!f));
\r
205 v1 = cs_unproject('-100 -100 1000');
\r
206 cvar_set("v_flipped", ftos(f));
\r
207 v2 = cs_unproject('-100 -100 1000');
\r
211 // non-supporting engine
\r
212 vid_width = cvar("vid_width");
\r
213 vid_height = cvar("vid_height");
\r
217 // supporting engine
\r
223 if(time > blurtest_time0 && time < blurtest_time1)
\r
227 t = (time - blurtest_time0) / (blurtest_time1 - blurtest_time0);
\r
228 r = t * blurtest_radius;
\r
229 f = 1 / pow(t, blurtest_power) - 1;
\r
231 cvar_set("r_glsl_postprocess", "1");
\r
232 cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(r), " ", ftos(f), " 0 0"));
\r
236 cvar_set("r_glsl_postprocess", "0");
\r
237 cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
\r
243 drawframetime = max(0.000001, time - drawtime);
\r
246 // watch for gametype changes here...
\r
247 // in ParseStuffCMD the cmd isn't executed yet :/
\r
248 // might even be better to add the gametype to TE_CSQC_INIT...?
\r
253 if(button_zoom || fov <= 59.5)
\r
255 if(!zoomscript_caught)
\r
257 localcmd("+button4\n");
\r
258 zoomscript_caught = 1;
\r
259 ignore_plus_zoom += 1;
\r
264 if(zoomscript_caught)
\r
266 localcmd("-button4\n");
\r
267 zoomscript_caught = 0;
\r
268 ignore_minus_zoom += 1;
\r
272 sbar_alpha_fg = cvar("sbar_alpha_fg" );
\r
273 sbar_hudselector = cvar("sbar_hudselector");
\r
274 ColorTranslateMode = cvar("cl_stripcolorcodes");
\r
275 activeweapon = getstati(STAT_SWITCHWEAPON);
\r
276 f = cvar("teamplay");
\r
283 if(last_weapon != activeweapon) {
\r
285 last_weapon = activeweapon;
\r
288 // ALWAYS Clear Current Scene First
\r
291 // Assign Standard Viewflags
\r
292 // Draw the World (and sky)
\r
293 R_SetView(VF_DRAWWORLD, 1);
\r
295 R_SetView(VF_FOV, GetCurrentFov(fov));
\r
297 // Camera for demo playback
\r
298 if (cvar("chase_active") > 1 && cvar("cl_demo_mousegrab") && isdemo())
\r
300 float speed, attenuation;
\r
301 vector new_origin, m;
\r
304 camera_active = TRUE;
\r
306 if(cvar("camera_free"))
\r
307 speed = cvar("camera_speed_free");
\r
309 speed = cvar("camera_speed_chase");
\r
311 attenuation = cvar("camera_speed_attenuation");
\r
313 attenuation = 1 / max(1, attenuation);
\r
315 if( cvar("camera_reset") || !camera_mode )
\r
317 camera_offset = '0 0 0';
\r
318 new_angles = view_angles;
\r
319 camera_offset_z += 20;
\r
320 camera_offset_x += 20 * -cos(new_angles_y * DEG2RAD);
\r
321 camera_offset_y += 20 * -sin(new_angles_y * DEG2RAD);
\r
322 current_origin = view_origin;
\r
326 if( cvar("camera_roll") )
\r
327 mouse_angles_z += cvar("camera_roll") * cvar("camera_speed_roll");
\r
329 if(!cvar("camera_look_player"))
\r
331 m = getmousepos() * 0.1;
\r
332 if(vlen(m)>cvar("camera_mouse_treshold"))
\r
334 mouse_angles_x += m_y * cos(mouse_angles_z * DEG2RAD) + (m_x * sin(mouse_angles_z * DEG2RAD));
\r
335 mouse_angles_y -= m_x * cos(mouse_angles_z * DEG2RAD) + (m_y * -sin(mouse_angles_z * DEG2RAD));
\r
338 while (mouse_angles_x < -180)
\r
339 mouse_angles_x = mouse_angles_x + 360;
\r
340 while (mouse_angles_x > 180)
\r
341 mouse_angles_x = mouse_angles_x - 360;
\r
342 while (mouse_angles_y < -180)
\r
343 mouse_angles_y = mouse_angles_y + 360;
\r
344 while (mouse_angles_y > 180)
\r
345 mouse_angles_y = mouse_angles_y - 360;
\r
348 if( mouse_angles_y < -90 && new_angles_y > 0)
\r
350 if( mouse_angles_y > 90 && new_angles_y < -90)
\r
351 delta = '0 -360 0';
\r
353 new_angles += (mouse_angles - new_angles + delta) * attenuation;
\r
357 if( cvar("camera_direction_x") )
\r
359 camera_offset_x += cvar("camera_direction_x") * speed * cos(new_angles_y * DEG2RAD);
\r
360 camera_offset_y += cvar("camera_direction_x") * speed * sin(new_angles_y * DEG2RAD);
\r
361 if( cvar("camera_forward_follows") )
\r
362 camera_offset_z += cvar("camera_direction_x") * speed * -sin(new_angles_x * DEG2RAD);
\r
365 if( cvar("camera_direction_y") )
\r
367 camera_offset_y += cvar("camera_direction_y") * speed * cos(new_angles_y * DEG2RAD) * cos(new_angles_z * DEG2RAD);
\r
368 camera_offset_x += cvar("camera_direction_y") * speed * -sin(new_angles_y * DEG2RAD);
\r
369 camera_offset_z += cvar("camera_direction_y") * speed * sin(new_angles_z * DEG2RAD);
\r
372 if( cvar("camera_direction_z") )
\r
373 camera_offset_z += cvar("camera_direction_z") * speed * cos(new_angles_z * DEG2RAD);
\r
375 current_camera_offset += (camera_offset - current_camera_offset) * attenuation;
\r
378 if( cvar("camera_free") )
\r
380 if ( camera_mode == CAMERA_CHASE )
\r
382 current_camera_offset = current_origin + current_camera_offset;
\r
383 camera_offset = current_origin + camera_offset;
\r
386 camera_mode = CAMERA_FREE;
\r
387 new_origin = current_camera_offset;
\r
391 if ( camera_mode == CAMERA_FREE )
\r
393 current_origin = view_origin;
\r
394 camera_offset = camera_offset - current_origin;
\r
395 current_camera_offset = current_camera_offset - current_origin;
\r
398 camera_mode = CAMERA_CHASE;
\r
400 if(cvar("camera_chase_smoothly"))
\r
401 current_origin += (view_origin - current_origin) * attenuation;
\r
403 current_origin = view_origin;
\r
405 new_origin = current_origin + current_camera_offset;
\r
408 if(cvar("camera_look_player"))
\r
413 dir = normalize(view_origin - new_origin);
\r
414 n = mouse_angles_z;
\r
415 mouse_angles = vectoangles(dir);
\r
416 mouse_angles_x = mouse_angles_x * -1;
\r
417 mouse_angles_z = n;
\r
419 while (mouse_angles_x < -180)
\r
420 mouse_angles_x = mouse_angles_x + 360;
\r
421 while (mouse_angles_x > 180)
\r
422 mouse_angles_x = mouse_angles_x - 360;
\r
423 while (mouse_angles_y < -180)
\r
424 mouse_angles_y = mouse_angles_y + 360;
\r
425 while (mouse_angles_y > 180)
\r
426 mouse_angles_y = mouse_angles_y - 360;
\r
429 if(mouse_angles_y < -90 && new_angles_y > 0)
\r
431 if(mouse_angles_y > 90 && new_angles_y < -90)
\r
432 delta = '0 -360 0';
\r
434 n = 1 / max(1, cvar("camera_look_attenuation"));
\r
435 new_angles += (mouse_angles - new_angles + delta) * n;
\r
438 while (new_angles_x < -180)
\r
439 new_angles_x = new_angles_x + 360;
\r
440 while (new_angles_x > 180)
\r
441 new_angles_x = new_angles_x - 360;
\r
442 while (new_angles_y < -180)
\r
443 new_angles_y = new_angles_y + 360;
\r
444 while (new_angles_y > 180)
\r
445 new_angles_y = new_angles_y - 360;
\r
447 R_SetView(VF_ANGLES, new_angles);
\r
448 R_SetView(VF_ORIGIN, new_origin);
\r
453 camera_active = FALSE;
\r
456 // Draw the Crosshair
\r
457 float scoreboard_active;
\r
458 scoreboard_active = Sbar_WouldDrawScoreboard();
\r
459 R_SetView(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden
\r
461 // Draw the Engine Status Bar (the default Quake HUD)
\r
462 R_SetView(VF_DRAWENGINESBAR, 0);
\r
464 // Set the console size vars
\r
465 vid_conwidth = cvar("vid_conwidth");
\r
466 vid_conheight = cvar("vid_conheight");
\r
467 vid_pixelheight = cvar("vid_pixelheight");
\r
469 // fetch this one only once per frame
\r
470 sbar_showbinds = cvar("sbar_showbinds");
\r
471 sbar_showbinds_limit = cvar("sbar_showbinds_limit");
\r
473 // Update the mouse position
\r
475 mousepos_x = vid_conwidth;
\r
476 mousepos_y = vid_conheight;
\r
477 mousepos = mousepos*0.5 + getmousepos();
\r
480 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
\r
483 for(self = world; (self = nextent(self)); )
\r
489 // now switch to 2D drawing mode by calling a 2D drawing function
\r
490 // then polygon drawing will draw as 2D stuff, and NOT get queued until the
\r
491 // next R_RenderScene call
\r
492 drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);
\r
495 if(!scoreboard_active && !ons_showmap) {
\r
496 string wcross_style;
\r
497 wcross_style = cvar_string("crosshair");
\r
499 if (wcross_style != "0") {
\r
500 vector wcross_color, wcross_size;
\r
501 string wcross_wep, wcross_name;
\r
502 float wcross_alpha, wcross_sizefloat;
\r
504 wcross_color_x = cvar("crosshair_color_red");
\r
505 wcross_color_y = cvar("crosshair_color_green");
\r
506 wcross_color_z = cvar("crosshair_color_blue");
\r
507 wcross_alpha = cvar("crosshair_color_alpha");
\r
508 wcross_sizefloat = cvar("crosshair_size");
\r
509 if (cvar("crosshair_per_weapon")) {
\r
510 e = get_weaponinfo(activeweapon);
\r
511 if (e && e.netname != "")
\r
513 wcross_wep = e.netname;
\r
514 wcross_style = cvar_string(strcat("crosshair_", wcross_wep));
\r
515 if(wcross_style == "")
\r
516 wcross_style = e.netname;
\r
518 if(!cvar("crosshair_color_override"))
\r
520 wcross_color_x = cvar(strcat("crosshair_", wcross_wep, "_color_red"));
\r
521 wcross_color_y = cvar(strcat("crosshair_", wcross_wep, "_color_green"));
\r
522 wcross_color_z = cvar(strcat("crosshair_", wcross_wep, "_color_blue"));
\r
525 wcross_alpha *= cvar(strcat("crosshair_", wcross_wep, "_color_alpha"));
\r
526 wcross_sizefloat *= cvar(strcat("crosshair_", wcross_wep, "_size"));
\r
530 wcross_name = strcat("gfx/crosshair", wcross_style);
\r
532 wcross_size = drawgetimagesize(wcross_name);
\r
533 wcross_size_x *= wcross_sizefloat;
\r
534 wcross_size_y *= wcross_sizefloat;
\r
536 drawpic('0.5 0 0' * (vid_conwidth - wcross_size_x) + '0 0.5 0' * (vid_conheight - wcross_size_y), wcross_name, wcross_size, wcross_color, wcross_alpha, DRAWFLAG_NORMAL);
\r
540 // Draw the mouse cursor
\r
541 // NOTE: drawpic must happen after R_RenderScene for some reason
\r
542 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
\r
543 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
\r
544 //self = edict_num(player_localnum);
\r
545 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
\r
546 //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
547 // as long as the ctf part isn't in, this is useless
\r
551 /*if(gametype == GAME_CTF)
\r
556 // draw 2D entities
\r
558 for(self = world; (self = nextent(self)); )
\r
564 if(teamplay || cvar("cl_teamradar") == 2)
\r
566 if((cvar_string("cl_teamradar") != "0" && !scoreboard_active) || ons_showmap)
\r
571 if(cvar("r_letterbox") == 0)
\r
572 if(cvar("viewsize") < 120)
\r
577 void CSQC_common_hud(void)
\r
579 // Sbar_SortFrags(); done in Sbar_Draw
\r
583 // KeyHunt HUD by victim
\r
584 void CSQC_kh_hud(void)
\r
586 // HUD 0 has the weapons on the right hand side - temporarily shown when needed
\r
587 // HUD 1 has the weapons on the bottom - permanently
\r
589 // use the following two binds to check the icons move correctly
\r
590 // bind g "toggle sbar_flagstatus_right; echo Menu right $sbar_flagstatus_right" // move the icons
\r
591 // bind h "toggle sbar_hudselector; echo HUD $sbar_hudselector" // change the HUD
\r
593 float kh_keys, kh_keys_status, kh_teams_set;
\r
594 float kh_margin_x, kh_margin_y, kh_key_box;
\r
595 string kh_carrying, kh_outline;
\r
596 vector red_pos, blue_pos, yellow_pos, pink_pos, kh_size;
\r
597 vector red, blue, yellow, pink;
\r
599 kh_keys = getstati(STAT_KH_KEYS);
\r
600 kh_keys_status = kh_keys / 256;
\r
601 kh_teams_set = cvar("_teams_available"); // set in keyhunt.qc
\r
604 kh_margin_x = (cvar("sbar_flagstatus_right") * sbar_hudselector * (vid_conwidth - 67)) + 10;
\r
605 // sbar_flagstatus_right 0/1; sbar_hudselector 0/1; screen width - key width + margin
\r
607 red_pos_x = blue_pos_x = yellow_pos_x = pink_pos_x = kh_margin_x;
\r
611 pink_pos_y = kh_margin_y + 0; // top
\r
612 yellow_pos_y = kh_margin_y + kh_key_box;
\r
613 blue_pos_y = kh_margin_y + kh_key_box * 2;
\r
614 red_pos_y = kh_margin_y + kh_key_box * 3; //bottom
\r
621 kh_size = '0 0 0'; // don't resize the image
\r
623 kh_carrying = "gfx/sb_kh_full";
\r
624 kh_outline = "gfx/sb_kh_outline";
\r
626 // drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
\r
627 // vector position = '0 0'; // 'x y' 0 0 (the origin) is the top left. X 0 - 799, Y 0 - 599
\r
629 // vector size = '0 0'; // 'x y' changes the x & y dimensions. '0 0' gives the default pic size
\r
630 // vector rgb = '0 0 0'; // 'r g b' range 0 - 1
\r
632 if (kh_keys_status & 1) // red
\r
633 drawpic (red_pos, kh_carrying, kh_size, red, 0.2, 0); // show 20% alpha key
\r
635 drawpic (red_pos, kh_outline, kh_size, red, 0.4, 0); // show key outline 40% alpha
\r
638 drawpic (red_pos, kh_carrying, kh_size, red, 1.0, 0); // show solid key 100% alpha
\r
641 if (kh_keys_status & 2) // blue
\r
642 drawpic (blue_pos, kh_carrying, kh_size, blue, 0.2, 0);
\r
644 drawpic (blue_pos, kh_outline, kh_size, blue, 0.4, 0);
\r
647 drawpic (blue_pos, kh_carrying, kh_size, blue, 1.0, 0);
\r
650 if (kh_teams_set & 4) // yellow
\r
652 if (kh_keys_status & 4)
\r
653 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 0.2, 0);
\r
655 drawpic (yellow_pos, kh_outline, kh_size, yellow, 0.4, 0);
\r
658 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 1.0, 0);
\r
662 if (kh_teams_set & 8) // pink
\r
664 if (kh_keys_status & 8)
\r
665 drawpic (pink_pos, kh_carrying, kh_size, pink, 0.2, 0);
\r
667 drawpic (pink_pos, kh_outline, kh_size, pink, 0.4, 0);
\r
670 drawpic (pink_pos, kh_carrying, kh_size, pink, 1.0, 0);
\r