From: MirceaKitsune Date: Wed, 13 Jul 2011 14:17:53 +0000 (+0300) Subject: Tweak the system for detecting respawns in View.qc X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7dc56bab78764c07a2f690dfcdd626de3ad4c22c;p=voretournament%2Fvoretournament.git Tweak the system for detecting respawns in View.qc --- diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index bf89e9a4..3507b274 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -248,16 +248,17 @@ void CSQC_ctf_hud(void); void PostInit(void); void CSQC_Demo_Camera(); float Sbar_WouldDrawScoreboard (); +float last_health, last_spectatee; float view_set; float camera_mode; float reticle_type; float chase_active_old; float artwork_fade; -float pickup_crosshair_time, pickup_crosshair_size, pickup_flash_time, vore_flash_laststate, respawn_flash_lasthealth; +float pickup_crosshair_time, pickup_crosshair_size, pickup_flash_time, vore_flash_laststate; float myhealth, myhealth_prev, myhealth_flash; float contentavgalpha, liquidalpha_prev; float old_blurradius, old_bluralpha, old_sharpen_intensity; -float stomachsplash_alpha, stomachsplash_remove_at_respawn; +float stomachsplash_alpha; float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2; float volume_modify_changed_1, volume_modify_changed_2; float eventchase_current_distance; @@ -274,6 +275,7 @@ void CSQC_UpdateView(float w, float h) float f, i, j; vector v, vo; float a; + float respawned; vector reticle_pos, reticle_size; vector splash_pos, splash_size; @@ -295,6 +297,10 @@ void CSQC_UpdateView(float w, float h) pmove_org = warpzone_fixview_origin - vo; input_angles = warpzone_fixview_angles; + if(last_health <= 0 && getstati(STAT_HEALTH) > 0) + if not(spectatee_status > 0 && last_spectatee != spectatee_status) // not if we switched players and that detects a different health + respawned = TRUE; // stays true for one frame + // event chase camera if(cvar("chase_active") <= 0) // greater than 0 means it's enabled manually, and this code is skipped { @@ -725,11 +731,9 @@ void CSQC_UpdateView(float w, float h) else stomachsplash_alpha = 0; } - if(getstati(STAT_HEALTH) <= 0) - stomachsplash_remove_at_respawn = 1; // schedule the effect to be removed next respawn - if(getstati(STAT_HEALTH) > 0 && stomachsplash_remove_at_respawn) - stomachsplash_alpha = stomachsplash_remove_at_respawn = 0; // we respawned, remove the effect + if(respawned) + stomachsplash_alpha = 0; // we respawned, remove the effect if(spectatee_status == -1) stomachsplash_alpha = 0; @@ -1040,6 +1044,8 @@ void CSQC_UpdateView(float w, float h) pickup_flash_time = getstatf(STAT_LAST_PICKUP); } if(cvar("cl_flash_vore")) + if(!respawned) // guards against a bug + if not(spectatee_status > 0 && last_spectatee != spectatee_status) // not if we switched players and that detects a different stomach load { float vore_flash_state; if(getstati(STAT_VORE_EATEN)) @@ -1055,15 +1061,8 @@ void CSQC_UpdateView(float w, float h) vore_flash_laststate = vore_flash_state; } if(cvar("cl_flash_respawn")) - { - float respawn_flash_health; - respawn_flash_health = getstati(STAT_HEALTH); - - if(respawn_flash_lasthealth <= 0 && respawn_flash_health > 0) - localcmd(strcat("bf ", cvar_string("cl_flash_respawn_color"), " ", cvar_string("cl_flash_respawn"), "\n")); - - respawn_flash_lasthealth = respawn_flash_health; - } + if(respawned) + localcmd(strcat("bf ", cvar_string("cl_flash_respawn_color"), " ", cvar_string("cl_flash_respawn"), "\n")); if not(getstati(STAT_VORE_EATEN)) // crosshair is useless if we're in the stomach { @@ -1377,6 +1376,10 @@ void CSQC_UpdateView(float w, float h) localcmd("sendcvar chase_active\n"); chase_active_old = cvar("chase_active"); } + + // update some stats to be detected next frame + last_health = getstati(STAT_HEALTH); + last_spectatee = spectatee_status; } void Sbar_Draw();