From 7006710900eaed8c62316d4c5895ec42a02b074a Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 13 Jul 2023 00:40:48 +0200 Subject: [PATCH] Darkness nade: fade darkness in and out --- qcsrc/common/mutators/mutator/nades/nades.qc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 3ee6020cf..9bd553337 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -43,12 +43,12 @@ entity Nade_TrailEffect(int proj, int nade_team) #include #include -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; } -- 2.39.2