]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/View.qc
Correct check on the cutsound cvars
[voretournament/voretournament.git] / data / qcsrc / client / View.qc
index 37090311ca38342258b94c9451e20733d5f00eb9..37926193de12c2cd1d3dfe33b0c19105096cbef5 100644 (file)
@@ -253,8 +253,13 @@ float camera_mode;
 float chase_active_old;\r
 float artwork_fade;\r
 float pickup_crosshair_time, pickup_crosshair_size;\r
+float myhealth, myhealth_prev, myhealth_flash;\r
 float contentavgalpha, liquidalpha_prev;\r
+float stomachsplash_alpha, stomachsplash_remove_at_respawn;\r
+float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2, volume_modify_default_set;\r
+vector myhealth_gentlergb;\r
 vector liquidcolor_prev;\r
+vector damage_blurpostprocess, content_blurpostprocess;\r
 string artwork_image;\r
 string intermission_song;\r
 string NextFrameCommand;\r
@@ -457,32 +462,41 @@ void CSQC_UpdateView(float w, float h)
        {\r
                float contentalpha_temp, incontent, liquidalpha, contentfadetime;\r
                vector liquidcolor;\r
-               \r
-               switch(pointcontents(view_origin))\r
+\r
+               if (getstati(STAT_VORE_EATEN))\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
+                       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
@@ -499,6 +513,224 @@ void CSQC_UpdateView(float w, float h)
                \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_blur"))\r
+                       {\r
+                               content_blurpostprocess_x = 1;\r
+                               content_blurpostprocess_y = contentavgalpha * cvar("hud_contents_blur");\r
+                               content_blurpostprocess_z = contentavgalpha * cvar("hud_contents_blur_alpha");\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
+               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('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);\r
+\r
+               if(cvar("hud_postprocessing"))\r
+               {\r
+                       if(cvar("hud_damage_blur"))\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('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);\r
+       }\r
+\r
+       if(cvar("hud_postprocessing"))\r
+       {\r
+               // lets apply the postprocess effects from the previous two functions if needed\r
+               if(damage_blurpostprocess_x || content_blurpostprocess_x)\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
+                       cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0"));\r
+                       cvar_set("r_glsl_postprocess_uservec1_enable", "1");\r
+               }\r
+               else\r
+               {\r
+                       cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");\r
+                       cvar_set("r_glsl_postprocess_uservec1_enable", "0");\r
+               }\r
+\r
+               if(cvar("hud_powerup"))\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
+                       sharpen_intensity = bound(0, sharpen_intensity, 5); // powerup warning time is 5 seconds, so fade the effect from there\r
+\r
+                       if(sharpen_intensity > 0)\r
+                       {\r
+                               cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(-sharpen_intensity * cvar("hud_powerup")), " 0 0"));\r
+                               cvar_set("r_glsl_postprocess_uservec2_enable", "1");\r
+                       }\r
+                       else\r
+                       {\r
+                               cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");\r
+                               cvar_set("r_glsl_postprocess_uservec2_enable", "0");\r
+                       }\r
+               }\r
+       }\r
+\r
+       if not(cvar("hud_damage") && cvar("hud_postprocessing"))\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 not(cvar("hud_powerup") && cvar("hud_postprocessing"))\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("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1)\r
+       {\r
+               if(!volume_modify_default_set)\r
+               {\r
+                       // set the initial volume\r
+                       volume_modify_default_1 = cvar("volume");\r
+                       volume_modify_default_2 = cvar("bgmvolume");\r
+                       volume_modify_default_set = TRUE;\r
+               }\r
+               if(spectatee_status == -1 || intermission)\r
+                       volume_modify_1 = volume_modify_2 = 1;\r
+               else if (getstati(STAT_VORE_EATEN))\r
+               {\r
+                       if (volume_modify_1 > cvar("cl_vore_cutvolume_sound"))\r
+                       {\r
+                               volume_modify_1 -= cvar("cl_vore_cutvolume_fade") * frametime;\r
+                               if(volume_modify_1 < cvar("cl_vore_cutvolume_sound"))\r
+                                       volume_modify_1 = cvar("cl_vore_cutvolume_sound");\r
+                       }\r
+                       if (volume_modify_2 > cvar("cl_vore_cutvolume_music"))\r
+                       {\r
+                               volume_modify_2 -= cvar("cl_vore_cutvolume_fade") * frametime;\r
+                               if(volume_modify_2 < cvar("cl_vore_cutvolume_music"))\r
+                                       volume_modify_2 = cvar("cl_vore_cutvolume_music");\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       if (volume_modify_1 < 1)\r
+                       {\r
+                               volume_modify_1 += cvar("cl_vore_cutvolume_fade") * frametime;\r
+                               if(volume_modify_1 > 1)\r
+                                       volume_modify_1 = 1;\r
+                       }\r
+                       if (volume_modify_2 < 1)\r
+                       {\r
+                               volume_modify_2 += cvar("cl_vore_cutvolume_fade") * frametime;\r
+                               if(volume_modify_2 > 1)\r
+                                       volume_modify_2 = 1;\r
+                       }\r
+               }\r
+               cvar_set("volume", ftos(volume_modify_default_1 * volume_modify_1));\r
+               cvar_set("bgmvolume", ftos(volume_modify_default_2 * 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 to go\r
        }\r
 \r
        // Draw the mouse cursor\r