]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
crosshair_chase: fix player alpha while walking through a warpzone and when view...
authorterencehill <piuntn@gmail.com>
Thu, 18 Mar 2021 00:14:45 +0000 (01:14 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 18 Mar 2021 00:14:45 +0000 (01:14 +0100)
qcsrc/client/hud/crosshair.qc
qcsrc/lib/vector.qh

index 3af4d570e40335cbe532e950adc0955ac8b89e9c..646d5b1ba4291a7f15877261102739fc14ee8400 100644 (file)
@@ -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;
                        }
index 5863fcf27657b67b7d1cda4add0fc4bca9c31200..13869b016ef35f03f16f8be5d5cfbb0e14ad9282 100644 (file)
@@ -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)