1 #define spider_rocket_icon "gfx/spiderbot/rocket_ico.tga"
\r
2 #define spider_rocket_targ "gfx/spiderbot/target.tga"
\r
3 #define SPIDER_CROSS "textures/spiderbot/cross.tga"
\r
5 #define rld_size_x 256
\r
6 #define rld_size_y 16
\r
10 float trace_dphitcontents;
\r
11 float Q3SURFACEFLAG_SLICK = 2; // low friction surface
\r
12 float DPCONTENTS_SOLID = 1; // blocks player movement
\r
13 float DPCONTENTS_BODY = 32; // blocks player movement
\r
14 float DPCONTENTS_CORPSE = 64; // blocks player movement
\r
15 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
\r
18 vector p, dir, ang, q, nextdir;
\r
19 float idx, portal_number, portal1_idx;
\r
21 if(activeweapon != WEP_PORTO || spectatee_status || gametype == GAME_NEXBALL)
\r
23 if(intermission == 1)
\r
25 if(intermission == 2)
\r
27 if (getstati(STAT_HEALTH) <= 0)
\r
32 if(angles_held_status)
\r
34 makevectors(angles_held);
\r
48 traceline(p, p + 65536 * dir, TRUE, porto);
\r
49 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
\r
51 nextdir = dir - 2 * (dir * trace_plane_normal) * trace_plane_normal; // mirror dir at trace_plane_normal
\r
57 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
\r
60 ang = vectoangles2(trace_plane_normal, dir);
\r
63 if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
\r
65 if(portal_number == 1)
\r
67 if(portal_number >= 2)
\r
73 p = polyline[idx-2];
\r
74 q = polyline[idx-1];
\r
76 p = p - view_up * 16;
\r
77 if(idx-1 >= portal1_idx)
\r
79 Draw_CylindricLine(p, q, 4, "", 1, 0, '0 0 1', 0.5, DRAWFLAG_NORMAL);
\r
83 Draw_CylindricLine(p, q, 4, "", 1, 0, '1 0 0', 0.5, DRAWFLAG_NORMAL);
\r
90 * Checks whether the server initiated a map restart (stat_game_starttime changed)
\r
92 * TODO: Use a better solution where a common shared entitiy is used that contains
\r
93 * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
\r
94 * and STAT_FRAGLIMIT to be auto-sent)
\r
96 void CheckForGamestartChange() {
\r
98 startTime = getstatf(STAT_GAMESTARTTIME);
\r
99 if (previous_game_starttime != startTime) {
\r
100 if ((time + 5.0) < startTime) {
\r
101 //if connecting to server while restart was active don't always play prepareforbattle
\r
102 sound(self, CHAN_VOICE, "announcer/robotic/prepareforbattle.wav", VOL_BASEVOICE, ATTN_NONE);
\r
104 if (time < startTime) {
\r
105 restartAnnouncer = spawn();
\r
106 restartAnnouncer.think = restartAnnouncer_Think;
\r
107 restartAnnouncer.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
\r
110 previous_game_starttime = startTime;
\r
116 porto.classname = "porto";
\r
117 porto.draw = Porto_Draw;
\r
118 porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
\r
125 return sin(x) / cos(x);
\r
127 float atan2(float y, float x)
\r
130 v = '1 0 0' * x + '0 1 0' * y;
\r
131 v = vectoangles(v);
\r
132 return v_y * 0.01745329251994329576;
\r
135 vector GetCurrentFov(float fov)
\r
137 float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
\r
139 zoomsensitivity = cvar("cl_zoomsensitivity");
\r
140 zoomfactor = cvar("cl_zoomfactor");
\r
141 if(zoomfactor < 1 || zoomfactor > 16)
\r
143 zoomspeed = cvar("cl_zoomspeed");
\r
145 if(zoomspeed < 0.5 || zoomspeed > 16)
\r
148 zoomdir = button_zoom;
\r
149 if(getstati(STAT_ACTIVEWEAPON) == WEP_NEX) // do NOT use switchweapon here
\r
150 zoomdir += button_attack2;
\r
151 if(spectatee_status > 0 || isdemo())
\r
153 if(spectatorbutton_zoom)
\r
154 zoomdir = 0 + !zoomdir;
\r
155 // do not even THINK about removing this 0
\r
156 // _I_ know what I am doing
\r
163 if(zoomin_effect || camera_active)
\r
165 current_viewzoom = min(1, current_viewzoom + drawframetime);
\r
169 if(zoomspeed < 0) // instant zoom
\r
172 current_viewzoom = 1 / zoomfactor;
\r
174 current_viewzoom = 1;
\r
179 current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
\r
181 current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
\r
185 if(almost_equals(current_viewzoom, 1))
\r
186 current_zoomfraction = 0;
\r
187 else if(almost_equals(current_viewzoom, 1/zoomfactor))
\r
188 current_zoomfraction = 1;
\r
190 current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1);
\r
192 if(zoomsensitivity < 1)
\r
193 setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
\r
195 setsensitivityscale(1);
\r
197 float frustumx, frustumy, fovx, fovy;
\r
198 frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom;
\r
199 frustumx = frustumy * vid_width / vid_height / vid_pixelheight;
\r
200 fovx = atan2(frustumx, 1) / 0.00872664625997164788;
\r
201 fovy = atan2(frustumy, 1) / 0.00872664625997164788;
\r
203 return '1 0 0' * fovx + '0 1 0' * fovy;
\r
206 // this function must match W_SetupShot!
\r
207 float zoomscript_caught;
\r
209 void TrueAim_Init()
\r
212 trueaim.classname = "trueaim";
\r
213 trueaim.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
\r
216 float TrueAimCheck()
\r
218 float nudge = 1; // added to traceline target and subtracted from result
\r
219 vector vecs, trueaimpoint, w_shotorg;
\r
224 switch(activeweapon)
\r
226 case WEP_TUBA: // no aim
\r
227 case WEP_PORTO: // shoots from eye
\r
228 case WEP_HOOK: // no trueaim
\r
229 case WEP_GRENADE_LAUNCHER: // toss curve
\r
231 case WEP_CAMPINGRIFLE:
\r
232 if(zoomscript_caught)
\r
233 return 1; // shoots from eye when zoomed
\r
235 case WEP_ROCKET_LAUNCHER: // projectile has a size!
\r
239 case WEP_SEEKER: // projectile has a size!
\r
243 case WEP_ELECTRO: // projectile has a size!
\r
249 vecs = decompressShotOrigin(getstati(STAT_SHOTORG));
\r
251 traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, MOVE_NOMONSTERS, trueaim);
\r
252 trueaimpoint = trace_endpos;
\r
259 dv = view_right * vecs_y + view_up * vecs_z;
\r
260 w_shotorg = view_origin + dv;
\r
262 // now move the vecs forward as much as requested if possible
\r
263 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
264 w_shotorg = trace_endpos - view_forward * nudge;
\r
266 // now test whether we will actually hit the trueaimpoint...
\r
267 tracebox(w_shotorg, mi, ma, trueaimpoint, MOVE_NOMONSTERS, trueaim);
\r
269 return vlen(trace_endpos - trueaimpoint) <= vlen(ma - mi) + 1;
\r
270 // 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
273 void CSQC_common_hud(void);
\r
275 void CSQC_kh_hud(void);
\r
276 void CSQC_ctf_hud(void);
\r
277 void PostInit(void);
\r
278 void CSQC_Demo_Camera();
\r
279 float Sbar_WouldDrawScoreboard ();
\r
282 string NextFrameCommand;
\r
283 void CSQC_spider_HUD();
\r
284 void CSQC_UpdateView(float w, float h)
\r
291 WaypointSprite_Load();
\r
293 ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
\r
295 // Render the Scene
\r
296 if(!intermission || !view_set)
\r
298 view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
\r
299 view_angles = input_angles;
\r
300 makevectors(view_angles);
\r
301 view_forward = v_forward;
\r
302 view_right = v_right;
\r
311 if(time > blurtest_time0 && time < blurtest_time1)
\r
315 t = (time - blurtest_time0) / (blurtest_time1 - blurtest_time0);
\r
316 r = t * blurtest_radius;
\r
317 f = 1 / pow(t, blurtest_power) - 1;
\r
319 cvar_set("r_glsl_postprocess", "1");
\r
320 cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(r), " ", ftos(f), " 0 0"));
\r
324 cvar_set("r_glsl_postprocess", "0");
\r
325 cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
\r
331 drawframetime = max(0.000001, time - drawtime);
\r
334 // watch for gametype changes here...
\r
335 // in ParseStuffCMD the cmd isn't executed yet :/
\r
336 // might even be better to add the gametype to TE_CSQC_INIT...?
\r
340 CheckForGamestartChange();
\r
341 maptimeAnnouncer();
\r
344 if(button_zoom || fov <= 59.5)
\r
346 if(!zoomscript_caught)
\r
348 localcmd("+button4\n");
\r
349 zoomscript_caught = 1;
\r
350 ignore_plus_zoom += 1;
\r
355 if(zoomscript_caught)
\r
357 localcmd("-button4\n");
\r
358 zoomscript_caught = 0;
\r
359 ignore_minus_zoom += 1;
\r
363 sbar_alpha_fg = cvar("sbar_alpha_fg" );
\r
364 sbar_hudselector = cvar("sbar_hudselector");
\r
365 sbar_hud_accuracy = cvar("sbar_hud_accuracy");
\r
366 ColorTranslateMode = cvar("cl_stripcolorcodes");
\r
367 activeweapon = getstati(STAT_SWITCHWEAPON);
\r
368 f = cvar("teamplay");
\r
375 if(last_weapon != activeweapon) {
\r
377 last_weapon = activeweapon;
\r
380 // ALWAYS Clear Current Scene First
\r
383 // Assign Standard Viewflags
\r
384 // Draw the World (and sky)
\r
385 R_SetView(VF_DRAWWORLD, 1);
\r
387 // Set the console size vars
\r
388 vid_conwidth = cvar("vid_conwidth");
\r
389 vid_conheight = cvar("vid_conheight");
\r
390 vid_pixelheight = cvar("vid_pixelheight");
\r
392 R_SetView(VF_FOV, GetCurrentFov(fov));
\r
394 // Camera for demo playback
\r
397 if(cvar("camera_enable"))
\r
398 CSQC_Demo_Camera();
\r
401 cvar_set("chase_active", ftos(chase_active_backup));
\r
402 cvar_set("cl_demo_mousegrab", "0");
\r
403 camera_active = FALSE;
\r
407 else if(cvar("camera_enable"))
\r
409 else if(cvar("camera_enable") && isdemo())
\r
412 // Enable required Darkplaces cvars
\r
413 chase_active_backup = cvar("chase_active");
\r
414 cvar_set("chase_active", "2");
\r
415 cvar_set("cl_demo_mousegrab", "1");
\r
416 camera_active = TRUE;
\r
417 camera_mode = FALSE;
\r
420 // Draw the Crosshair
\r
421 float scoreboard_active;
\r
422 scoreboard_active = Sbar_WouldDrawScoreboard();
\r
423 R_SetView(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden
\r
425 // Draw the Engine Status Bar (the default Quake HUD)
\r
426 R_SetView(VF_DRAWENGINESBAR, 0);
\r
428 // fetch this one only once per frame
\r
429 sbar_showbinds = cvar("sbar_showbinds");
\r
430 sbar_showbinds_limit = cvar("sbar_showbinds_limit");
\r
432 // Update the mouse position
\r
434 mousepos_x = vid_conwidth;
\r
435 mousepos_y = vid_conheight;
\r
436 mousepos = mousepos*0.5 + getmousepos();
\r
439 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
\r
442 for(self = world; (self = nextent(self)); )
\r
448 // now switch to 2D drawing mode by calling a 2D drawing function
\r
449 // then polygon drawing will draw as 2D stuff, and NOT get queued until the
\r
450 // next R_RenderScene call
\r
451 drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);
\r
453 // Draw the mouse cursor
\r
454 // NOTE: drawpic must happen after R_RenderScene for some reason
\r
455 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
\r
456 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
\r
457 //self = edict_num(player_localnum);
\r
458 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
\r
459 //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
460 // as long as the ctf part isn't in, this is useless
\r
464 /*if(gametype == GAME_CTF)
\r
469 // draw 2D entities
\r
471 for(self = world; (self = nextent(self)); )
\r
483 cvar_string("cl_teamradar") != "0"
\r
486 cvar("cl_teamradar") == 2
\r
494 if (cvar("cl_showpressedkeys")) // draw pressed keys when spectating and playing
\r
496 if(spectatee_status > 0 || cvar("cl_showpressedkeys") >= 2)
\r
497 Sbar_DrawPressedKeys();
\r
501 if(cvar("r_letterbox") == 0) {
\r
502 Sbar_DrawCenterPrint(); // draw centerprint messages even if viewsize >= 120
\r
507 hud = getstati(STAT_HUD);
\r
508 if(hud == HUD_SPIDEBOT)
\r
512 sz = drawgetimagesize(SPIDER_CROSS);
\r
513 sz_x *= cvar_or("cl_vehicle_spiderbot_cross_size",1);
\r
514 sz_y *= cvar_or("cl_vehicle_spiderbot_cross_size",1);
\r
515 drawpic('0.5 0 0' * (vid_conwidth - sz_x) + '0 0.5 0' * (vid_conheight - sz_y), SPIDER_CROSS, sz, '1 1 1', cvar_or("cl_vehicle_spiderbot_cross_alpha",0.6), DRAWFLAG_NORMAL);
\r
519 if(cvar("r_letterbox") == 0)
\r
520 if(cvar("viewsize") < 120)
\r
523 // crosshair goes VERY LAST
\r
524 if(!scoreboard_active && !ons_showmap && !camera_active) {
\r
528 if(cvar("crosshair_hittest"))
\r
529 goodshot = TrueAimCheck();
\r
533 string wcross_style;
\r
534 wcross_style = cvar_string("crosshair");
\r
536 if (wcross_style != "0") {
\r
537 vector wcross_color, wcross_size;
\r
538 string wcross_wep, wcross_name;
\r
539 float wcross_alpha, wcross_sizefloat;
\r
541 wcross_color_x = cvar("crosshair_color_red");
\r
542 wcross_color_y = cvar("crosshair_color_green");
\r
543 wcross_color_z = cvar("crosshair_color_blue");
\r
544 wcross_alpha = cvar("crosshair_color_alpha");
\r
545 wcross_sizefloat = cvar("crosshair_size");
\r
546 if (cvar("crosshair_per_weapon")) {
\r
547 e = get_weaponinfo(activeweapon);
\r
548 if (e && e.netname != "")
\r
550 wcross_wep = e.netname;
\r
551 wcross_style = cvar_string(strcat("crosshair_", wcross_wep));
\r
552 if(wcross_style == "")
\r
553 wcross_style = e.netname;
\r
555 if(!cvar("crosshair_color_override"))
\r
557 wcross_color_x = cvar(strcat("crosshair_", wcross_wep, "_color_red"));
\r
558 wcross_color_y = cvar(strcat("crosshair_", wcross_wep, "_color_green"));
\r
559 wcross_color_z = cvar(strcat("crosshair_", wcross_wep, "_color_blue"));
\r
562 wcross_alpha *= cvar(strcat("crosshair_", wcross_wep, "_color_alpha"));
\r
563 wcross_sizefloat *= cvar(strcat("crosshair_", wcross_wep, "_size"));
\r
567 wcross_name = strcat("gfx/crosshair", wcross_style);
\r
569 wcross_size = drawgetimagesize(wcross_name);
\r
570 wcross_size_x *= wcross_sizefloat;
\r
571 wcross_size_y *= wcross_sizefloat;
\r
575 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
579 wcross_alpha *= 0.04 * 0.75;
\r
580 for(i = -2; i <= 2; ++i)
\r
581 for(j = -2; j <= 2; ++j)
\r
582 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
588 if(NextFrameCommand)
\r
590 localcmd("\n", NextFrameCommand, "\n");
\r
591 NextFrameCommand = string_null;
\r
596 void CSQC_spider_HUD()
\r
598 float rockets,reload,heat,hp,shield,i;
\r
601 rockets = getstati(STAT_SPIDERBOT_ROCKETS);
\r
602 heat = min(getstatf(STAT_SPIDERBOT_HEAT),1);
\r
603 reload = min(getstatf(STAT_SPIDERBOT_RELOAD),1);
\r
604 hp = min(getstatf(STAT_SPIDERBOT_HEALTH),1);
\r
605 shield = min(getstatf(STAT_SPIDERBOT_SHIELD),1);
\r
608 p = '0.5 0 0' * (vid_conwidth - (rkt_size * 8));
\r
609 p = p + '0 1 0' * vid_conheight - '0 32 0';
\r
610 //pp = ('0 1 0' * hp) + ('1 0 0' * (1-hp));
\r
611 drawfill(p, '256 0 0' * shield + '0 8 0' , '0.5 0.5 1', 0.75, DRAWFLAG_NORMAL);
\r
613 drawfill(p, '256 0 0' * hp + '0 8 0' , '0 1 0', 0.75, DRAWFLAG_NORMAL);
\r
615 drawfill(p, '256 0 0' * (1-hp) + '0 8 0' , '0 0 0', 0.75, DRAWFLAG_NORMAL);
\r
617 // Draw minigun heat indicator
\r
618 p = '0.5 0 0' * (vid_conwidth - 256);
\r
619 p = p + '0 1 0' * vid_conheight - '0 34 0';
\r
620 drawfill(p, '256 0 0' * (1-heat) + '0 2 0' ,'0 0 1', 0.5, DRAWFLAG_NORMAL);
\r
621 p_x += 256 * (1-heat);
\r
622 drawfill(p, '256 0 0' * heat + '0 2 0' , '1 0 0', 0.5, DRAWFLAG_NORMAL);
\r
624 // Draw rocket icons for loaded/empty tubes.
\r
625 pp = '0.5 0 0' * (vid_conwidth - (rkt_size * 8));
\r
626 pp += '0 1 0' * vid_conheight - '0 64 0';
\r
627 for(i = 0; i < 8; ++i)
\r
629 p = pp + '1 0 0' * (rkt_size * i);
\r
632 if(floor(reload * 8) == i)
\r
634 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '1 0 0' + '0 1 0' * ((reload*8)-i), 0.75 , DRAWFLAG_NORMAL);
\r
636 else if(i < reload * 8)
\r
637 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '1 1 0', 0.75 , DRAWFLAG_NORMAL);
\r
639 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '0.5 0.5 0.5', 0.75, DRAWFLAG_NORMAL);
\r
644 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '0 0 0', 0.25, DRAWFLAG_NORMAL);
\r
646 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '0 1 0' * reload, 0.75, DRAWFLAG_NORMAL);
\r
652 Sbar_DrawScoreboard();
\r
653 Sbar_DrawCenterPrint();
\r
657 void CSQC_common_hud(void)
\r
660 // Sbar_SortFrags(); done in Sbar_Draw
\r
662 hud = getstati(STAT_HUD);
\r
678 // following vectors must be global to allow seamless switching between camera modes
\r
679 vector camera_offset, current_camera_offset, mouse_angles, current_angles, current_origin, current_position;
\r
680 void CSQC_Demo_Camera()
\r
682 float speed, attenuation, dimensions;
\r
685 if( cvar("camera_reset") || !camera_mode )
\r
687 camera_offset = '0 0 0';
\r
688 current_angles = '0 0 0';
\r
689 camera_direction = '0 0 0';
\r
690 camera_offset_z += 30;
\r
691 camera_offset_x += 30 * -cos(current_angles_y * DEG2RAD);
\r
692 camera_offset_y += 30 * -sin(current_angles_y * DEG2RAD);
\r
693 current_origin = view_origin;
\r
694 current_camera_offset = camera_offset;
\r
695 cvar_set("camera_reset", "0");
\r
696 camera_mode = CAMERA_CHASE;
\r
701 mouse_angles_z += camera_roll * cvar("camera_speed_roll");
\r
703 if(cvar("camera_look_player"))
\r
708 dir = normalize(view_origin - current_position);
\r
709 n = mouse_angles_z;
\r
710 mouse_angles = vectoangles(dir);
\r
711 mouse_angles_x = mouse_angles_x * -1;
\r
712 mouse_angles_z = n;
\r
716 tmp = getmousepos() * 0.1;
\r
717 if(vlen(tmp)>cvar("camera_mouse_treshold"))
\r
719 mouse_angles_x += tmp_y * cos(mouse_angles_z * DEG2RAD) + (tmp_x * sin(mouse_angles_z * DEG2RAD));
\r
720 mouse_angles_y -= tmp_x * cos(mouse_angles_z * DEG2RAD) + (tmp_y * -sin(mouse_angles_z * DEG2RAD));
\r
724 while (mouse_angles_x < -180) mouse_angles_x = mouse_angles_x + 360;
\r
725 while (mouse_angles_x > 180) mouse_angles_x = mouse_angles_x - 360;
\r
726 while (mouse_angles_y < -180) mouse_angles_y = mouse_angles_y + 360;
\r
727 while (mouse_angles_y > 180) mouse_angles_y = mouse_angles_y - 360;
\r
729 // Fix difference when angles don't have the same sign
\r
731 if(mouse_angles_y < -60 && current_angles_y > 60)
\r
733 if(mouse_angles_y > 60 && current_angles_y < -60)
\r
734 delta = '0 -360 0';
\r
736 if(cvar("camera_look_player"))
\r
737 attenuation = cvar("camera_look_attenuation");
\r
739 attenuation = cvar("camera_speed_attenuation");
\r
741 attenuation = 1 / max(1, attenuation);
\r
742 current_angles += (mouse_angles - current_angles + delta) * attenuation;
\r
744 while (current_angles_x < -180) current_angles_x = current_angles_x + 360;
\r
745 while (current_angles_x > 180) current_angles_x = current_angles_x - 360;
\r
746 while (current_angles_y < -180) current_angles_y = current_angles_y + 360;
\r
747 while (current_angles_y > 180) current_angles_y = current_angles_y - 360;
\r
753 if( camera_direction_x )
\r
755 tmp_x = camera_direction_x * cos(current_angles_y * DEG2RAD);
\r
756 tmp_y = camera_direction_x * sin(current_angles_y * DEG2RAD);
\r
757 if( cvar("camera_forward_follows") && !cvar("camera_look_player") )
\r
758 tmp_z = camera_direction_x * -sin(current_angles_x * DEG2RAD);
\r
762 if( camera_direction_y )
\r
764 tmp_x += camera_direction_y * -sin(current_angles_y * DEG2RAD);
\r
765 tmp_y += camera_direction_y * cos(current_angles_y * DEG2RAD) * cos(current_angles_z * DEG2RAD);
\r
766 tmp_z += camera_direction_y * sin(current_angles_z * DEG2RAD);
\r
770 if( camera_direction_z )
\r
772 tmp_z += camera_direction_z * cos(current_angles_z * DEG2RAD);
\r
776 if(cvar("camera_free"))
\r
777 speed = cvar("camera_speed_free");
\r
779 speed = cvar("camera_speed_chase");
\r
783 speed = speed * sqrt(1 / dimensions);
\r
784 camera_offset += tmp * speed;
\r
787 current_camera_offset += (camera_offset - current_camera_offset) * attenuation;
\r
790 if( cvar("camera_free") )
\r
792 if ( camera_mode == CAMERA_CHASE )
\r
794 current_camera_offset = current_origin + current_camera_offset;
\r
795 camera_offset = current_origin + camera_offset;
\r
798 camera_mode = CAMERA_FREE;
\r
799 current_position = current_camera_offset;
\r
803 if ( camera_mode == CAMERA_FREE )
\r
805 current_origin = view_origin;
\r
806 camera_offset = camera_offset - current_origin;
\r
807 current_camera_offset = current_camera_offset - current_origin;
\r
810 camera_mode = CAMERA_CHASE;
\r
812 if(cvar("camera_chase_smoothly"))
\r
813 current_origin += (view_origin - current_origin) * attenuation;
\r
815 current_origin = view_origin;
\r
817 current_position = current_origin + current_camera_offset;
\r
820 R_SetView(VF_ANGLES, current_angles);
\r
821 R_SetView(VF_ORIGIN, current_position);
\r