]> git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/View.qc
Don't trigger the helper in many circumstances
[voretournament/voretournament.git] / data / qcsrc / client / View.qc
index ae594dc83637c42a7f4f903864ed6dd4945e756f..5d91a7ef6e9fe32f5dcbd243ea9e0e4707613fd1 100644 (file)
@@ -203,11 +203,6 @@ float TrueAimCheck()
        ta = trueaim;\r
        mv = MOVE_NOMONSTERS;\r
 \r
-       switch(activeweapon)\r
-       {\r
-               case WEP_GRABBER: // no trueaim\r
-       }\r
-\r
        vecs = decompressShotOrigin(getstati(STAT_SHOTORG));\r
 \r
        traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, mv, ta);\r
@@ -248,19 +243,22 @@ void CSQC_ctf_hud(void);
 void PostInit(void);\r
 void CSQC_Demo_Camera();\r
 float Sbar_WouldDrawScoreboard ();\r
+float last_health, last_spectatee;\r
 float view_set;\r
 float camera_mode;\r
 float reticle_type;\r
 float chase_active_old;\r
 float artwork_fade;\r
-float pickup_crosshair_time, pickup_crosshair_size, pickup_flash_time;\r
+float pickup_crosshair_time, pickup_crosshair_size, pickup_flash_time, vore_flash_laststate;\r
+float spawnfov_current;\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 stomachsplash_alpha;\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
+float helper_pause, helper_health;\r
 vector myhealth_gentlergb;\r
 vector liquidcolor_prev;\r
 vector damage_blurpostprocess, content_blurpostprocess;\r
@@ -274,6 +272,7 @@ void CSQC_UpdateView(float w, float h)
        float f, i, j;\r
        vector v, vo;\r
        float a;\r
+       float respawned;\r
 \r
        vector reticle_pos, reticle_size;\r
        vector splash_pos, splash_size;\r
@@ -295,6 +294,28 @@ void CSQC_UpdateView(float w, float h)
        pmove_org = warpzone_fixview_origin - vo;\r
        input_angles = warpzone_fixview_angles;\r
 \r
+       if((last_health <= 0 && getstati(STAT_HEALTH) > 0) || (!spectatee_status && last_spectatee)) // also cover switching from a spectator to a player instantly\r
+       if not(spectatee_status && last_spectatee != spectatee_status) // not if we switched players and that detects a different health\r
+               respawned = TRUE; // stays true for one frame\r
+\r
+       // helper system\r
+       if(cvar("cl_helper"))\r
+       if(helper_pause <= time)\r
+       if(!intermission && !respawned && spectatee_status >= 0 && getstati(STAT_HEALTH) > 0 && !getstati(STAT_VORE_EATEN))\r
+       {\r
+               if(getstati(STAT_HEALTH) <= cvar("cl_helper_health_value"))\r
+               {\r
+                       if(!helper_health)\r
+                       {\r
+                               sound(self, CHAN_VOICE, strcat("helper/", cvar_string("cl_helper_voice"), "/health_low.wav"), VOL_BASEVOICE, ATTN_NONE);\r
+                               helper_health = TRUE;\r
+                               helper_pause = time + cvar("cl_helper_pause");\r
+                       }\r
+               }\r
+               else if(helper_health)\r
+                       helper_health = FALSE;\r
+       }\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
@@ -440,6 +461,19 @@ void CSQC_UpdateView(float w, float h)
        vid_conheight = cvar("vid_conheight");\r
        vid_pixelheight = cvar("vid_pixelheight");\r
 \r
+       // spawn fov effect\r
+       if(cvar("cl_spawnfov"))\r
+       {\r
+               if(respawned)\r
+                       spawnfov_current = 1 + cvar("cl_spawnfov");\r
+\r
+               if(spawnfov_current > 1)\r
+                       spawnfov_current -= cvar("cl_spawnfov_speed") * frametime;\r
+               else\r
+                       spawnfov_current = 1;\r
+               fov *= spawnfov_current;\r
+       }\r
+\r
        R_SetView(VF_FOV, GetCurrentFov(fov));\r
 \r
        // Camera for demo playback\r
@@ -725,11 +759,9 @@ void CSQC_UpdateView(float w, float h)
                        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(respawned)\r
+                       stomachsplash_alpha = 0; // we respawned, remove the effect\r
                if(spectatee_status == -1)\r
                        stomachsplash_alpha = 0;\r
 \r
@@ -907,6 +939,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
@@ -1032,6 +1065,35 @@ 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 not(spectatee_status && last_spectatee != spectatee_status) // not if we switched players and that detects a different stomach 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
+\r
+               // always update the last vore state, or the flash can be triggered when switching spectated players one frame after\r
+               vore_flash_laststate = vore_flash_state;\r
+       }\r
+       if(cvar("cl_flash_respawn"))\r
+       if(respawned)\r
+               localcmd(strcat("bf ", cvar_string("cl_flash_respawn_color"), " ", cvar_string("cl_flash_respawn"), "\n"));\r
+\r
        if not(getstati(STAT_VORE_EATEN)) // crosshair is useless if we're in the stomach\r
        {\r
                // crosshair goes VERY LAST\r
@@ -1070,7 +1132,15 @@ void CSQC_UpdateView(float w, float h)
                        else if(swallow_indicator < 0)\r
                                wcross_style = "_canswallow_no.tga";\r
                        else\r
-                               wcross_style = cvar_string("crosshair");\r
+                       {\r
+                               // normal crosshair, based on what weapon we have and what firing type we can use\r
+                               if(!activeweapon)\r
+                                       wcross_style = cvar_string("crosshair");\r
+                               else if(getstati(STAT_CROSSHAIR_STYLE))\r
+                                       wcross_style = cvar_string("crosshair_secondary");\r
+                               else\r
+                                       wcross_style = cvar_string("crosshair_primary");\r
+                       }\r
 \r
                        if (wcross_style != "0") {\r
                                vector wcross_color, wcross_size;\r
@@ -1175,13 +1245,6 @@ void CSQC_UpdateView(float w, float h)
                                        wcross_scale += sin(pickup_crosshair_size) * cvar("crosshair_pickup");\r
                                }\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
-\r
                                if(shottype == SHOTTYPE_HITENEMY)\r
                                        wcross_scale *= cvar("crosshair_hittest"); // is not queried if hittest is 0\r
                                if(shottype == SHOTTYPE_HITTEAM)\r
@@ -1351,6 +1414,10 @@ void CSQC_UpdateView(float w, float h)
                localcmd("sendcvar chase_active\n");\r
                chase_active_old = cvar("chase_active");\r
        }\r
+\r
+       // update some stats to be detected next frame\r
+       last_health = getstati(STAT_HEALTH);\r
+       last_spectatee = spectatee_status;\r
 }\r
 \r
 void Sbar_Draw();\r