From: mand1nga Date: Tue, 19 Apr 2011 01:01:21 +0000 (-0300) Subject: Added cvar bot_debug_tracewalk to enable visual indicators for short-term navigation X-Git-Tag: xonotic-v0.5.0~109^2~24^2~3^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ab7e762ff13edcadbfdf343efc757a0d4e5aa2fa;p=xonotic%2Fxonotic-data.pk3dir.git Added cvar bot_debug_tracewalk to enable visual indicators for short-term navigation --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index f7351e2fa..ec96c6ff0 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -416,6 +416,7 @@ set bot_nofire 0 "When set, bots never fire. Mainly for testing in g_waypointedi seta bot_prefix [BOT] "Prefix in front of the bot names" seta bot_suffix "" "Suffix behind the bot names" seta skill_auto 0 "when 1, \"skill\" gets adjusted to match the best player on the map" +set bot_debug_tracewalk 0 "Enable visual indicators for short-term navigation. Green: Goal Reached / Yellow: Obstacle found / Red: Unsolvable obstacle found" // general bot AI cvars set bot_ai_thinkinterval 0.05 set bot_ai_strategyinterval 5 "How often a new objective is chosen" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index d5652b775..54167d076 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -54,6 +54,7 @@ float autocvar_bot_sound_monopoly; #define autocvar_bot_suffix cvar_string("bot_suffix") float autocvar_bot_usemodelnames; float autocvar_bot_vs_human; +float autocvar_bot_debug_tracewalk; float autocvar_captureleadlimit_override; #define autocvar_capturelimit_override cvar("capturelimit_override") float autocvar_deathmatch_force_teamplay; diff --git a/qcsrc/server/bot/navigation.qc b/qcsrc/server/bot/navigation.qc index 9e1a92a22..1f9d38972 100644 --- a/qcsrc/server/bot/navigation.qc +++ b/qcsrc/server/bot/navigation.qc @@ -14,10 +14,11 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float local float ignorehazards; local float swimming; - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) + { debugresetnodes(); debugnode(start); - #endif + } move = end - start; move_z = 0; @@ -44,9 +45,9 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float if (trace_startsolid) { // Bad start - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnodestatus(start, DEBUG_NODE_FAIL); - #endif + //print("tracewalk: ", vtos(start), " is a bad start\n"); return FALSE; } @@ -59,15 +60,14 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float if (boxesoverlap(end, end, org + m1 + '-1 -1 -1', org + m2 + '1 1 1')) { // Succeeded - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnodestatus(org, DEBUG_NODE_SUCCESS); - #endif + //print("tracewalk: ", vtos(start), " can reach ", vtos(end), "\n"); return TRUE; } - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnode(org); - #endif if (dist <= 0) break; @@ -80,9 +80,9 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float if (trace_dpstartcontents & (DPCONTENTS_SLIME | DPCONTENTS_LAVA)) { // hazards blocking path - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnodestatus(org, DEBUG_NODE_FAIL); - #endif + //print("tracewalk: ", vtos(start), " hits a hazard when trying to reach ", vtos(end), "\n"); return FALSE; } @@ -92,9 +92,8 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float move = normalize(end - org); tracebox(org, m1, m2, org + move * stepdist, movemode, e); - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnode(trace_endpos); - #endif if (trace_fraction < 1) { @@ -102,18 +101,18 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float org = trace_endpos - normalize(org - trace_endpos) * stepdist; for(; org_z < end_z + self.maxs_z; org_z += stepdist) { - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnode(org); - #endif + if(pointcontents(org) == CONTENT_EMPTY) break; } if not (pointcontents(org + '0 0 1') == CONTENT_EMPTY) { - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnodestatus(org, DEBUG_NODE_FAIL); - #endif + return FALSE; //print("tracewalk: ", vtos(start), " failed under water\n"); } @@ -128,9 +127,8 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float move = dir * stepdist + org; tracebox(org, m1, m2, move, movemode, e); - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnode(trace_endpos); - #endif // hit something if (trace_fraction < 1) @@ -139,9 +137,8 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float tracebox(org + stepheightvec, m1, m2, move + stepheightvec, movemode, e); if (trace_fraction < 1 || trace_startsolid) { - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnodestatus(trace_endpos, DEBUG_NODE_WARNING); - #endif // check for doors traceline( org, move, movemode, e); @@ -158,9 +155,9 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float } else { - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnodestatus(trace_endpos, DEBUG_NODE_FAIL); - #endif + //print("tracewalk: ", vtos(start), " hit something when trying to reach ", vtos(end), "\n"); //te_explosion(trace_endpos); //print(ftos(e.dphitcontentsmask), "\n"); @@ -197,9 +194,8 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float //print("tracewalk: ", vtos(start), " did not arrive at ", vtos(end), " but at ", vtos(org), "\n"); // moved but didn't arrive at the intended destination - #ifdef DEBUG_TRACEWALK + if(autocvar_bot_debug_tracewalk) debugnodestatus(org, DEBUG_NODE_FAIL); - #endif return FALSE; }; @@ -970,8 +966,6 @@ void botframe_updatedangerousobjects(float maxupdate) } }; -#ifdef DEBUG_TRACEWALK - void debugresetnodes() { debuglastnode = '0 0 0'; @@ -994,28 +988,26 @@ void debugnode(vector node) void debugnodestatus(vector position, float status) { - vector color; + vector c; switch (status) { case DEBUG_NODE_SUCCESS: - color = '0 15 0'; + c = '0 15 0'; break; case DEBUG_NODE_WARNING: - color = '15 15 0'; + c = '15 15 0'; break; case DEBUG_NODE_FAIL: - color = '15 0 0'; + c = '15 0 0'; break; default: - color = '15 15 15'; + c = '15 15 15'; } - te_customflash(position, 40, 2, color); + te_customflash(position, 40, 2, c); } -#endif - #ifdef DEBUG_BOT_GOALSTACK .float goalcounter; diff --git a/qcsrc/server/bot/navigation.qh b/qcsrc/server/bot/navigation.qh index 666db4e5e..2f41210c1 100644 --- a/qcsrc/server/bot/navigation.qh +++ b/qcsrc/server/bot/navigation.qh @@ -30,22 +30,18 @@ entity navigation_bestgoal; .entity navigation_jetpack_goal; .vector navigation_jetpack_point; -#ifdef DEBUG_TRACEWALK float DEBUG_NODE_SUCCESS = 1; float DEBUG_NODE_WARNING = 2; float DEBUG_NODE_FAIL = 3; vector debuglastnode; -#endif /* * Functions */ -#ifdef DEBUG_TRACEWALK void debugresetnodes(); void debugnode(vector node); void debugnodestatus(vector position, float status); -#endif #ifdef DEBUG_BOT_GOALSTACK void debuggoalstack();