From 3e2237da63fcc0dabe6f9cd54ce4b5e0bce49f6d Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 14 Mar 2017 04:03:34 +0100 Subject: [PATCH] Bot AI: improve ladder usage --- qcsrc/server/bot/default/navigation.qc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 488da59d4..75ddd15f5 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -50,6 +50,7 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float m float stepdist; float ignorehazards; float swimming; + entity tw_ladder = NULL; if(autocvar_bot_debug_tracewalk) { @@ -138,11 +139,11 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float m org = trace_endpos - normalize(org - trace_endpos) * stepdist; for (; org.z < end.z + e.maxs.z; org.z += stepdist) { - if(autocvar_bot_debug_tracewalk) - debugnode(e, org); + if(autocvar_bot_debug_tracewalk) + debugnode(e, org); - if(pointcontents(org) == CONTENT_EMPTY) - break; + if(pointcontents(org) == CONTENT_EMPTY) + break; } if(pointcontents(org + '0 0 1') != CONTENT_EMPTY) @@ -201,6 +202,7 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float m } else if (trace_ent.classname == "func_ladder") { + tw_ladder = trace_ent; vector ladder_bottom = trace_endpos - dir * m2.x; vector ladder_top = ladder_bottom; ladder_top.z = trace_ent.absmax.z + (-m1.z + 1); @@ -255,6 +257,16 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float m org = trace_endpos; } + + if(tw_ladder && org.z < tw_ladder.absmax.z) + { + // stop tracewalk if destination height is lower than the top of the ladder + // otherwise bot can't easily figure out climbing direction + if(autocvar_bot_debug_tracewalk) + debugnodestatus(org, DEBUG_NODE_FAIL); + + return false; + } } //print("tracewalk: ", vtos(start), " did not arrive at ", vtos(end), " but at ", vtos(org), "\n"); -- 2.39.2