]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Check for dangerous liquids only while walking and do it on step end rather than...
authorterencehill <piuntn@gmail.com>
Sun, 23 Jul 2017 16:05:14 +0000 (18:05 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 23 Jul 2017 16:05:14 +0000 (18:05 +0200)
qcsrc/server/bot/default/navigation.qc

index 8fa2fd82c64f2f7da1af35adb2e3741443054498..1009af29dfd415438db50554582c03dd71c458b0 100644 (file)
@@ -55,9 +55,10 @@ bool navigation_checkladders(entity e, vector org, vector m1, vector m2, vector
        return false;
 }
 
-#define IN_WATER(pos) (cont = pointcontents(pos), (cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME))
-#define SUBMERGED(pos) IN_WATER(pos + autocvar_sv_player_viewoffset)
-#define WETFEET(pos) IN_WATER(pos + eZ * (m1.z + 1))
+#define IN_LAVA(pos) (cont = pointcontents(pos), (cont == CONTENT_LAVA || cont == CONTENT_SLIME))
+#define IN_LIQUID(pos) (cont = pointcontents(pos), (cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME))
+#define SUBMERGED(pos) IN_LIQUID(pos + autocvar_sv_player_viewoffset)
+#define WETFEET(pos) IN_LIQUID(pos + eZ * (m1.z + 1))
 
 vector resurface_limited(vector org, float lim, vector m1)
 {
@@ -110,12 +111,7 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float e
        traceline(start, start, MOVE_NORMAL, e);
        if (trace_dpstartcontents & (DPCONTENTS_SLIME | DPCONTENTS_LAVA))
                ignorehazards = true;
-       else
-       {
-               traceline( start, start + '0 0 -65536', MOVE_NORMAL, e);
-               if (trace_dpstartcontents & (DPCONTENTS_SLIME | DPCONTENTS_LAVA))
-                       ignorehazards = true;
-       }
+
        tracebox(start, m1, m2, start, MOVE_NOMONSTERS, e);
        if (trace_startsolid)
        {
@@ -200,21 +196,6 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float e
                if (dist <= 0)
                        break;
 
-               traceline(org, org, MOVE_NORMAL, e);
-
-               if (!ignorehazards)
-               {
-                       if (trace_dpstartcontents & (DPCONTENTS_SLIME | DPCONTENTS_LAVA))
-                       {
-                               // hazards blocking path
-                               if(autocvar_bot_debug_tracewalk)
-                                       debugnodestatus(org, DEBUG_NODE_FAIL);
-
-                               //print("tracewalk: ", vtos(start), " hits a hazard when trying to reach ", vtos(end), "\n");
-                               return false;
-                       }
-               }
-
                if(nav_action == NAV_SWIM_UNDERWATER || (nav_action == NAV_SWIM_ONWATER && org.z > end2.z))
                {
                        // can't use movement direction here to calculate move because of
@@ -517,6 +498,21 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float e
 
                        org = trace_endpos;
 
+                       if (!ignorehazards)
+                       {
+                               if (IN_LAVA(org))
+                               {
+                                       if(autocvar_bot_debug_tracewalk)
+                                       {
+                                               debugnode(e, trace_endpos);
+                                               debugnodestatus(org, DEBUG_NODE_FAIL);
+                                       }
+
+                                       //print("tracewalk: ", vtos(start), " hits a hazard when trying to reach ", vtos(end), "\n");
+                                       return false;
+                               }
+                       }
+
                        if(org.z > move.z - 1 || !SUBMERGED(org))
                        {
                                nav_action = NAV_WALK;