Tweak the system for detecting respawns in View.qc
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 13 Jul 2011 14:17:53 +0000 (17:17 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 13 Jul 2011 14:17:53 +0000 (17:17 +0300)
data/qcsrc/client/View.qc

index bf89e9a..3507b27 100644 (file)
@@ -248,16 +248,17 @@ 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, vore_flash_laststate, respawn_flash_lasthealth;\r
+float pickup_crosshair_time, pickup_crosshair_size, pickup_flash_time, vore_flash_laststate;\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
@@ -274,6 +275,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 +297,10 @@ 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)\r
+       if not(spectatee_status > 0 && 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
        // event chase camera\r
        if(cvar("chase_active") <= 0) // greater than 0 means it's enabled manually, and this code is skipped\r
        {\r
@@ -725,11 +731,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
@@ -1040,6 +1044,8 @@ void CSQC_UpdateView(float w, float h)
                pickup_flash_time = getstatf(STAT_LAST_PICKUP);\r
        }\r
        if(cvar("cl_flash_vore"))\r
+       if(!respawned) // guards against a bug\r
+       if not(spectatee_status > 0 && last_spectatee != spectatee_status) // not if we switched players and that detects a different stomach load\r
        {\r
                float vore_flash_state;\r
                if(getstati(STAT_VORE_EATEN))\r
@@ -1055,15 +1061,8 @@ void CSQC_UpdateView(float w, float h)
                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
+       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
@@ -1377,6 +1376,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