]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/bot.qc
Merge remote-tracking branch 'origin/divVerent/allow-override-item-model'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / bot.qc
index 1b6d8eb4ea440fed2954148d180b317469972203..039e21daed025bf588322272997456ed3f2fb240 100644 (file)
@@ -375,7 +375,8 @@ void bot_clientdisconnect()
        self.netname_freeme = string_null;
        self.playermodel_freeme = string_null;
        self.playerskin_freeme = string_null;
-       remove(self.bot_cmd_current);
+       if(self.bot_cmd_current)
+               remove(self.bot_cmd_current);
        if(bot_waypoint_queue_owner==self)
                bot_waypoint_queue_owner = world;
 }
@@ -537,28 +538,10 @@ void bot_calculate_stepheightvec(void)
                // 0.75 factor is for safety to make the jumps easy
 }
 
-void bot_serverframe()
+float bot_fixcount()
 {
-       float realplayers, bots, activerealplayers;
        entity head;
-
-       if (intermission_running)
-               return;
-
-       if (time < 2)
-               return;
-
-       bot_calculate_stepheightvec();
-       bot_navigation_movemode = ((autocvar_bot_navigation_ignoreplayers) ? MOVE_NOMONSTERS : MOVE_NORMAL);
-
-       if(time > autoskill_nextthink)
-       {
-               float a;
-               a = autocvar_skill_auto;
-               if(a)
-                       autoskill(a);
-               autoskill_nextthink = time + 5;
-       }
+       float realplayers, bots, activerealplayers;
 
        activerealplayers = 0;
        realplayers = 0;
@@ -597,8 +580,6 @@ void bot_serverframe()
                bots = 0;
        }
 
-       bot_ignore_bots = autocvar_bot_ignore_bots;
-
        // only add one bot per frame to avoid utter chaos
        if(time > botframe_nextthink)
        {
@@ -608,21 +589,51 @@ void bot_serverframe()
                        if (bot_spawn() == world)
                        {
                                bprint("Can not add bot, server full.\n");
-                               botframe_nextthink = time + 10;
-                               break;
+                               return FALSE;
                        }
                }
                while (currentbots > bots)
                        bot_removenewest();
        }
 
+       return TRUE;
+}
+
+void bot_serverframe()
+{
+       if (intermission_running)
+               return;
+
+       if (time < 2)
+               return;
+
+       bot_calculate_stepheightvec();
+       bot_navigation_movemode = ((autocvar_bot_navigation_ignoreplayers) ? MOVE_NOMONSTERS : MOVE_NORMAL);
+
+       if(time > autoskill_nextthink)
+       {
+               float a;
+               a = autocvar_skill_auto;
+               if(a)
+                       autoskill(a);
+               autoskill_nextthink = time + 5;
+       }
+
+       if(time > botframe_nextthink)
+       {
+               if(!bot_fixcount())
+                       botframe_nextthink = time + 10;
+       }
+
+       bot_ignore_bots = autocvar_bot_ignore_bots;
+
        if(botframe_spawnedwaypoints)
        {
                if(autocvar_waypoint_benchmark)
                        localcmd("quit\n");
        }
 
-       if (currentbots > 0 || autocvar_g_waypointeditor)
+       if (currentbots > 0 || autocvar_g_waypointeditor || autocvar_g_waypointeditor_auto)
        if (botframe_spawnedwaypoints)
        {
                if(botframe_cachedwaypointlinks)
@@ -674,6 +685,9 @@ void bot_serverframe()
        if (autocvar_g_waypointeditor)
                botframe_showwaypointlinks();
 
+       if (autocvar_g_waypointeditor_auto)
+               botframe_autowaypoints();
+
        if(time > bot_cvar_nextthink)
        {
                if(currentbots>0)