Bot navigation: slighltly improve ladder detection
authorterencehill <piuntn@gmail.com>
Wed, 3 May 2017 19:58:09 +0000 (21:58 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 3 May 2017 21:01:20 +0000 (23:01 +0200)
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/navigation.qh

index 3fa56d9..575ab48 100644 (file)
@@ -571,9 +571,8 @@ void autoskill(float factor)
 void bot_calculate_stepheightvec()
 {
        stepheightvec = autocvar_sv_stepheight * '0 0 1';
-       jumpstepheightvec = stepheightvec +
-               ((autocvar_sv_jumpvelocity * autocvar_sv_jumpvelocity) / (2 * autocvar_sv_gravity)) * '0 0 0.85';
-               // 0.75 factor is for safety to make the jumps easy
+       jumpheight_vec = (autocvar_sv_jumpvelocity ** 2) / (2 * autocvar_sv_gravity) * '0 0 1';
+       jumpstepheightvec = stepheightvec + jumpheight_vec * 0.85; // reduce it a bit to make the jumps easy
 }
 
 float bot_fixcount()
index 840ca49..14d9446 100644 (file)
@@ -178,15 +178,16 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float m
                                        if (trace_fraction < 1 || trace_startsolid)
                                        {
                                                bool ladder_found = false;
-                                               FOREACH_ENTITY_CLASS("func_ladder", boxesoverlap(trace_endpos + m1 + '-1 -1 -1', trace_endpos + m2 + '1 1 1', it.absmin, it.absmax),
+                                               FOREACH_ENTITY_CLASS("func_ladder", true,
                                                {
+                                                       if(boxesoverlap(org + jumpheight_vec + m1 + '-1 -1 -1', org + jumpheight_vec + m2 + '1 1 1', it.absmin, it.absmax))
                                                        if(boxesoverlap(end, end, it.absmin + (m1 - eZ * m1.z - '1 1 0'), it.absmax + (m2 - eZ * m2.z + '1 1 0')))
                                                                ladder_found = true; // can't return here ("Loop mutex held by tracewalk" error)
                                                });
                                                if(ladder_found)
                                                {
                                                        if(autocvar_bot_debug_tracewalk)
-                                                               debugnodestatus(org, DEBUG_NODE_SUCCESS);
+                                                               debugnodestatus(end, DEBUG_NODE_SUCCESS);
 
                                                        //print("tracewalk: ", vtos(start), " can reach ", vtos(end), "\n");
                                                        return true;
index 9a6a0c8..078f1ed 100644 (file)
@@ -9,6 +9,7 @@ float navigation_testtracewalk;
 
 vector jumpstepheightvec;
 vector stepheightvec;
+vector jumpheight_vec;
 
 entity navigation_bestgoal;