]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 3fa56d942b3bb2b15e1a2ede11eca9516e36c5d3..575ab48a3105c45414eb4f35f517a2190ed42348 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 840ca49f17fd9e72e767b24e37b6a408322499c8..14d944623c275931e1f1bb6e9db9ea4ff2351bf1 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 9a6a0c8a6adf6368b57fadaa3df6985b082768e2..078f1ede7308306022a0cf341370e2cdf46f79db 100644 (file)
@@ -9,6 +9,7 @@ float navigation_testtracewalk;
 
 vector jumpstepheightvec;
 vector stepheightvec;
+vector jumpheight_vec;
 
 entity navigation_bestgoal;