]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Find a new goal as soon as the item bot is running to gets taken by someone else
authorterencehill <piuntn@gmail.com>
Tue, 14 Feb 2017 22:05:23 +0000 (23:05 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 14 Feb 2017 22:11:28 +0000 (23:11 +0100)
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/navigation.qc

index 606857611490466116175de4c81f3bb210637438..ba8757502bc5afe21e8f09832ddd3a1ff7cac9f7 100644 (file)
@@ -674,7 +674,33 @@ void havocbot_movetogoal(entity this)
        if (this.goalcurrent == NULL)
                return;
 
-       navigation_poptouchedgoals(this);
+
+       bool locked_goal = false;
+       if(this.goalentity.bot_pickup)
+       {
+               if(this.goalentity.bot_pickup_respawning)
+               {
+                       if(this.goalentity.solid) // item respawned
+                               this.goalentity.bot_pickup_respawning = false;
+                       else if(time < this.goalentity.scheduledrespawntime - 10) // item already taken (by someone else)
+                       {
+                               this.goalentity.bot_pickup_respawning = false;
+                               navigation_clearroute(this);
+                               this.bot_strategytime = 0;
+                               return;
+                       }
+                       else if(this.goalentity == this.goalcurrent)
+                               locked_goal = true; // wait for item to respawn
+               }
+               else if(!this.goalentity.solid)
+               {
+                       navigation_clearroute(this);
+                       this.bot_strategytime = 0;
+                       return;
+               }
+       }
+       if(!locked_goal)
+               navigation_poptouchedgoals(this);
 
        // if ran out of goals try to use an alternative goal or get a new strategy asap
        if(this.goalcurrent == NULL)
index 5d612e10f0641b0384f4e8ae6a6f08ab66a05096..95d787e002f2f1e40d57bf40d4b8f8d3a999f5cd 100644 (file)
@@ -232,6 +232,7 @@ void navigation_clearroute(entity this)
 {
        //print("bot ", etos(this), " clear\n");
        this.navigation_hasgoals = false;
+       this.goalentity = NULL;
        this.goalcurrent = NULL;
        this.goalstack01 = NULL;
        this.goalstack02 = NULL;
@@ -275,6 +276,8 @@ void navigation_clearroute(entity this)
 void navigation_pushroute(entity this, entity e)
 {
        //print("bot ", etos(this), " push ", etos(e), "\n");
+       if(this.goalstack31 == this.goalentity)
+               this.goalentity = NULL;
        this.goalstack31 = this.goalstack30;
        this.goalstack30 = this.goalstack29;
        this.goalstack29 = this.goalstack28;
@@ -315,6 +318,8 @@ void navigation_pushroute(entity this, entity e)
 void navigation_poproute(entity this)
 {
        //print("bot ", etos(this), " pop\n");
+       if(this.goalcurrent == this.goalentity)
+               this.goalentity = NULL;
        this.goalcurrent = this.goalstack01;
        this.goalstack01 = this.goalstack02;
        this.goalstack02 = this.goalstack03;
@@ -943,16 +948,6 @@ void navigation_poptouchedgoals(entity this)
                }
        }
 
-       if(this.goalcurrent.bot_pickup_respawning)
-       {
-               if(!this.goalcurrent.solid)
-               {
-                       if(time > this.goalcurrent.scheduledrespawntime - 10) // item not yet taken (by someone else)
-                               return; // wait for item to respawn
-               }
-               this.goalcurrent.bot_pickup_respawning = false;
-       }
-
        // If for some reason the bot is closer to the next goal, pop the current one
        if(this.goalstack01 && !wasfreed(this.goalstack01))
        if(vlen2(this.goalcurrent.origin - this.origin) > vlen2(this.goalstack01.origin - this.origin))