+ // Draw the aiming reticle for weapons that use it\r
+ // reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use\r
+ // It must be a persisted float for fading out to work properly (you let go of the zoom button for\r
+ // the view to go back to normal, so reticle_type would become 0 as we fade out)\r
+ if(spectatee_status || getstati(STAT_HEALTH) <= 0)\r
+ reticle_type = 0; // prevent reticle from showing during the respawn zoom effect or for spectators\r
+ else if(activeweapon && (button_zoom || zoomscript_caught))\r
+ reticle_type = 2; // weapon zoom\r
+ else if(button_zoom || zoomscript_caught)\r
+ reticle_type = 1; // normal zoom\r
+\r
+ if (reticle_type)\r
+ {\r
+ if(cvar("cl_reticle_stretch"))\r
+ {\r
+ reticle_size_x = vid_conwidth;\r
+ reticle_size_y = vid_conheight;\r
+ reticle_pos_x = 0;\r
+ reticle_pos_y = 0;\r
+ }\r
+ else\r
+ {\r
+ reticle_size_x = max(vid_conwidth, vid_conheight);\r
+ reticle_size_y = max(vid_conwidth, vid_conheight);\r
+ reticle_pos_x = (vid_conwidth - reticle_size_x) / 2;\r
+ reticle_pos_y = (vid_conheight - reticle_size_y) / 2;\r
+ }\r
+\r
+ f = current_zoomfraction;\r
+ if(zoomscript_caught)\r
+ f = 1;\r
+ if(cvar("cl_reticle_item_normal"))\r
+ {\r
+ if(reticle_type == 1 && f)\r
+ drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * cvar("cl_reticle_item_normal"), DRAWFLAG_NORMAL);\r
+ }\r
+ if(cvar("cl_reticle_item_weapon"))\r
+ {\r
+ if(reticle_type == 2 && f)\r
+ drawpic(reticle_pos, "gfx/reticle_weapon", reticle_size, '1 1 1', f * cvar("cl_reticle_item_weapon"), DRAWFLAG_NORMAL);\r
+ }\r
+ }\r
+\r
+ // screen effects\r
+ if(cvar("hud_contents"))\r
+ {\r
+ float contentalpha_temp, incontent, liquidalpha, contentfadetime;\r
+ vector liquidcolor;\r
+\r
+ if (getstati(STAT_VORE_EATEN))\r
+ {\r
+ liquidalpha = cvar("hud_contents_stomach_alpha");\r
+ liquidcolor = stov(cvar_string("hud_contents_stomach_color"));\r
+ incontent = 1;\r
+ }\r
+ else\r
+ {\r
+ switch(pointcontents(view_origin))\r
+ {\r
+ case CONTENT_WATER:\r
+ liquidalpha = cvar("hud_contents_water_alpha");\r
+ liquidcolor = stov(cvar_string("hud_contents_water_color"));\r
+ incontent = 1;\r
+ break;\r
+ \r
+ case CONTENT_LAVA:\r
+ liquidalpha = cvar("hud_contents_lava_alpha");\r
+ liquidcolor = stov(cvar_string("hud_contents_lava_color"));\r
+ incontent = 1;\r
+ break; \r
+ \r
+ case CONTENT_SLIME:\r
+ liquidalpha = cvar("hud_contents_slime_alpha");\r
+ liquidcolor = stov(cvar_string("hud_contents_slime_color"));\r
+ incontent = 1;\r
+ break;\r
+ \r
+ default:\r
+ liquidalpha = 0;\r
+ liquidcolor = '0 0 0';\r
+ incontent = 0;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ 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
+ { // also lets delcare previous values for blending properties, this way it isn't reset until after you have entered a different content\r
+ contentfadetime = cvar("hud_contents_fadeintime");\r
+ liquidalpha_prev = liquidalpha;\r
+ liquidcolor_prev = liquidcolor;\r
+ }\r
+ else\r
+ contentfadetime = cvar("hud_contents_fadeouttime");\r
+ \r
+ contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1);\r
+ contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp;\r
+\r
+ if(contentavgalpha)\r
+ drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL);\r
+\r
+ if(cvar("hud_postprocessing"))\r
+ {\r
+ if(cvar("hud_contents_liquid_blur") && contentavgalpha)\r
+ {\r
+ // when inside the stomach, we use different blur settings than when we're inside other fluids\r
+ content_blurpostprocess_x = 1;\r
+ if(getstati(STAT_VORE_EATEN))\r
+ {\r
+ content_blurpostprocess_y = contentavgalpha * cvar("hud_contents_stomach_blur");\r
+ content_blurpostprocess_z = contentavgalpha * cvar("hud_contents_stomach_blur_alpha");\r
+ }\r
+ else\r
+ {\r
+ content_blurpostprocess_y = contentavgalpha * cvar("hud_contents_liquid_blur");\r
+ content_blurpostprocess_z = contentavgalpha * cvar("hud_contents_liquid_blur_alpha");\r
+ }\r
+ }\r
+ else\r
+ {\r
+ content_blurpostprocess_x = 0;\r
+ content_blurpostprocess_y = 0;\r
+ content_blurpostprocess_z = 0;\r
+ }\r
+ }\r
+ }\r
+\r
+ if(cvar("hud_damage"))\r
+ {\r
+ splash_size_x = max(vid_conwidth, vid_conheight);\r
+ splash_size_y = max(vid_conwidth, vid_conheight);\r
+ splash_pos_x = (vid_conwidth - splash_size_x) / 2;\r
+ splash_pos_y = (vid_conheight - splash_size_y) / 2;\r
+\r
+ float myhealth_flash_temp;\r
+ myhealth = getstati(STAT_HEALTH);\r
+\r
+ // fade out\r
+ myhealth_flash = max(0, myhealth_flash - cvar("hud_damage_fade_rate") * frametime);\r
+ // add new damage\r
+ myhealth_flash = bound(0, myhealth_flash + dmg_take * cvar("hud_damage_factor"), cvar("hud_damage_maxalpha"));\r
+\r
+ float pain_threshold, pain_threshold_lower, pain_threshold_lower_health;\r
+ pain_threshold = cvar("hud_damage_pain_threshold");\r
+ pain_threshold_lower = cvar("hud_damage_pain_threshold_lower");\r
+ pain_threshold_lower_health = cvar("hud_damage_pain_threshold_lower_health");\r
+\r
+ if(pain_threshold_lower && myhealth < pain_threshold_lower_health)\r
+ {\r
+ 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
+ }\r
+\r
+ myhealth_flash_temp = bound(0, myhealth_flash - pain_threshold, 1);\r
+\r
+ if(myhealth_prev < 1)\r
+ {\r
+ if(myhealth >= 1)\r
+ {\r
+ myhealth_flash = 0; // just spawned, clear the flash immediately\r
+ myhealth_flash_temp = 0;\r
+ }\r
+ else\r
+ {\r
+ myhealth_flash += cvar("hud_damage_fade_rate") * frametime; // dead\r
+ }\r
+ }\r
+\r
+ if(spectatee_status == -1 || intermission)\r
+ {\r
+ myhealth_flash = 0; // observing, or match ended\r
+ myhealth_flash_temp = 0;\r
+ }\r
+\r
+ myhealth_prev = myhealth;\r
+\r
+ if(cvar("cl_gentle_damage") || cvar("cl_gentle"))\r
+ {\r
+ if(cvar("cl_gentle_damage") == 2)\r
+ {\r
+ if(myhealth_flash < pain_threshold) // only randomize when the flash is gone\r
+ {\r
+ myhealth_gentlergb = '1 0 0' * random() + '0 1 0' * random() + '0 0 1' * random();\r
+ }\r
+ }\r
+ else\r
+ myhealth_gentlergb = stov(cvar_string("hud_damage_gentle_color"));\r
+\r
+ 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
+ }\r
+ else\r
+ 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
+\r
+ if(cvar("hud_postprocessing"))\r
+ {\r
+ if(cvar("hud_damage_blur") && myhealth_flash_temp)\r
+ {\r
+ damage_blurpostprocess_x = 1;\r
+ damage_blurpostprocess_y = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur");\r
+ damage_blurpostprocess_z = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur_alpha");\r
+ }\r
+ else\r
+ {\r
+ damage_blurpostprocess_x = 0;\r
+ damage_blurpostprocess_y = 0;\r
+ damage_blurpostprocess_z = 0;\r
+ }\r
+ }\r
+ }\r
+\r
+ if(cvar("hud_stomach"))\r
+ {\r
+ if(getstati(STAT_VORE_EATEN))\r
+ {\r
+ if(stomachsplash_alpha < cvar("hud_stomach"))\r
+ stomachsplash_alpha += cvar("hud_stomach_fade_in") * frametime;\r
+ else\r
+ stomachsplash_alpha = cvar("hud_stomach");\r
+ }\r
+ else if(getstati(STAT_HEALTH) > 0)\r
+ {\r
+ if(stomachsplash_alpha > 0)\r
+ stomachsplash_alpha -= cvar("hud_stomach_fade_out") * frametime;\r
+ else\r
+ stomachsplash_alpha = 0;\r
+ }\r
+ if(getstati(STAT_HEALTH) <= 0)\r
+ stomachsplash_remove_at_respawn = 1; // schedule the effect to be removed next respawn\r
+\r
+ if(getstati(STAT_HEALTH) > 0 && stomachsplash_remove_at_respawn)\r
+ stomachsplash_alpha = stomachsplash_remove_at_respawn = 0; // we respawned, remove the effect\r
+ if(spectatee_status == -1)\r
+ stomachsplash_alpha = 0;\r
+\r
+ stomachsplash_alpha = bound(0, stomachsplash_alpha, 1);\r
+ drawpic(splash_pos, "gfx/food", splash_size, stov(cvar_string("hud_stomach_color")), stomachsplash_alpha, DRAWFLAG_NORMAL);\r
+ }\r
+\r
+ if(cvar("hud_postprocessing"))\r
+ {\r
+ // all of this should be done in the engine eventually\r
+\r
+ // disable damage blur when dead, but keep content blur\r
+ if(getstati(STAT_HEALTH) <= 0)\r
+ damage_blurpostprocess = '0 0 0';\r
+\r
+ // enable or disable rendering types if they are used or not\r
+ if(cvar("r_glsl_postprocess_uservec1_enable") != (cvar("hud_postprocessing_maxbluralpha") != 0))\r
+ cvar_set("r_glsl_postprocess_uservec1_enable", ftos(cvar("hud_postprocessing_maxbluralpha") != 0));\r
+ if(cvar("r_glsl_postprocess_uservec2_enable") != (cvar("hud_powerup") != 0))\r
+ cvar_set("r_glsl_postprocess_uservec2_enable", ftos(cvar("hud_powerup") != 0));\r
+\r
+ // lets apply the postprocess effects from the previous two functions if needed\r
+ if((damage_blurpostprocess_x || content_blurpostprocess_x) && cvar("chase_active") >= 0) // not while the event chase camera is active\r
+ {\r
+ float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, cvar("hud_postprocessing_maxblurradius"));\r
+ float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, cvar("hud_postprocessing_maxbluralpha"));\r
+ if(blurradius != old_blurradius || bluralpha != old_bluralpha) // reduce cvar_set spam as much as possible\r
+ {\r
+ cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0"));\r
+ old_blurradius = blurradius;\r
+ old_bluralpha = bluralpha;\r
+ }\r
+ }\r
+ else if(cvar_string("r_glsl_postprocess_uservec1") != "0 0 0 0") // reduce cvar_set spam as much as possible\r
+ {\r
+ cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");\r
+ old_blurradius = 0;\r
+ old_bluralpha = 0;\r
+ }\r
+\r
+ float sharpen_intensity;\r
+ if (getstatf(STAT_STRENGTH_FINISHED) - time > 0)\r
+ sharpen_intensity += (getstatf(STAT_STRENGTH_FINISHED) - time);\r
+ if (getstatf(STAT_INVINCIBLE_FINISHED) - time > 0)\r
+ sharpen_intensity += (getstatf(STAT_INVINCIBLE_FINISHED) - time);\r
+\r
+ if(cvar("hud_powerup") && sharpen_intensity > 0 && cvar("chase_active") >= 0) // not while the event chase camera is active\r
+ {\r
+ sharpen_intensity = bound(0, sharpen_intensity, 5); // powerup warning time is 5 seconds, so fade the effect from there\r
+\r
+ if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible\r
+ {\r
+ cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(-sharpen_intensity * cvar("hud_powerup")), " 0 0"));\r
+ old_sharpen_intensity = sharpen_intensity;\r
+ }\r
+ }\r
+ else if(cvar_string("r_glsl_postprocess_uservec2") != "0 0 0 0") // reduce cvar_set spam as much as possible\r
+ {\r
+ cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");\r
+ old_sharpen_intensity = 0;\r
+ }\r
+ }\r
+\r
+ if(cvar("hud_postprocessing") && !cvar("hud_postprocessing_maxbluralpha"))\r
+ if(cvar("r_glsl_postprocess_uservec1_enable"))\r
+ {\r
+ // don't allow blur to get stuck on if we disable the cvar while damaged\r
+ cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");\r
+ cvar_set("r_glsl_postprocess_uservec1_enable", "0");\r
+ }\r
+ if(cvar("hud_postprocessing") && !cvar("hud_powerup"))\r
+ if(cvar("r_glsl_postprocess_uservec2_enable"))\r
+ {\r
+ // don't allow sharpen to get stuck on if we disable the cvar while powered up\r
+ cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");\r
+ cvar_set("r_glsl_postprocess_uservec2_enable", "0");\r
+ }\r
+\r
+ if(cvar("hud_postprocessing"))\r
+ {\r
+ // change saturation based on the amount of armor we have\r
+ // ranges between 0.5 and 1 saturation, over 0 armor and half the armor limit\r
+\r
+ if(cvar("hud_saturation") && armor_max && spectatee_status != -1 && getstati(STAT_HEALTH) > 0)\r
+ {\r
+ float saturation;\r
+ saturation = 0.5 + (getstati(STAT_ARMOR) / armor_max);\r
+ saturation = bound(0, saturation, 1);\r
+\r
+ if(cvar("r_glsl_saturation") != saturation)\r
+ cvar_set("r_glsl_saturation", ftos(saturation));\r
+ }\r
+ else if(cvar("r_glsl_saturation") != 1)\r
+ cvar_set("r_glsl_saturation", "1");\r
+ }\r
+\r
+ // volume cutting\r
+ if(cvar("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1)\r
+ {\r
+ float volume_modify_1_target, volume_modify_2_target, volume_modify_fade;\r
+\r
+ if(volume_modify_changed_1 != cvar("menu_volume") || volume_modify_changed_2 != cvar("menu_bgmvolume"))\r
+ {\r
+ // An ugly hack to allow the cutvolume feature to work with the menu audio sliders.\r
+ // Without it, adjusting the music or master sound sliders while fading that volume would have bad results.\r
+ // This needs to be done in a better way! Currently, changing the volume sliders will just reset the fading.\r
+\r
+ volume_modify_default_1 = cvar("menu_volume");\r
+ volume_modify_default_2 = cvar("menu_bgmvolume");\r
+\r
+ volume_modify_changed_1 = cvar("menu_volume");\r
+ volume_modify_changed_2 = cvar("menu_bgmvolume");\r
+ }\r
+ else\r
+ {\r
+ if(spectatee_status == -1 || intermission)\r
+ {\r
+ volume_modify_1_target = volume_modify_default_1;\r
+ volume_modify_2_target = volume_modify_default_2;\r
+ }\r
+ else if(getstati(STAT_VORE_EATEN))\r
+ {\r
+ volume_modify_1_target = volume_modify_default_1 * cvar("cl_vore_cutvolume_sound");\r
+ volume_modify_2_target = volume_modify_default_2 * cvar("cl_vore_cutvolume_music");\r
+ }\r
+ else\r
+ {\r
+ volume_modify_1_target = volume_modify_default_1;\r
+ volume_modify_2_target = volume_modify_default_2;\r
+ }\r
+ volume_modify_fade = cvar("cl_vore_cutvolume_fade") * frametime;\r
+\r
+ if(volume_modify_1 != volume_modify_1_target || volume_modify_2 != volume_modify_2_target)\r
+ {\r
+ if (volume_modify_1 > volume_modify_1_target + volume_modify_fade)\r
+ volume_modify_1 -= volume_modify_fade;\r
+ else if (volume_modify_1 < volume_modify_1_target - volume_modify_fade)\r
+ volume_modify_1 += volume_modify_fade;\r
+ else\r
+ volume_modify_1 = volume_modify_1_target;\r
+\r
+ if (volume_modify_2 > volume_modify_2_target + volume_modify_fade)\r
+ volume_modify_2 -= volume_modify_fade;\r
+ else if (volume_modify_2 < volume_modify_2_target - volume_modify_fade)\r
+ volume_modify_2 += volume_modify_fade;\r
+ else\r
+ volume_modify_2 = volume_modify_2_target;\r
+\r
+ cvar_set("volume", ftos(volume_modify_1));\r
+ cvar_set("bgmvolume", ftos(volume_modify_2));\r
+ // TODO: Setting the "volume" cvar is a bad way to go, and modifies the menu slider! We need a better way\r
+ }\r
+ }\r
+ }\r
+\r