From 83e9739d3ec15b5b789866d30ac48c9119a251ce Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 18 Mar 2021 12:29:11 +0100 Subject: [PATCH] crosshair_chase: fade in/out player alpha changes and apply player alpha to the weapon too --- qcsrc/client/hud/crosshair.qc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/qcsrc/client/hud/crosshair.qc b/qcsrc/client/hud/crosshair.qc index 646d5b1ba4..160887da92 100644 --- a/qcsrc/client/hud/crosshair.qc +++ b/qcsrc/client/hud/crosshair.qc @@ -265,7 +265,9 @@ void HUD_Crosshair(entity this) else if(autocvar_chase_active > 0 && autocvar_crosshair_chase) { vector player_org = ((csqcplayer) ? csqcplayer.origin + csqcplayer.view_ofs : view_origin); - if(csqcplayer && autocvar_crosshair_chase_playeralpha && autocvar_crosshair_chase_playeralpha < 1) + float my_alpha = (!csqcplayer.m_alpha) ? 1 : csqcplayer.m_alpha; + if(csqcplayer && autocvar_crosshair_chase_playeralpha && autocvar_crosshair_chase_playeralpha < 1 + && my_alpha > autocvar_crosshair_chase_playeralpha) { bool hit = false; if (pointinsidebox(view_origin, csqcplayer.absmin, csqcplayer.absmax)) @@ -276,13 +278,19 @@ void HUD_Crosshair(entity this) if(trace_ent == csqcplayer) hit = true; } + float prev_alpha = csqcplayer.alpha; if(hit) + csqcplayer.alpha = max(csqcplayer.alpha - frametime * 5, autocvar_crosshair_chase_playeralpha); + else + csqcplayer.alpha = min(csqcplayer.alpha + frametime * 5, my_alpha); + + if (csqcplayer.alpha != prev_alpha) { - float myalpha = (!csqcplayer.m_alpha) ? 1 : csqcplayer.m_alpha; - csqcplayer.alpha = min(autocvar_crosshair_chase_playeralpha, myalpha); + FOREACH_ENTITY_CLASS("ENT_CLIENT_MODEL", it.tag_entity == csqcplayer, + { + it.alpha = csqcplayer.alpha; + }); } - else - csqcplayer.alpha = csqcplayer.m_alpha; } traceline(player_org, player_org + max_shot_distance * view_forward, MOVE_WORLDONLY, NULL); wcross_origin = project_3d_to_2d(trace_endpos); -- 2.39.2