From: terencehill Date: Thu, 18 Mar 2021 00:14:45 +0000 (+0100) Subject: crosshair_chase: fix player alpha while walking through a warpzone and when view... X-Git-Tag: xonotic-v0.8.5~495^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1597f5c6dd578d807b84299600aa9c1a5f65c4e1;p=xonotic%2Fxonotic-data.pk3dir.git crosshair_chase: fix player alpha while walking through a warpzone and when view origin is inside the player --- diff --git a/qcsrc/client/hud/crosshair.qc b/qcsrc/client/hud/crosshair.qc index 3af4d570e..646d5b1ba 100644 --- a/qcsrc/client/hud/crosshair.qc +++ b/qcsrc/client/hud/crosshair.qc @@ -267,10 +267,20 @@ void HUD_Crosshair(entity this) vector player_org = ((csqcplayer) ? csqcplayer.origin + csqcplayer.view_ofs : view_origin); if(csqcplayer && autocvar_crosshair_chase_playeralpha && autocvar_crosshair_chase_playeralpha < 1) { - traceline(view_origin, view_origin + max_shot_distance * view_forward, MOVE_NORMAL, NULL); - float myalpha = (!csqcplayer.m_alpha) ? 1 : csqcplayer.m_alpha; - if(trace_ent == csqcplayer) + bool hit = false; + if (pointinsidebox(view_origin, csqcplayer.absmin, csqcplayer.absmax)) + hit = true; + else + { + WarpZone_TraceLine(view_origin, view_origin + max_shot_distance * view_forward, MOVE_NORMAL, NULL); + if(trace_ent == csqcplayer) + hit = true; + } + if(hit) + { + float myalpha = (!csqcplayer.m_alpha) ? 1 : csqcplayer.m_alpha; csqcplayer.alpha = min(autocvar_crosshair_chase_playeralpha, myalpha); + } else csqcplayer.alpha = csqcplayer.m_alpha; } diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index 5863fcf27..13869b016 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -76,6 +76,8 @@ float boxesoverlap(vector m1, vector m2, vector m3, vector m4) { return m2_x >= ERASEABLE float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { return smins.x >= bmins.x && smaxs.x <= bmaxs.x && smins.y >= bmins.y && smaxs.y <= bmaxs.y && smins.z >= bmins.z && smaxs.z <= bmaxs.z; } +#define pointinsidebox(point, bmins, bmaxs) boxinsidebox(point, point, bmins, bmaxs) + #define PITCH(v) ((v).x) #define YAW(v) ((v).y) #define ROLL(v) ((v).z)