From: terencehill Date: Thu, 18 Mar 2021 11:29:11 +0000 (+0100) Subject: crosshair_chase: fade in/out player alpha changes and apply player alpha to the weapo... X-Git-Tag: xonotic-v0.8.5~495^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=83e9739d3ec15b5b789866d30ac48c9119a251ce;p=xonotic%2Fxonotic-data.pk3dir.git crosshair_chase: fade in/out player alpha changes and apply player alpha to the weapon too --- diff --git a/qcsrc/client/hud/crosshair.qc b/qcsrc/client/hud/crosshair.qc index 646d5b1ba..160887da9 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);