X-Git-Url: http://de.git.xonotic.org/?p=voretournament%2Fvoretournament.git;a=blobdiff_plain;f=data%2Fqcsrc%2Fclient%2FView.qc;h=0e4167c83fff54e70f9dbb7bff3e2c9aa5b1a41b;hp=b497665a19f964f8faf6cbb2240667e16e7825af;hb=8cac9a6f0e00ad7b1a39f9b616e4da769550df3d;hpb=e45245942a8fe06b0e9fe658cca2e3a595c5b7cb diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index b497665a..0e4167c8 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -252,7 +252,16 @@ float view_set; float camera_mode; 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 stomachsplash_alpha, stomachsplash_remove_at_respawn; +float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2; +vector myhealth_gentlergb; +vector liquidcolor_prev; +vector damage_blurpostprocess, content_blurpostprocess; string artwork_image; +string intermission_song; string NextFrameCommand; void CSQC_UpdateView(float w, float h) { @@ -449,6 +458,293 @@ void CSQC_UpdateView(float w, float h) // next R_RenderScene call drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0); + if(cvar("hud_contents")) + { + float contentalpha_temp, incontent, liquidalpha, contentfadetime; + vector liquidcolor; + + if (getstati(STAT_VORE_EATEN)) + { + liquidalpha = cvar("hud_contents_stomach_alpha"); + liquidcolor = stov(cvar_string("hud_contents_stomach_color")); + incontent = 1; + } + else + { + switch(pointcontents(view_origin)) + { + case CONTENT_WATER: + liquidalpha = cvar("hud_contents_water_alpha"); + liquidcolor = stov(cvar_string("hud_contents_water_color")); + incontent = 1; + break; + + case CONTENT_LAVA: + liquidalpha = cvar("hud_contents_lava_alpha"); + liquidcolor = stov(cvar_string("hud_contents_lava_color")); + incontent = 1; + break; + + case CONTENT_SLIME: + liquidalpha = cvar("hud_contents_slime_alpha"); + liquidcolor = stov(cvar_string("hud_contents_slime_color")); + incontent = 1; + break; + + default: + liquidalpha = 0; + liquidcolor = '0 0 0'; + incontent = 0; + break; + } + } + + if(incontent) // fade in/out at different speeds so you can do e.g. instant fade when entering water and slow when leaving it. + { // also lets delcare previous values for blending properties, this way it isn't reset until after you have entered a different content + contentfadetime = cvar("hud_contents_fadeintime"); + liquidalpha_prev = liquidalpha; + liquidcolor_prev = liquidcolor; + } + else + contentfadetime = cvar("hud_contents_fadeouttime"); + + 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); + + if(cvar("hud_postprocessing")) + { + if(cvar("hud_contents_liquid_blur")) + { + // 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")) + { + float myhealth_flash_temp; + myhealth = getstati(STAT_HEALTH); + + // fade out + myhealth_flash = max(0, myhealth_flash - cvar("hud_damage_fade_rate") * frametime); + // add new damage + myhealth_flash = bound(0, myhealth_flash + dmg_take * cvar("hud_damage_factor"), cvar("hud_damage_maxalpha")); + + float pain_threshold, pain_threshold_lower, pain_threshold_lower_health; + pain_threshold = cvar("hud_damage_pain_threshold"); + pain_threshold_lower = cvar("hud_damage_pain_threshold_lower"); + pain_threshold_lower_health = cvar("hud_damage_pain_threshold_lower_health"); + + if(pain_threshold_lower && myhealth < pain_threshold_lower_health) + { + 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); + } + + myhealth_flash_temp = bound(0, myhealth_flash - pain_threshold, 1); + + if(myhealth_prev < 1) + { + if(myhealth >= 1) + { + myhealth_flash = 0; // just spawned, clear the flash immediately + myhealth_flash_temp = 0; + } + else + { + myhealth_flash += cvar("hud_damage_fade_rate") * frametime; // dead + } + } + + if(spectatee_status == -1 || intermission) + { + myhealth_flash = 0; // observing, or match ended + myhealth_flash_temp = 0; + } + + myhealth_prev = myhealth; + + if(cvar("cl_gentle_damage") || cvar("cl_gentle")) + { + if(cvar("cl_gentle_damage") == 2) + { + if(myhealth_flash < pain_threshold) // only randomize when the flash is gone + { + myhealth_gentlergb = '1 0 0' * random() + '0 1 0' * random() + '0 0 1' * random(); + } + } + else + myhealth_gentlergb = stov(cvar_string("hud_damage_gentle_color")); + + 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); + + if(cvar("hud_postprocessing")) + { + if(cvar("hud_damage_blur")) + { + damage_blurpostprocess_x = 1; + damage_blurpostprocess_y = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur"); + damage_blurpostprocess_z = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur_alpha"); + } + else + { + damage_blurpostprocess_x = 0; + damage_blurpostprocess_y = 0; + damage_blurpostprocess_z = 0; + } + } + } + + if(cvar("hud_stomach")) + { + if(getstati(STAT_VORE_EATEN)) + { + if(stomachsplash_alpha < cvar("hud_stomach")) + stomachsplash_alpha += cvar("hud_stomach_fade_in") * frametime; + else + stomachsplash_alpha = cvar("hud_stomach"); + } + 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) + 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); + } + + if(cvar("hud_postprocessing")) + { + // 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"); + } + else + { + cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0"); + cvar_set("r_glsl_postprocess_uservec1_enable", "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); + sharpen_intensity = bound(0, sharpen_intensity, 5); // powerup warning time is 5 seconds, so fade the effect from there + + if(sharpen_intensity > 0) + { + cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(-sharpen_intensity * cvar("hud_powerup")), " 0 0")); + cvar_set("r_glsl_postprocess_uservec2_enable", "1"); + } + else + { + cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0"); + cvar_set("r_glsl_postprocess_uservec2_enable", "0"); + } + } + } + + if not(cvar("hud_damage") && cvar("hud_postprocessing")) + { + // 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")) + { + // 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("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1) + { + float volume_modify_1_target, volume_modify_2_target, volume_modify_fade; + 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 = 1; + volume_modify_2_target = 1; + } + volume_modify_fade = cvar("cl_vore_cutvolume_fade") * frametime; + + if(spectatee_status == -1 || intermission) + { + // no volume fading is currently taking place, so if we change the volume settings, update the initial volume + volume_modify_default_1 = cvar("volume"); + volume_modify_default_2 = cvar("bgmvolume"); + } + else 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_1_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 + } + else if(cvar("volume") != volume_modify_default_1 || cvar("bgmvolume") != volume_modify_default_2) + { + // no volume fading is currently taking place, so if we change the volume settings, update the initial volume + volume_modify_default_1 = cvar("volume"); + volume_modify_default_2 = cvar("bgmvolume"); + } + } + // Draw the mouse cursor // NOTE: drawpic must happen after R_RenderScene for some reason //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0); @@ -490,56 +786,82 @@ void CSQC_UpdateView(float w, float h) ) teamradar_view(); - // Draw Artwork - if(intermission && !isdemo()) // the match has ended - if(!spectatee_status) + // 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 { - if(artwork_image == "") + if(cvar("cl_artwork")) { - if(getstati(STAT_WINNING)) // we are the winner + if(artwork_image == "") + { + if(getstati(STAT_WINNING)) // we are the winner + { + if(cvar("cl_artwork_win")) + { + artwork_image = strcat("gfx/artwork_won_", ftos(floor(1 + (random() * cvar("cl_artwork_win"))))); + artwork_image = strzone(artwork_image); + } + } + else // we have lost + { + if(cvar("cl_artwork_lose")) + { + artwork_image = strcat("gfx/artwork_lost_", ftos(floor(1 + (random() * cvar("cl_artwork_lose"))))); + artwork_image = strzone(artwork_image); + } + } + } + + if(cvar("cl_artwork_stretch")) { - if(cvar("cl_artwork_win")) - artwork_image = strcat("gfx/artwork_won_", ftos(floor(1 + (random() * cvar("cl_artwork_win"))))); + artwork_size_x = vid_conwidth; + artwork_size_y = vid_conheight; + artwork_pos_x = 0; + artwork_pos_y = 0; } - else // we have lost + else { - if(cvar("cl_artwork_lose")) - artwork_image = strcat("gfx/artwork_lost_", ftos(floor(1 + (random() * cvar("cl_artwork_lose"))))); + artwork_size_x = max(vid_conwidth, vid_conheight); + artwork_size_y = max(vid_conwidth, vid_conheight); + artwork_pos_x = (vid_conwidth - artwork_size_x) / 2; + artwork_pos_y = (vid_conheight - artwork_size_y) / 2; } - artwork_image = strzone(artwork_image); - } - if(cvar("cl_artwork_stretch")) - { - artwork_size_x = vid_conwidth; - artwork_size_y = vid_conheight; - artwork_pos_x = 0; - artwork_pos_y = 0; + if(artwork_fade < cvar("cl_artwork_alpha") && cvar("cl_artwork_fade")) + artwork_fade += frametime * cvar("cl_artwork_fade"); + else + artwork_fade = cvar("cl_artwork_alpha"); + + if(artwork_image != "") + drawpic(artwork_pos, artwork_image, artwork_size, '1 1 1', artwork_fade, DRAWFLAG_NORMAL); } - else + + if(cvar("cl_intermission") && intermission_song == "") // don't start the song each frame { - artwork_size_x = max(vid_conwidth, vid_conheight); - artwork_size_y = max(vid_conwidth, vid_conheight); - artwork_pos_x = (vid_conwidth - artwork_size_x) / 2; - artwork_pos_y = (vid_conheight - artwork_size_y) / 2; + if(getstati(STAT_WINNING)) + intermission_song = cvar_string("cl_intermission_cdtrack_win"); + else + intermission_song = cvar_string("cl_intermission_cdtrack_lose"); + if(intermission_song != "") + { + localcmd(strcat("\ncd play ", intermission_song, "\n")); + intermission_song = strzone(intermission_song); + } } - - if(artwork_fade < cvar("cl_artwork_alpha") && cvar("cl_artwork_fade")) - artwork_fade += frametime * cvar("cl_artwork_fade"); - else - artwork_fade = cvar("cl_artwork_alpha"); - - if(artwork_image != "") - drawpic(artwork_pos, artwork_image, artwork_size, '1 1 1', artwork_fade, DRAWFLAG_NORMAL); } else { + artwork_fade = 0; if(artwork_image != "") { strunzone(artwork_image); artwork_image = ""; } - artwork_fade = 0; + + if(intermission_song != "") + { + strunzone(intermission_song); + intermission_song = ""; + } } // draw sbar @@ -618,6 +940,22 @@ void CSQC_UpdateView(float w, float h) wcross_scale = 1; } + if(cvar("crosshair_pickup")) + { + if(pickup_crosshair_time < getstatf(STAT_LAST_PICKUP)) + { + pickup_crosshair_size = 1; + pickup_crosshair_time = getstatf(STAT_LAST_PICKUP); + } + + if(pickup_crosshair_size > 0) + pickup_crosshair_size -= cvar("crosshair_pickup_speed") * frametime; + else + pickup_crosshair_size = 0; + + wcross_scale += sin(pickup_crosshair_size) * cvar("crosshair_pickup"); + } + if(shottype == SHOTTYPE_HITENEMY) wcross_scale *= cvar("crosshair_hittest"); // is not queried if hittest is 0 if(shottype == SHOTTYPE_HITTEAM)