X-Git-Url: https://de.git.xonotic.org/?p=voretournament%2Fvoretournament.git;a=blobdiff_plain;f=data%2Fqcsrc%2Fclient%2FView.qc;h=1a758a7925ead45b8d6ae4747da12a5b943a5db2;hp=0045ac9da277d8ac05a1e239068192896a10d47b;hb=d2be8795987c599bcfe6091c9374aa0c67e26520;hpb=6df6dfde348e2f189767d98acc5db89aa7a62224 diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index 0045ac9d..1a758a79 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -250,12 +250,17 @@ void CSQC_Demo_Camera(); float Sbar_WouldDrawScoreboard (); float view_set; float camera_mode; +float reticle_type; float chase_active_old; float artwork_fade; float pickup_crosshair_time, pickup_crosshair_size; 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 eventchase_current_distance; vector myhealth_gentlergb; vector liquidcolor_prev; vector damage_blurpostprocess, content_blurpostprocess; @@ -268,7 +273,10 @@ void CSQC_UpdateView(float w, float h) float fov; float f, i, j; vector v, vo; + float a; + vector reticle_pos, reticle_size; + vector splash_pos, splash_size; vector artwork_pos, artwork_size; WaypointSprite_Load(); @@ -287,6 +295,41 @@ void CSQC_UpdateView(float w, float h) pmove_org = warpzone_fixview_origin - vo; input_angles = warpzone_fixview_angles; + // 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)) + { + // 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 R_SetView() + 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 = pmove_org - v_forward * eventchase_current_distance; + + traceline(pmove_org, 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 = pmove_org - v_forward * eventchase_current_distance * (trace_fraction - 0.1); + + R_SetView(VF_ORIGIN, eventchase_target_origin); + } + 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 + } + } + // Render the Scene if(!intermission || !view_set) { @@ -457,6 +500,50 @@ void CSQC_UpdateView(float w, float h) // next R_RenderScene call drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0); + // Draw the aiming reticle for weapons that use it + // reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use + // It must be a persisted float for fading out to work properly (you let go of the zoom button for + // the view to go back to normal, so reticle_type would become 0 as we fade out) + if(spectatee_status || getstati(STAT_HEALTH) <= 0) + reticle_type = 0; // prevent reticle from showing during the respawn zoom effect or for spectators + else if(activeweapon && (button_zoom || zoomscript_caught)) + reticle_type = 2; // weapon zoom + else if(button_zoom || zoomscript_caught) + reticle_type = 1; // normal zoom + + if (reticle_type) + { + 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")) + { + 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 if(cvar("hud_contents")) { float contentalpha_temp, incontent, liquidalpha, contentfadetime; @@ -512,10 +599,40 @@ void CSQC_UpdateView(float w, float h) if(contentavgalpha) drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL); + + if(cvar("hud_postprocessing")) + { + if(cvar("hud_contents_liquid_blur") && contentavgalpha) + { + // when inside the stomach, we use different blur settings than when we're inside other fluids + content_blurpostprocess_x = 1; + if(getstati(STAT_VORE_EATEN)) + { + content_blurpostprocess_y = contentavgalpha * cvar("hud_contents_stomach_blur"); + content_blurpostprocess_z = contentavgalpha * cvar("hud_contents_stomach_blur_alpha"); + } + else + { + content_blurpostprocess_y = contentavgalpha * cvar("hud_contents_liquid_blur"); + content_blurpostprocess_z = contentavgalpha * cvar("hud_contents_liquid_blur_alpha"); + } + } + else + { + content_blurpostprocess_x = 0; + content_blurpostprocess_y = 0; + content_blurpostprocess_z = 0; + } + } } 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); @@ -572,11 +689,11 @@ 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")) { - if(cvar("hud_damage_blur")) + if(cvar("hud_damage_blur") && myhealth_flash_temp) { damage_blurpostprocess_x = 1; damage_blurpostprocess_y = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur"); @@ -600,36 +717,148 @@ void CSQC_UpdateView(float w, float h) else stomachsplash_alpha = cvar("hud_stomach"); } - else + else if(getstati(STAT_HEALTH) > 0) { if(stomachsplash_alpha > 0) stomachsplash_alpha -= cvar("hud_stomach_fade_out") * frametime; else stomachsplash_alpha = 0; } - if (getstati(STAT_HEALTH) <= 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(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")) - { // lets apply the postprocess effects from the previous two functions if needed + { + // all of this should be done in the engine eventually + + // 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)); + + // lets apply the postprocess effects from the previous two functions if needed if(damage_blurpostprocess_x || content_blurpostprocess_x) { 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")); - cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0")); - cvar_set("r_glsl_postprocess_uservec1_enable", "1"); + if(blurradius != old_blurradius || bluralpha != old_bluralpha) // reduce cvar_set spam as much as possible + { + cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0")); + old_blurradius = blurradius; + old_bluralpha = bluralpha; + } } - else + else if(cvar_string("r_glsl_postprocess_uservec1") != "0 0 0 0") // reduce cvar_set spam as much as possible { cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0"); - cvar_set("r_glsl_postprocess_uservec1_enable", "0"); + old_blurradius = 0; + 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) + { + 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 + { + cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(-sharpen_intensity * cvar("hud_powerup")), " 0 0")); + old_sharpen_intensity = sharpen_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; + } + } + + if(cvar("hud_postprocessing") && !cvar("hud_postprocessing_maxbluralpha")) + if(cvar("r_glsl_postprocess_uservec1_enable")) + { + // don't allow blur to get stuck on if we disable the cvar while damaged + 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("r_glsl_postprocess_uservec2_enable")) + { + // don't allow sharpen to get stuck on if we disable the cvar while powered up + cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0"); + cvar_set("r_glsl_postprocess_uservec2_enable", "0"); + } + + // volume cutting + if(cvar("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1) + { + float volume_modify_1_target, volume_modify_2_target, volume_modify_fade; + + if(volume_modify_changed_1 != cvar("menu_volume") || volume_modify_changed_2 != cvar("menu_bgmvolume")) + { + // 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. + + 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"); + } + 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; + + 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 + } } } @@ -767,6 +996,12 @@ void CSQC_UpdateView(float w, float h) Sbar_DrawCenterPrint(); // draw centerprint messages even if viewsize >= 120 } + float weapon_clipload, weapon_clipsize, ring_scale; + + float swallow_indicator; + if(cvar("crosshair_swallowindicator")) + swallow_indicator = getstati(STAT_VORE_CANSWALLOW); + float hud; hud = getstati(STAT_HUD); @@ -784,6 +1019,7 @@ void CSQC_UpdateView(float w, float h) wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward); wcross_origin_z = 0; if(cvar("crosshair_hittest")) + if(!swallow_indicator) { vector wcross_oldorigin; wcross_oldorigin = wcross_origin; @@ -803,19 +1039,89 @@ void CSQC_UpdateView(float w, float h) shottype = SHOTTYPE_HITWORLD; string wcross_style; - wcross_style = cvar_string("crosshair"); + + if(swallow_indicator > 1) + 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"); if (wcross_style != "0") { vector wcross_color, wcross_size; string wcross_name; float wcross_alpha, wcross_scale, wcross_blur, wcross_resolution; - wcross_color_x = cvar("crosshair_color_red"); - wcross_color_y = cvar("crosshair_color_green"); - wcross_color_z = cvar("crosshair_color_blue"); + if(swallow_indicator && (cvar("crosshair_swallowindicator_color_red") || cvar("crosshair_swallowindicator_color_green") || cvar("crosshair_swallowindicator_color_blue"))) + { + wcross_color_x = cvar("crosshair_swallowindicator_color_red"); + wcross_color_y = cvar("crosshair_swallowindicator_color_green"); + wcross_color_z = cvar("crosshair_swallowindicator_color_blue"); + } + else if(cvar("crosshair_color_by_health")) + { + local float x = getstati(STAT_HEALTH); + + //x = red + //y = green + //z = blue + + wcross_color_z = 0; + + if(x > 200) + { + wcross_color_x = 0; + wcross_color_y = 1; + } + else if(x > 150) + { + wcross_color_x = 0.4 - (x-150)*0.02 * 0.4; + wcross_color_y = 0.9 + (x-150)*0.02 * 0.1; + } + else if(x > 100) + { + wcross_color_x = 1 - (x-100)*0.02 * 0.6; + wcross_color_y = 1 - (x-100)*0.02 * 0.1; + wcross_color_z = 1 - (x-100)*0.02; + } + else if(x > 50) + { + wcross_color_x = 1; + wcross_color_y = 1; + wcross_color_z = 0.2 + (x-50)*0.02 * 0.8; + } + else if(x > 20) + { + wcross_color_x = 1; + wcross_color_y = (x-20)*90/27/100; + wcross_color_z = (x-20)*90/27/100 * 0.2; + } + else + { + wcross_color_x = 1; + wcross_color_y = 0; + } + } + 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_resolution = cvar("crosshair_size"); + if(!activeweapon) + if(!swallow_indicator) + { + if(cvar("crosshair_unarmed_dim_color")) + wcross_color *= cvar("crosshair_unarmed_dim_color"); + if(cvar("crosshair_unarmed_dim_alpha")) + wcross_alpha *= cvar("crosshair_unarmed_dim_alpha"); + } + wcross_name = strcat("gfx/crosshair", wcross_style); if(cvar("crosshair_effect_scalefade")) @@ -827,6 +1133,8 @@ void CSQC_UpdateView(float w, float h) { wcross_scale = 1; } + if(swallow_indicator) + wcross_scale *= cvar("crosshair_swallowindicator_size"); if(cvar("crosshair_pickup")) { @@ -933,6 +1241,18 @@ void CSQC_UpdateView(float w, float h) wcross_size = drawgetimagesize(wcross_name) * wcross_scale; CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f); wcross_name_alpha_goal_prev = f; + + // ring around crosshair representing ammo left in weapon clip + weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD); + a = cvar("crosshair_ring_alpha"); + if (weapon_clipload && a) + if (!swallow_indicator) + { + weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE); + ring_scale = cvar("crosshair_ring_size"); + f = bound(0, weapon_clipload / weapon_clipsize, 1); + DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring.tga", f, wcross_color, wcross_alpha * a, DRAWFLAG_ADDITIVE); + } } } else