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 vecs = decompressShotOrigin(getstati(STAT_SHOTORG));
\r
208 traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
\r
209 trueaimpoint = trace_endpos;
\r
216 dv = view_right * vecs_y + view_up * vecs_z;
\r
217 w_shotorg = view_origin + dv;
\r
219 // now move the vecs forward as much as requested if possible
\r
220 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
221 w_shotorg = trace_endpos - view_forward * nudge;
\r
223 tracebox(w_shotorg, mi, ma, trueaimpoint, MOVE_NORMAL, ta);
\r
224 shottype = EnemyHitCheck();
\r
225 if(shottype != SHOTTYPE_HITWORLD)
\r
229 // FIXME WHY DOES THIS NOT WORK FOR THE ROCKET LAUNCHER?
\r
230 // or rather, I know why, but see no fix
\r
231 if(vlen(trace_endpos - trueaimpoint) > vlen(ma) + vlen(mi) + 1)
\r
232 // 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
233 return SHOTTYPE_HITOBSTRUCTION;
\r
236 return SHOTTYPE_HITWORLD;
\r
239 void CSQC_common_hud(void);
\r
241 void CSQC_kh_hud(void);
\r
242 void CSQC_ctf_hud(void);
\r
243 void PostInit(void);
\r
244 void CSQC_Demo_Camera();
\r
245 float Sbar_WouldDrawScoreboard ();
\r
246 float last_health, last_spectatee;
\r
249 float reticle_type;
\r
250 float chase_active_old;
\r
251 float artwork_fade;
\r
252 float pickup_crosshair_time, pickup_crosshair_size, pickup_flash_time, vore_flash_laststate;
\r
253 float spawnfov_current;
\r
254 float myhealth, myhealth_prev, myhealth_flash;
\r
255 float contentavgalpha, liquidalpha_prev;
\r
256 float old_blurradius, old_bluralpha, old_sharpen_intensity;
\r
257 float stomachsplash_alpha;
\r
258 float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2;
\r
259 float volume_modify_changed_1, volume_modify_changed_2;
\r
260 float eventchase_current_distance;
\r
261 float helper_pause, helper_health, helper_armor, helper_ammo, helper_speed, helper_stomachload;
\r
262 vector myhealth_gentlergb;
\r
263 vector liquidcolor_prev;
\r
264 vector damage_blurpostprocess, content_blurpostprocess;
\r
265 string artwork_image;
\r
266 string intermission_song;
\r
267 string NextFrameCommand;
\r
268 void CSQC_UpdateView(float w, float h)
\r
277 vector reticle_pos, reticle_size;
\r
278 vector splash_pos, splash_size;
\r
279 vector artwork_pos, artwork_size;
\r
281 WaypointSprite_Load();
\r
283 if(spectatee_status)
\r
284 myteam = GetPlayerColor(spectatee_status - 1);
\r
286 myteam = GetPlayerColor(player_localentnum - 1);
\r
288 ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
\r
289 vo = '0 0 1' * getstati(STAT_VIEWHEIGHT);
\r
291 warpzone_fixview_origin = pmove_org + vo;
\r
292 warpzone_fixview_angles = input_angles;
\r
293 WarpZone_FixView();
\r
294 pmove_org = warpzone_fixview_origin - vo;
\r
295 input_angles = warpzone_fixview_angles;
\r
297 if((last_health <= 0 && getstati(STAT_HEALTH) > 0) || (!spectatee_status && last_spectatee)) // also cover switching from a spectator to a player instantly
\r
298 if not(spectatee_status && last_spectatee != spectatee_status) // not if we switched players and that detects a different health
\r
299 respawned = TRUE; // stays true for one frame
\r
302 if(cvar("cl_helper"))
\r
304 if(intermission || respawned || spectatee_status < 0 || getstati(STAT_HEALTH) <= 0 || getstati(STAT_VORE_EATEN))
\r
306 // Set these helper messages as having been triggered, so that the player must first reach them before they complain.
\r
307 // Otherwise, if you don't have any start armor for instance, the helper will complain about low armor when we spawn.
\r
308 helper_health = TRUE;
\r
309 helper_armor = TRUE;
\r
310 helper_ammo = TRUE;
\r
312 else if(helper_pause <= time)
\r
315 if(getstati(STAT_HEALTH) <= cvar("cl_helper_item_health"))
\r
317 if(cvar("cl_helper_item_health") && !helper_health)
\r
319 sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/health.wav"), VOL_BASEVOICE, ATTN_NONE);
\r
320 helper_health = TRUE;
\r
321 helper_pause = time + cvar("cl_helper_pause");
\r
322 helper_ammo = time + cvar("cl_helper_pause");
\r
325 else if(helper_health)
\r
326 helper_health = FALSE;
\r
329 if(getstati(STAT_ARMOR) <= cvar("cl_helper_item_armor"))
\r
331 if(cvar("cl_helper_item_armor") && !helper_armor)
\r
333 sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/armor.wav"), VOL_BASEVOICE, ATTN_NONE);
\r
334 helper_armor = TRUE;
\r
335 helper_pause = time + cvar("cl_helper_pause");
\r
338 else if(helper_armor)
\r
339 helper_armor = FALSE;
\r
342 if(getstati(STAT_FUEL) <= cvar("cl_helper_item_ammo_fuel"))
\r
344 if(cvar("cl_helper_item_ammo_fuel") && !helper_ammo)
\r
346 sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/ammo.wav"), VOL_BASEVOICE, ATTN_NONE);
\r
347 helper_ammo = TRUE;
\r
348 helper_pause = time + cvar("cl_helper_pause");
\r
351 else if(helper_ammo)
\r
352 helper_ammo = FALSE;
\r
355 if(vlen(pmove_vel) >= cvar("cl_helper_item_speed"))
\r
357 if(cvar("cl_helper_item_speed") && !helper_speed)
\r
359 sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/speed.wav"), VOL_BASEVOICE, ATTN_NONE);
\r
360 helper_speed = TRUE;
\r
361 helper_pause = time + cvar("cl_helper_pause");
\r
364 else if(helper_speed)
\r
365 helper_speed = FALSE;
\r
367 // stomach load helper
\r
368 if(getstati(STAT_VORE_LOAD) / getstati(STAT_VORE_MAXLOAD) >= cvar("cl_helper_item_stomachload"))
\r
370 if(cvar("cl_helper_item_stomachload") && !helper_stomachload)
\r
372 sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/stomachload.wav"), VOL_BASEVOICE, ATTN_NONE);
\r
373 helper_stomachload = TRUE;
\r
374 helper_pause = time + cvar("cl_helper_pause");
\r
377 else if(helper_stomachload)
\r
378 helper_stomachload = FALSE;
\r
382 // event chase camera
\r
383 if(cvar("chase_active") <= 0) // greater than 0 means it's enabled manually, and this code is skipped
\r
385 if(!getstati(STAT_VORE_EATEN) && spectatee_status >= 0 && (cvar("cl_eventchase_death") && getstati(STAT_HEALTH) <= 0 && !intermission))
\r
387 // We must enable chase_active to get a third person view (weapon viewmodel hidden and own player model showing).
\r
388 // Ideally, there should be another way to enable third person cameras, such as through R_SetView()
\r
389 if(!cvar("chase_active"))
\r
390 cvar_set("chase_active", "-1"); // -1 enables chase_active while marking it as set by this code, and not by the user (which would be 1)
\r
392 // make the camera smooth back
\r
393 if(cvar("cl_eventchase_speed") && eventchase_current_distance < cvar("cl_eventchase_distance"))
\r
394 eventchase_current_distance += cvar("cl_eventchase_speed") * (cvar("cl_eventchase_distance") - eventchase_current_distance) * frametime; // slow down the further we get
\r
395 else if(eventchase_current_distance != cvar("cl_eventchase_distance"))
\r
396 eventchase_current_distance = cvar("cl_eventchase_distance");
\r
398 vector eventchase_target_origin;
\r
399 makevectors(view_angles);
\r
400 // pass 1, used to check where the camera would go and obtain the trace_fraction
\r
401 eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance;
\r
403 traceline(pmove_org, eventchase_target_origin, MOVE_WORLDONLY, self);
\r
404 // pass 2, also multiplying view_forward with trace_fraction, to prevent the camera from going through walls
\r
405 // The 0.1 subtraction is to not limit the camera precisely at the wall surface, as that allows the view to poke through
\r
406 eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance * (trace_fraction - 0.1);
\r
408 R_SetView(VF_ORIGIN, eventchase_target_origin);
\r
409 R_SetView(VF_ANGLES, view_angles);
\r
411 else if(cvar("chase_active") < 0) // time to disable chase_active if it was set by this code
\r
413 cvar_set("chase_active", "0");
\r
414 eventchase_current_distance = 0; // start from 0 next time
\r
418 // Render the Scene
\r
419 if(!intermission || !view_set)
\r
421 view_origin = pmove_org + vo;
\r
422 view_angles = input_angles;
\r
423 makevectors(view_angles);
\r
424 view_forward = v_forward;
\r
425 view_right = v_right;
\r
434 if(time > blurtest_time0 && time < blurtest_time1)
\r
438 t = (time - blurtest_time0) / (blurtest_time1 - blurtest_time0);
\r
439 r = t * blurtest_radius;
\r
440 f = 1 / pow(t, blurtest_power) - 1;
\r
442 cvar_set("r_glsl_postprocess", "1");
\r
443 cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(r), " ", ftos(f), " 0 0"));
\r
447 cvar_set("r_glsl_postprocess", "0");
\r
448 cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
\r
452 TargetMusic_Advance();
\r
455 drawframetime = max(0.000001, time - drawtime);
\r
458 // watch for gametype changes here...
\r
459 // in ParseStuffCMD the cmd isn't executed yet :/
\r
460 // might even be better to add the gametype to TE_CSQC_INIT...?
\r
464 if(intermission && !isdemo() && !(calledhooks & HOOK_END))
\r
465 if(calledhooks & HOOK_START)
\r
467 localcmd("\ncl_hook_gameend;");
\r
469 localcmd("\ncl_hook_campaign_gameend;");
\r
470 calledhooks |= HOOK_END;
\r
473 CheckForGamestartChange();
\r
475 maptimeAnnouncer();
\r
476 carrierAnnouncer();
\r
479 if(button_zoom || fov <= 59.5)
\r
481 if(!zoomscript_caught)
\r
483 localcmd("+button4\n");
\r
484 zoomscript_caught = 1;
\r
485 ignore_plus_zoom += 1;
\r
490 if(zoomscript_caught)
\r
492 localcmd("-button4\n");
\r
493 zoomscript_caught = 0;
\r
494 ignore_minus_zoom += 1;
\r
498 sbar_alpha_fg = cvar("sbar_alpha_fg" ) * (1 - cvar("_menu_alpha"));
\r
499 sbar_hudselector = cvar("sbar_hudselector");
\r
500 sbar_accuracy_hud = cvar_or("sbar_accuracy_hud", 1);
\r
501 ColorTranslateMode = cvar("cl_stripcolorcodes");
\r
502 activeweapon = getstati(STAT_SWITCHWEAPON);
\r
503 f = cvar("teamplay");
\r
510 if(last_weapon != activeweapon) {
\r
512 last_weapon = activeweapon;
\r
515 // ALWAYS Clear Current Scene First
\r
518 // Assign Standard Viewflags
\r
519 // Draw the World (and sky)
\r
520 R_SetView(VF_DRAWWORLD, 1);
\r
522 // Set the console size vars
\r
523 vid_conwidth = cvar("vid_conwidth");
\r
524 vid_conheight = cvar("vid_conheight");
\r
525 vid_pixelheight = cvar("vid_pixelheight");
\r
527 // spawn fov effect
\r
528 if(cvar("cl_spawnfov"))
\r
531 spawnfov_current = 1 + cvar("cl_spawnfov");
\r
533 if(spawnfov_current > 1)
\r
534 spawnfov_current -= cvar("cl_spawnfov_speed") * frametime;
\r
536 spawnfov_current = 1;
\r
537 fov *= spawnfov_current;
\r
540 R_SetView(VF_FOV, GetCurrentFov(fov));
\r
542 // Camera for demo playback
\r
545 if(cvar("camera_enable"))
\r
546 CSQC_Demo_Camera();
\r
549 cvar_set("chase_active", ftos(chase_active_backup));
\r
550 cvar_set("cl_demo_mousegrab", "0");
\r
551 camera_active = FALSE;
\r
555 else if(cvar("camera_enable"))
\r
557 else if(cvar("camera_enable") && isdemo())
\r
560 // Enable required Darkplaces cvars
\r
561 chase_active_backup = cvar("chase_active");
\r
562 cvar_set("chase_active", "2");
\r
563 cvar_set("cl_demo_mousegrab", "1");
\r
564 camera_active = TRUE;
\r
565 camera_mode = FALSE;
\r
568 // Draw the Crosshair
\r
569 float scoreboard_active;
\r
570 scoreboard_active = Sbar_WouldDrawScoreboard();
\r
571 R_SetView(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden
\r
573 // Draw the Engine Status Bar (the default Quake HUD)
\r
574 R_SetView(VF_DRAWENGINESBAR, 0);
\r
576 // fetch this one only once per frame
\r
577 sbar_showbinds = cvar("sbar_showbinds");
\r
578 sbar_showbinds_limit = cvar("sbar_showbinds_limit");
\r
580 // Update the mouse position
\r
582 mousepos_x = vid_conwidth;
\r
583 mousepos_y = vid_conheight;
\r
584 mousepos = mousepos*0.5 + getmousepos();
\r
588 for(self = world; (self = nextent(self)); )
\r
593 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
\r
596 // now switch to 2D drawing mode by calling a 2D drawing function
\r
597 // then polygon drawing will draw as 2D stuff, and NOT get queued until the
\r
598 // next R_RenderScene call
\r
599 drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);
\r
601 // Draw the aiming reticle for weapons that use it
\r
602 // reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use
\r
603 // It must be a persisted float for fading out to work properly (you let go of the zoom button for
\r
604 // the view to go back to normal, so reticle_type would become 0 as we fade out)
\r
605 if(spectatee_status || getstati(STAT_HEALTH) <= 0)
\r
606 reticle_type = 0; // prevent reticle from showing during the respawn zoom effect or for spectators
\r
607 else if(activeweapon && (button_zoom || zoomscript_caught))
\r
608 reticle_type = 2; // weapon zoom
\r
609 else if(button_zoom || zoomscript_caught)
\r
610 reticle_type = 1; // normal zoom
\r
614 if(cvar("cl_reticle_stretch"))
\r
616 reticle_size_x = vid_conwidth;
\r
617 reticle_size_y = vid_conheight;
\r
623 reticle_size_x = max(vid_conwidth, vid_conheight);
\r
624 reticle_size_y = max(vid_conwidth, vid_conheight);
\r
625 reticle_pos_x = (vid_conwidth - reticle_size_x) / 2;
\r
626 reticle_pos_y = (vid_conheight - reticle_size_y) / 2;
\r
629 f = current_zoomfraction;
\r
630 if(zoomscript_caught)
\r
632 if(cvar("cl_reticle_item_normal"))
\r
634 if(reticle_type == 1 && f)
\r
635 drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * cvar("cl_reticle_item_normal"), DRAWFLAG_NORMAL);
\r
637 if(cvar("cl_reticle_item_weapon"))
\r
639 if(reticle_type == 2 && f)
\r
640 drawpic(reticle_pos, "gfx/reticle_weapon", reticle_size, '1 1 1', f * cvar("cl_reticle_item_weapon"), DRAWFLAG_NORMAL);
\r
645 if(cvar("hud_contents"))
\r
647 float contentalpha_temp, incontent, liquidalpha, contentfadetime;
\r
648 vector liquidcolor;
\r
650 if (getstati(STAT_VORE_EATEN))
\r
652 liquidalpha = cvar("hud_contents_stomach_alpha");
\r
653 liquidcolor = stov(cvar_string("hud_contents_stomach_color"));
\r
658 switch(pointcontents(view_origin))
\r
660 case CONTENT_WATER:
\r
661 liquidalpha = cvar("hud_contents_water_alpha");
\r
662 liquidcolor = stov(cvar_string("hud_contents_water_color"));
\r
667 liquidalpha = cvar("hud_contents_lava_alpha");
\r
668 liquidcolor = stov(cvar_string("hud_contents_lava_color"));
\r
672 case CONTENT_SLIME:
\r
673 liquidalpha = cvar("hud_contents_slime_alpha");
\r
674 liquidcolor = stov(cvar_string("hud_contents_slime_color"));
\r
680 liquidcolor = '0 0 0';
\r
686 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
687 { // also lets delcare previous values for blending properties, this way it isn't reset until after you have entered a different content
\r
688 contentfadetime = cvar("hud_contents_fadeintime");
\r
689 liquidalpha_prev = liquidalpha;
\r
690 liquidcolor_prev = liquidcolor;
\r
693 contentfadetime = cvar("hud_contents_fadeouttime");
\r
695 contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1);
\r
696 contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp;
\r
698 if(contentavgalpha)
\r
699 drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL);
\r
701 if(cvar("hud_postprocessing"))
\r
703 if(cvar("hud_contents_liquid_blur") && contentavgalpha)
\r
705 // when inside the stomach, we use different blur settings than when we're inside other fluids
\r
706 content_blurpostprocess_x = 1;
\r
707 if(getstati(STAT_VORE_EATEN))
\r
709 content_blurpostprocess_y = contentavgalpha * cvar("hud_contents_stomach_blur");
\r
710 content_blurpostprocess_z = contentavgalpha * cvar("hud_contents_stomach_blur_alpha");
\r
714 content_blurpostprocess_y = contentavgalpha * cvar("hud_contents_liquid_blur");
\r
715 content_blurpostprocess_z = contentavgalpha * cvar("hud_contents_liquid_blur_alpha");
\r
720 content_blurpostprocess_x = 0;
\r
721 content_blurpostprocess_y = 0;
\r
722 content_blurpostprocess_z = 0;
\r
727 if(cvar("hud_damage"))
\r
729 splash_size_x = max(vid_conwidth, vid_conheight);
\r
730 splash_size_y = max(vid_conwidth, vid_conheight);
\r
731 splash_pos_x = (vid_conwidth - splash_size_x) / 2;
\r
732 splash_pos_y = (vid_conheight - splash_size_y) / 2;
\r
734 float myhealth_flash_temp;
\r
735 myhealth = getstati(STAT_HEALTH);
\r
738 myhealth_flash = max(0, myhealth_flash - cvar("hud_damage_fade_rate") * frametime);
\r
740 myhealth_flash = bound(0, myhealth_flash + dmg_take * cvar("hud_damage_factor"), cvar("hud_damage_maxalpha"));
\r
742 float pain_threshold, pain_threshold_lower, pain_threshold_lower_health;
\r
743 pain_threshold = cvar("hud_damage_pain_threshold");
\r
744 pain_threshold_lower = cvar("hud_damage_pain_threshold_lower");
\r
745 pain_threshold_lower_health = cvar("hud_damage_pain_threshold_lower_health");
\r
747 if(pain_threshold_lower && myhealth < pain_threshold_lower_health)
\r
749 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
752 myhealth_flash_temp = bound(0, myhealth_flash - pain_threshold, 1);
\r
754 if(myhealth_prev < 1)
\r
758 myhealth_flash = 0; // just spawned, clear the flash immediately
\r
759 myhealth_flash_temp = 0;
\r
763 myhealth_flash += cvar("hud_damage_fade_rate") * frametime; // dead
\r
767 if(spectatee_status == -1 || intermission)
\r
769 myhealth_flash = 0; // observing, or match ended
\r
770 myhealth_flash_temp = 0;
\r
773 myhealth_prev = myhealth;
\r
775 if(cvar("cl_gentle_damage") || cvar("cl_gentle"))
\r
777 if(cvar("cl_gentle_damage") == 2)
\r
779 if(myhealth_flash < pain_threshold) // only randomize when the flash is gone
\r
781 myhealth_gentlergb = '1 0 0' * random() + '0 1 0' * random() + '0 0 1' * random();
\r
785 myhealth_gentlergb = stov(cvar_string("hud_damage_gentle_color"));
\r
787 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
790 drawpic(splash_pos, "gfx/blood", splash_size, stov(cvar_string("hud_damage_color")), bound(0, myhealth_flash_temp, 1) * cvar("hud_damage"), DRAWFLAG_NORMAL);
\r
792 if(cvar("hud_postprocessing"))
\r
794 if(cvar("hud_damage_blur") && myhealth_flash_temp)
\r
796 damage_blurpostprocess_x = 1;
\r
797 damage_blurpostprocess_y = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur");
\r
798 damage_blurpostprocess_z = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur_alpha");
\r
802 damage_blurpostprocess_x = 0;
\r
803 damage_blurpostprocess_y = 0;
\r
804 damage_blurpostprocess_z = 0;
\r
809 if(cvar("hud_stomach"))
\r
811 if(getstati(STAT_VORE_EATEN))
\r
813 if(stomachsplash_alpha < cvar("hud_stomach"))
\r
814 stomachsplash_alpha += cvar("hud_stomach_fade_in") * frametime;
\r
816 stomachsplash_alpha = cvar("hud_stomach");
\r
818 else if(getstati(STAT_HEALTH) > 0)
\r
820 if(stomachsplash_alpha > 0)
\r
821 stomachsplash_alpha -= cvar("hud_stomach_fade_out") * frametime;
\r
823 stomachsplash_alpha = 0;
\r
827 stomachsplash_alpha = 0; // we respawned, remove the effect
\r
828 if(spectatee_status == -1)
\r
829 stomachsplash_alpha = 0;
\r
831 stomachsplash_alpha = bound(0, stomachsplash_alpha, 1);
\r
832 drawpic(splash_pos, "gfx/food", splash_size, stov(cvar_string("hud_stomach_color")), stomachsplash_alpha, DRAWFLAG_NORMAL);
\r
835 if(cvar("hud_postprocessing"))
\r
837 // all of this should be done in the engine eventually
\r
839 // disable damage blur when dead, but keep content blur
\r
840 if(getstati(STAT_HEALTH) <= 0)
\r
841 damage_blurpostprocess = '0 0 0';
\r
843 // enable or disable rendering types if they are used or not
\r
844 if(cvar("r_glsl_postprocess_uservec1_enable") != (cvar("hud_postprocessing_maxbluralpha") != 0))
\r
845 cvar_set("r_glsl_postprocess_uservec1_enable", ftos(cvar("hud_postprocessing_maxbluralpha") != 0));
\r
846 if(cvar("r_glsl_postprocess_uservec2_enable") != (cvar("hud_powerup") != 0))
\r
847 cvar_set("r_glsl_postprocess_uservec2_enable", ftos(cvar("hud_powerup") != 0));
\r
849 // lets apply the postprocess effects from the previous two functions if needed
\r
850 if((damage_blurpostprocess_x || content_blurpostprocess_x) && cvar("chase_active") >= 0) // not while the event chase camera is active
\r
852 float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, cvar("hud_postprocessing_maxblurradius"));
\r
853 float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, cvar("hud_postprocessing_maxbluralpha"));
\r
854 if(blurradius != old_blurradius || bluralpha != old_bluralpha) // reduce cvar_set spam as much as possible
\r
856 cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0"));
\r
857 old_blurradius = blurradius;
\r
858 old_bluralpha = bluralpha;
\r
861 else if(cvar_string("r_glsl_postprocess_uservec1") != "0 0 0 0") // reduce cvar_set spam as much as possible
\r
863 cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
\r
864 old_blurradius = 0;
\r
868 float sharpen_intensity;
\r
869 if (getstatf(STAT_STRENGTH_FINISHED) - time > 0)
\r
870 sharpen_intensity += (getstatf(STAT_STRENGTH_FINISHED) - time);
\r
871 if (getstatf(STAT_INVINCIBLE_FINISHED) - time > 0)
\r
872 sharpen_intensity += (getstatf(STAT_INVINCIBLE_FINISHED) - time);
\r
874 if(cvar("hud_powerup") && sharpen_intensity > 0 && cvar("chase_active") >= 0) // not while the event chase camera is active
\r
876 sharpen_intensity = bound(0, sharpen_intensity, 5); // powerup warning time is 5 seconds, so fade the effect from there
\r
878 if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible
\r
880 cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(-sharpen_intensity * cvar("hud_powerup")), " 0 0"));
\r
881 old_sharpen_intensity = sharpen_intensity;
\r
884 else if(cvar_string("r_glsl_postprocess_uservec2") != "0 0 0 0") // reduce cvar_set spam as much as possible
\r
886 cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");
\r
887 old_sharpen_intensity = 0;
\r
891 if(cvar("hud_postprocessing") && !cvar("hud_postprocessing_maxbluralpha"))
\r
892 if(cvar("r_glsl_postprocess_uservec1_enable"))
\r
894 // don't allow blur to get stuck on if we disable the cvar while damaged
\r
895 cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
\r
896 cvar_set("r_glsl_postprocess_uservec1_enable", "0");
\r
898 if(cvar("hud_postprocessing") && !cvar("hud_powerup"))
\r
899 if(cvar("r_glsl_postprocess_uservec2_enable"))
\r
901 // don't allow sharpen to get stuck on if we disable the cvar while powered up
\r
902 cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");
\r
903 cvar_set("r_glsl_postprocess_uservec2_enable", "0");
\r
906 if(cvar("hud_postprocessing"))
\r
908 // change saturation based on the amount of armor we have
\r
909 // ranges between 0.5 and 1 saturation, over 0 armor and half the armor limit
\r
911 if(cvar("hud_saturation") && armor_max && spectatee_status != -1 && getstati(STAT_HEALTH) > 0)
\r
914 saturation = 0.5 + (getstati(STAT_ARMOR) / armor_max);
\r
915 saturation = bound(0, saturation, 1);
\r
917 if(cvar("r_glsl_saturation") != saturation)
\r
918 cvar_set("r_glsl_saturation", ftos(saturation));
\r
920 else if(cvar("r_glsl_saturation") != 1)
\r
921 cvar_set("r_glsl_saturation", "1");
\r
925 if(cvar("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1)
\r
927 float volume_modify_1_target, volume_modify_2_target, volume_modify_fade;
\r
929 if(volume_modify_changed_1 != cvar("menu_volume") || volume_modify_changed_2 != cvar("menu_bgmvolume"))
\r
931 // An ugly hack to allow the cutvolume feature to work with the menu audio sliders.
\r
932 // Without it, adjusting the music or master sound sliders while fading that volume would have bad results.
\r
933 // This needs to be done in a better way! Currently, changing the volume sliders will just reset the fading.
\r
935 volume_modify_default_1 = cvar("menu_volume");
\r
936 volume_modify_default_2 = cvar("menu_bgmvolume");
\r
938 volume_modify_changed_1 = cvar("menu_volume");
\r
939 volume_modify_changed_2 = cvar("menu_bgmvolume");
\r
943 if(spectatee_status == -1 || intermission)
\r
945 volume_modify_1_target = volume_modify_default_1;
\r
946 volume_modify_2_target = volume_modify_default_2;
\r
948 else if(getstati(STAT_VORE_EATEN))
\r
950 volume_modify_1_target = volume_modify_default_1 * cvar("cl_vore_cutvolume_sound");
\r
951 volume_modify_2_target = volume_modify_default_2 * cvar("cl_vore_cutvolume_music");
\r
955 volume_modify_1_target = volume_modify_default_1;
\r
956 volume_modify_2_target = volume_modify_default_2;
\r
958 volume_modify_fade = cvar("cl_vore_cutvolume_fade") * frametime;
\r
960 if(volume_modify_1 != volume_modify_1_target || volume_modify_2 != volume_modify_2_target)
\r
962 if (volume_modify_1 > volume_modify_1_target + volume_modify_fade)
\r
963 volume_modify_1 -= volume_modify_fade;
\r
964 else if (volume_modify_1 < volume_modify_1_target - volume_modify_fade)
\r
965 volume_modify_1 += volume_modify_fade;
\r
967 volume_modify_1 = volume_modify_1_target;
\r
969 if (volume_modify_2 > volume_modify_2_target + volume_modify_fade)
\r
970 volume_modify_2 -= volume_modify_fade;
\r
971 else if (volume_modify_2 < volume_modify_2_target - volume_modify_fade)
\r
972 volume_modify_2 += volume_modify_fade;
\r
974 volume_modify_2 = volume_modify_2_target;
\r
976 cvar_set("volume", ftos(volume_modify_1));
\r
977 cvar_set("bgmvolume", ftos(volume_modify_2));
\r
978 // TODO: Setting the "volume" cvar is a bad way to go, and modifies the menu slider! We need a better way
\r
983 // Draw the mouse cursor
\r
984 // NOTE: drawpic must happen after R_RenderScene for some reason
\r
985 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
\r
986 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
\r
987 //self = edict_num(player_localnum);
\r
988 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
\r
989 //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
990 // as long as the ctf part isn't in, this is useless
\r
994 /*if(gametype == GAME_CTF)
\r
999 // draw 2D entities
\r
1001 for(self = world; (self = nextent(self)); )
\r
1005 Draw_ShowNames_All();
\r
1012 !scoreboard_active
\r
1014 cvar_string("cl_teamradar") != "0"
\r
1017 cvar("cl_teamradar") == 2
\r
1025 // Draw artwork and play intermission music
\r
1026 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
1028 if(cvar("cl_artwork"))
\r
1030 if(artwork_image == "")
\r
1032 if(getstati(STAT_WINNING)) // we are the winner
\r
1034 if(cvar("cl_artwork_win"))
\r
1036 artwork_image = strcat("gfx/artwork_won_", ftos(floor(1 + (random() * cvar("cl_artwork_win")))));
\r
1037 artwork_image = strzone(artwork_image);
\r
1040 else // we have lost
\r
1042 if(cvar("cl_artwork_lose"))
\r
1044 artwork_image = strcat("gfx/artwork_lost_", ftos(floor(1 + (random() * cvar("cl_artwork_lose")))));
\r
1045 artwork_image = strzone(artwork_image);
\r
1050 if(cvar("cl_artwork_stretch"))
\r
1052 artwork_size_x = vid_conwidth;
\r
1053 artwork_size_y = vid_conheight;
\r
1054 artwork_pos_x = 0;
\r
1055 artwork_pos_y = 0;
\r
1059 artwork_size_x = max(vid_conwidth, vid_conheight);
\r
1060 artwork_size_y = max(vid_conwidth, vid_conheight);
\r
1061 artwork_pos_x = (vid_conwidth - artwork_size_x) / 2;
\r
1062 artwork_pos_y = (vid_conheight - artwork_size_y) / 2;
\r
1065 if(artwork_fade < cvar("cl_artwork_alpha") && cvar("cl_artwork_fade"))
\r
1066 artwork_fade += frametime * cvar("cl_artwork_fade");
\r
1068 artwork_fade = cvar("cl_artwork_alpha");
\r
1070 if(artwork_image != "")
\r
1071 drawpic(artwork_pos, artwork_image, artwork_size, '1 1 1', artwork_fade, DRAWFLAG_NORMAL);
\r
1074 if(cvar("cl_intermission") && intermission_song == "") // don't start the song each frame
\r
1076 if(getstati(STAT_WINNING))
\r
1077 intermission_song = cvar_string("cl_intermission_cdtrack_win");
\r
1079 intermission_song = cvar_string("cl_intermission_cdtrack_lose");
\r
1080 if(intermission_song != "")
\r
1082 localcmd(strcat("\ncd play ", intermission_song, "\n"));
\r
1083 intermission_song = strzone(intermission_song);
\r
1090 if(artwork_image != "")
\r
1092 strunzone(artwork_image);
\r
1093 artwork_image = "";
\r
1096 if(intermission_song != "")
\r
1098 strunzone(intermission_song);
\r
1099 intermission_song = "";
\r
1104 if(cvar("r_letterbox") == 0) {
\r
1105 if (cvar("cl_showpressedkeys")) { // draw pressed keys when spectating and playing
\r
1106 if(spectatee_status > 0 || cvar("cl_showpressedkeys") >= 2)
\r
1107 Sbar_DrawPressedKeys();
\r
1110 if (cvar("cl_showspeed"))
\r
1112 if (cvar("cl_showacceleration"))
\r
1113 Sbar_ShowAcceleration();
\r
1115 Sbar_DrawCenterPrint(); // draw centerprint messages even if viewsize >= 120
\r
1118 float weapon_clipload, weapon_clipsize, ring_scale;
\r
1120 float swallow_indicator;
\r
1121 if(cvar("crosshair_swallowindicator"))
\r
1122 swallow_indicator = getstati(STAT_VORE_CANSWALLOW);
\r
1125 hud = getstati(STAT_HUD);
\r
1127 if(cvar("r_letterbox") == 0)
\r
1128 if(cvar("viewsize") < 120)
\r
1129 CSQC_common_hud();
\r
1131 if(cvar("cl_flash_pickup"))
\r
1132 if(pickup_flash_time < getstatf(STAT_LAST_PICKUP))
\r
1134 localcmd(strcat("bf ", cvar_string("cl_flash_pickup_color"), " ", cvar_string("cl_flash_pickup"), "\n"));
\r
1135 pickup_flash_time = getstatf(STAT_LAST_PICKUP);
\r
1137 if(cvar("cl_flash_vore"))
\r
1139 float vore_flash_state;
\r
1140 if(getstati(STAT_VORE_EATEN))
\r
1141 vore_flash_state = -1;
\r
1143 vore_flash_state = getstati(STAT_VORE_LOAD);
\r
1145 if not(spectatee_status && last_spectatee != spectatee_status) // not if we switched players and that detects a different stomach load
\r
1147 if(vore_flash_state > vore_flash_laststate && vore_flash_state > 0) // stomach load is bigger, so we ate someone
\r
1148 localcmd(strcat("bf ", cvar_string("cl_flash_vore_color_pred"), " ", cvar_string("cl_flash_vore"), "\n"));
\r
1149 if(vore_flash_state < vore_flash_laststate && vore_flash_state < 0) // -1 means we have been eaten
\r
1150 localcmd(strcat("bf ", cvar_string("cl_flash_vore_color_prey"), " ", cvar_string("cl_flash_vore"), "\n"));
\r
1153 // always update the last vore state, or the flash can be triggered when switching spectated players one frame after
\r
1154 vore_flash_laststate = vore_flash_state;
\r
1156 if(cvar("cl_flash_respawn"))
\r
1158 localcmd(strcat("bf ", cvar_string("cl_flash_respawn_color"), " ", cvar_string("cl_flash_respawn"), "\n"));
\r
1160 if not(getstati(STAT_VORE_EATEN)) // crosshair is useless if we're in the stomach
\r
1162 // crosshair goes VERY LAST
\r
1163 if(!scoreboard_active && !ons_showmap && !camera_active) {
\r
1166 // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
\r
1167 wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward);
\r
1168 wcross_origin_z = 0;
\r
1169 if(cvar("crosshair_hittest"))
\r
1170 if(!swallow_indicator)
\r
1172 vector wcross_oldorigin;
\r
1173 wcross_oldorigin = wcross_origin;
\r
1174 shottype = TrueAimCheck();
\r
1175 if(shottype == SHOTTYPE_HITWORLD)
\r
1177 v = wcross_origin - wcross_oldorigin;
\r
1178 v_x /= vid_conwidth;
\r
1179 v_y /= vid_conheight;
\r
1180 if(vlen(v) > 0.01)
\r
1181 shottype = SHOTTYPE_HITOBSTRUCTION;
\r
1183 if(!cvar("crosshair_hittest_showimpact"))
\r
1184 wcross_origin = wcross_oldorigin;
\r
1187 shottype = SHOTTYPE_HITWORLD;
\r
1189 string wcross_style;
\r
1191 if(swallow_indicator > 1)
\r
1192 wcross_style = "_canswallow_team.tga";
\r
1193 else if(swallow_indicator > 0)
\r
1194 wcross_style = "_canswallow.tga";
\r
1195 else if(swallow_indicator < 0)
\r
1196 wcross_style = "_canswallow_no.tga";
\r
1199 // normal crosshair, based on what weapon we have and what firing type we can use
\r
1201 wcross_style = cvar_string("crosshair");
\r
1202 else if(getstati(STAT_CROSSHAIR_STYLE))
\r
1203 wcross_style = cvar_string("crosshair_secondary");
\r
1205 wcross_style = cvar_string("crosshair_primary");
\r
1208 if (wcross_style != "0") {
\r
1209 vector wcross_color, wcross_size;
\r
1210 string wcross_name;
\r
1211 float wcross_alpha, wcross_scale, wcross_blur, wcross_resolution;
\r
1213 if(swallow_indicator && (cvar("crosshair_swallowindicator_color_red") || cvar("crosshair_swallowindicator_color_green") || cvar("crosshair_swallowindicator_color_blue")))
\r
1215 wcross_color_x = cvar("crosshair_swallowindicator_color_red");
\r
1216 wcross_color_y = cvar("crosshair_swallowindicator_color_green");
\r
1217 wcross_color_z = cvar("crosshair_swallowindicator_color_blue");
\r
1219 else if(cvar("crosshair_color_by_health"))
\r
1221 local float x = getstati(STAT_HEALTH);
\r
1227 wcross_color_z = 0;
\r
1231 wcross_color_x = 0;
\r
1232 wcross_color_y = 1;
\r
1236 wcross_color_x = 0.4 - (x-150)*0.02 * 0.4;
\r
1237 wcross_color_y = 0.9 + (x-150)*0.02 * 0.1;
\r
1241 wcross_color_x = 1 - (x-100)*0.02 * 0.6;
\r
1242 wcross_color_y = 1 - (x-100)*0.02 * 0.1;
\r
1243 wcross_color_z = 1 - (x-100)*0.02;
\r
1247 wcross_color_x = 1;
\r
1248 wcross_color_y = 1;
\r
1249 wcross_color_z = 0.2 + (x-50)*0.02 * 0.8;
\r
1253 wcross_color_x = 1;
\r
1254 wcross_color_y = (x-20)*90/27/100;
\r
1255 wcross_color_z = (x-20)*90/27/100 * 0.2;
\r
1259 wcross_color_x = 1;
\r
1260 wcross_color_y = 0;
\r
1264 wcross_color = stov(cvar_string("crosshair_color"));
\r
1265 wcross_alpha = cvar("crosshair_alpha");
\r
1266 wcross_resolution = cvar("crosshair_size");
\r
1269 if(!swallow_indicator)
\r
1271 if(cvar("crosshair_unarmed_dim_color"))
\r
1272 wcross_color *= cvar("crosshair_unarmed_dim_color");
\r
1273 if(cvar("crosshair_unarmed_dim_alpha"))
\r
1274 wcross_alpha *= cvar("crosshair_unarmed_dim_alpha");
\r
1277 wcross_name = strcat("gfx/crosshair", wcross_style);
\r
1279 if(cvar("crosshair_effect_scalefade"))
\r
1281 wcross_scale = wcross_resolution;
\r
1282 wcross_resolution = 1;
\r
1288 if(swallow_indicator)
\r
1289 wcross_scale *= cvar("crosshair_swallowindicator_size");
\r
1291 if(cvar("crosshair_pickup"))
\r
1293 if(pickup_crosshair_time < getstatf(STAT_LAST_PICKUP))
\r
1295 pickup_crosshair_size = 1;
\r
1296 pickup_crosshair_time = getstatf(STAT_LAST_PICKUP);
\r
1299 if(pickup_crosshair_size > 0)
\r
1300 pickup_crosshair_size -= cvar("crosshair_pickup_speed") * frametime;
\r
1302 pickup_crosshair_size = 0;
\r
1304 wcross_scale += sin(pickup_crosshair_size) * cvar("crosshair_pickup");
\r
1307 if(shottype == SHOTTYPE_HITENEMY)
\r
1308 wcross_scale *= cvar("crosshair_hittest"); // is not queried if hittest is 0
\r
1309 if(shottype == SHOTTYPE_HITTEAM)
\r
1310 wcross_scale /= cvar("crosshair_hittest"); // is not queried if hittest is 0
\r
1312 f = cvar("crosshair_effect_speed");
\r
1313 if(wcross_scale != wcross_scale_goal_prev || wcross_alpha != wcross_alpha_goal_prev || wcross_color != wcross_color_goal_prev)
\r
1315 wcross_changedonetime = time + f;
\r
1317 if(wcross_name != wcross_name_goal_prev || wcross_resolution != wcross_resolution_goal_prev)
\r
1319 wcross_name_changestarttime = time;
\r
1320 wcross_name_changedonetime = time + f;
\r
1321 if(wcross_name_goal_prev_prev)
\r
1322 strunzone(wcross_name_goal_prev_prev);
\r
1323 wcross_name_goal_prev_prev = wcross_name_goal_prev;
\r
1324 wcross_name_goal_prev = strzone(wcross_name);
\r
1325 wcross_name_alpha_goal_prev_prev = wcross_name_alpha_goal_prev;
\r
1326 wcross_resolution_goal_prev_prev = wcross_resolution_goal_prev;
\r
1327 wcross_resolution_goal_prev = wcross_resolution;
\r
1330 wcross_scale_goal_prev = wcross_scale;
\r
1331 wcross_alpha_goal_prev = wcross_alpha;
\r
1332 wcross_color_goal_prev = wcross_color;
\r
1334 if(shottype == SHOTTYPE_HITTEAM || (shottype == SHOTTYPE_HITOBSTRUCTION && cvar("crosshair_hittest_blur") && !cvar("chase_active")))
\r
1337 wcross_alpha *= 0.75;
\r
1341 // *_prev is at time-frametime
\r
1342 // * is at wcross_changedonetime+f
\r
1343 // what do we have at time?
\r
1344 if(time < wcross_changedonetime)
\r
1346 f = frametime / (wcross_changedonetime - time + frametime);
\r
1347 wcross_scale = f * wcross_scale + (1 - f) * wcross_scale_prev;
\r
1348 wcross_alpha = f * wcross_alpha + (1 - f) * wcross_alpha_prev;
\r
1349 wcross_color = f * wcross_color + (1 - f) * wcross_color_prev;
\r
1352 wcross_scale_prev = wcross_scale;
\r
1353 wcross_alpha_prev = wcross_alpha;
\r
1354 wcross_color_prev = wcross_color;
\r
1356 wcross_scale *= 1 - cvar("_menu_alpha");
\r
1357 wcross_alpha *= 1 - cvar("_menu_alpha");
\r
1359 #define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \
\r
1362 if(wcross_blur > 0) \
\r
1364 for(i = -2; i <= 2; ++i) \
\r
1365 for(j = -2; j <= 2; ++j) \
\r
1366 M(i,j,sz,wcross_name,wcross_alpha*0.04); \
\r
1370 M(0,0,sz,wcross_name,wcross_alpha); \
\r
1375 #define CROSSHAIR_DRAW_SINGLE(i,j,sz,wcross_name,wcross_alpha) \
\r
1376 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
1378 #define CROSSHAIR_DRAW(sz,wcross_name,wcross_alpha) \
\r
1379 CROSSHAIR_DO_BLUR(CROSSHAIR_DRAW_SINGLE,sz,wcross_name,wcross_alpha)
\r
1381 if(time < wcross_name_changedonetime && wcross_name != wcross_name_goal_prev_prev && wcross_name_goal_prev_prev)
\r
1383 f = (wcross_name_changedonetime - time) / (wcross_name_changedonetime - wcross_name_changestarttime);
\r
1384 wcross_size = drawgetimagesize(wcross_name_goal_prev_prev) * wcross_scale;
\r
1385 CROSSHAIR_DRAW(wcross_resolution_goal_prev_prev, wcross_name_goal_prev_prev, wcross_alpha * f * wcross_name_alpha_goal_prev_prev);
\r
1393 wcross_size = drawgetimagesize(wcross_name) * wcross_scale;
\r
1394 CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f);
\r
1395 wcross_name_alpha_goal_prev = f;
\r
1397 // ring around crosshair representing ammo left in weapon clip
\r
1398 weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);
\r
1399 a = cvar("crosshair_ring_alpha");
\r
1400 if (weapon_clipload && a)
\r
1401 if (!swallow_indicator)
\r
1403 weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);
\r
1404 ring_scale = cvar("crosshair_ring_size");
\r
1405 f = bound(0, weapon_clipload / weapon_clipsize, 1);
\r
1406 DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring.tga", f, wcross_color, wcross_alpha * a, DRAWFLAG_ADDITIVE);
\r
1412 wcross_scale_prev = 0;
\r
1413 wcross_alpha_prev = 0;
\r
1414 wcross_scale_goal_prev = 0;
\r
1415 wcross_alpha_goal_prev = 0;
\r
1416 wcross_changedonetime = 0;
\r
1417 if(wcross_name_goal_prev)
\r
1418 strunzone(wcross_name_goal_prev);
\r
1419 wcross_name_goal_prev = string_null;
\r
1420 if(wcross_name_goal_prev_prev)
\r
1421 strunzone(wcross_name_goal_prev_prev);
\r
1422 wcross_name_goal_prev_prev = string_null;
\r
1423 wcross_name_changestarttime = 0;
\r
1424 wcross_name_changedonetime = 0;
\r
1425 wcross_name_alpha_goal_prev = 0;
\r
1426 wcross_name_alpha_goal_prev_prev = 0;
\r
1427 wcross_resolution_goal_prev = 0;
\r
1428 wcross_resolution_goal_prev_prev = 0;
\r
1432 if(NextFrameCommand)
\r
1434 localcmd("\n", NextFrameCommand, "\n");
\r
1435 NextFrameCommand = string_null;
\r
1438 // we must do this check AFTER a frame was rendered, or it won't work
\r
1439 if(cs_project_is_b0rked == 0)
\r
1442 w0 = cvar_string("vid_conwidth");
\r
1443 h0 = cvar_string("vid_conheight");
\r
1444 //R_SetView(VF_VIEWPORT, '0 0 0', '640 480 0');
\r
1445 //R_SetView(VF_FOV, '90 90 0');
\r
1446 R_SetView(VF_ORIGIN, '0 0 0');
\r
1447 R_SetView(VF_ANGLES, '0 0 0');
\r
1448 R_SetView(VF_PERSPECTIVE, 1);
\r
1449 makevectors('0 0 0');
\r
1451 cvar_set("vid_conwidth", "800");
\r
1452 cvar_set("vid_conheight", "600");
\r
1453 v1 = cs_project(v_forward);
\r
1454 cvar_set("vid_conwidth", "640");
\r
1455 cvar_set("vid_conheight", "480");
\r
1456 v2 = cs_project(v_forward);
\r
1458 cs_project_is_b0rked = 1;
\r
1460 cs_project_is_b0rked = -1;
\r
1461 cvar_set("vid_conwidth", w0);
\r
1462 cvar_set("vid_conheight", h0);
\r
1465 // be safe against triggerbots until everyone has the fixed engine
\r
1466 // this call is meant to overwrite the trace globals by something
\r
1468 traceline('0 0 0', '0 0 0', MOVE_WORLDONLY, world);
\r
1470 // this cvar must be constantly updated on the server
\r
1471 if(chase_active_old != cvar("chase_active"))
\r
1473 localcmd("sendcvar chase_active\n");
\r
1474 chase_active_old = cvar("chase_active");
\r
1477 // update some stats to be detected next frame
\r
1478 last_health = getstati(STAT_HEALTH);
\r
1479 last_spectatee = spectatee_status;
\r
1484 void CSQC_common_hud(void)
\r
1486 // Sbar_SortFrags(); done in Sbar_Draw
\r
1488 hud = getstati(STAT_HUD);
\r
1500 // following vectors must be global to allow seamless switching between camera modes
\r
1501 vector camera_offset, current_camera_offset, mouse_angles, current_angles, current_origin, current_position;
\r
1502 void CSQC_Demo_Camera()
\r
1504 float speed, attenuation, dimensions;
\r
1505 vector tmp, delta;
\r
1507 if( cvar("camera_reset") || !camera_mode )
\r
1509 camera_offset = '0 0 0';
\r
1510 current_angles = '0 0 0';
\r
1511 camera_direction = '0 0 0';
\r
1512 camera_offset_z += 30;
\r
1513 camera_offset_x += 30 * -cos(current_angles_y * DEG2RAD);
\r
1514 camera_offset_y += 30 * -sin(current_angles_y * DEG2RAD);
\r
1515 current_origin = view_origin;
\r
1516 current_camera_offset = camera_offset;
\r
1517 cvar_set("camera_reset", "0");
\r
1518 camera_mode = CAMERA_CHASE;
\r
1523 mouse_angles_z += camera_roll * cvar("camera_speed_roll");
\r
1525 if(cvar("camera_look_player"))
\r
1530 dir = normalize(view_origin - current_position);
\r
1531 n = mouse_angles_z;
\r
1532 mouse_angles = vectoangles(dir);
\r
1533 mouse_angles_x = mouse_angles_x * -1;
\r
1534 mouse_angles_z = n;
\r
1538 tmp = getmousepos() * 0.1;
\r
1539 if(vlen(tmp)>cvar("camera_mouse_treshold"))
\r
1541 mouse_angles_x += tmp_y * cos(mouse_angles_z * DEG2RAD) + (tmp_x * sin(mouse_angles_z * DEG2RAD));
\r
1542 mouse_angles_y -= tmp_x * cos(mouse_angles_z * DEG2RAD) + (tmp_y * -sin(mouse_angles_z * DEG2RAD));
\r
1546 while (mouse_angles_x < -180) mouse_angles_x = mouse_angles_x + 360;
\r
1547 while (mouse_angles_x > 180) mouse_angles_x = mouse_angles_x - 360;
\r
1548 while (mouse_angles_y < -180) mouse_angles_y = mouse_angles_y + 360;
\r
1549 while (mouse_angles_y > 180) mouse_angles_y = mouse_angles_y - 360;
\r
1551 // Fix difference when angles don't have the same sign
\r
1553 if(mouse_angles_y < -60 && current_angles_y > 60)
\r
1554 delta = '0 360 0';
\r
1555 if(mouse_angles_y > 60 && current_angles_y < -60)
\r
1556 delta = '0 -360 0';
\r
1558 if(cvar("camera_look_player"))
\r
1559 attenuation = cvar("camera_look_attenuation");
\r
1561 attenuation = cvar("camera_speed_attenuation");
\r
1563 attenuation = 1 / max(1, attenuation);
\r
1564 current_angles += (mouse_angles - current_angles + delta) * attenuation;
\r
1566 while (current_angles_x < -180) current_angles_x = current_angles_x + 360;
\r
1567 while (current_angles_x > 180) current_angles_x = current_angles_x - 360;
\r
1568 while (current_angles_y < -180) current_angles_y = current_angles_y + 360;
\r
1569 while (current_angles_y > 180) current_angles_y = current_angles_y - 360;
\r
1571 // Camera position
\r
1575 if( camera_direction_x )
\r
1577 tmp_x = camera_direction_x * cos(current_angles_y * DEG2RAD);
\r
1578 tmp_y = camera_direction_x * sin(current_angles_y * DEG2RAD);
\r
1579 if( cvar("camera_forward_follows") && !cvar("camera_look_player") )
\r
1580 tmp_z = camera_direction_x * -sin(current_angles_x * DEG2RAD);
\r
1584 if( camera_direction_y )
\r
1586 tmp_x += camera_direction_y * -sin(current_angles_y * DEG2RAD);
\r
1587 tmp_y += camera_direction_y * cos(current_angles_y * DEG2RAD) * cos(current_angles_z * DEG2RAD);
\r
1588 tmp_z += camera_direction_y * sin(current_angles_z * DEG2RAD);
\r
1592 if( camera_direction_z )
\r
1594 tmp_z += camera_direction_z * cos(current_angles_z * DEG2RAD);
\r
1598 if(cvar("camera_free"))
\r
1599 speed = cvar("camera_speed_free");
\r
1601 speed = cvar("camera_speed_chase");
\r
1605 speed = speed * sqrt(1 / dimensions);
\r
1606 camera_offset += tmp * speed;
\r
1609 current_camera_offset += (camera_offset - current_camera_offset) * attenuation;
\r
1612 if( cvar("camera_free") )
\r
1614 if ( camera_mode == CAMERA_CHASE )
\r
1616 current_camera_offset = current_origin + current_camera_offset;
\r
1617 camera_offset = current_origin + camera_offset;
\r
1620 camera_mode = CAMERA_FREE;
\r
1621 current_position = current_camera_offset;
\r
1625 if ( camera_mode == CAMERA_FREE )
\r
1627 current_origin = view_origin;
\r
1628 camera_offset = camera_offset - current_origin;
\r
1629 current_camera_offset = current_camera_offset - current_origin;
\r
1632 camera_mode = CAMERA_CHASE;
\r
1634 if(cvar("camera_chase_smoothly"))
\r
1635 current_origin += (view_origin - current_origin) * attenuation;
\r
1637 current_origin = view_origin;
\r
1639 current_position = current_origin + current_camera_offset;
\r
1642 R_SetView(VF_ANGLES, current_angles);
\r
1643 R_SetView(VF_ORIGIN, current_position);
\r