X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fclient%2FView.qc;h=2ef460109ed8c78d161c47090c2d7f7af2296dad;hb=839df364feaf743dc458ad20852ca3df07c9eab5;hp=af6ebd65ee90cfd627ee9320bb8c5990477d3150;hpb=31205ac844e9d62a550556852e11a1b33d24e456;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index af6ebd65..2ef46010 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -203,11 +203,6 @@ float TrueAimCheck() ta = trueaim; mv = MOVE_NOMONSTERS; - switch(activeweapon) - { - case WEP_GRABBER: // no trueaim - } - vecs = decompressShotOrigin(getstati(STAT_SHOTORG)); traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, mv, ta); @@ -248,18 +243,20 @@ void CSQC_ctf_hud(void); void PostInit(void); void CSQC_Demo_Camera(); float Sbar_WouldDrawScoreboard (); -float view_set; +float last_health, last_spectatee; float camera_mode; float reticle_type; float chase_active_old; float artwork_fade; -float pickup_crosshair_time, pickup_crosshair_size; +float pickup_crosshair_time, pickup_crosshair_size, pickup_flash_time, vore_flash_laststate; +float spawnfov_current; float myhealth, myhealth_prev, myhealth_flash; float contentavgalpha, liquidalpha_prev; -float old_blurradius, old_bluralpha, old_sharpen_intensity; -float stomachsplash_alpha, stomachsplash_remove_at_respawn; -float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2; -float volume_modify_changed_1, volume_modify_changed_2; +float old_blurradius, old_bluralpha, old_cartoon_intensity; +float stomachsplash_alpha; +float eventchase_current_distance; +float helper_pause, helper_health, helper_armor, helper_ammo, helper_speed, helper_stomachload; +vector freeze_org, freeze_ang; vector myhealth_gentlergb; vector liquidcolor_prev; vector damage_blurpostprocess, content_blurpostprocess; @@ -273,8 +270,10 @@ void CSQC_UpdateView(float w, float h) float f, i, j; vector v, vo; float a; + float respawned; vector reticle_pos, reticle_size; + vector splash_pos, splash_size; vector artwork_pos, artwork_size; WaypointSprite_Load(); @@ -293,18 +292,182 @@ void CSQC_UpdateView(float w, float h) pmove_org = warpzone_fixview_origin - vo; input_angles = warpzone_fixview_angles; - // Render the Scene - if(!intermission || !view_set) + if((last_health <= 0 && getstati(STAT_HEALTH) > 0) || (!spectatee_status && last_spectatee)) // also cover switching from a spectator to a player instantly + if not(spectatee_status && last_spectatee != spectatee_status) // not if we switched players and that detects a different health + respawned = TRUE; // stays true for one frame + + // helper system + if(cvar("cl_helper")) + if not(getstati(STAT_ARMOR) < g_power || time <= power_boot) + { + if(intermission || respawned || spectatee_status < 0 || getstati(STAT_HEALTH) <= 0 || getstati(STAT_VORE_EATEN)) + { + // Set these helper messages as having been triggered, so that the player must first reach them before they complain. + // Otherwise, if you don't have any start armor for instance, the helper will complain about low armor when we spawn. + helper_health = TRUE; + helper_armor = TRUE; + helper_ammo = TRUE; + helper_stomachload = TRUE; + } + else if(helper_pause <= time) + { + // health helper + if(getstati(STAT_HEALTH) <= cvar("cl_helper_item_health")) + { + if(cvar("cl_helper_item_health") && !helper_health) + { + sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/health.wav"), VOL_BASEVOICE, ATTN_NONE); + helper_health = TRUE; + helper_pause = time + cvar("cl_helper_pause"); + helper_ammo = time + cvar("cl_helper_pause"); + } + } + else if(helper_health) + helper_health = FALSE; + + // armor helper + if(getstati(STAT_ARMOR) <= cvar("cl_helper_item_armor")) + { + if(cvar("cl_helper_item_armor") && !helper_armor) + { + sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/armor.wav"), VOL_BASEVOICE, ATTN_NONE); + helper_armor = TRUE; + helper_pause = time + cvar("cl_helper_pause"); + } + } + else if(helper_armor) + helper_armor = FALSE; + + // ammo helper + if(getstati(STAT_FUEL) <= cvar("cl_helper_item_ammo_fuel")) + { + if(cvar("cl_helper_item_ammo_fuel") && !helper_ammo) + { + sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/ammo.wav"), VOL_BASEVOICE, ATTN_NONE); + helper_ammo = TRUE; + helper_pause = time + cvar("cl_helper_pause"); + } + } + else if(helper_ammo) + helper_ammo = FALSE; + + // speed helper + if(vlen(pmove_vel) >= cvar("cl_helper_item_speed")) + { + if(cvar("cl_helper_item_speed") && !helper_speed) + { + sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/speed.wav"), VOL_BASEVOICE, ATTN_NONE); + helper_speed = TRUE; + helper_pause = time + cvar("cl_helper_pause"); + } + } + else if(helper_speed) + helper_speed = FALSE; + + // stomach load helper + if(getstati(STAT_VORE_LOAD) / getstati(STAT_VORE_MAXLOAD) >= cvar("cl_helper_item_stomachload")) + { + if(cvar("cl_helper_item_stomachload") && !helper_stomachload) + { + sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/stomachload.wav"), VOL_BASEVOICE, ATTN_NONE); + helper_stomachload = TRUE; + helper_pause = time + cvar("cl_helper_pause"); + } + } + else if(helper_stomachload) + helper_stomachload = FALSE; + } + } + + // event chase camera + if(cvar("chase_active") <= 0) // greater than 0 means it's enabled manually, and this code is skipped + { + if(spectatee_status >= 0 && (cvar("cl_eventchase_death") && getstati(STAT_HEALTH) <= 0 && !intermission && !getstati(STAT_VORE_EATEN)) || intermission) + { + // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.) + vector current_view_origin = getpropertyvec(VF_ORIGIN); + + // We must enable chase_active to get a third person view (weapon viewmodel hidden and own player model showing). + // Ideally, there should be another way to enable third person cameras, such as through setproperty() + if(!cvar("chase_active")) + 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) + + // make the camera smooth back + if(cvar("cl_eventchase_speed") && eventchase_current_distance < cvar("cl_eventchase_distance")) + eventchase_current_distance += cvar("cl_eventchase_speed") * (cvar("cl_eventchase_distance") - eventchase_current_distance) * frametime; // slow down the further we get + else if(eventchase_current_distance != cvar("cl_eventchase_distance")) + eventchase_current_distance = cvar("cl_eventchase_distance"); + + vector eventchase_target_origin; + makevectors(view_angles); + // pass 1, used to check where the camera would go and obtain the trace_fraction + eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance; + WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self); + // pass 2, also multiplying view_forward with trace_fraction, to prevent the camera from going through walls + // The 0.1 subtraction is to not limit the camera precisely at the wall surface, as that allows the view to poke through + eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance * (trace_fraction - 0.1); + WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self); + + setproperty(VF_ORIGIN, trace_endpos); + setproperty(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles)); + } + else if(cvar("chase_active") < 0) // time to disable chase_active if it was set by this code + { + cvar_set("chase_active", "0"); + eventchase_current_distance = 0; // start from 0 next time + } + } + + if(frametime) { - view_origin = pmove_org + vo; - view_angles = input_angles; - makevectors(view_angles); - view_forward = v_forward; - view_right = v_right; - view_up = v_up; - view_set = 1; + float apply_fov; + apply_fov = cvar("menu_fov"); + if(g_healthsize_center >= 0 && cvar("cl_healthsize_fov") && spectatee_status >= 0) + apply_fov += (g_healthsize_center - bound(g_healthsize_min, getstati(STAT_HEALTH), g_healthsize_max)) * cvar("cl_healthsize_fov"); + if(cvar("fov") != apply_fov) + cvar_set("fov", ftos(apply_fov)); } + float apply_idlescale; + if(cvar("cl_vore_vieweffects_idlescale_prey") && frametime) + { + apply_idlescale += getstatf(STAT_VORE_PROGRESS_PREY) * cvar("cl_vore_vieweffects_idlescale_prey"); + if(cvar("v_idlescale") != apply_idlescale) + cvar_set("v_idlescale", ftos(apply_idlescale)); + } + if(cvar("cl_vore_vieweffects_idlescale_predator") && frametime) + { + apply_idlescale += getstatf(STAT_VORE_PROGRESS_PRED) * cvar("cl_vore_vieweffects_idlescale_predator"); + if(cvar("v_idlescale") != apply_idlescale) + cvar_set("v_idlescale", ftos(apply_idlescale)); + } + if(cvar("cl_vore_vieweffects_idlescale_stomach") && frametime) + { + apply_idlescale += getstati(STAT_VORE_EATEN) * cvar("cl_vore_vieweffects_idlescale_stomach"); + if(cvar("v_idlescale") != apply_idlescale) + cvar_set("v_idlescale", ftos(apply_idlescale)); + } + + // do lockview after event chase camera so that it still applies whenever necessary. + if(intermission > 1) + { + setproperty(VF_ORIGIN, freeze_org); + setproperty(VF_ANGLES, freeze_ang); + } + else + { + freeze_org = getpropertyvec(VF_ORIGIN); + freeze_ang = getpropertyvec(VF_ANGLES); + } + + // Render the Scene + view_origin = getpropertyvec(VF_ORIGIN); + view_angles = getpropertyvec(VF_ANGLES); + makevectors(view_angles); + view_forward = v_forward; + view_right = v_right; + view_up = v_up; + vid_width = w; vid_height = h; @@ -393,16 +556,43 @@ void CSQC_UpdateView(float w, float h) // ALWAYS Clear Current Scene First R_ClearScene(); + if(checkextension("DP_CSQC_ROTATEMOVES")) + { + setproperty(VF_ORIGIN, view_origin); + setproperty(VF_ANGLES, view_angles); + } + // Assign Standard Viewflags // Draw the World (and sky) - R_SetView(VF_DRAWWORLD, 1); + setproperty(VF_DRAWWORLD, 1); // Set the console size vars vid_conwidth = cvar("vid_conwidth"); vid_conheight = cvar("vid_conheight"); vid_pixelheight = cvar("vid_pixelheight"); - R_SetView(VF_FOV, GetCurrentFov(fov)); + // spawn fov effect + if(cvar("cl_spawnfov")) + { + if(respawned) + spawnfov_current = 1 + cvar("cl_spawnfov"); + + if(spawnfov_current > 1) + spawnfov_current -= cvar("cl_spawnfov_speed") * frametime; + else + spawnfov_current = 1; + fov *= spawnfov_current; + } + + if(respawned) + { + if(g_power_reboot_spawn) + power_boot = time + g_power_reboot; + else + power_boot = time; + } + + setproperty(VF_FOV, GetCurrentFov(fov)); // Camera for demo playback if(camera_active) @@ -433,10 +623,10 @@ void CSQC_UpdateView(float w, float h) // Draw the Crosshair float scoreboard_active; scoreboard_active = Sbar_WouldDrawScoreboard(); - R_SetView(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden + setproperty(VF_DRAWCROSSHAIR, 0); //Make sure engine crosshairs are always hidden // Draw the Engine Status Bar (the default Quake HUD) - R_SetView(VF_DRAWENGINESBAR, 0); + setproperty(VF_DRAWENGINESBAR, 0); // fetch this one only once per frame sbar_showbinds = cvar("sbar_showbinds"); @@ -474,35 +664,36 @@ void CSQC_UpdateView(float w, float h) else if(button_zoom || zoomscript_caught) reticle_type = 1; // normal zoom - if(cvar("cl_reticle_stretch")) + if (reticle_type) { - reticle_size_x = vid_conwidth; - reticle_size_y = vid_conheight; - reticle_pos_x = 0; - reticle_pos_y = 0; - } - else - { - reticle_size_x = max(vid_conwidth, vid_conheight); - reticle_size_y = max(vid_conwidth, vid_conheight); - reticle_pos_x = (vid_conwidth - reticle_size_x) / 2; - reticle_pos_y = (vid_conheight - reticle_size_y) / 2; - } + if(cvar("cl_reticle_stretch")) + { + reticle_size_x = vid_conwidth; + reticle_size_y = vid_conheight; + reticle_pos_x = 0; + reticle_pos_y = 0; + } + else + { + reticle_size_x = max(vid_conwidth, vid_conheight); + reticle_size_y = max(vid_conwidth, vid_conheight); + reticle_pos_x = (vid_conwidth - reticle_size_x) / 2; + reticle_pos_y = (vid_conheight - reticle_size_y) / 2; + } - f = current_zoomfraction; - if(zoomscript_caught) - f = 1; - if(cvar("cl_reticle_item_normal")) - { - precache_pic("gfx/reticle_normal"); - if(reticle_type == 1 && f) - drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * cvar("cl_reticle_item_normal"), DRAWFLAG_NORMAL); - } - if(cvar("cl_reticle_item_weapon")) - { - precache_pic("gfx/reticle_weapon"); - if(reticle_type == 2 && f) - drawpic(reticle_pos, "gfx/reticle_weapon", reticle_size, '1 1 1', f * cvar("cl_reticle_item_weapon"), DRAWFLAG_NORMAL); + f = current_zoomfraction; + if(zoomscript_caught) + f = 1; + if(cvar("cl_reticle_item_normal")) + { + if(reticle_type == 1 && f) + drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * cvar("cl_reticle_item_normal"), DRAWFLAG_NORMAL); + } + if(cvar("cl_reticle_item_weapon")) + { + if(reticle_type == 2 && f) + drawpic(reticle_pos, "gfx/reticle_weapon", reticle_size, '1 1 1', f * cvar("cl_reticle_item_weapon"), DRAWFLAG_NORMAL); + } } // screen effects @@ -517,6 +708,12 @@ void CSQC_UpdateView(float w, float h) liquidcolor = stov(cvar_string("hud_contents_stomach_color")); incontent = 1; } + else if(getstatf(STAT_VORE_PROGRESS_PREY)) + { + liquidalpha = cvar("hud_contents_swallow_alpha"); + liquidcolor = stov(cvar_string("hud_contents_swallow_color")); + incontent = getstatf(STAT_VORE_PROGRESS_PREY); // based on the swallow progress + } else { switch(pointcontents(view_origin)) @@ -558,7 +755,7 @@ void CSQC_UpdateView(float w, float h) contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1); contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp; - + if(contentavgalpha) drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL); @@ -590,6 +787,11 @@ void CSQC_UpdateView(float w, float h) if(cvar("hud_damage")) { + splash_size_x = max(vid_conwidth, vid_conheight); + splash_size_y = max(vid_conwidth, vid_conheight); + splash_pos_x = (vid_conwidth - splash_size_x) / 2; + splash_pos_y = (vid_conheight - splash_size_y) / 2; + float myhealth_flash_temp; myhealth = getstati(STAT_HEALTH); @@ -646,7 +848,7 @@ void CSQC_UpdateView(float w, float h) 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); } else - 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); + drawpic(splash_pos, "gfx/blood", splash_size, stov(cvar_string("hud_damage_color")), bound(0, myhealth_flash_temp, 1) * cvar("hud_damage"), DRAWFLAG_NORMAL); if(cvar("hud_postprocessing")) { @@ -681,30 +883,32 @@ void CSQC_UpdateView(float w, float h) else stomachsplash_alpha = 0; } - if(getstati(STAT_HEALTH) <= 0) - stomachsplash_remove_at_respawn = 1; // schedule the effect to be removed next respawn - if(getstati(STAT_HEALTH) > 0 && stomachsplash_remove_at_respawn) - stomachsplash_alpha = stomachsplash_remove_at_respawn = 0; // we respawned, remove the effect + if(respawned) + stomachsplash_alpha = 0; // we respawned, remove the effect if(spectatee_status == -1) stomachsplash_alpha = 0; stomachsplash_alpha = bound(0, stomachsplash_alpha, 1); - drawpic('0 0 0', "gfx/food", '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, stov(cvar_string("hud_stomach_color")), stomachsplash_alpha, DRAWFLAG_NORMAL); + drawpic(splash_pos, "gfx/food", splash_size, stov(cvar_string("hud_stomach_color")), stomachsplash_alpha, DRAWFLAG_NORMAL); } if(cvar("hud_postprocessing")) { // all of this should be done in the engine eventually + // disable damage blur when dead, but keep content blur + if(getstati(STAT_HEALTH) <= 0) + damage_blurpostprocess = '0 0 0'; + // enable or disable rendering types if they are used or not if(cvar("r_glsl_postprocess_uservec1_enable") != (cvar("hud_postprocessing_maxbluralpha") != 0)) cvar_set("r_glsl_postprocess_uservec1_enable", ftos(cvar("hud_postprocessing_maxbluralpha") != 0)); - if(cvar("r_glsl_postprocess_uservec2_enable") != (cvar("hud_powerup") != 0)) - cvar_set("r_glsl_postprocess_uservec2_enable", ftos(cvar("hud_powerup") != 0)); + if(cvar("r_glsl_postprocess_uservec2_enable") != (cvar("hud_cartoon") != 0)) + cvar_set("r_glsl_postprocess_uservec2_enable", ftos(cvar("hud_cartoon") != 0)); // lets apply the postprocess effects from the previous two functions if needed - if(damage_blurpostprocess_x || content_blurpostprocess_x) + if((damage_blurpostprocess_x || content_blurpostprocess_x) && cvar("chase_active") >= 0) // not while the event chase camera is active { float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, cvar("hud_postprocessing_maxblurradius")); float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, cvar("hud_postprocessing_maxbluralpha")); @@ -722,26 +926,27 @@ void CSQC_UpdateView(float w, float h) old_bluralpha = 0; } - float sharpen_intensity; - if (getstatf(STAT_STRENGTH_FINISHED) - time > 0) - sharpen_intensity += (getstatf(STAT_STRENGTH_FINISHED) - time); - if (getstatf(STAT_INVINCIBLE_FINISHED) - time > 0) - sharpen_intensity += (getstatf(STAT_INVINCIBLE_FINISHED) - time); - - if(cvar("hud_powerup") && sharpen_intensity > 0) + if(cvar("hud_cartoon")) { - sharpen_intensity = bound(0, sharpen_intensity, 5); // powerup warning time is 5 seconds, so fade the effect from there - - if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible + // When having the strength or invincible powerups, cartoon lines will be white instead of black. + // As powerup time goes under 5 seconds (warning time), lines will fade from white to nothing then from nothing back to black. + float cartoon_intensity, cartoon_powerup; + cartoon_intensity = -cvar("hud_cartoon"); + cartoon_powerup = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 5) + bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 5); + cartoon_powerup = bound(0, cartoon_powerup, 5); + if (cartoon_powerup && cvar("chase_active") >= 0) // not while the event chase camera is active + cartoon_intensity *= 1 - cartoon_powerup / 2.5; // cycle between -1 and 1 + + if(cartoon_intensity != old_cartoon_intensity) // reduce cvar_set spam as much as possible { - cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(-sharpen_intensity * cvar("hud_powerup")), " 0 0")); - old_sharpen_intensity = sharpen_intensity; + cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(cartoon_intensity), " ", cvar_string("hud_cartoon_tolerance"), " 0")); + old_cartoon_intensity = cartoon_intensity; } } else if(cvar_string("r_glsl_postprocess_uservec2") != "0 0 0 0") // reduce cvar_set spam as much as possible { cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0"); - old_sharpen_intensity = 0; + old_cartoon_intensity = 0; } } @@ -752,7 +957,7 @@ void CSQC_UpdateView(float w, float h) cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0"); cvar_set("r_glsl_postprocess_uservec1_enable", "0"); } - if(cvar("hud_postprocessing") && !cvar("hud_powerup")) + if(cvar("hud_postprocessing") && !cvar("hud_cartoon")) if(cvar("r_glsl_postprocess_uservec2_enable")) { // don't allow sharpen to get stuck on if we disable the cvar while powered up @@ -760,63 +965,50 @@ void CSQC_UpdateView(float w, float h) cvar_set("r_glsl_postprocess_uservec2_enable", "0"); } - // volume cutting - if(cvar("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1) + if(cvar("hud_postprocessing")) { - float volume_modify_1_target, volume_modify_2_target, volume_modify_fade; + // change saturation based on the amount of armor we have + // ranges between 0.5 and 1 saturation, over 0 armor and half the armor limit - if(volume_modify_changed_1 != cvar("menu_volume") || volume_modify_changed_2 != cvar("menu_bgmvolume")) + if(cvar("hud_saturation") && armor_max && spectatee_status != -1 && getstati(STAT_HEALTH) > 0) { - // An ugly hack to allow the cutvolume feature to work with the menu audio sliders. - // Without it, adjusting the music or master sound sliders while fading that volume would have bad results. - // This needs to be done in a better way! Currently, changing the volume sliders will just reset the fading. + float saturation; + saturation = 0.5 + (getstati(STAT_ARMOR) / armor_max); + saturation = bound(0, saturation, 1); - volume_modify_default_1 = cvar("menu_volume"); - volume_modify_default_2 = cvar("menu_bgmvolume"); - - volume_modify_changed_1 = cvar("menu_volume"); - volume_modify_changed_2 = cvar("menu_bgmvolume"); + if(cvar("r_glsl_saturation") != saturation) + cvar_set("r_glsl_saturation", ftos(saturation)); } - else - { - if(spectatee_status == -1 || intermission) - { - volume_modify_1_target = volume_modify_default_1; - volume_modify_2_target = volume_modify_default_2; - } - else if(getstati(STAT_VORE_EATEN)) - { - volume_modify_1_target = volume_modify_default_1 * cvar("cl_vore_cutvolume_sound"); - volume_modify_2_target = volume_modify_default_2 * cvar("cl_vore_cutvolume_music"); - } - else - { - volume_modify_1_target = volume_modify_default_1; - volume_modify_2_target = volume_modify_default_2; - } - volume_modify_fade = cvar("cl_vore_cutvolume_fade") * frametime; - - if(volume_modify_1 != volume_modify_1_target || volume_modify_2 != volume_modify_2_target) - { - if (volume_modify_1 > volume_modify_1_target + volume_modify_fade) - volume_modify_1 -= volume_modify_fade; - else if (volume_modify_1 < volume_modify_1_target - volume_modify_fade) - volume_modify_1 += volume_modify_fade; - else - volume_modify_1 = volume_modify_1_target; - - if (volume_modify_2 > volume_modify_2_target + volume_modify_fade) - volume_modify_2 -= volume_modify_fade; - else if (volume_modify_2 < volume_modify_2_target - volume_modify_fade) - volume_modify_2 += volume_modify_fade; - else - volume_modify_2 = volume_modify_2_target; + else if(cvar("r_glsl_saturation") != 1) + cvar_set("r_glsl_saturation", "1"); + } - cvar_set("volume", ftos(volume_modify_1)); - cvar_set("bgmvolume", ftos(volume_modify_2)); - // TODO: Setting the "volume" cvar is a bad way to go, and modifies the menu slider! We need a better way - } - } + float target_volume; + if(cvar("cl_vore_cutvolume_sound") && frametime) + { + // sound volume cutting + target_volume = 0; + if(getstatf(STAT_VORE_PROGRESS_PREY)) + target_volume = getstatf(STAT_VORE_PROGRESS_PREY); + else if(getstati(STAT_VORE_EATEN)) + target_volume = 1; + target_volume = cvar("menu_volume") * (1 - target_volume * cvar("cl_vore_cutvolume_sound")); + + if(cvar("volume") != target_volume) // reduce cvar_set spam as much as possible + cvar_set("volume", ftos(target_volume)); + } + if(cvar("cl_vore_cutvolume_music") && frametime) + { + // music volume cutting + target_volume = 0; + if(getstatf(STAT_VORE_PROGRESS_PREY)) + target_volume = getstatf(STAT_VORE_PROGRESS_PREY); + else if(getstati(STAT_VORE_EATEN)) + target_volume = 1; + target_volume = cvar("menu_bgmvolume") * (1 - target_volume * cvar("cl_vore_cutvolume_music")); + + if(cvar("bgmvolume") != target_volume) // reduce cvar_set spam as much as possible + cvar_set("bgmvolume", ftos(target_volume)); } // Draw the mouse cursor @@ -841,24 +1033,25 @@ void CSQC_UpdateView(float w, float h) if(self.draw2d) self.draw2d(); self = e; + Draw_ShowNames_All(); // draw radar if( - ons_showmap + showmap || ( !scoreboard_active && - cvar_string("cl_teamradar") != "0" + cvar_string("cl_radar") != "0" && ( - cvar("cl_teamradar") == 2 + cvar("cl_radar") == 2 || teamplay ) ) ) - teamradar_view(); + radar_view(); // Draw artwork and play intermission music 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 @@ -963,13 +1156,46 @@ void CSQC_UpdateView(float w, float h) hud = getstati(STAT_HUD); if(cvar("r_letterbox") == 0) - if(cvar("viewsize") < 120) + if(cvar("viewsize") < 120 && sbar_hudselector) CSQC_common_hud(); + if(sbar_hudselector) // flashes require some HUD components to work + { + if(cvar("cl_flash_pickup")) + if(pickup_flash_time < getstatf(STAT_LAST_PICKUP)) + { + localcmd(strcat("bf ", cvar_string("cl_flash_pickup_color"), " ", cvar_string("cl_flash_pickup"), "\n")); + pickup_flash_time = getstatf(STAT_LAST_PICKUP); + } + if(cvar("cl_flash_vore")) + { + float vore_flash_state; + if(getstati(STAT_VORE_EATEN)) + vore_flash_state = -1; + else + vore_flash_state = hud_total_prey; + + if not(spectatee_status && last_spectatee != spectatee_status) // not if we switched players and that detects a different stomach load + { + if(vore_flash_state > vore_flash_laststate && vore_flash_state > 0) // stomach load is bigger, so we ate someone + localcmd(strcat("bf ", cvar_string("cl_flash_vore_color_pred"), " ", cvar_string("cl_flash_vore"), "\n")); + if(vore_flash_state < vore_flash_laststate && vore_flash_state < 0) // -1 means we have been eaten + localcmd(strcat("bf ", cvar_string("cl_flash_vore_color_prey"), " ", cvar_string("cl_flash_vore"), "\n")); + } + + // always update the last vore state, or the flash can be triggered when switching spectated players one frame after + vore_flash_laststate = vore_flash_state; + } + if(cvar("cl_flash_respawn")) + if(respawned) + localcmd(strcat("bf ", cvar_string("cl_flash_respawn_color"), " ", cvar_string("cl_flash_respawn"), "\n")); + } + if not(getstati(STAT_VORE_EATEN)) // crosshair is useless if we're in the stomach + if not(getstati(STAT_ARMOR) < g_power || time <= power_boot) { // crosshair goes VERY LAST - if(!scoreboard_active && !ons_showmap && !camera_active) { + if(!scoreboard_active && !showmap && !camera_active) { // TrueAim check float shottype; // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight; @@ -1001,8 +1227,18 @@ void CSQC_UpdateView(float w, float h) wcross_style = "_canswallow_team.tga"; else if(swallow_indicator > 0) wcross_style = "_canswallow.tga"; + else if(swallow_indicator < 0) + wcross_style = "_canswallow_no.tga"; else - wcross_style = cvar_string("crosshair"); + { + // normal crosshair, based on what weapon we have and what firing type we can use + if(!activeweapon) + wcross_style = cvar_string("crosshair"); + else if(getstati(STAT_CROSSHAIR_STYLE)) + wcross_style = cvar_string("crosshair_secondary"); + else + wcross_style = cvar_string("crosshair_primary"); + } if (wcross_style != "0") { vector wcross_color, wcross_size; @@ -1060,12 +1296,8 @@ void CSQC_UpdateView(float w, float h) } } else - { - wcross_color_x = cvar("crosshair_color_red"); - wcross_color_y = cvar("crosshair_color_green"); - wcross_color_z = cvar("crosshair_color_blue"); - } - wcross_alpha = cvar("crosshair_color_alpha"); + wcross_color = stov(cvar_string("crosshair_color")); + wcross_alpha = cvar("crosshair_alpha"); wcross_resolution = cvar("crosshair_size"); if(!activeweapon) @@ -1244,11 +1476,11 @@ void CSQC_UpdateView(float w, float h) string w0, h0; w0 = cvar_string("vid_conwidth"); h0 = cvar_string("vid_conheight"); - //R_SetView(VF_VIEWPORT, '0 0 0', '640 480 0'); - //R_SetView(VF_FOV, '90 90 0'); - R_SetView(VF_ORIGIN, '0 0 0'); - R_SetView(VF_ANGLES, '0 0 0'); - R_SetView(VF_PERSPECTIVE, 1); + //setproperty(VF_VIEWPORT, '0 0 0', '640 480 0'); + //setproperty(VF_FOV, '90 90 0'); + setproperty(VF_ORIGIN, '0 0 0'); + setproperty(VF_ANGLES, '0 0 0'); + setproperty(VF_PERSPECTIVE, 1); makevectors('0 0 0'); vector v1, v2; cvar_set("vid_conwidth", "800"); @@ -1276,6 +1508,10 @@ void CSQC_UpdateView(float w, float h) localcmd("sendcvar chase_active\n"); chase_active_old = cvar("chase_active"); } + + // update some stats to be detected next frame + last_health = getstati(STAT_HEALTH); + last_spectatee = spectatee_status; } void Sbar_Draw(); @@ -1438,6 +1674,6 @@ void CSQC_Demo_Camera() current_position = current_origin + current_camera_offset; } - R_SetView(VF_ANGLES, current_angles); - R_SetView(VF_ORIGIN, current_position); + setproperty(VF_ANGLES, current_angles); + setproperty(VF_ORIGIN, current_position); }