]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow bots to climb ladders up
authorterencehill <piuntn@gmail.com>
Mon, 13 Mar 2017 01:12:23 +0000 (02:12 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 13 Mar 2017 01:12:23 +0000 (02:12 +0100)
qcsrc/server/bot/default/navigation.qc

index 9f1d5d9222426b0b432cfdd24e2eaa1b97493b7a..488da59d47ace5d5ac92190b1d25e29c928912d8 100644 (file)
@@ -180,8 +180,14 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float m
                                                if(autocvar_bot_debug_tracewalk)
                                                        debugnodestatus(trace_endpos, DEBUG_NODE_WARNING);
 
-                                               // check for doors
+                                               FOREACH_ENTITY_CLASS("func_ladder", true,
+                                                       { it.solid = SOLID_BSP; });
+
                                                traceline( org, move, movemode, e);
+
+                                               FOREACH_ENTITY_CLASS("func_ladder", true,
+                                                       { it.solid = SOLID_TRIGGER; });
+
                                                if ( trace_ent.classname == "door_rotating" || trace_ent.classname == "door")
                                                {
                                                        vector nextmove;
@@ -193,6 +199,23 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float m
                                                                move = nextmove;
                                                        }
                                                }
+                                               else if (trace_ent.classname == "func_ladder")
+                                               {
+                                                       vector ladder_bottom = trace_endpos - dir * m2.x;
+                                                       vector ladder_top = ladder_bottom;
+                                                       ladder_top.z = trace_ent.absmax.z + (-m1.z + 1);
+                                                       tracebox(ladder_bottom, m1, m2, ladder_top, movemode, e);
+                                                       if (trace_fraction < 1 || trace_startsolid)
+                                                       {
+                                                               if(autocvar_bot_debug_tracewalk)
+                                                                       debugnodestatus(trace_endpos, DEBUG_NODE_FAIL);
+
+                                                               return false; // failed
+                                                       }
+                                                       org = ladder_top + dir * m2.x;
+                                                       move = org + dir * stepdist;
+                                                       continue;
+                                               }
                                                else
                                                {
                                                        if(autocvar_bot_debug_tracewalk)