]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added cvar bot_debug_tracewalk to enable visual indicators for short-term navigation
authormand1nga <mand1nga@xonotic.org>
Tue, 19 Apr 2011 01:01:21 +0000 (22:01 -0300)
committermand1nga <mand1nga@xonotic.org>
Tue, 19 Apr 2011 01:01:21 +0000 (22:01 -0300)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/bot/navigation.qc
qcsrc/server/bot/navigation.qh

index f7351e2fa7a3893e325214e6951bf32b6908b081..ec96c6ff039dc2a2c4f117f9f80e4953bd320943 100644 (file)
@@ -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"
index d5652b775e4620b3831c96b0ae44d16ba1f737b8..54167d076de7acb0c684bb868182c1b7d640d155 100644 (file)
@@ -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;
index 9e1a92a22249465776fba51660cd37bc25d96191..1f9d3897214f89bdb6e224477c739acb228e5d3d 100644 (file)
@@ -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;
index 666db4e5ee36988c81af2d998777a81ee2a33fac..2f41210c17142491c5f98c9045312a234c018b27 100644 (file)
@@ -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();