]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cl_deathfade: new effect which makes the screen fade to dark red when you die......
authorsamual <samual@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 13 Sep 2009 06:24:07 +0000 (06:24 +0000)
committersamual <samual@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 13 Sep 2009 06:24:07 +0000 (06:24 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9187 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
client.h
render.h
view.c

index 0cb016a842b007468bba7595d6df6149184da3ee..108701a79fba11b664e333f051253397feae706d 100644 (file)
--- 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);
index 60e76f43c2f52c3e31b22d16d809ebc3c368ad08..a8ed83445c08dd29603e9bc582a08e42b02841bb 100644 (file)
--- 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;
index 7bf72d7cae249ef28e59ab91bf56ca9a7031b052..d01a87093f19d3c43a747119ded5341466e45147 100644 (file)
--- 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 72d812bb1bf9752fbf2f511862ee9fb4df15d7c4..6f99af586487441c75dcd8bf43cb27f2d6fb453e 100644 (file)
--- 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);
+               }
        }
 }