From 8b5fe1801072ca9f649ff4c470f5c09105821985 Mon Sep 17 00:00:00 2001 From: mand1nga Date: Mon, 18 Apr 2011 22:16:51 -0300 Subject: [PATCH] Added cvar bot_debug_goalstack to visualize the path that each bot is trying to follow --- defaultXonotic.cfg | 1 + qcsrc/server/autocvars.qh | 1 + qcsrc/server/bot/havocbot/havocbot.qc | 13 ++--- qcsrc/server/bot/navigation.qc | 80 +++++++++++++-------------- qcsrc/server/bot/navigation.qh | 2 - 5 files changed, 48 insertions(+), 49 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index ec96c6ff0..e4e43babe 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -417,6 +417,7 @@ 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" +set bot_debug_goalstack 0 "Visualize the current path that each bot is following. Use with as few bots as possible." // 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 54167d076..b7e053403 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -55,6 +55,7 @@ float autocvar_bot_sound_monopoly; float autocvar_bot_usemodelnames; float autocvar_bot_vs_human; float autocvar_bot_debug_tracewalk; +float autocvar_bot_debug_goalstack; float autocvar_captureleadlimit_override; #define autocvar_capturelimit_override cvar("capturelimit_override") float autocvar_deathmatch_force_teamplay; diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index e67bc214e..708ae9452 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -416,10 +416,11 @@ void havocbot_movetogoal() if(self.goalcurrent==self.navigation_jetpack_goal) if(self.ammo_fuel) { - #ifdef DEBUG_BOT_GOALSTACK + if(autocvar_bot_debug_goalstack) + { debuggoalstack(); te_wizspike(self.navigation_jetpack_point); - #endif + } // Take off if not(self.aistatus & AI_STATUS_JETPACK_FLYING) @@ -653,9 +654,8 @@ void havocbot_movetogoal() return; } -#ifdef DEBUG_BOT_GOALSTACK - debuggoalstack(); -#endif + if(autocvar_bot_debug_goalstack) + debuggoalstack(); m1 = self.goalcurrent.origin + self.goalcurrent.mins; m2 = self.goalcurrent.origin + self.goalcurrent.maxs; @@ -1139,9 +1139,8 @@ float havocbot_moveto(vector pos) } } - #ifdef DEBUG_BOT_GOALSTACK + if(autocvar_bot_debug_goalstack) debuggoalstack(); - #endif // Heading local vector dir = self.goalcurrent.origin - (self.origin + self.view_ofs); diff --git a/qcsrc/server/bot/navigation.qc b/qcsrc/server/bot/navigation.qc index 1f9d38972..95f5d5f00 100644 --- a/qcsrc/server/bot/navigation.qc +++ b/qcsrc/server/bot/navigation.qc @@ -966,6 +966,8 @@ void botframe_updatedangerousobjects(float maxupdate) } }; +// Support for debugging tracewalk visually + void debugresetnodes() { debuglastnode = '0 0 0'; @@ -1008,7 +1010,7 @@ void debugnodestatus(vector position, float status) te_customflash(position, 40, 2, c); } -#ifdef DEBUG_BOT_GOALSTACK +// Support for debugging the goal stack visually .float goalcounter; .vector lastposition; @@ -1016,43 +1018,43 @@ void debugnodestatus(vector position, float status) // Debug the goal stack visually void debuggoalstack() { - local entity target; + local entity goal; local vector org; - if(self.goalcounter==0)target=self.goalcurrent; - else if(self.goalcounter==1)target=self.goalstack01; - else if(self.goalcounter==2)target=self.goalstack02; - else if(self.goalcounter==3)target=self.goalstack03; - else if(self.goalcounter==4)target=self.goalstack04; - else if(self.goalcounter==5)target=self.goalstack05; - else if(self.goalcounter==6)target=self.goalstack06; - else if(self.goalcounter==7)target=self.goalstack07; - else if(self.goalcounter==8)target=self.goalstack08; - else if(self.goalcounter==9)target=self.goalstack09; - else if(self.goalcounter==10)target=self.goalstack10; - else if(self.goalcounter==11)target=self.goalstack11; - else if(self.goalcounter==12)target=self.goalstack12; - else if(self.goalcounter==13)target=self.goalstack13; - else if(self.goalcounter==14)target=self.goalstack14; - else if(self.goalcounter==15)target=self.goalstack15; - else if(self.goalcounter==16)target=self.goalstack16; - else if(self.goalcounter==17)target=self.goalstack17; - else if(self.goalcounter==18)target=self.goalstack18; - else if(self.goalcounter==19)target=self.goalstack19; - else if(self.goalcounter==20)target=self.goalstack20; - else if(self.goalcounter==21)target=self.goalstack21; - else if(self.goalcounter==22)target=self.goalstack22; - else if(self.goalcounter==23)target=self.goalstack23; - else if(self.goalcounter==24)target=self.goalstack24; - else if(self.goalcounter==25)target=self.goalstack25; - else if(self.goalcounter==26)target=self.goalstack26; - else if(self.goalcounter==27)target=self.goalstack27; - else if(self.goalcounter==28)target=self.goalstack28; - else if(self.goalcounter==29)target=self.goalstack29; - else if(self.goalcounter==30)target=self.goalstack30; - else if(self.goalcounter==31)target=self.goalstack31; - - if(target==world) + if(self.goalcounter==0)goal=self.goalcurrent; + else if(self.goalcounter==1)goal=self.goalstack01; + else if(self.goalcounter==2)goal=self.goalstack02; + else if(self.goalcounter==3)goal=self.goalstack03; + else if(self.goalcounter==4)goal=self.goalstack04; + else if(self.goalcounter==5)goal=self.goalstack05; + else if(self.goalcounter==6)goal=self.goalstack06; + else if(self.goalcounter==7)goal=self.goalstack07; + else if(self.goalcounter==8)goal=self.goalstack08; + else if(self.goalcounter==9)goal=self.goalstack09; + else if(self.goalcounter==10)goal=self.goalstack10; + else if(self.goalcounter==11)goal=self.goalstack11; + else if(self.goalcounter==12)goal=self.goalstack12; + else if(self.goalcounter==13)goal=self.goalstack13; + else if(self.goalcounter==14)goal=self.goalstack14; + else if(self.goalcounter==15)goal=self.goalstack15; + else if(self.goalcounter==16)goal=self.goalstack16; + else if(self.goalcounter==17)goal=self.goalstack17; + else if(self.goalcounter==18)goal=self.goalstack18; + else if(self.goalcounter==19)goal=self.goalstack19; + else if(self.goalcounter==20)goal=self.goalstack20; + else if(self.goalcounter==21)goal=self.goalstack21; + else if(self.goalcounter==22)goal=self.goalstack22; + else if(self.goalcounter==23)goal=self.goalstack23; + else if(self.goalcounter==24)goal=self.goalstack24; + else if(self.goalcounter==25)goal=self.goalstack25; + else if(self.goalcounter==26)goal=self.goalstack26; + else if(self.goalcounter==27)goal=self.goalstack27; + else if(self.goalcounter==28)goal=self.goalstack28; + else if(self.goalcounter==29)goal=self.goalstack29; + else if(self.goalcounter==30)goal=self.goalstack30; + else if(self.goalcounter==31)goal=self.goalstack31; + + if(goal==world) { self.goalcounter = 0; self.lastposition='0 0 0'; @@ -1065,10 +1067,8 @@ void debuggoalstack() org = self.lastposition; - te_lightning2(world, org, target.origin); - self.lastposition = target.origin; + te_lightning2(world, org, goal.origin); + self.lastposition = goal.origin; self.goalcounter++; } - -#endif diff --git a/qcsrc/server/bot/navigation.qh b/qcsrc/server/bot/navigation.qh index 2f41210c1..06bbb85c3 100644 --- a/qcsrc/server/bot/navigation.qh +++ b/qcsrc/server/bot/navigation.qh @@ -43,9 +43,7 @@ void debugresetnodes(); void debugnode(vector node); void debugnodestatus(vector position, float status); -#ifdef DEBUG_BOT_GOALSTACK void debuggoalstack(); -#endif float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float movemode); -- 2.39.2