From cf7140c9799cb2d2f40f6dbfd6abeb9694645ad5 Mon Sep 17 00:00:00 2001 From: samual Date: Sun, 13 Sep 2009 06:24:07 +0000 Subject: [PATCH] cl_deathfade: new effect which makes the screen fade to dark red when you die... disabled by default git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9187 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 3 +++ client.h | 3 +++ render.h | 2 ++ view.c | 24 +++++++++++++++++++----- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/cl_main.c b/cl_main.c index 0cb016a8..108701a7 100644 --- a/cl_main.c +++ b/cl_main.c @@ -72,6 +72,8 @@ cvar_t cl_beams_quakepositionhack = {CVAR_SAVE, "cl_beams_quakepositionhack", "1 cvar_t cl_beams_instantaimhack = {CVAR_SAVE, "cl_beams_instantaimhack", "0", "makes your lightning gun aiming update instantly"}; cvar_t cl_beams_lightatend = {CVAR_SAVE, "cl_beams_lightatend", "0", "make a light at the end of the beam"}; +cvar_t cl_deathfade = {CVAR_SAVE, "cl_deathfade", "0", "fade screen to dark red when dead, value = how fast the fade is"}; + cvar_t cl_noplayershadow = {CVAR_SAVE, "cl_noplayershadow", "0","hide player shadow"}; cvar_t cl_dlights_decayradius = {CVAR_SAVE, "cl_dlights_decayradius", "1", "reduces size of light flashes over time"}; @@ -2238,6 +2240,7 @@ void CL_Init (void) Cvar_RegisterVariable (&cl_anglespeedkey); Cvar_RegisterVariable (&cl_shownet); Cvar_RegisterVariable (&cl_nolerp); + Cvar_RegisterVariable (&cl_deathfade); Cvar_RegisterVariable (&lookspring); Cvar_RegisterVariable (&lookstrafe); Cvar_RegisterVariable (&sensitivity); diff --git a/client.h b/client.h index 60e76f43..a8ed8344 100644 --- a/client.h +++ b/client.h @@ -889,6 +889,9 @@ typedef struct client_state_s // how long it has been since the previous client frame in real time // (not game time, for that use cl.time - cl.oldtime) double realframetime; + + // fade var for fading while dead + float deathfade; // copy of realtime from last recieved message, for net trouble icon float last_received_message; diff --git a/render.h b/render.h index 7bf72d7c..d01a8709 100644 --- a/render.h +++ b/render.h @@ -175,6 +175,8 @@ extern cvar_t r_glsl_deluxemapping; extern cvar_t gl_polyblend; extern cvar_t gl_dither; +extern cvar_t cl_deathfade; + extern cvar_t r_smoothnormals_areaweighting; extern cvar_t r_test; diff --git a/view.c b/view.c index 72d812bb..6f99af58 100644 --- a/view.c +++ b/view.c @@ -701,11 +701,25 @@ void V_CalcViewBlend(void) a2 = 1 / r_refdef.viewblend[3]; VectorScale(r_refdef.viewblend, a2, r_refdef.viewblend); } - - r_refdef.viewblend[0] = bound(0.0f, r_refdef.viewblend[0] * (1.0f/255.0f), 1.0f); - r_refdef.viewblend[1] = bound(0.0f, r_refdef.viewblend[1] * (1.0f/255.0f), 1.0f); - r_refdef.viewblend[2] = bound(0.0f, r_refdef.viewblend[2] * (1.0f/255.0f), 1.0f); - r_refdef.viewblend[3] = bound(0.0f, r_refdef.viewblend[3] * gl_polyblend.value, 1.0f); + // Samual: Ugly hack, I know. But it's the best we can do since + // there is no way to detect client states from the engine. + if (cl.stats[STAT_HEALTH] <= 0 && cl.stats[STAT_HEALTH] != -666 && + cl.stats[STAT_HEALTH] != -2342 && cl_deathfade.value > 0) + { + cl.deathfade += bound(0.0f, cl_deathfade.value, 2.0f) * max(0.0001, cl.time - cl.oldtime); + r_refdef.viewblend[0] = 0.3f; + r_refdef.viewblend[1] = 0.0f; + r_refdef.viewblend[2] = 0.0f; + r_refdef.viewblend[3] = bound(0.0f, cl.deathfade, 0.9f); + } + else + { + cl.deathfade = 0.0f; + r_refdef.viewblend[0] = bound(0.0f, r_refdef.viewblend[0] * (1.0f/255.0f), 1.0f); + r_refdef.viewblend[1] = bound(0.0f, r_refdef.viewblend[1] * (1.0f/255.0f), 1.0f); + r_refdef.viewblend[2] = bound(0.0f, r_refdef.viewblend[2] * (1.0f/255.0f), 1.0f); + r_refdef.viewblend[3] = bound(0.0f, r_refdef.viewblend[3] * gl_polyblend.value, 1.0f); + } } } -- 2.39.2