3 float trace_dphitcontents;
\r
4 float Q3SURFACEFLAG_SLICK = 2; // low friction surface
\r
5 float DPCONTENTS_SOLID = 1; // blocks player movement
\r
6 float DPCONTENTS_BODY = 32; // blocks player movement
\r
7 float DPCONTENTS_CORPSE = 64; // blocks player movement
\r
8 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
\r
11 vector p, dir, ang, q, nextdir;
\r
12 float idx, portal_number, portal1_idx;
\r
14 if(activeweapon != WEP_PORTO || spectatee_status || gametype == GAME_NEXBALL)
\r
16 if(intermission == 1)
\r
18 if(intermission == 2)
\r
20 if (getstati(STAT_HEALTH) <= 0)
\r
25 if(angles_held_status)
\r
27 makevectors(angles_held);
\r
41 traceline(p, p + 65536 * dir, TRUE, porto);
\r
42 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
\r
44 nextdir = dir - 2 * (dir * trace_plane_normal) * trace_plane_normal; // mirror dir at trace_plane_normal
\r
50 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
\r
53 ang = vectoangles2(trace_plane_normal, dir);
\r
56 if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
\r
58 if(portal_number == 1)
\r
60 if(portal_number >= 2)
\r
66 p = polyline[idx-2];
\r
67 q = polyline[idx-1];
\r
69 p = p - view_up * 16;
\r
70 if(idx-1 >= portal1_idx)
\r
72 Draw_CylindricLine(p, q, 4, "", 1, 0, '0 0 1', 0.5, DRAWFLAG_NORMAL);
\r
76 Draw_CylindricLine(p, q, 4, "", 1, 0, '1 0 0', 0.5, DRAWFLAG_NORMAL);
\r
83 * Checks whether the server initiated a map restart (stat_game_starttime changed)
\r
85 * TODO: Use a better solution where a common shared entitiy is used that contains
\r
86 * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
\r
87 * and STAT_FRAGLIMIT to be auto-sent)
\r
89 void CheckForGamestartChange() {
\r
91 startTime = getstatf(STAT_GAMESTARTTIME);
\r
92 if (previous_game_starttime != startTime) {
\r
93 if ((time + 5.0) < startTime) {
\r
94 //if connecting to server while restart was active don't always play prepareforbattle
\r
95 sound(self, CHAN_VOICE, "announcer/robotic/prepareforbattle.wav", VOL_BASEVOICE, ATTN_NONE);
\r
97 if (time < startTime) {
\r
98 restartAnnouncer = spawn();
\r
99 restartAnnouncer.think = restartAnnouncer_Think;
\r
100 restartAnnouncer.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
\r
103 previous_game_starttime = startTime;
\r
109 porto.classname = "porto";
\r
110 porto.draw = Porto_Draw;
\r
111 porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
\r
118 return sin(x) / cos(x);
\r
120 float atan2(float y, float x)
\r
123 v = '1 0 0' * x + '0 1 0' * y;
\r
124 v = vectoangles(v);
\r
125 return v_y * 0.01745329251994329576;
\r
128 vector GetCurrentFov(float fov)
\r
130 float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
\r
132 zoomsensitivity = cvar("cl_zoomsensitivity");
\r
133 zoomfactor = cvar("cl_zoomfactor");
\r
134 if(zoomfactor < 1 || zoomfactor > 16)
\r
136 zoomspeed = cvar("cl_zoomspeed");
\r
138 if(zoomspeed < 0.5 || zoomspeed > 16)
\r
141 zoomdir = button_zoom;
\r
142 if(getstati(STAT_ACTIVEWEAPON) == WEP_NEX) // do NOT use switchweapon here
\r
143 zoomdir += button_attack2;
\r
144 if(spectatee_status > 0 || isdemo())
\r
146 if(spectatorbutton_zoom)
\r
147 zoomdir = 0 + !zoomdir;
\r
148 // do not even THINK about removing this 0
\r
149 // _I_ know what I am doing
\r
156 if(zoomin_effect || camera_active)
\r
158 current_viewzoom = min(1, current_viewzoom + drawframetime);
\r
162 if(zoomspeed < 0) // instant zoom
\r
165 current_viewzoom = 1 / zoomfactor;
\r
167 current_viewzoom = 1;
\r
172 current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
\r
174 current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
\r
178 if(almost_equals(current_viewzoom, 1))
\r
179 current_zoomfraction = 0;
\r
180 else if(almost_equals(current_viewzoom, 1/zoomfactor))
\r
181 current_zoomfraction = 1;
\r
183 current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1);
\r
185 if(zoomsensitivity < 1)
\r
186 setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
\r
188 setsensitivityscale(1);
\r
190 float frustumx, frustumy, fovx, fovy;
\r
191 frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom;
\r
192 frustumx = frustumy * vid_width / vid_height / vid_pixelheight;
\r
193 fovx = atan2(frustumx, 1) / 0.00872664625997164788;
\r
194 fovy = atan2(frustumy, 1) / 0.00872664625997164788;
\r
196 return '1 0 0' * fovx + '0 1 0' * fovy;
\r
199 // this function must match W_SetupShot!
\r
200 float zoomscript_caught;
\r
202 void TrueAim_Init()
\r
205 trueaim.classname = "trueaim";
\r
206 trueaim.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
\r
209 float TrueAimCheck()
\r
211 float nudge = 1; // added to traceline target and subtracted from result
\r
212 vector vecs, trueaimpoint, w_shotorg;
\r
217 switch(activeweapon)
\r
219 case WEP_PORTO: // shoots from eye
\r
220 case WEP_HOOK: // no trueaim
\r
221 case WEP_GRENADE_LAUNCHER: // toss curve
\r
223 case WEP_CAMPINGRIFLE:
\r
224 if(zoomscript_caught)
\r
225 return 1; // shoots from eye when zoomed
\r
227 case WEP_ROCKET_LAUNCHER: // projectile has a size!
\r
231 case WEP_SEEKER: // projectile has a size!
\r
235 case WEP_ELECTRO: // projectile has a size!
\r
241 vecs = decompressShotOrigin(getstati(STAT_SHOTORG));
\r
243 traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, MOVE_NOMONSTERS, trueaim);
\r
244 trueaimpoint = trace_endpos;
\r
251 dv = view_right * vecs_y + view_up * vecs_z;
\r
252 w_shotorg = view_origin + dv;
\r
254 // now move the vecs forward as much as requested if possible
\r
255 tracebox(w_shotorg, mi, ma, w_shotorg + view_forward * (vecs_x + nudge), MOVE_NORMAL, trueaim); // FIXME this MOVE_NORMAL part will misbehave a little in csqc
\r
256 w_shotorg = trace_endpos - view_forward * nudge;
\r
258 // now test whether we will actually hit the trueaimpoint...
\r
259 tracebox(w_shotorg, mi, ma, trueaimpoint, MOVE_NOMONSTERS, trueaim);
\r
261 return vlen(trace_endpos - trueaimpoint) <= vlen(ma - mi) + 1;
\r
262 // yes, this is an ugly hack... but it seems good enough to find out whether the test hits the same place as the initial trace
\r
265 void CSQC_common_hud(void);
\r
267 void CSQC_kh_hud(void);
\r
268 void CSQC_ctf_hud(void);
\r
269 void PostInit(void);
\r
270 void CSQC_Demo_Camera();
\r
271 float Sbar_WouldDrawScoreboard ();
\r
274 string NextFrameCommand;
\r
275 void CSQC_UpdateView(float w, float h)
\r
282 WaypointSprite_Load();
\r
284 ticrate = getstatf(STAT_SYS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
\r
286 // Render the Scene
\r
287 if(!intermission || !view_set)
\r
289 view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
\r
290 view_angles = input_angles;
\r
291 makevectors(view_angles);
\r
292 view_forward = v_forward;
\r
293 view_right = v_right;
\r
302 if(time > blurtest_time0 && time < blurtest_time1)
\r
306 t = (time - blurtest_time0) / (blurtest_time1 - blurtest_time0);
\r
307 r = t * blurtest_radius;
\r
308 f = 1 / pow(t, blurtest_power) - 1;
\r
310 cvar_set("r_glsl_postprocess", "1");
\r
311 cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(r), " ", ftos(f), " 0 0"));
\r
315 cvar_set("r_glsl_postprocess", "0");
\r
316 cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
\r
322 drawframetime = max(0.000001, time - drawtime);
\r
325 // watch for gametype changes here...
\r
326 // in ParseStuffCMD the cmd isn't executed yet :/
\r
327 // might even be better to add the gametype to TE_CSQC_INIT...?
\r
331 CheckForGamestartChange();
\r
332 maptimeAnnouncer();
\r
335 if(button_zoom || fov <= 59.5)
\r
337 if(!zoomscript_caught)
\r
339 localcmd("+button4\n");
\r
340 zoomscript_caught = 1;
\r
341 ignore_plus_zoom += 1;
\r
346 if(zoomscript_caught)
\r
348 localcmd("-button4\n");
\r
349 zoomscript_caught = 0;
\r
350 ignore_minus_zoom += 1;
\r
354 sbar_alpha_fg = cvar("sbar_alpha_fg" );
\r
355 sbar_hudselector = cvar("sbar_hudselector");
\r
356 ColorTranslateMode = cvar("cl_stripcolorcodes");
\r
357 activeweapon = getstati(STAT_SWITCHWEAPON);
\r
358 f = cvar("teamplay");
\r
365 if(last_weapon != activeweapon) {
\r
367 last_weapon = activeweapon;
\r
370 // ALWAYS Clear Current Scene First
\r
373 // Assign Standard Viewflags
\r
374 // Draw the World (and sky)
\r
375 R_SetView(VF_DRAWWORLD, 1);
\r
377 // Set the console size vars
\r
378 vid_conwidth = cvar("vid_conwidth");
\r
379 vid_conheight = cvar("vid_conheight");
\r
380 vid_pixelheight = cvar("vid_pixelheight");
\r
382 R_SetView(VF_FOV, GetCurrentFov(fov));
\r
384 // Camera for demo playback
\r
387 if(cvar("camera_enable"))
\r
388 CSQC_Demo_Camera();
\r
391 cvar_set("chase_active", ftos(chase_active_backup));
\r
392 cvar_set("cl_demo_mousegrab", "0");
\r
393 camera_active = FALSE;
\r
397 else if(cvar("camera_enable"))
\r
399 else if(cvar("camera_enable") && isdemo())
\r
402 // Enable required Darkplaces cvars
\r
403 chase_active_backup = cvar("chase_active");
\r
404 cvar_set("chase_active", "2");
\r
405 cvar_set("cl_demo_mousegrab", "1");
\r
406 camera_active = TRUE;
\r
407 camera_mode = FALSE;
\r
410 // Draw the Crosshair
\r
411 float scoreboard_active;
\r
412 scoreboard_active = Sbar_WouldDrawScoreboard();
\r
413 R_SetView(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden
\r
415 // Draw the Engine Status Bar (the default Quake HUD)
\r
416 R_SetView(VF_DRAWENGINESBAR, 0);
\r
418 // fetch this one only once per frame
\r
419 sbar_showbinds = cvar("sbar_showbinds");
\r
420 sbar_showbinds_limit = cvar("sbar_showbinds_limit");
\r
422 // Update the mouse position
\r
424 mousepos_x = vid_conwidth;
\r
425 mousepos_y = vid_conheight;
\r
426 mousepos = mousepos*0.5 + getmousepos();
\r
429 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
\r
432 for(self = world; (self = nextent(self)); )
\r
438 // now switch to 2D drawing mode by calling a 2D drawing function
\r
439 // then polygon drawing will draw as 2D stuff, and NOT get queued until the
\r
440 // next R_RenderScene call
\r
441 drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);
\r
443 // Draw the mouse cursor
\r
444 // NOTE: drawpic must happen after R_RenderScene for some reason
\r
445 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
\r
446 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
\r
447 //self = edict_num(player_localnum);
\r
448 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
\r
449 //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
450 // as long as the ctf part isn't in, this is useless
\r
454 /*if(gametype == GAME_CTF)
\r
459 // draw 2D entities
\r
461 for(self = world; (self = nextent(self)); )
\r
473 cvar_string("cl_teamradar") != "0"
\r
476 cvar("cl_teamradar") == 2
\r
484 if (cvar("cl_showpressedkeys")) // draw pressed keys when spectating and playing
\r
486 if(spectatee_status > 0 || cvar("cl_showpressedkeys") >= 2)
\r
487 Sbar_DrawPressedKeys();
\r
491 if(cvar("r_letterbox") == 0)
\r
492 if(cvar("viewsize") < 120)
\r
495 // crosshair goes VERY LAST
\r
496 if(!scoreboard_active && !ons_showmap && !camera_active) {
\r
500 goodshot = TrueAimCheck();
\r
502 string wcross_style;
\r
503 wcross_style = cvar_string("crosshair");
\r
505 if (wcross_style != "0") {
\r
506 vector wcross_color, wcross_size;
\r
507 string wcross_wep, wcross_name;
\r
508 float wcross_alpha, wcross_sizefloat;
\r
510 wcross_color_x = cvar("crosshair_color_red");
\r
511 wcross_color_y = cvar("crosshair_color_green");
\r
512 wcross_color_z = cvar("crosshair_color_blue");
\r
513 wcross_alpha = cvar("crosshair_color_alpha");
\r
514 wcross_sizefloat = cvar("crosshair_size");
\r
515 if (cvar("crosshair_per_weapon")) {
\r
516 e = get_weaponinfo(activeweapon);
\r
517 if (e && e.netname != "")
\r
519 wcross_wep = e.netname;
\r
520 wcross_style = cvar_string(strcat("crosshair_", wcross_wep));
\r
521 if(wcross_style == "")
\r
522 wcross_style = e.netname;
\r
524 if(!cvar("crosshair_color_override"))
\r
526 wcross_color_x = cvar(strcat("crosshair_", wcross_wep, "_color_red"));
\r
527 wcross_color_y = cvar(strcat("crosshair_", wcross_wep, "_color_green"));
\r
528 wcross_color_z = cvar(strcat("crosshair_", wcross_wep, "_color_blue"));
\r
531 wcross_alpha *= cvar(strcat("crosshair_", wcross_wep, "_color_alpha"));
\r
532 wcross_sizefloat *= cvar(strcat("crosshair_", wcross_wep, "_size"));
\r
536 wcross_name = strcat("gfx/crosshair", wcross_style);
\r
538 wcross_size = drawgetimagesize(wcross_name);
\r
539 wcross_size_x *= wcross_sizefloat;
\r
540 wcross_size_y *= wcross_sizefloat;
\r
542 if(goodshot || !cvar("crosshair_hittest"))
\r
544 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
548 wcross_alpha *= 0.04 * 0.75;
\r
549 for(i = -2; i <= 2; ++i)
\r
550 for(j = -2; j <= 2; ++j)
\r
551 drawpic('0.5 0 0' * (vid_conwidth - wcross_size_x + i) + '0 0.5 0' * (vid_conheight - wcross_size_y + j), wcross_name, wcross_size, wcross_color, wcross_alpha, DRAWFLAG_NORMAL);
\r
556 if(NextFrameCommand)
\r
558 localcmd("\n", NextFrameCommand, "\n");
\r
559 NextFrameCommand = string_null;
\r
564 void CSQC_common_hud(void)
\r
566 // Sbar_SortFrags(); done in Sbar_Draw
\r
570 // KeyHunt HUD by victim
\r
571 void CSQC_kh_hud(void)
\r
573 // HUD 0 has the weapons on the right hand side - temporarily shown when needed
\r
574 // HUD 1 has the weapons on the bottom - permanently
\r
576 // use the following two binds to check the icons move correctly
\r
577 // bind g "toggle sbar_flagstatus_right; echo Menu right $sbar_flagstatus_right" // move the icons
\r
578 // bind h "toggle sbar_hudselector; echo HUD $sbar_hudselector" // change the HUD
\r
580 float kh_keys, kh_keys_status, kh_teams_set;
\r
581 float kh_margin_x, kh_margin_y, kh_key_box;
\r
582 string kh_carrying, kh_outline;
\r
583 vector red_pos, blue_pos, yellow_pos, pink_pos, kh_size;
\r
584 vector red, blue, yellow, pink;
\r
586 kh_keys = getstati(STAT_KH_KEYS);
\r
587 kh_keys_status = kh_keys / 256;
\r
588 kh_teams_set = cvar("_teams_available"); // set in keyhunt.qc
\r
591 kh_margin_x = (cvar("sbar_flagstatus_right") * sbar_hudselector * (vid_conwidth - 67)) + 10;
\r
592 // sbar_flagstatus_right 0/1; sbar_hudselector 0/1; screen width - key width + margin
\r
594 red_pos_x = blue_pos_x = yellow_pos_x = pink_pos_x = kh_margin_x;
\r
598 pink_pos_y = kh_margin_y + 0; // top
\r
599 yellow_pos_y = kh_margin_y + kh_key_box;
\r
600 blue_pos_y = kh_margin_y + kh_key_box * 2;
\r
601 red_pos_y = kh_margin_y + kh_key_box * 3; //bottom
\r
608 kh_size = '0 0 0'; // don't resize the image
\r
610 kh_carrying = "gfx/sb_kh_full";
\r
611 kh_outline = "gfx/sb_kh_outline";
\r
613 // drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
\r
614 // vector position = '0 0'; // 'x y' 0 0 (the origin) is the top left. X 0 - 799, Y 0 - 599
\r
616 // vector size = '0 0'; // 'x y' changes the x & y dimensions. '0 0' gives the default pic size
\r
617 // vector rgb = '0 0 0'; // 'r g b' range 0 - 1
\r
619 if (kh_keys_status & 1) // red
\r
620 drawpic (red_pos, kh_carrying, kh_size, red, 0.2, 0); // show 20% alpha key
\r
622 drawpic (red_pos, kh_outline, kh_size, red, 0.4, 0); // show key outline 40% alpha
\r
625 drawpic (red_pos, kh_carrying, kh_size, red, 1.0, 0); // show solid key 100% alpha
\r
628 if (kh_keys_status & 2) // blue
\r
629 drawpic (blue_pos, kh_carrying, kh_size, blue, 0.2, 0);
\r
631 drawpic (blue_pos, kh_outline, kh_size, blue, 0.4, 0);
\r
634 drawpic (blue_pos, kh_carrying, kh_size, blue, 1.0, 0);
\r
637 if (kh_teams_set & 4) // yellow
\r
639 if (kh_keys_status & 4)
\r
640 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 0.2, 0);
\r
642 drawpic (yellow_pos, kh_outline, kh_size, yellow, 0.4, 0);
\r
645 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 1.0, 0);
\r
649 if (kh_teams_set & 8) // pink
\r
651 if (kh_keys_status & 8)
\r
652 drawpic (pink_pos, kh_carrying, kh_size, pink, 0.2, 0);
\r
654 drawpic (pink_pos, kh_outline, kh_size, pink, 0.4, 0);
\r
657 drawpic (pink_pos, kh_carrying, kh_size, pink, 1.0, 0);
\r
662 // following vectors must be global to allow seamless switching between camera modes
\r
663 vector camera_offset, current_camera_offset, mouse_angles, current_angles, current_origin, current_position;
\r
664 void CSQC_Demo_Camera()
\r
666 float speed, attenuation, dimensions;
\r
669 if( cvar("camera_reset") || !camera_mode )
\r
671 camera_offset = '0 0 0';
\r
672 current_angles = '0 0 0';
\r
673 camera_direction = '0 0 0';
\r
674 camera_offset_z += 30;
\r
675 camera_offset_x += 30 * -cos(current_angles_y * DEG2RAD);
\r
676 camera_offset_y += 30 * -sin(current_angles_y * DEG2RAD);
\r
677 current_origin = view_origin;
\r
678 current_camera_offset = camera_offset;
\r
679 cvar_set("camera_reset", "0");
\r
680 camera_mode = CAMERA_CHASE;
\r
685 mouse_angles_z += camera_roll * cvar("camera_speed_roll");
\r
687 if(cvar("camera_look_player"))
\r
692 dir = normalize(view_origin - current_position);
\r
693 n = mouse_angles_z;
\r
694 mouse_angles = vectoangles(dir);
\r
695 mouse_angles_x = mouse_angles_x * -1;
\r
696 mouse_angles_z = n;
\r
700 tmp = getmousepos() * 0.1;
\r
701 if(vlen(tmp)>cvar("camera_mouse_treshold"))
\r
703 mouse_angles_x += tmp_y * cos(mouse_angles_z * DEG2RAD) + (tmp_x * sin(mouse_angles_z * DEG2RAD));
\r
704 mouse_angles_y -= tmp_x * cos(mouse_angles_z * DEG2RAD) + (tmp_y * -sin(mouse_angles_z * DEG2RAD));
\r
708 while (mouse_angles_x < -180) mouse_angles_x = mouse_angles_x + 360;
\r
709 while (mouse_angles_x > 180) mouse_angles_x = mouse_angles_x - 360;
\r
710 while (mouse_angles_y < -180) mouse_angles_y = mouse_angles_y + 360;
\r
711 while (mouse_angles_y > 180) mouse_angles_y = mouse_angles_y - 360;
\r
713 // Fix difference when angles don't have the same sign
\r
715 if(mouse_angles_y < -60 && current_angles_y > 60)
\r
717 if(mouse_angles_y > 60 && current_angles_y < -60)
\r
718 delta = '0 -360 0';
\r
720 if(cvar("camera_look_player"))
\r
721 attenuation = cvar("camera_look_attenuation");
\r
723 attenuation = cvar("camera_speed_attenuation");
\r
725 attenuation = 1 / max(1, attenuation);
\r
726 current_angles += (mouse_angles - current_angles + delta) * attenuation;
\r
728 while (current_angles_x < -180) current_angles_x = current_angles_x + 360;
\r
729 while (current_angles_x > 180) current_angles_x = current_angles_x - 360;
\r
730 while (current_angles_y < -180) current_angles_y = current_angles_y + 360;
\r
731 while (current_angles_y > 180) current_angles_y = current_angles_y - 360;
\r
737 if( camera_direction_x )
\r
739 tmp_x = camera_direction_x * cos(current_angles_y * DEG2RAD);
\r
740 tmp_y = camera_direction_x * sin(current_angles_y * DEG2RAD);
\r
741 if( cvar("camera_forward_follows") && !cvar("camera_look_player") )
\r
742 tmp_z = camera_direction_x * -sin(current_angles_x * DEG2RAD);
\r
746 if( camera_direction_y )
\r
748 tmp_x += camera_direction_y * -sin(current_angles_y * DEG2RAD);
\r
749 tmp_y += camera_direction_y * cos(current_angles_y * DEG2RAD) * cos(current_angles_z * DEG2RAD);
\r
750 tmp_z += camera_direction_y * sin(current_angles_z * DEG2RAD);
\r
754 if( camera_direction_z )
\r
756 tmp_z += camera_direction_z * cos(current_angles_z * DEG2RAD);
\r
760 if(cvar("camera_free"))
\r
761 speed = cvar("camera_speed_free");
\r
763 speed = cvar("camera_speed_chase");
\r
767 speed = speed * sqrt(1 / dimensions);
\r
768 camera_offset += tmp * speed;
\r
771 current_camera_offset += (camera_offset - current_camera_offset) * attenuation;
\r
774 if( cvar("camera_free") )
\r
776 if ( camera_mode == CAMERA_CHASE )
\r
778 current_camera_offset = current_origin + current_camera_offset;
\r
779 camera_offset = current_origin + camera_offset;
\r
782 camera_mode = CAMERA_FREE;
\r
783 current_position = current_camera_offset;
\r
787 if ( camera_mode == CAMERA_FREE )
\r
789 current_origin = view_origin;
\r
790 camera_offset = camera_offset - current_origin;
\r
791 current_camera_offset = current_camera_offset - current_origin;
\r
794 camera_mode = CAMERA_CHASE;
\r
796 if(cvar("camera_chase_smoothly"))
\r
797 current_origin += (view_origin - current_origin) * attenuation;
\r
799 current_origin = view_origin;
\r
801 current_position = current_origin + current_camera_offset;
\r
804 R_SetView(VF_ANGLES, current_angles);
\r
805 R_SetView(VF_ORIGIN, current_position);
\r