X-Git-Url: http://de.git.xonotic.org/?p=voretournament%2Fvoretournament.git;a=blobdiff_plain;f=data%2Fqcsrc%2Fclient%2FView.qc;h=e6f9a562a584045863c29ea27dd471b2ce5d24e6;hp=3e21c77e511f25ec928937d5af581c9dddcb3030;hb=3f3552b3713c4e207b1e364cc3e4f37a64726b65;hpb=68efbd15fda57a6c140dab797e7d1c0fdf19bba4 diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index 3e21c77e..e6f9a562 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -253,13 +253,14 @@ 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; 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; @@ -275,6 +276,7 @@ void CSQC_UpdateView(float w, float h) float a; vector reticle_pos, reticle_size; + vector splash_pos, splash_size; vector artwork_pos, artwork_size; WaypointSprite_Load(); @@ -293,6 +295,42 @@ 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(!getstati(STAT_VORE_EATEN) && 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); + R_SetView(VF_ANGLES, 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 + } + } + // Render the Scene if(!intermission || !view_set) { @@ -474,35 +512,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 @@ -558,7 +597,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 +629,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 +690,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")) { @@ -690,69 +734,98 @@ void CSQC_UpdateView(float w, float h) 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)); + // 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")); 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")); - cvar_set("r_glsl_postprocess_uservec1_enable", "1"); old_blurradius = blurradius; old_bluralpha = bluralpha; } } - else if(cvar("r_glsl_postprocess_uservec1_enable")) // reduce cvar_set spam as much as possible + 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; } - if(cvar("hud_powerup")) + 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 && cvar("chase_active") >= 0) // not while the event chase camera is active { - 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); sharpen_intensity = bound(0, sharpen_intensity, 5); // powerup warning time is 5 seconds, so fade the effect from there - if(sharpen_intensity > 0) - { - 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")); - cvar_set("r_glsl_postprocess_uservec2_enable", "1"); - old_sharpen_intensity = sharpen_intensity; - } - } - else if(cvar("r_glsl_postprocess_uservec2_enable")) // reduce cvar_set spam as much as possible + if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible { - cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0"); - cvar_set("r_glsl_postprocess_uservec2_enable", "0"); + 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 not(cvar("hud_damage") && cvar("hud_postprocessing")) + 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 not(cvar("hud_powerup") && cvar("hud_postprocessing")) + 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"); } + if(cvar("hud_postprocessing")) + { + // change saturation based on the amount of armor we have + // ranges between 0 and 50 armor. 0 armor is saturation 0.5, and 0.5 armor or above is saturation 1 + + if(cvar("hud_saturation") && armor_enabled && spectatee_status != -1 && getstati(STAT_HEALTH) > 0) + { + float saturation; + saturation = 0.5 + (getstati(STAT_ARMOR) * 1 * 0.01); + saturation = bound(0, saturation, 1); + + if(cvar("r_glsl_saturation") != saturation) + cvar_set("r_glsl_saturation", ftos(saturation)); + } + else if(cvar("r_glsl_saturation") != 1) + cvar_set("r_glsl_saturation", "1"); + } + // volume cutting if(cvar("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1) { @@ -994,6 +1067,8 @@ 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"); @@ -1100,6 +1175,13 @@ void CSQC_UpdateView(float w, float h) wcross_scale += sin(pickup_crosshair_size) * cvar("crosshair_pickup"); } + 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(shottype == SHOTTYPE_HITENEMY) wcross_scale *= cvar("crosshair_hittest"); // is not queried if hittest is 0 if(shottype == SHOTTYPE_HITTEAM) @@ -1190,7 +1272,7 @@ void CSQC_UpdateView(float w, float h) CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f); wcross_name_alpha_goal_prev = f; - // ring around crosshair representing bullets left in weapon clip + // ring around crosshair representing ammo left in weapon clip weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD); a = cvar("crosshair_ring_alpha"); if (weapon_clipload && a)