]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Don't assign needlessly a frame to find a new goal to dead or frozen bots as they...
authorterencehill <piuntn@gmail.com>
Thu, 2 Nov 2017 17:10:08 +0000 (18:10 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 2 Nov 2017 21:46:21 +0000 (22:46 +0100)
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/havocbot/havocbot.qc

index 0b591915d648b06654e57cdd53f387f7a9c4ccec..61a69747c79517341a1c96232ef1df854cbc1168 100644 (file)
@@ -771,10 +771,22 @@ void bot_serverframe()
                if (bot_strategytoken_taken)
                {
                        bot_strategytoken_taken = false;
-                       if (bot_strategytoken)
-                               bot_strategytoken = bot_strategytoken.nextbot;
-                       if (!bot_strategytoken)
-                               bot_strategytoken = bot_list;
+                       entity bot_strategytoken_save = bot_strategytoken;
+                       while (true)
+                       {
+                               if (bot_strategytoken)
+                                       bot_strategytoken = bot_strategytoken.nextbot;
+                               if (!bot_strategytoken)
+                                       bot_strategytoken = bot_list;
+
+                               if (!(IS_DEAD(bot_strategytoken) || STAT(FROZEN, bot_strategytoken)))
+                                       break;
+
+                               if (!bot_strategytoken_save) // break loop if all the bots are dead or frozen
+                                       break;
+                               if (bot_strategytoken == bot_strategytoken_save)
+                                       bot_strategytoken_save = NULL; // looped through all the bots
+                       }
                }
 
                if (botframe_nextdangertime < time)
index cf4136c6eca969f35224cef869248b11913787ab..98f8b790bd898ccf1f69fbeeed29fcdb6a604b50 100644 (file)
@@ -33,8 +33,7 @@ void havocbot_ai(entity this)
        if(bot_execute_commands(this))
                return;
 
-       if (bot_strategytoken == this)
-       if (!bot_strategytoken_taken)
+       if (bot_strategytoken == this && !bot_strategytoken_taken)
        {
                if(this.havocbot_blockhead)
                {