]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/View.qc
Respawn screen flash
[voretournament/voretournament.git] / data / qcsrc / client / View.qc
index 7bf9b48af180224946f1099e8bb1347350368825..bf89e9a4257dfd24a8333f995bbf25ea87e49747 100644 (file)
@@ -253,13 +253,14 @@ float camera_mode;
 float reticle_type;\r
 float chase_active_old;\r
 float artwork_fade;\r
-float pickup_crosshair_time, pickup_crosshair_size;\r
+float pickup_crosshair_time, pickup_crosshair_size, pickup_flash_time, vore_flash_laststate, respawn_flash_lasthealth;\r
 float myhealth, myhealth_prev, myhealth_flash;\r
 float contentavgalpha, liquidalpha_prev;\r
 float old_blurradius, old_bluralpha, old_sharpen_intensity;\r
 float stomachsplash_alpha, stomachsplash_remove_at_respawn;\r
 float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2;\r
 float volume_modify_changed_1, volume_modify_changed_2;\r
+float eventchase_current_distance;\r
 vector myhealth_gentlergb;\r
 vector liquidcolor_prev;\r
 vector damage_blurpostprocess, content_blurpostprocess;\r
@@ -275,6 +276,7 @@ void CSQC_UpdateView(float w, float h)
        float a;\r
 \r
        vector reticle_pos, reticle_size;\r
+       vector splash_pos, splash_size;\r
        vector artwork_pos, artwork_size;\r
 \r
        WaypointSprite_Load();\r
@@ -293,6 +295,42 @@ void CSQC_UpdateView(float w, float h)
        pmove_org = warpzone_fixview_origin - vo;\r
        input_angles = warpzone_fixview_angles;\r
 \r
+       // event chase camera\r
+       if(cvar("chase_active") <= 0) // greater than 0 means it's enabled manually, and this code is skipped\r
+       {\r
+               if(!getstati(STAT_VORE_EATEN) && spectatee_status >= 0 && (cvar("cl_eventchase_death") && getstati(STAT_HEALTH) <= 0 && !intermission))\r
+               {\r
+                       // We must enable chase_active to get a third person view (weapon viewmodel hidden and own player model showing).\r
+                       // Ideally, there should be another way to enable third person cameras, such as through R_SetView()\r
+                       if(!cvar("chase_active"))\r
+                               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)\r
+\r
+                       // make the camera smooth back\r
+                       if(cvar("cl_eventchase_speed") && eventchase_current_distance < cvar("cl_eventchase_distance"))\r
+                               eventchase_current_distance += cvar("cl_eventchase_speed") * (cvar("cl_eventchase_distance") - eventchase_current_distance) * frametime; // slow down the further we get\r
+                       else if(eventchase_current_distance != cvar("cl_eventchase_distance"))\r
+                               eventchase_current_distance = cvar("cl_eventchase_distance");\r
+\r
+                       vector eventchase_target_origin;\r
+                       makevectors(view_angles);\r
+                       // pass 1, used to check where the camera would go and obtain the trace_fraction\r
+                       eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance;\r
+\r
+                       traceline(pmove_org, eventchase_target_origin, MOVE_WORLDONLY, self);\r
+                       // pass 2, also multiplying view_forward with trace_fraction, to prevent the camera from going through walls\r
+                       // The 0.1 subtraction is to not limit the camera precisely at the wall surface, as that allows the view to poke through\r
+                       eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance * (trace_fraction - 0.1);\r
+\r
+                       R_SetView(VF_ORIGIN, eventchase_target_origin);\r
+                       R_SetView(VF_ANGLES, view_angles);\r
+               }\r
+               else if(cvar("chase_active") < 0) // time to disable chase_active if it was set by this code\r
+               {\r
+                       cvar_set("chase_active", "0");\r
+                       eventchase_current_distance = 0; // start from 0 next time\r
+               }\r
+       }\r
+\r
        // Render the Scene\r
        if(!intermission || !view_set)\r
        {\r
@@ -474,35 +512,36 @@ void CSQC_UpdateView(float w, float h)
        else if(button_zoom || zoomscript_caught)\r
                reticle_type = 1; // normal zoom\r
 \r
-       if(cvar("cl_reticle_stretch"))\r
+       if (reticle_type)\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
+               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
-               precache_pic("gfx/reticle_normal");\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
-               precache_pic("gfx/reticle_weapon");\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
+               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
@@ -558,7 +597,7 @@ void CSQC_UpdateView(float w, float h)
                        \r
                contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1);\r
                contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp;\r
-               \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
@@ -590,6 +629,11 @@ void CSQC_UpdateView(float w, float h)
 \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
@@ -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);\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
+                       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
@@ -690,54 +734,63 @@ void CSQC_UpdateView(float w, float h)
                        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
+               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)\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
-                               cvar_set("r_glsl_postprocess_uservec1_enable", "1");\r
                                old_blurradius = blurradius;\r
                                old_bluralpha = bluralpha;\r
                        }\r
                }\r
-               else if(cvar("r_glsl_postprocess_uservec1_enable")) // reduce cvar_set spam as much as possible\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
-                       cvar_set("r_glsl_postprocess_uservec1_enable", "0");\r
+                       old_blurradius = 0;\r
+                       old_bluralpha = 0;\r
                }\r
 \r
-               if(cvar("hud_powerup"))\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
-                       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
-                               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
-                                       cvar_set("r_glsl_postprocess_uservec2_enable", "1");\r
-                                       old_sharpen_intensity = sharpen_intensity;\r
-                               }\r
-                       }\r
-                       else if(cvar("r_glsl_postprocess_uservec2_enable")) // reduce cvar_set spam as much as possible\r
+                       if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible\r
                        {\r
-                               cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");\r
-                               cvar_set("r_glsl_postprocess_uservec2_enable", "0");\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
@@ -755,6 +808,24 @@ void CSQC_UpdateView(float w, float h)
                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
@@ -836,6 +907,7 @@ void CSQC_UpdateView(float w, float h)
                if(self.draw2d)\r
                        self.draw2d();\r
        self = e;\r
+       Draw_ShowNames_All();\r
 \r
        // draw radar\r
        if(\r
@@ -961,6 +1033,38 @@ void CSQC_UpdateView(float w, float h)
                if(cvar("viewsize") < 120)\r
                        CSQC_common_hud();\r
 \r
+       if(cvar("cl_flash_pickup"))\r
+       if(pickup_flash_time < getstatf(STAT_LAST_PICKUP))\r
+       {\r
+               localcmd(strcat("bf ", cvar_string("cl_flash_pickup_color"), " ", cvar_string("cl_flash_pickup"), "\n"));\r
+               pickup_flash_time = getstatf(STAT_LAST_PICKUP);\r
+       }\r
+       if(cvar("cl_flash_vore"))\r
+       {\r
+               float vore_flash_state;\r
+               if(getstati(STAT_VORE_EATEN))\r
+                       vore_flash_state = -1;\r
+               else\r
+                       vore_flash_state = getstati(STAT_VORE_LOAD);\r
+\r
+               if(vore_flash_state > vore_flash_laststate && vore_flash_state > 0) // stomach load is bigger, so we ate someone\r
+                       localcmd(strcat("bf ", cvar_string("cl_flash_vore_color_pred"), " ", cvar_string("cl_flash_vore"), "\n"));\r
+               if(vore_flash_state < vore_flash_laststate && vore_flash_state < 0) // -1 means we have been eaten\r
+                       localcmd(strcat("bf ", cvar_string("cl_flash_vore_color_prey"), " ", cvar_string("cl_flash_vore"), "\n"));\r
+\r
+               vore_flash_laststate = vore_flash_state;\r
+       }\r
+       if(cvar("cl_flash_respawn"))\r
+       {\r
+               float respawn_flash_health;\r
+               respawn_flash_health = getstati(STAT_HEALTH);\r
+\r
+               if(respawn_flash_lasthealth <= 0 && respawn_flash_health > 0)\r
+                       localcmd(strcat("bf ", cvar_string("cl_flash_respawn_color"), " ", cvar_string("cl_flash_respawn"), "\n"));\r
+\r
+               respawn_flash_lasthealth = respawn_flash_health;\r
+       }\r
+\r
        if not(getstati(STAT_VORE_EATEN)) // crosshair is useless if we're in the stomach\r
        {\r
                // crosshair goes VERY LAST\r
@@ -996,6 +1100,8 @@ void CSQC_UpdateView(float w, float h)
                                wcross_style = "_canswallow_team.tga";\r
                        else if(swallow_indicator > 0)\r
                                wcross_style = "_canswallow.tga";\r
+                       else if(swallow_indicator < 0)\r
+                               wcross_style = "_canswallow_no.tga";\r
                        else\r
                                wcross_style = cvar_string("crosshair");\r
 \r
@@ -1192,7 +1298,7 @@ void CSQC_UpdateView(float w, float h)
                                CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f);\r
                                wcross_name_alpha_goal_prev = f;\r
 \r
-                               // ring around crosshair representing bullets left in weapon clip\r
+                               // ring around crosshair representing ammo left in weapon clip\r
                                weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);\r
                                a = cvar("crosshair_ring_alpha");\r
                                if (weapon_clipload && a)\r