]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Darkness nade: fade darkness in and out
authorterencehill <piuntn@gmail.com>
Wed, 12 Jul 2023 22:40:48 +0000 (00:40 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 12 Jul 2023 22:40:48 +0000 (00:40 +0200)
qcsrc/common/mutators/mutator/nades/nades.qc

index 3ee6020cfb53c7a989b2c24fcb7f0920f282e684..9bd55333746a18a7a62368b85aa6562cf10ddb9f 100644 (file)
@@ -43,12 +43,12 @@ entity Nade_TrailEffect(int proj, int nade_team)
 #include <client/draw.qh>
 #include <client/hud/hud.qh>
 
-bool darkblink;
+bool darkness_fadealpha;
 
 void HUD_DarkBlinking()
 {
        vector bottomright = vec2(vid_conwidth, vid_conheight);
-       drawfill('0 0 0', bottomright, NADE_TYPE_DARKNESS.m_color, 0.986, DRAWFLAG_NORMAL);
+       drawfill('0 0 0', bottomright, NADE_TYPE_DARKNESS.m_color, darkness_fadealpha, DRAWFLAG_NORMAL);
 }
 
 REGISTER_MUTATOR(cl_nades, true);
@@ -56,14 +56,19 @@ MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
 {
        if (STAT(NADE_DARKNESS_TIME) > time)
        {
-               if (!darkblink)
+               if (!darkness_fadealpha)
                        sound(csqcplayer, CH_PAIN, SND_BLIND, VOL_BASE, ATTEN_NORM);
-               darkblink = true;
+               darkness_fadealpha = min(0.986, darkness_fadealpha + frametime * 7);
+       }
+       else if (darkness_fadealpha > 0)
+               darkness_fadealpha = max(0, darkness_fadealpha - frametime * 7);
+
+       if (darkness_fadealpha > 0)
+       {
                HUD_DarkBlinking();
                M_ARGV(1, float) = 0; // alpha_multipl 0, don't draw normal overlay
                return true;
        }
-       darkblink = false;
        return false;
 }