From: terencehill Date: Wed, 12 Jul 2023 22:40:48 +0000 (+0200) Subject: Darkness nade: fade darkness in and out X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7006710900eaed8c62316d4c5895ec42a02b074a;p=xonotic%2Fxonotic-data.pk3dir.git Darkness nade: fade darkness in and out --- 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; }