1 #define spider_rocket_icon "gfx/spiderbot/rocket_ico.tga"
2 #define spider_rocket_targ "gfx/spiderbot/target.tga"
3 #define SPIDER_CROSS "textures/spiderbot/cross.tga"
10 float trace_dphitcontents;
11 float trace_networkentity;
12 float Q3SURFACEFLAG_SLICK = 2; // low friction surface
13 float DPCONTENTS_SOLID = 1; // blocks player movement
14 float DPCONTENTS_BODY = 32; // blocks player movement
15 float DPCONTENTS_CORPSE = 64; // blocks player movement
16 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
19 vector p, dir, ang, q, nextdir;
20 float idx, portal_number, portal1_idx;
22 if(activeweapon != WEP_PORTO || spectatee_status || gametype == GAME_NEXBALL)
28 if (getstati(STAT_HEALTH) <= 0)
33 if(angles_held_status)
35 makevectors(angles_held);
49 traceline(p, p + 65536 * dir, TRUE, porto);
50 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
52 nextdir = dir - 2 * (dir * trace_plane_normal) * trace_plane_normal; // mirror dir at trace_plane_normal
58 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
61 ang = vectoangles2(trace_plane_normal, dir);
64 if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
66 if(portal_number == 1)
68 if(portal_number >= 2)
78 if(idx-1 >= portal1_idx)
80 Draw_CylindricLine(p, q, 4, "", 1, 0, '0 0 1', 0.5, DRAWFLAG_NORMAL);
84 Draw_CylindricLine(p, q, 4, "", 1, 0, '1 0 0', 0.5, DRAWFLAG_NORMAL);
91 * Checks whether the server initiated a map restart (stat_game_starttime changed)
93 * TODO: Use a better solution where a common shared entitiy is used that contains
94 * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
95 * and STAT_FRAGLIMIT to be auto-sent)
97 void CheckForGamestartChange() {
99 startTime = getstatf(STAT_GAMESTARTTIME);
100 if (previous_game_starttime != startTime) {
101 if ((time + 5.0) < startTime) {
102 //if connecting to server while restart was active don't always play prepareforbattle
103 sound(self, CHAN_VOICE, "announcer/robotic/prepareforbattle.wav", VOL_BASEVOICE, ATTN_NONE);
105 if (time < startTime) {
106 restartAnnouncer = spawn();
107 restartAnnouncer.think = restartAnnouncer_Think;
108 restartAnnouncer.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
111 previous_game_starttime = startTime;
117 porto.classname = "porto";
118 porto.draw = Porto_Draw;
119 porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
126 return sin(x) / cos(x);
128 float atan2(float y, float x)
131 v = '1 0 0' * x + '0 1 0' * y;
133 return v_y * 0.01745329251994329576;
136 vector GetCurrentFov(float fov)
138 float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
140 zoomsensitivity = cvar("cl_zoomsensitivity");
141 zoomfactor = cvar("cl_zoomfactor");
142 if(zoomfactor < 1 || zoomfactor > 16)
144 zoomspeed = cvar("cl_zoomspeed");
146 if(zoomspeed < 0.5 || zoomspeed > 16)
149 zoomdir = button_zoom;
150 if(getstati(STAT_ACTIVEWEAPON) == WEP_NEX) // do NOT use switchweapon here
151 zoomdir += button_attack2;
152 if(spectatee_status > 0 || isdemo())
154 if(spectatorbutton_zoom)
155 zoomdir = 0 + !zoomdir;
156 // do not even THINK about removing this 0
157 // _I_ know what I am doing
164 if(zoomin_effect || camera_active)
166 current_viewzoom = min(1, current_viewzoom + drawframetime);
170 if(zoomspeed < 0) // instant zoom
173 current_viewzoom = 1 / zoomfactor;
175 current_viewzoom = 1;
180 current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
182 current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
186 if(almost_equals(current_viewzoom, 1))
187 current_zoomfraction = 0;
188 else if(almost_equals(current_viewzoom, 1/zoomfactor))
189 current_zoomfraction = 1;
191 current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1);
193 if(zoomsensitivity < 1)
194 setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
196 setsensitivityscale(1);
198 float frustumx, frustumy, fovx, fovy;
199 frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom;
200 frustumx = frustumy * vid_width / vid_height / vid_pixelheight;
201 fovx = atan2(frustumx, 1) / 0.00872664625997164788;
202 fovy = atan2(frustumy, 1) / 0.00872664625997164788;
204 return '1 0 0' * fovx + '0 1 0' * fovy;
207 // this function must match W_SetupShot!
208 float zoomscript_caught;
210 vector wcross_origin;
211 float wcross_scale_prev, wcross_alpha_prev;
212 vector wcross_color_prev;
213 float wcross_scale_goal_prev, wcross_alpha_goal_prev;
214 vector wcross_color_goal_prev;
215 float wcross_changedonetime;
217 string wcross_name_goal_prev, wcross_name_goal_prev_prev;
218 float wcross_resolution_goal_prev, wcross_resolution_goal_prev_prev;
219 float wcross_name_changestarttime, wcross_name_changedonetime;
220 float wcross_name_alpha_goal_prev, wcross_name_alpha_goal_prev_prev;
222 entity trueaim_rifle;
224 #define SHOTTYPE_HITTEAM 1
225 #define SHOTTYPE_HITOBSTRUCTION 2
226 #define SHOTTYPE_HITWORLD 3
227 #define SHOTTYPE_HITENEMY 4
232 trueaim.classname = "trueaim";
233 trueaim.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
234 trueaim_rifle = spawn();
235 trueaim_rifle.classname = "trueaim_rifle";
236 trueaim_rifle.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
239 float EnemyHitCheck()
242 wcross_origin = project_3d_to_2d(trace_endpos);
244 if(trace_networkentity < 1)
245 return SHOTTYPE_HITWORLD;
246 if(trace_networkentity > maxclients)
247 return SHOTTYPE_HITWORLD;
248 t = GetPlayerColor(trace_networkentity - 1);
251 return SHOTTYPE_HITTEAM;
252 if(t == COLOR_SPECTATOR)
253 return SHOTTYPE_HITWORLD;
254 return SHOTTYPE_HITENEMY;
259 float nudge = 1; // added to traceline target and subtracted from result
260 vector vecs, trueaimpoint, w_shotorg;
268 case WEP_TUBA: // no aim
269 case WEP_PORTO: // shoots from eye
270 case WEP_HOOK: // no trueaim
271 case WEP_GRENADE_LAUNCHER: // toss curve
272 return SHOTTYPE_HITWORLD;
273 case WEP_CAMPINGRIFLE:
274 if(zoomscript_caught)
276 tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, trueaim);
277 return EnemyHitCheck();
280 case WEP_ROCKET_LAUNCHER: // projectile has a size!
284 case WEP_FIREBALL: // projectile has a size!
288 case WEP_ELECTRO: // projectile has a size!
294 vecs = decompressShotOrigin(getstati(STAT_SHOTORG));
296 if(activeweapon == WEP_CAMPINGRIFLE)
297 traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, trueaim_rifle);
299 traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, MOVE_NOMONSTERS, trueaim);
300 trueaimpoint = trace_endpos;
307 dv = view_right * vecs_y + view_up * vecs_z;
308 w_shotorg = view_origin + dv;
310 // now move the vecs forward as much as requested if possible
311 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
312 w_shotorg = trace_endpos - view_forward * nudge;
314 tracebox(w_shotorg, mi, ma, trueaimpoint, MOVE_NORMAL, trueaim);
315 shottype = EnemyHitCheck();
316 if(shottype != SHOTTYPE_HITWORLD)
320 // FIXME WHY DOES THIS NOT WORK FOR THE ROCKET LAUNCHER?
321 // or rather, I know why, but see no fix
322 if(vlen(trace_endpos - trueaimpoint) > vlen(ma) + vlen(mi) + 1)
323 // 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
324 return SHOTTYPE_HITOBSTRUCTION;
327 return SHOTTYPE_HITWORLD;
330 void CSQC_common_hud(void);
332 void CSQC_kh_hud(void);
333 void CSQC_ctf_hud(void);
335 void CSQC_Demo_Camera();
336 float Sbar_WouldDrawScoreboard ();
339 string NextFrameCommand;
340 void CSQC_spider_HUD();
341 void CSQC_UpdateView(float w, float h)
349 WaypointSprite_Load();
352 myteam = GetPlayerColor(spectatee_status - 1);
354 myteam = GetPlayerColor(player_localentnum - 1);
356 ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
359 if(!intermission || !view_set)
361 view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
362 view_angles = input_angles;
363 makevectors(view_angles);
364 view_forward = v_forward;
365 view_right = v_right;
374 if(time > blurtest_time0 && time < blurtest_time1)
378 t = (time - blurtest_time0) / (blurtest_time1 - blurtest_time0);
379 r = t * blurtest_radius;
380 f = 1 / pow(t, blurtest_power) - 1;
382 cvar_set("r_glsl_postprocess", "1");
383 cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(r), " ", ftos(f), " 0 0"));
387 cvar_set("r_glsl_postprocess", "0");
388 cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
394 drawframetime = max(0.000001, time - drawtime);
397 // watch for gametype changes here...
398 // in ParseStuffCMD the cmd isn't executed yet :/
399 // might even be better to add the gametype to TE_CSQC_INIT...?
403 if(intermission && !isdemo() && !(calledhooks & HOOK_END))
404 if(calledhooks & HOOK_START)
406 localcmd("\ncl_hook_gameend;");
407 calledhooks |= HOOK_END;
410 CheckForGamestartChange();
414 if(button_zoom || fov <= 59.5)
416 if(!zoomscript_caught)
418 localcmd("+button4\n");
419 zoomscript_caught = 1;
420 ignore_plus_zoom += 1;
425 if(zoomscript_caught)
427 localcmd("-button4\n");
428 zoomscript_caught = 0;
429 ignore_minus_zoom += 1;
433 sbar_alpha_fg = cvar("sbar_alpha_fg" ) * (1 - cvar("_menu_alpha"));
434 sbar_currentammo = cvar("sbar_showcurrentammo");
435 sbar_hudselector = cvar("sbar_hudselector");
436 sbar_hud_accuracy = cvar("sbar_hud_accuracy");
437 ColorTranslateMode = cvar("cl_stripcolorcodes");
438 activeweapon = getstati(STAT_SWITCHWEAPON);
439 f = cvar("teamplay");
446 if(last_weapon != activeweapon) {
448 last_weapon = activeweapon;
451 // ALWAYS Clear Current Scene First
454 // Assign Standard Viewflags
455 // Draw the World (and sky)
456 R_SetView(VF_DRAWWORLD, 1);
458 // Set the console size vars
459 vid_conwidth = cvar("vid_conwidth");
460 vid_conheight = cvar("vid_conheight");
461 vid_pixelheight = cvar("vid_pixelheight");
463 R_SetView(VF_FOV, GetCurrentFov(fov));
465 // Camera for demo playback
468 if(cvar("camera_enable"))
472 cvar_set("chase_active", ftos(chase_active_backup));
473 cvar_set("cl_demo_mousegrab", "0");
474 camera_active = FALSE;
478 else if(cvar("camera_enable"))
480 else if(cvar("camera_enable") && isdemo())
483 // Enable required Darkplaces cvars
484 chase_active_backup = cvar("chase_active");
485 cvar_set("chase_active", "2");
486 cvar_set("cl_demo_mousegrab", "1");
487 camera_active = TRUE;
491 // Draw the Crosshair
492 float scoreboard_active;
493 scoreboard_active = Sbar_WouldDrawScoreboard();
494 R_SetView(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden
496 // Draw the Engine Status Bar (the default Quake HUD)
497 R_SetView(VF_DRAWENGINESBAR, 0);
499 // fetch this one only once per frame
500 sbar_showbinds = cvar("sbar_showbinds");
501 sbar_showbinds_limit = cvar("sbar_showbinds_limit");
503 // Update the mouse position
505 mousepos_x = vid_conwidth;
506 mousepos_y = vid_conheight;
507 mousepos = mousepos*0.5 + getmousepos();
511 for(self = world; (self = nextent(self)); )
516 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
519 // now switch to 2D drawing mode by calling a 2D drawing function
520 // then polygon drawing will draw as 2D stuff, and NOT get queued until the
521 // next R_RenderScene call
522 drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);
524 // Draw the mouse cursor
525 // NOTE: drawpic must happen after R_RenderScene for some reason
526 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
527 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
528 //self = edict_num(player_localnum);
529 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
530 //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);
531 // as long as the ctf part isn't in, this is useless
535 /*if(gametype == GAME_CTF)
542 for(self = world; (self = nextent(self)); )
554 cvar_string("cl_teamradar") != "0"
557 cvar("cl_teamradar") == 2
566 if(cvar("r_letterbox") == 0) {
567 if (cvar("cl_showpressedkeys")) { // draw pressed keys when spectating and playing
568 if(spectatee_status > 0 || cvar("cl_showpressedkeys") >= 2)
569 Sbar_DrawPressedKeys();
572 if (cvar("cl_showspeed"))
574 if (cvar("cl_showacceleration"))
575 Sbar_ShowAcceleration();
577 Sbar_DrawCenterPrint(); // draw centerprint messages even if viewsize >= 120
581 hud = getstati(STAT_HUD);
582 if(hud == HUD_SPIDERBOT)
586 sz = drawgetimagesize(SPIDER_CROSS);
587 sz_x *= cvar_or("cl_vehicle_spiderbot_cross_size",1);
588 sz_y *= cvar_or("cl_vehicle_spiderbot_cross_size",1);
589 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);
593 if(cvar("r_letterbox") == 0)
594 if(cvar("viewsize") < 120)
597 // crosshair goes VERY LAST
598 if(!scoreboard_active && !ons_showmap && !camera_active) {
601 float bullets, ring_scale;
602 // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
603 wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward);
605 if(cvar("crosshair_hittest"))
607 vector wcross_oldorigin;
608 wcross_oldorigin = wcross_origin;
609 shottype = TrueAimCheck();
610 if(shottype == SHOTTYPE_HITWORLD)
612 v = wcross_origin - wcross_oldorigin;
614 v_y /= vid_conheight;
616 shottype = SHOTTYPE_HITOBSTRUCTION;
618 if(!cvar("crosshair_hittest_showimpact"))
619 wcross_origin = wcross_oldorigin;
622 shottype = SHOTTYPE_HITWORLD;
625 wcross_style = cvar_string("crosshair");
627 if (wcross_style != "0") {
628 vector wcross_color, wcross_size;
629 string wcross_wep, wcross_name;
630 float wcross_alpha, wcross_scale, wcross_blur, wcross_resolution;
632 wcross_color_x = cvar("crosshair_color_red");
633 wcross_color_y = cvar("crosshair_color_green");
634 wcross_color_z = cvar("crosshair_color_blue");
635 wcross_alpha = cvar("crosshair_color_alpha");
636 wcross_resolution = cvar("crosshair_size");
637 if (cvar("crosshair_per_weapon")) {
638 e = get_weaponinfo(activeweapon);
639 if (e && e.netname != "")
641 wcross_wep = e.netname;
642 wcross_style = cvar_string(strcat("crosshair_", wcross_wep));
643 if(wcross_style == "")
644 wcross_style = e.netname;
646 if(!cvar("crosshair_color_override"))
648 wcross_color_x = cvar(strcat("crosshair_", wcross_wep, "_color_red"));
649 wcross_color_y = cvar(strcat("crosshair_", wcross_wep, "_color_green"));
650 wcross_color_z = cvar(strcat("crosshair_", wcross_wep, "_color_blue"));
653 wcross_alpha *= cvar(strcat("crosshair_", wcross_wep, "_color_alpha"));
654 wcross_resolution *= cvar(strcat("crosshair_", wcross_wep, "_size"));
658 wcross_name = strcat("gfx/crosshair", wcross_style);
660 if(cvar("crosshair_effect_scalefade"))
662 wcross_scale = wcross_resolution;
663 wcross_resolution = 1;
670 if(shottype == SHOTTYPE_HITENEMY)
671 wcross_scale *= cvar("crosshair_hittest"); // is not queried if hittest is 0
672 if(shottype == SHOTTYPE_HITTEAM)
673 wcross_scale /= cvar("crosshair_hittest"); // is not queried if hittest is 0
675 f = cvar("crosshair_effect_speed");
677 f *= -2 * g_weaponswitchdelay;
678 if(wcross_scale != wcross_scale_goal_prev || wcross_alpha != wcross_alpha_goal_prev || wcross_color != wcross_color_goal_prev)
680 wcross_changedonetime = time + f;
682 if(wcross_name != wcross_name_goal_prev || wcross_resolution != wcross_resolution_goal_prev)
684 wcross_name_changestarttime = time;
685 wcross_name_changedonetime = time + f;
686 if(wcross_name_goal_prev_prev)
687 strunzone(wcross_name_goal_prev_prev);
688 wcross_name_goal_prev_prev = wcross_name_goal_prev;
689 wcross_name_goal_prev = strzone(wcross_name);
690 wcross_name_alpha_goal_prev_prev = wcross_name_alpha_goal_prev;
691 wcross_resolution_goal_prev_prev = wcross_resolution_goal_prev;
692 wcross_resolution_goal_prev = wcross_resolution;
695 wcross_scale_goal_prev = wcross_scale;
696 wcross_alpha_goal_prev = wcross_alpha;
697 wcross_color_goal_prev = wcross_color;
699 if(shottype == SHOTTYPE_HITTEAM || (shottype == SHOTTYPE_HITOBSTRUCTION && cvar("crosshair_hittest_blur") && !cvar("chase_active")))
702 wcross_alpha *= 0.75;
706 // *_prev is at time-frametime
707 // * is at wcross_changedonetime+f
708 // what do we have at time?
709 if(time < wcross_changedonetime)
711 f = frametime / (wcross_changedonetime - time + frametime);
712 wcross_scale = f * wcross_scale + (1 - f) * wcross_scale_prev;
713 wcross_alpha = f * wcross_alpha + (1 - f) * wcross_alpha_prev;
714 wcross_color = f * wcross_color + (1 - f) * wcross_color_prev;
717 wcross_scale_prev = wcross_scale;
718 wcross_alpha_prev = wcross_alpha;
719 wcross_color_prev = wcross_color;
721 wcross_scale *= 1 - cvar("_menu_alpha");
722 wcross_alpha *= 1 - cvar("_menu_alpha");
724 wcross_size = drawgetimagesize(wcross_name) * wcross_scale;
726 // ring around crosshair representing bullets left in camping rifle clip
727 if (activeweapon == WEP_CAMPINGRIFLE)
729 ring_scale = cvar("crosshair_campingrifle_ring_size");
730 bullets = bound(0, getstati(STAT_BULLETS_LOADED), 8);
735 #define CROSSHAIR_DRAW_RING(i,j,sz,dummy1,dummy2) \
736 drawpic(wcross_origin - ('0.5 0 0' * (sz * wcross_size_x * ring_scale + i * wcross_blur) + '0 0.5 0' * (sz * wcross_size_y * ring_scale + j * wcross_blur)), strcat("gfx/hud/rifle_ring_", ftos(bullets)), sz * wcross_size * ring_scale, wcross_color, wcross_alpha, DRAWFLAG_NORMAL)
738 #define CROSSHAIR_DO_BLUR(M,sz,a,b) \
741 if(wcross_blur > 0) \
743 wcross_alpha = wcross_alpha * 0.04; \
744 for(i = -2; i <= 2; ++i) \
745 for(j = -2; j <= 2; ++j) \
755 #define CROSSHAIR_DRAW_SINGLE(i,j,sz,wcross_name,wcross_alpha) \
756 drawpic(wcross_origin - ('0.5 0 0' * (sz * wcross_size_x + i * wcross_blur) + '0 0.5 0' * (sz * wcross_size_y + j * wcross_blur)), wcross_name, sz * wcross_size, wcross_color, wcross_alpha, DRAWFLAG_NORMAL)
758 #define CROSSHAIR_DRAW(sz,wcross_name,wcross_alpha) \
759 CROSSHAIR_DO_BLUR(CROSSHAIR_DRAW_SINGLE,sz,wcross_name,wcross_alpha)
763 CROSSHAIR_DO_BLUR(CROSSHAIR_DRAW_RING, wcross_resolution, 0, 0);
766 if(time < wcross_name_changedonetime && wcross_name != wcross_name_goal_prev_prev && wcross_name_goal_prev_prev)
768 f = (wcross_name_changedonetime - time) / (wcross_name_changedonetime - wcross_name_changestarttime);
769 CROSSHAIR_DRAW(wcross_resolution_goal_prev_prev, wcross_name_goal_prev_prev, wcross_alpha * f * wcross_name_alpha_goal_prev_prev);
776 CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f);
777 wcross_name_alpha_goal_prev = f;
782 wcross_scale_prev = 0;
783 wcross_alpha_prev = 0;
784 wcross_scale_goal_prev = 0;
785 wcross_alpha_goal_prev = 0;
786 wcross_changedonetime = 0;
787 if(wcross_name_goal_prev)
788 strunzone(wcross_name_goal_prev);
789 wcross_name_goal_prev = string_null;
790 if(wcross_name_goal_prev_prev)
791 strunzone(wcross_name_goal_prev_prev);
792 wcross_name_goal_prev_prev = string_null;
793 wcross_name_changestarttime = 0;
794 wcross_name_changedonetime = 0;
795 wcross_name_alpha_goal_prev = 0;
796 wcross_name_alpha_goal_prev_prev = 0;
797 wcross_resolution_goal_prev = 0;
798 wcross_resolution_goal_prev_prev = 0;
804 localcmd("\n", NextFrameCommand, "\n");
805 NextFrameCommand = string_null;
808 // we must do this check AFTER a frame was rendered, or it won't work
809 if(cs_project_is_b0rked == 0)
812 w0 = cvar_string("vid_conwidth");
813 h0 = cvar_string("vid_conheight");
814 //R_SetView(VF_VIEWPORT, '0 0 0', '640 480 0');
815 //R_SetView(VF_FOV, '90 90 0');
816 R_SetView(VF_ORIGIN, '0 0 0');
817 R_SetView(VF_ANGLES, '0 0 0');
818 R_SetView(VF_PERSPECTIVE, 1);
819 makevectors('0 0 0');
821 cvar_set("vid_conwidth", "800");
822 cvar_set("vid_conheight", "600");
823 v1 = cs_project(v_forward);
824 cvar_set("vid_conwidth", "640");
825 cvar_set("vid_conheight", "480");
826 v2 = cs_project(v_forward);
828 cs_project_is_b0rked = 1;
830 cs_project_is_b0rked = -1;
831 cvar_set("vid_conwidth", w0);
832 cvar_set("vid_conheight", h0);
835 // be safe against triggerbots until everyone has the fixed engine
836 // this call is meant to overwrite the trace globals by something
838 traceline('0 0 0', '0 0 0', MOVE_WORLDONLY, world);
842 void CSQC_spider_HUD()
844 float rockets,reload,heat,hp,shield,i;
847 rockets = getstati(STAT_SPIDERBOT_ROCKETS);
848 heat = min(getstatf(STAT_SPIDERBOT_HEAT),1);
849 reload = min(getstatf(STAT_SPIDERBOT_RELOAD),1);
850 hp = min(getstatf(STAT_SPIDERBOT_HEALTH),1);
851 shield = min(getstatf(STAT_SPIDERBOT_SHIELD),1);
854 p = '0.5 0 0' * (vid_conwidth - (rkt_size * 8));
855 p = p + '0 1 0' * vid_conheight - '0 32 0';
856 //pp = ('0 1 0' * hp) + ('1 0 0' * (1-hp));
857 drawfill(p, '256 0 0' * shield + '0 8 0' , '0.5 0.5 1', 0.75, DRAWFLAG_NORMAL);
859 drawfill(p, '256 0 0' * hp + '0 8 0' , '0 1 0', 0.75, DRAWFLAG_NORMAL);
861 drawfill(p, '256 0 0' * (1-hp) + '0 8 0' , '0 0 0', 0.75, DRAWFLAG_NORMAL);
863 // Draw minigun heat indicator
864 p = '0.5 0 0' * (vid_conwidth - 256);
865 p = p + '0 1 0' * vid_conheight - '0 34 0';
866 drawfill(p, '256 0 0' * (1-heat) + '0 2 0' ,'0 0 1', 0.5, DRAWFLAG_NORMAL);
867 p_x += 256 * (1-heat);
868 drawfill(p, '256 0 0' * heat + '0 2 0' , '1 0 0', 0.5, DRAWFLAG_NORMAL);
870 // Draw rocket icons for loaded/empty tubes.
871 pp = '0.5 0 0' * (vid_conwidth - (rkt_size * 8));
872 pp += '0 1 0' * vid_conheight - '0 64 0';
873 for(i = 0; i < 8; ++i)
875 p = pp + '1 0 0' * (rkt_size * i);
878 if(floor(reload * 8) == i)
880 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '1 0 0' + '0 1 0' * ((reload*8)-i), 0.75 , DRAWFLAG_NORMAL);
882 else if(i < reload * 8)
883 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '1 1 0', 0.75 , DRAWFLAG_NORMAL);
885 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '0.5 0.5 0.5', 0.75, DRAWFLAG_NORMAL);
890 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '0 0 0', 0.25, DRAWFLAG_NORMAL);
892 drawpic(p, spider_rocket_icon, '1 1 0' * rkt_size, '0 1 0' * reload, 0.75, DRAWFLAG_NORMAL);
898 Sbar_DrawScoreboard();
899 Sbar_DrawCenterPrint();
903 void CSQC_common_hud(void)
905 // Sbar_SortFrags(); done in Sbar_Draw
907 hud = getstati(STAT_HUD);
923 // following vectors must be global to allow seamless switching between camera modes
924 vector camera_offset, current_camera_offset, mouse_angles, current_angles, current_origin, current_position;
925 void CSQC_Demo_Camera()
927 float speed, attenuation, dimensions;
930 if( cvar("camera_reset") || !camera_mode )
932 camera_offset = '0 0 0';
933 current_angles = '0 0 0';
934 camera_direction = '0 0 0';
935 camera_offset_z += 30;
936 camera_offset_x += 30 * -cos(current_angles_y * DEG2RAD);
937 camera_offset_y += 30 * -sin(current_angles_y * DEG2RAD);
938 current_origin = view_origin;
939 current_camera_offset = camera_offset;
940 cvar_set("camera_reset", "0");
941 camera_mode = CAMERA_CHASE;
946 mouse_angles_z += camera_roll * cvar("camera_speed_roll");
948 if(cvar("camera_look_player"))
953 dir = normalize(view_origin - current_position);
955 mouse_angles = vectoangles(dir);
956 mouse_angles_x = mouse_angles_x * -1;
961 tmp = getmousepos() * 0.1;
962 if(vlen(tmp)>cvar("camera_mouse_treshold"))
964 mouse_angles_x += tmp_y * cos(mouse_angles_z * DEG2RAD) + (tmp_x * sin(mouse_angles_z * DEG2RAD));
965 mouse_angles_y -= tmp_x * cos(mouse_angles_z * DEG2RAD) + (tmp_y * -sin(mouse_angles_z * DEG2RAD));
969 while (mouse_angles_x < -180) mouse_angles_x = mouse_angles_x + 360;
970 while (mouse_angles_x > 180) mouse_angles_x = mouse_angles_x - 360;
971 while (mouse_angles_y < -180) mouse_angles_y = mouse_angles_y + 360;
972 while (mouse_angles_y > 180) mouse_angles_y = mouse_angles_y - 360;
974 // Fix difference when angles don't have the same sign
976 if(mouse_angles_y < -60 && current_angles_y > 60)
978 if(mouse_angles_y > 60 && current_angles_y < -60)
981 if(cvar("camera_look_player"))
982 attenuation = cvar("camera_look_attenuation");
984 attenuation = cvar("camera_speed_attenuation");
986 attenuation = 1 / max(1, attenuation);
987 current_angles += (mouse_angles - current_angles + delta) * attenuation;
989 while (current_angles_x < -180) current_angles_x = current_angles_x + 360;
990 while (current_angles_x > 180) current_angles_x = current_angles_x - 360;
991 while (current_angles_y < -180) current_angles_y = current_angles_y + 360;
992 while (current_angles_y > 180) current_angles_y = current_angles_y - 360;
998 if( camera_direction_x )
1000 tmp_x = camera_direction_x * cos(current_angles_y * DEG2RAD);
1001 tmp_y = camera_direction_x * sin(current_angles_y * DEG2RAD);
1002 if( cvar("camera_forward_follows") && !cvar("camera_look_player") )
1003 tmp_z = camera_direction_x * -sin(current_angles_x * DEG2RAD);
1007 if( camera_direction_y )
1009 tmp_x += camera_direction_y * -sin(current_angles_y * DEG2RAD);
1010 tmp_y += camera_direction_y * cos(current_angles_y * DEG2RAD) * cos(current_angles_z * DEG2RAD);
1011 tmp_z += camera_direction_y * sin(current_angles_z * DEG2RAD);
1015 if( camera_direction_z )
1017 tmp_z += camera_direction_z * cos(current_angles_z * DEG2RAD);
1021 if(cvar("camera_free"))
1022 speed = cvar("camera_speed_free");
1024 speed = cvar("camera_speed_chase");
1028 speed = speed * sqrt(1 / dimensions);
1029 camera_offset += tmp * speed;
1032 current_camera_offset += (camera_offset - current_camera_offset) * attenuation;
1035 if( cvar("camera_free") )
1037 if ( camera_mode == CAMERA_CHASE )
1039 current_camera_offset = current_origin + current_camera_offset;
1040 camera_offset = current_origin + camera_offset;
1043 camera_mode = CAMERA_FREE;
1044 current_position = current_camera_offset;
1048 if ( camera_mode == CAMERA_FREE )
1050 current_origin = view_origin;
1051 camera_offset = camera_offset - current_origin;
1052 current_camera_offset = current_camera_offset - current_origin;
1055 camera_mode = CAMERA_CHASE;
1057 if(cvar("camera_chase_smoothly"))
1058 current_origin += (view_origin - current_origin) * attenuation;
1060 current_origin = view_origin;
1062 current_position = current_origin + current_camera_offset;
1065 R_SetView(VF_ANGLES, current_angles);
1066 R_SetView(VF_ORIGIN, current_position);