2 #define rld_size_x 256
\r
3 #define rld_size_y 16
\r
6 float trace_networkentity;
\r
7 float Q3SURFACEFLAG_SLICK = 2; // low friction surface
\r
8 float DPCONTENTS_SOLID = 1; // blocks player movement
\r
9 float DPCONTENTS_BODY = 32; // blocks player movement
\r
10 float DPCONTENTS_CORPSE = 64; // blocks player movement
\r
11 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
\r
16 if(spectatee_status)
\r
18 if(intermission == 1)
\r
20 if(intermission == 2)
\r
22 if (getstati(STAT_HEALTH) <= 0)
\r
27 if(angles_held_status)
\r
29 makevectors(angles_held);
\r
35 * Checks whether the server initiated a map restart (stat_game_starttime changed)
\r
37 * TODO: Use a better solution where a common shared entitiy is used that contains
\r
38 * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
\r
39 * and STAT_FRAGLIMIT to be auto-sent)
\r
41 void CheckForGamestartChange() {
\r
43 startTime = getstatf(STAT_GAMESTARTTIME);
\r
44 if (previous_game_starttime != startTime) {
\r
45 if ((time + 5.0) < startTime) {
\r
46 //if connecting to server while restart was active don't always play prepareforbattle
\r
47 sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/prepareforbattle.wav"), VOL_BASEVOICE, ATTN_NONE);
\r
49 if (time < startTime) {
\r
50 restartAnnouncer = spawn();
\r
51 restartAnnouncer.think = restartAnnouncer_Think;
\r
52 restartAnnouncer.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
\r
55 previous_game_starttime = startTime;
\r
61 porto.classname = "porto";
\r
62 porto.draw = Porto_Draw;
\r
63 porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
\r
68 vector GetCurrentFov(float fov)
\r
70 float zoomsensitivity, zoomspeed, zoomfactor, zoomdir, velocityzoom;
\r
72 zoomsensitivity = cvar("cl_zoomsensitivity");
\r
73 zoomfactor = cvar("cl_zoomfactor");
\r
74 if(zoomfactor < 1 || zoomfactor > 16)
\r
76 zoomspeed = cvar("cl_zoomspeed");
\r
78 if(zoomspeed < 0.5 || zoomspeed > 16)
\r
81 zoomdir = button_zoom;
\r
82 if(spectatee_status > 0 || isdemo())
\r
84 if(spectatorbutton_zoom)
\r
85 zoomdir = 0 + !zoomdir;
\r
86 // do not even THINK about removing this 0
\r
87 // _I_ know what I am doing
\r
94 if(zoomin_effect || camera_active)
\r
96 current_viewzoom = min(1, current_viewzoom + drawframetime);
\r
100 if(zoomspeed < 0) // instant zoom
\r
103 current_viewzoom = 1 / zoomfactor;
\r
105 current_viewzoom = 1;
\r
110 current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
\r
112 current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
\r
116 if(almost_equals(current_viewzoom, 1))
\r
117 current_zoomfraction = 0;
\r
118 else if(almost_equals(current_viewzoom, 1/zoomfactor))
\r
119 current_zoomfraction = 1;
\r
121 current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1);
\r
123 if(zoomsensitivity < 1)
\r
124 setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
\r
126 setsensitivityscale(1);
\r
128 velocityzoom = bound(0, drawframetime / max(0.000000001, cvar_or("cl_velocityzoomtime", 0.3)), 1);
\r
129 avgspeed = avgspeed * (1 - velocityzoom) + (vlen(pmove_vel) / 1000) * velocityzoom;
\r
130 velocityzoom = exp(float2range11(avgspeed * -cvar_or("cl_velocityzoom", 0) / 1) * 1);
\r
132 //print(ftos(avgspeed), " avgspeed, ", ftos(cvar_or("cl_velocityzoom", 0)), " cvar, ", ftos(velocityzoom), " return\n"); // for debugging
\r
134 float frustumx, frustumy, fovx, fovy;
\r
135 frustumy = tan(fov * M_PI / 360.0) * 0.75 * current_viewzoom * velocityzoom;
\r
136 frustumx = frustumy * vid_width / vid_height / vid_pixelheight;
\r
137 fovx = atan2(frustumx, 1) / M_PI * 360.0;
\r
138 fovy = atan2(frustumy, 1) / M_PI * 360.0;
\r
140 return '1 0 0' * fovx + '0 1 0' * fovy;
\r
143 // this function must match W_SetupShot!
\r
144 float zoomscript_caught;
\r
146 vector wcross_origin;
\r
147 float wcross_scale_prev, wcross_alpha_prev;
\r
148 vector wcross_color_prev;
\r
149 float wcross_scale_goal_prev, wcross_alpha_goal_prev;
\r
150 vector wcross_color_goal_prev;
\r
151 float wcross_changedonetime;
\r
153 string wcross_name_goal_prev, wcross_name_goal_prev_prev;
\r
154 float wcross_resolution_goal_prev, wcross_resolution_goal_prev_prev;
\r
155 float wcross_name_changestarttime, wcross_name_changedonetime;
\r
156 float wcross_name_alpha_goal_prev, wcross_name_alpha_goal_prev_prev;
\r
158 entity trueaim_rifle;
\r
160 #define SHOTTYPE_HITTEAM 1
\r
161 #define SHOTTYPE_HITOBSTRUCTION 2
\r
162 #define SHOTTYPE_HITWORLD 3
\r
163 #define SHOTTYPE_HITENEMY 4
\r
165 void TrueAim_Init()
\r
168 trueaim.classname = "trueaim";
\r
169 trueaim.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
\r
170 trueaim_rifle = spawn();
\r
171 trueaim_rifle.classname = "trueaim_rifle";
\r
172 trueaim_rifle.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
\r
175 float EnemyHitCheck()
\r
178 wcross_origin = project_3d_to_2d(trace_endpos);
\r
179 wcross_origin_z = 0;
\r
180 if(trace_networkentity < 1)
\r
181 return SHOTTYPE_HITWORLD;
\r
182 if(trace_networkentity > maxclients)
\r
183 return SHOTTYPE_HITWORLD;
\r
184 t = GetPlayerColor(trace_networkentity - 1);
\r
187 return SHOTTYPE_HITTEAM;
\r
188 if(t == COLOR_SPECTATOR)
\r
189 return SHOTTYPE_HITWORLD;
\r
190 return SHOTTYPE_HITENEMY;
\r
193 float TrueAimCheck()
\r
195 float nudge = 1; // added to traceline target and subtracted from result
\r
196 vector vecs, trueaimpoint, w_shotorg;
\r
204 mv = MOVE_NOMONSTERS;
\r
206 switch(activeweapon)
\r
208 case WEP_GRABBER: // no trueaim
\r
211 vecs = decompressShotOrigin(getstati(STAT_SHOTORG));
\r
213 traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
\r
214 trueaimpoint = trace_endpos;
\r
221 dv = view_right * vecs_y + view_up * vecs_z;
\r
222 w_shotorg = view_origin + dv;
\r
224 // now move the vecs forward as much as requested if possible
\r
225 tracebox(w_shotorg, mi, ma, w_shotorg + view_forward * (vecs_x + nudge), MOVE_NORMAL, ta); // FIXME this MOVE_NORMAL part will misbehave a little in csqc
\r
226 w_shotorg = trace_endpos - view_forward * nudge;
\r
228 tracebox(w_shotorg, mi, ma, trueaimpoint, MOVE_NORMAL, ta);
\r
229 shottype = EnemyHitCheck();
\r
230 if(shottype != SHOTTYPE_HITWORLD)
\r
234 // FIXME WHY DOES THIS NOT WORK FOR THE ROCKET LAUNCHER?
\r
235 // or rather, I know why, but see no fix
\r
236 if(vlen(trace_endpos - trueaimpoint) > vlen(ma) + vlen(mi) + 1)
\r
237 // 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
238 return SHOTTYPE_HITOBSTRUCTION;
\r
241 return SHOTTYPE_HITWORLD;
\r
244 void CSQC_common_hud(void);
\r
246 void CSQC_kh_hud(void);
\r
247 void CSQC_ctf_hud(void);
\r
248 void PostInit(void);
\r
249 void CSQC_Demo_Camera();
\r
250 float Sbar_WouldDrawScoreboard ();
\r
253 float chase_active_old;
\r
254 float artwork_fade;
\r
255 float pickup_crosshair_time, pickup_crosshair_size;
\r
256 float myhealth, myhealth_prev, myhealth_flash;
\r
257 float contentavgalpha, liquidalpha_prev;
\r
258 vector myhealth_gentlergb;
\r
259 vector liquidcolor_prev;
\r
260 vector damage_blurpostprocess, content_blurpostprocess;
\r
261 string artwork_image;
\r
262 string intermission_song;
\r
263 string NextFrameCommand;
\r
264 void CSQC_UpdateView(float w, float h)
\r
271 vector artwork_pos, artwork_size;
\r
273 WaypointSprite_Load();
\r
275 if(spectatee_status)
\r
276 myteam = GetPlayerColor(spectatee_status - 1);
\r
278 myteam = GetPlayerColor(player_localentnum - 1);
\r
280 ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
\r
281 vo = '0 0 1' * getstati(STAT_VIEWHEIGHT);
\r
283 warpzone_fixview_origin = pmove_org + vo;
\r
284 warpzone_fixview_angles = input_angles;
\r
285 WarpZone_FixView();
\r
286 pmove_org = warpzone_fixview_origin - vo;
\r
287 input_angles = warpzone_fixview_angles;
\r
289 // Render the Scene
\r
290 if(!intermission || !view_set)
\r
292 view_origin = pmove_org + vo;
\r
293 view_angles = input_angles;
\r
294 makevectors(view_angles);
\r
295 view_forward = v_forward;
\r
296 view_right = v_right;
\r
305 if(time > blurtest_time0 && time < blurtest_time1)
\r
309 t = (time - blurtest_time0) / (blurtest_time1 - blurtest_time0);
\r
310 r = t * blurtest_radius;
\r
311 f = 1 / pow(t, blurtest_power) - 1;
\r
313 cvar_set("r_glsl_postprocess", "1");
\r
314 cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(r), " ", ftos(f), " 0 0"));
\r
318 cvar_set("r_glsl_postprocess", "0");
\r
319 cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
\r
323 TargetMusic_Advance();
\r
326 drawframetime = max(0.000001, time - drawtime);
\r
329 // watch for gametype changes here...
\r
330 // in ParseStuffCMD the cmd isn't executed yet :/
\r
331 // might even be better to add the gametype to TE_CSQC_INIT...?
\r
335 if(intermission && !isdemo() && !(calledhooks & HOOK_END))
\r
336 if(calledhooks & HOOK_START)
\r
338 localcmd("\ncl_hook_gameend;");
\r
340 localcmd("\ncl_hook_campaign_gameend;");
\r
341 calledhooks |= HOOK_END;
\r
344 CheckForGamestartChange();
\r
346 maptimeAnnouncer();
\r
347 carrierAnnouncer();
\r
350 if(button_zoom || fov <= 59.5)
\r
352 if(!zoomscript_caught)
\r
354 localcmd("+button4\n");
\r
355 zoomscript_caught = 1;
\r
356 ignore_plus_zoom += 1;
\r
361 if(zoomscript_caught)
\r
363 localcmd("-button4\n");
\r
364 zoomscript_caught = 0;
\r
365 ignore_minus_zoom += 1;
\r
369 sbar_alpha_fg = cvar("sbar_alpha_fg" ) * (1 - cvar("_menu_alpha"));
\r
370 sbar_hudselector = cvar("sbar_hudselector");
\r
371 sbar_accuracy_hud = cvar_or("sbar_accuracy_hud", 1);
\r
372 ColorTranslateMode = cvar("cl_stripcolorcodes");
\r
373 activeweapon = getstati(STAT_SWITCHWEAPON);
\r
374 f = cvar("teamplay");
\r
381 if(last_weapon != activeweapon) {
\r
383 last_weapon = activeweapon;
\r
386 // ALWAYS Clear Current Scene First
\r
389 // Assign Standard Viewflags
\r
390 // Draw the World (and sky)
\r
391 R_SetView(VF_DRAWWORLD, 1);
\r
393 // Set the console size vars
\r
394 vid_conwidth = cvar("vid_conwidth");
\r
395 vid_conheight = cvar("vid_conheight");
\r
396 vid_pixelheight = cvar("vid_pixelheight");
\r
398 R_SetView(VF_FOV, GetCurrentFov(fov));
\r
400 // Camera for demo playback
\r
403 if(cvar("camera_enable"))
\r
404 CSQC_Demo_Camera();
\r
407 cvar_set("chase_active", ftos(chase_active_backup));
\r
408 cvar_set("cl_demo_mousegrab", "0");
\r
409 camera_active = FALSE;
\r
413 else if(cvar("camera_enable"))
\r
415 else if(cvar("camera_enable") && isdemo())
\r
418 // Enable required Darkplaces cvars
\r
419 chase_active_backup = cvar("chase_active");
\r
420 cvar_set("chase_active", "2");
\r
421 cvar_set("cl_demo_mousegrab", "1");
\r
422 camera_active = TRUE;
\r
423 camera_mode = FALSE;
\r
426 // Draw the Crosshair
\r
427 float scoreboard_active;
\r
428 scoreboard_active = Sbar_WouldDrawScoreboard();
\r
429 R_SetView(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden
\r
431 // Draw the Engine Status Bar (the default Quake HUD)
\r
432 R_SetView(VF_DRAWENGINESBAR, 0);
\r
434 // fetch this one only once per frame
\r
435 sbar_showbinds = cvar("sbar_showbinds");
\r
436 sbar_showbinds_limit = cvar("sbar_showbinds_limit");
\r
438 // Update the mouse position
\r
440 mousepos_x = vid_conwidth;
\r
441 mousepos_y = vid_conheight;
\r
442 mousepos = mousepos*0.5 + getmousepos();
\r
446 for(self = world; (self = nextent(self)); )
\r
451 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
\r
454 // now switch to 2D drawing mode by calling a 2D drawing function
\r
455 // then polygon drawing will draw as 2D stuff, and NOT get queued until the
\r
456 // next R_RenderScene call
\r
457 drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);
\r
459 if(cvar("hud_contents"))
\r
461 float contentalpha_temp, incontent, liquidalpha, contentfadetime;
\r
462 vector liquidcolor;
\r
464 if (getstati(STAT_VORE_EATEN))
\r
466 liquidalpha = cvar("hud_contents_stomach_alpha");
\r
467 liquidcolor = stov(cvar_string("hud_contents_stomach_color"));
\r
472 switch(pointcontents(view_origin))
\r
474 case CONTENT_WATER:
\r
475 liquidalpha = cvar("hud_contents_water_alpha");
\r
476 liquidcolor = stov(cvar_string("hud_contents_water_color"));
\r
481 liquidalpha = cvar("hud_contents_lava_alpha");
\r
482 liquidcolor = stov(cvar_string("hud_contents_lava_color"));
\r
486 case CONTENT_SLIME:
\r
487 liquidalpha = cvar("hud_contents_slime_alpha");
\r
488 liquidcolor = stov(cvar_string("hud_contents_slime_color"));
\r
494 liquidcolor = '0 0 0';
\r
500 if(incontent) // fade in/out at different speeds so you can do e.g. instant fade when entering water and slow when leaving it.
\r
501 { // also lets delcare previous values for blending properties, this way it isn't reset until after you have entered a different content
\r
502 contentfadetime = cvar("hud_contents_fadeintime");
\r
503 liquidalpha_prev = liquidalpha;
\r
504 liquidcolor_prev = liquidcolor;
\r
507 contentfadetime = cvar("hud_contents_fadeouttime");
\r
509 contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1);
\r
510 contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp;
\r
512 if(contentavgalpha)
\r
513 drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL);
\r
516 if(cvar("hud_damage"))
\r
518 float myhealth_flash_temp;
\r
519 myhealth = getstati(STAT_HEALTH);
\r
522 myhealth_flash = max(0, myhealth_flash - cvar("hud_damage_fade_rate") * frametime);
\r
524 myhealth_flash = bound(0, myhealth_flash + dmg_take * cvar("hud_damage_factor"), cvar("hud_damage_maxalpha"));
\r
526 float pain_threshold, pain_threshold_lower, pain_threshold_lower_health;
\r
527 pain_threshold = cvar("hud_damage_pain_threshold");
\r
528 pain_threshold_lower = cvar("hud_damage_pain_threshold_lower");
\r
529 pain_threshold_lower_health = cvar("hud_damage_pain_threshold_lower_health");
\r
531 if(pain_threshold_lower && myhealth < pain_threshold_lower_health)
\r
533 pain_threshold = pain_threshold - max(cvar("hud_damage_pain_threshold_pulsating_min"), fabs(sin(M_PI * time / cvar("hud_damage_pain_threshold_pulsating_period")))) * pain_threshold_lower * (1 - max(0, myhealth)/pain_threshold_lower_health);
\r
536 myhealth_flash_temp = bound(0, myhealth_flash - pain_threshold, 1);
\r
538 if(myhealth_prev < 1)
\r
542 myhealth_flash = 0; // just spawned, clear the flash immediately
\r
543 myhealth_flash_temp = 0;
\r
547 myhealth_flash += cvar("hud_damage_fade_rate") * frametime; // dead
\r
551 if(spectatee_status == -1 || intermission)
\r
553 myhealth_flash = 0; // observing, or match ended
\r
554 myhealth_flash_temp = 0;
\r
557 myhealth_prev = myhealth;
\r
559 if(cvar("cl_gentle_damage") || cvar("cl_gentle"))
\r
561 if(cvar("cl_gentle_damage") == 2)
\r
563 if(myhealth_flash < pain_threshold) // only randomize when the flash is gone
\r
565 myhealth_gentlergb = '1 0 0' * random() + '0 1 0' * random() + '0 0 1' * random();
\r
569 myhealth_gentlergb = stov(cvar_string("hud_damage_gentle_color"));
\r
571 drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, myhealth_gentlergb, cvar("hud_damage_gentle_alpha_multiplier") * bound(0, myhealth_flash_temp, 1) * cvar("hud_damage"), DRAWFLAG_NORMAL);
\r
574 drawpic('0 0 0', "gfx/blood", '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, stov(cvar_string("hud_damage_color")), bound(0, myhealth_flash_temp, 1) * cvar("hud_damage"), DRAWFLAG_NORMAL);
\r
576 if(cvar("hud_postprocessing"))
\r
578 if(cvar("hud_damage_blur"))
\r
580 damage_blurpostprocess_x = 1;
\r
581 damage_blurpostprocess_y = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur");
\r
582 damage_blurpostprocess_z = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur_alpha");
\r
586 damage_blurpostprocess_x = 0;
\r
587 damage_blurpostprocess_y = 0;
\r
588 damage_blurpostprocess_z = 0;
\r
593 if(cvar("hud_postprocessing"))
\r
594 { // lets apply the postprocess effects from the previous two functions if needed
\r
595 if(damage_blurpostprocess_x || content_blurpostprocess_x)
\r
597 float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, cvar("hud_postprocessing_maxblurradius"));
\r
598 float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, cvar("hud_postprocessing_maxbluralpha"));
\r
599 cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0"));
\r
600 cvar_set("r_glsl_postprocess_uservec1_enable", "1");
\r
604 cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
\r
605 cvar_set("r_glsl_postprocess_uservec1_enable", "0");
\r
609 // Draw the mouse cursor
\r
610 // NOTE: drawpic must happen after R_RenderScene for some reason
\r
611 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
\r
612 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
\r
613 //self = edict_num(player_localnum);
\r
614 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
\r
615 //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
616 // as long as the ctf part isn't in, this is useless
\r
620 /*if(gametype == GAME_CTF)
\r
625 // draw 2D entities
\r
627 for(self = world; (self = nextent(self)); )
\r
639 cvar_string("cl_teamradar") != "0"
\r
642 cvar("cl_teamradar") == 2
\r
650 // Draw artwork and play intermission music
\r
651 if(intermission && !isdemo() && gametype != GAME_RPG && !spectatee_status) // the match has ended. Don't do this for RPG because no one wins or loses there
\r
653 if(cvar("cl_artwork"))
\r
655 if(artwork_image == "")
\r
657 if(getstati(STAT_WINNING)) // we are the winner
\r
659 if(cvar("cl_artwork_win"))
\r
661 artwork_image = strcat("gfx/artwork_won_", ftos(floor(1 + (random() * cvar("cl_artwork_win")))));
\r
662 artwork_image = strzone(artwork_image);
\r
665 else // we have lost
\r
667 if(cvar("cl_artwork_lose"))
\r
669 artwork_image = strcat("gfx/artwork_lost_", ftos(floor(1 + (random() * cvar("cl_artwork_lose")))));
\r
670 artwork_image = strzone(artwork_image);
\r
675 if(cvar("cl_artwork_stretch"))
\r
677 artwork_size_x = vid_conwidth;
\r
678 artwork_size_y = vid_conheight;
\r
684 artwork_size_x = max(vid_conwidth, vid_conheight);
\r
685 artwork_size_y = max(vid_conwidth, vid_conheight);
\r
686 artwork_pos_x = (vid_conwidth - artwork_size_x) / 2;
\r
687 artwork_pos_y = (vid_conheight - artwork_size_y) / 2;
\r
690 if(artwork_fade < cvar("cl_artwork_alpha") && cvar("cl_artwork_fade"))
\r
691 artwork_fade += frametime * cvar("cl_artwork_fade");
\r
693 artwork_fade = cvar("cl_artwork_alpha");
\r
695 if(artwork_image != "")
\r
696 drawpic(artwork_pos, artwork_image, artwork_size, '1 1 1', artwork_fade, DRAWFLAG_NORMAL);
\r
699 if(cvar("cl_intermission") && intermission_song == "") // don't start the song each frame
\r
701 if(getstati(STAT_WINNING))
\r
702 intermission_song = cvar_string("cl_intermission_cdtrack_win");
\r
704 intermission_song = cvar_string("cl_intermission_cdtrack_lose");
\r
705 if(intermission_song != "")
\r
707 localcmd(strcat("\ncd play ", intermission_song, "\n"));
\r
708 intermission_song = strzone(intermission_song);
\r
715 if(artwork_image != "")
\r
717 strunzone(artwork_image);
\r
718 artwork_image = "";
\r
721 if(intermission_song != "")
\r
723 strunzone(intermission_song);
\r
724 intermission_song = "";
\r
729 if(cvar("r_letterbox") == 0) {
\r
730 if (cvar("cl_showpressedkeys")) { // draw pressed keys when spectating and playing
\r
731 if(spectatee_status > 0 || cvar("cl_showpressedkeys") >= 2)
\r
732 Sbar_DrawPressedKeys();
\r
735 if (cvar("cl_showspeed"))
\r
737 if (cvar("cl_showacceleration"))
\r
738 Sbar_ShowAcceleration();
\r
740 Sbar_DrawCenterPrint(); // draw centerprint messages even if viewsize >= 120
\r
744 hud = getstati(STAT_HUD);
\r
746 if(cvar("r_letterbox") == 0)
\r
747 if(cvar("viewsize") < 120)
\r
750 if not(getstati(STAT_VORE_EATEN)) // crosshair is useless if we're in the stomach
\r
752 // crosshair goes VERY LAST
\r
753 if(!scoreboard_active && !ons_showmap && !camera_active) {
\r
756 // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
\r
757 wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward);
\r
758 wcross_origin_z = 0;
\r
759 if(cvar("crosshair_hittest"))
\r
761 vector wcross_oldorigin;
\r
762 wcross_oldorigin = wcross_origin;
\r
763 shottype = TrueAimCheck();
\r
764 if(shottype == SHOTTYPE_HITWORLD)
\r
766 v = wcross_origin - wcross_oldorigin;
\r
767 v_x /= vid_conwidth;
\r
768 v_y /= vid_conheight;
\r
770 shottype = SHOTTYPE_HITOBSTRUCTION;
\r
772 if(!cvar("crosshair_hittest_showimpact"))
\r
773 wcross_origin = wcross_oldorigin;
\r
776 shottype = SHOTTYPE_HITWORLD;
\r
778 string wcross_style;
\r
779 wcross_style = cvar_string("crosshair");
\r
781 if (wcross_style != "0") {
\r
782 vector wcross_color, wcross_size;
\r
783 string wcross_name;
\r
784 float wcross_alpha, wcross_scale, wcross_blur, wcross_resolution;
\r
786 wcross_color_x = cvar("crosshair_color_red");
\r
787 wcross_color_y = cvar("crosshair_color_green");
\r
788 wcross_color_z = cvar("crosshair_color_blue");
\r
789 wcross_alpha = cvar("crosshair_color_alpha");
\r
790 wcross_resolution = cvar("crosshair_size");
\r
792 wcross_name = strcat("gfx/crosshair", wcross_style);
\r
794 if(cvar("crosshair_effect_scalefade"))
\r
796 wcross_scale = wcross_resolution;
\r
797 wcross_resolution = 1;
\r
804 if(cvar("crosshair_pickup"))
\r
806 if(pickup_crosshair_time < getstatf(STAT_LAST_PICKUP))
\r
808 pickup_crosshair_size = 1;
\r
809 pickup_crosshair_time = getstatf(STAT_LAST_PICKUP);
\r
812 if(pickup_crosshair_size > 0)
\r
813 pickup_crosshair_size -= cvar("crosshair_pickup_speed") * frametime;
\r
815 pickup_crosshair_size = 0;
\r
817 wcross_scale += sin(pickup_crosshair_size) * cvar("crosshair_pickup");
\r
820 if(shottype == SHOTTYPE_HITENEMY)
\r
821 wcross_scale *= cvar("crosshair_hittest"); // is not queried if hittest is 0
\r
822 if(shottype == SHOTTYPE_HITTEAM)
\r
823 wcross_scale /= cvar("crosshair_hittest"); // is not queried if hittest is 0
\r
825 f = cvar("crosshair_effect_speed");
\r
826 if(wcross_scale != wcross_scale_goal_prev || wcross_alpha != wcross_alpha_goal_prev || wcross_color != wcross_color_goal_prev)
\r
828 wcross_changedonetime = time + f;
\r
830 if(wcross_name != wcross_name_goal_prev || wcross_resolution != wcross_resolution_goal_prev)
\r
832 wcross_name_changestarttime = time;
\r
833 wcross_name_changedonetime = time + f;
\r
834 if(wcross_name_goal_prev_prev)
\r
835 strunzone(wcross_name_goal_prev_prev);
\r
836 wcross_name_goal_prev_prev = wcross_name_goal_prev;
\r
837 wcross_name_goal_prev = strzone(wcross_name);
\r
838 wcross_name_alpha_goal_prev_prev = wcross_name_alpha_goal_prev;
\r
839 wcross_resolution_goal_prev_prev = wcross_resolution_goal_prev;
\r
840 wcross_resolution_goal_prev = wcross_resolution;
\r
843 wcross_scale_goal_prev = wcross_scale;
\r
844 wcross_alpha_goal_prev = wcross_alpha;
\r
845 wcross_color_goal_prev = wcross_color;
\r
847 if(shottype == SHOTTYPE_HITTEAM || (shottype == SHOTTYPE_HITOBSTRUCTION && cvar("crosshair_hittest_blur") && !cvar("chase_active")))
\r
850 wcross_alpha *= 0.75;
\r
854 // *_prev is at time-frametime
\r
855 // * is at wcross_changedonetime+f
\r
856 // what do we have at time?
\r
857 if(time < wcross_changedonetime)
\r
859 f = frametime / (wcross_changedonetime - time + frametime);
\r
860 wcross_scale = f * wcross_scale + (1 - f) * wcross_scale_prev;
\r
861 wcross_alpha = f * wcross_alpha + (1 - f) * wcross_alpha_prev;
\r
862 wcross_color = f * wcross_color + (1 - f) * wcross_color_prev;
\r
865 wcross_scale_prev = wcross_scale;
\r
866 wcross_alpha_prev = wcross_alpha;
\r
867 wcross_color_prev = wcross_color;
\r
869 wcross_scale *= 1 - cvar("_menu_alpha");
\r
870 wcross_alpha *= 1 - cvar("_menu_alpha");
\r
872 #define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \
\r
875 if(wcross_blur > 0) \
\r
877 for(i = -2; i <= 2; ++i) \
\r
878 for(j = -2; j <= 2; ++j) \
\r
879 M(i,j,sz,wcross_name,wcross_alpha*0.04); \
\r
883 M(0,0,sz,wcross_name,wcross_alpha); \
\r
888 #define CROSSHAIR_DRAW_SINGLE(i,j,sz,wcross_name,wcross_alpha) \
\r
889 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)
\r
891 #define CROSSHAIR_DRAW(sz,wcross_name,wcross_alpha) \
\r
892 CROSSHAIR_DO_BLUR(CROSSHAIR_DRAW_SINGLE,sz,wcross_name,wcross_alpha)
\r
894 if(time < wcross_name_changedonetime && wcross_name != wcross_name_goal_prev_prev && wcross_name_goal_prev_prev)
\r
896 f = (wcross_name_changedonetime - time) / (wcross_name_changedonetime - wcross_name_changestarttime);
\r
897 wcross_size = drawgetimagesize(wcross_name_goal_prev_prev) * wcross_scale;
\r
898 CROSSHAIR_DRAW(wcross_resolution_goal_prev_prev, wcross_name_goal_prev_prev, wcross_alpha * f * wcross_name_alpha_goal_prev_prev);
\r
906 wcross_size = drawgetimagesize(wcross_name) * wcross_scale;
\r
907 CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f);
\r
908 wcross_name_alpha_goal_prev = f;
\r
913 wcross_scale_prev = 0;
\r
914 wcross_alpha_prev = 0;
\r
915 wcross_scale_goal_prev = 0;
\r
916 wcross_alpha_goal_prev = 0;
\r
917 wcross_changedonetime = 0;
\r
918 if(wcross_name_goal_prev)
\r
919 strunzone(wcross_name_goal_prev);
\r
920 wcross_name_goal_prev = string_null;
\r
921 if(wcross_name_goal_prev_prev)
\r
922 strunzone(wcross_name_goal_prev_prev);
\r
923 wcross_name_goal_prev_prev = string_null;
\r
924 wcross_name_changestarttime = 0;
\r
925 wcross_name_changedonetime = 0;
\r
926 wcross_name_alpha_goal_prev = 0;
\r
927 wcross_name_alpha_goal_prev_prev = 0;
\r
928 wcross_resolution_goal_prev = 0;
\r
929 wcross_resolution_goal_prev_prev = 0;
\r
933 if(NextFrameCommand)
\r
935 localcmd("\n", NextFrameCommand, "\n");
\r
936 NextFrameCommand = string_null;
\r
939 // we must do this check AFTER a frame was rendered, or it won't work
\r
940 if(cs_project_is_b0rked == 0)
\r
943 w0 = cvar_string("vid_conwidth");
\r
944 h0 = cvar_string("vid_conheight");
\r
945 //R_SetView(VF_VIEWPORT, '0 0 0', '640 480 0');
\r
946 //R_SetView(VF_FOV, '90 90 0');
\r
947 R_SetView(VF_ORIGIN, '0 0 0');
\r
948 R_SetView(VF_ANGLES, '0 0 0');
\r
949 R_SetView(VF_PERSPECTIVE, 1);
\r
950 makevectors('0 0 0');
\r
952 cvar_set("vid_conwidth", "800");
\r
953 cvar_set("vid_conheight", "600");
\r
954 v1 = cs_project(v_forward);
\r
955 cvar_set("vid_conwidth", "640");
\r
956 cvar_set("vid_conheight", "480");
\r
957 v2 = cs_project(v_forward);
\r
959 cs_project_is_b0rked = 1;
\r
961 cs_project_is_b0rked = -1;
\r
962 cvar_set("vid_conwidth", w0);
\r
963 cvar_set("vid_conheight", h0);
\r
966 // be safe against triggerbots until everyone has the fixed engine
\r
967 // this call is meant to overwrite the trace globals by something
\r
969 traceline('0 0 0', '0 0 0', MOVE_WORLDONLY, world);
\r
971 // this cvar must be constantly updated on the server
\r
972 if(chase_active_old != cvar("chase_active"))
\r
974 localcmd("sendcvar chase_active\n");
\r
975 chase_active_old = cvar("chase_active");
\r
981 void CSQC_common_hud(void)
\r
983 // Sbar_SortFrags(); done in Sbar_Draw
\r
985 hud = getstati(STAT_HUD);
\r
997 // following vectors must be global to allow seamless switching between camera modes
\r
998 vector camera_offset, current_camera_offset, mouse_angles, current_angles, current_origin, current_position;
\r
999 void CSQC_Demo_Camera()
\r
1001 float speed, attenuation, dimensions;
\r
1002 vector tmp, delta;
\r
1004 if( cvar("camera_reset") || !camera_mode )
\r
1006 camera_offset = '0 0 0';
\r
1007 current_angles = '0 0 0';
\r
1008 camera_direction = '0 0 0';
\r
1009 camera_offset_z += 30;
\r
1010 camera_offset_x += 30 * -cos(current_angles_y * DEG2RAD);
\r
1011 camera_offset_y += 30 * -sin(current_angles_y * DEG2RAD);
\r
1012 current_origin = view_origin;
\r
1013 current_camera_offset = camera_offset;
\r
1014 cvar_set("camera_reset", "0");
\r
1015 camera_mode = CAMERA_CHASE;
\r
1020 mouse_angles_z += camera_roll * cvar("camera_speed_roll");
\r
1022 if(cvar("camera_look_player"))
\r
1027 dir = normalize(view_origin - current_position);
\r
1028 n = mouse_angles_z;
\r
1029 mouse_angles = vectoangles(dir);
\r
1030 mouse_angles_x = mouse_angles_x * -1;
\r
1031 mouse_angles_z = n;
\r
1035 tmp = getmousepos() * 0.1;
\r
1036 if(vlen(tmp)>cvar("camera_mouse_treshold"))
\r
1038 mouse_angles_x += tmp_y * cos(mouse_angles_z * DEG2RAD) + (tmp_x * sin(mouse_angles_z * DEG2RAD));
\r
1039 mouse_angles_y -= tmp_x * cos(mouse_angles_z * DEG2RAD) + (tmp_y * -sin(mouse_angles_z * DEG2RAD));
\r
1043 while (mouse_angles_x < -180) mouse_angles_x = mouse_angles_x + 360;
\r
1044 while (mouse_angles_x > 180) mouse_angles_x = mouse_angles_x - 360;
\r
1045 while (mouse_angles_y < -180) mouse_angles_y = mouse_angles_y + 360;
\r
1046 while (mouse_angles_y > 180) mouse_angles_y = mouse_angles_y - 360;
\r
1048 // Fix difference when angles don't have the same sign
\r
1050 if(mouse_angles_y < -60 && current_angles_y > 60)
\r
1051 delta = '0 360 0';
\r
1052 if(mouse_angles_y > 60 && current_angles_y < -60)
\r
1053 delta = '0 -360 0';
\r
1055 if(cvar("camera_look_player"))
\r
1056 attenuation = cvar("camera_look_attenuation");
\r
1058 attenuation = cvar("camera_speed_attenuation");
\r
1060 attenuation = 1 / max(1, attenuation);
\r
1061 current_angles += (mouse_angles - current_angles + delta) * attenuation;
\r
1063 while (current_angles_x < -180) current_angles_x = current_angles_x + 360;
\r
1064 while (current_angles_x > 180) current_angles_x = current_angles_x - 360;
\r
1065 while (current_angles_y < -180) current_angles_y = current_angles_y + 360;
\r
1066 while (current_angles_y > 180) current_angles_y = current_angles_y - 360;
\r
1068 // Camera position
\r
1072 if( camera_direction_x )
\r
1074 tmp_x = camera_direction_x * cos(current_angles_y * DEG2RAD);
\r
1075 tmp_y = camera_direction_x * sin(current_angles_y * DEG2RAD);
\r
1076 if( cvar("camera_forward_follows") && !cvar("camera_look_player") )
\r
1077 tmp_z = camera_direction_x * -sin(current_angles_x * DEG2RAD);
\r
1081 if( camera_direction_y )
\r
1083 tmp_x += camera_direction_y * -sin(current_angles_y * DEG2RAD);
\r
1084 tmp_y += camera_direction_y * cos(current_angles_y * DEG2RAD) * cos(current_angles_z * DEG2RAD);
\r
1085 tmp_z += camera_direction_y * sin(current_angles_z * DEG2RAD);
\r
1089 if( camera_direction_z )
\r
1091 tmp_z += camera_direction_z * cos(current_angles_z * DEG2RAD);
\r
1095 if(cvar("camera_free"))
\r
1096 speed = cvar("camera_speed_free");
\r
1098 speed = cvar("camera_speed_chase");
\r
1102 speed = speed * sqrt(1 / dimensions);
\r
1103 camera_offset += tmp * speed;
\r
1106 current_camera_offset += (camera_offset - current_camera_offset) * attenuation;
\r
1109 if( cvar("camera_free") )
\r
1111 if ( camera_mode == CAMERA_CHASE )
\r
1113 current_camera_offset = current_origin + current_camera_offset;
\r
1114 camera_offset = current_origin + camera_offset;
\r
1117 camera_mode = CAMERA_FREE;
\r
1118 current_position = current_camera_offset;
\r
1122 if ( camera_mode == CAMERA_FREE )
\r
1124 current_origin = view_origin;
\r
1125 camera_offset = camera_offset - current_origin;
\r
1126 current_camera_offset = current_camera_offset - current_origin;
\r
1129 camera_mode = CAMERA_CHASE;
\r
1131 if(cvar("camera_chase_smoothly"))
\r
1132 current_origin += (view_origin - current_origin) * attenuation;
\r
1134 current_origin = view_origin;
\r
1136 current_position = current_origin + current_camera_offset;
\r
1139 R_SetView(VF_ANGLES, current_angles);
\r
1140 R_SetView(VF_ORIGIN, current_position);
\r