]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/bot.qc
Merge remote branch 'refs/remotes/origin/fruitiex/racefixes'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / bot.qc
index 940782c8239d9538f474405d87d7b21f967dc447..945600a886b208e6af45bb58aba71cd5d304a4ce 100644 (file)
@@ -43,7 +43,7 @@ void bot_think()
        //self.bot_painintensity = self.bot_painintensity + self.bot_oldhealth - self.health;
        //self.bot_painintensity = bound(0, self.bot_painintensity, 100);
 
-       if(time < game_starttime || ((cvar("g_campaign") && !campaign_bots_may_start)))
+       if (cvar("g_campaign") && !campaign_bots_may_start)
        {
                self.nextthink = time + 0.5;
                return;
@@ -81,6 +81,14 @@ void bot_think()
        self.BUTTON_CHAT = 0;
        self.BUTTON_USE = 0;
 
+       if (time < game_starttime)
+       {
+               // block the bot during the countdown to game start
+               self.movement = '0 0 0';
+               self.nextthink = game_starttime;
+               return;
+       }
+
        // if dead, just wait until we can respawn
        if (self.deadflag)
        {
@@ -136,7 +144,8 @@ void bot_setnameandstuff()
                        prio = 1;
                        FOR_EACH_CLIENT(p)
                        {
-                               if(strcat(prefix, s, suffix) == p.netname)
+                               if(clienttype(p) == CLIENTTYPE_BOT)
+                               if(s == p.cleanname)
                                {
                                        prio = 0;
                                        break;
@@ -200,8 +209,6 @@ void bot_setnameandstuff()
        else
                name = bot_name;
 
-       self.cleanname = strzone(name);
-
        // number bots with identical names
        float i;
        i = 0;
@@ -212,7 +219,11 @@ void bot_setnameandstuff()
                                ++i;
        }
        if (i)
-               name = strcat(name, "(", ftos(i), ")");
+               self.netname = self.netname_freeme = strzone(strcat(prefix, name, "(", ftos(i), ")", suffix));
+       else
+               self.netname = self.netname_freeme = strzone(strcat(prefix, name, suffix));
+
+       self.cleanname = strzone(name);
 
        // pick the model and skin
        if(substring(bot_model, -4, 1) != ".")
@@ -220,8 +231,6 @@ void bot_setnameandstuff()
        self.playermodel = self.playermodel_freeme = strzone(strcat("models/player/", bot_model));
        self.playerskin = self.playerskin_freeme = strzone(bot_skin);
 
-       self.netname = self.netname_freeme = strzone(strcat(prefix, name, suffix));
-
        self.cvar_cl_accuracy_data_share = 1;  // share the bots weapon accuracy data with the world
        self.cvar_cl_accuracy_data_receive = 0;  // don't receive any weapon accuracy data
 };
@@ -554,17 +563,16 @@ void bot_serverframe()
        // But don't remove bots immediately on level change, as the real players
        // usually haven't rejoined yet
        bots_would_leave = FALSE;
-       if ((realplayers || cvar("bot_join_empty") || (currentbots > 0 && time < 5)))
+       if (teamplay && cvar("bot_vs_human") && (c3==-1 && c4==-1))
+               bots = min(ceil(fabs(cvar("bot_vs_human")) * activerealplayers), maxclients - realplayers);
+       else if ((realplayers || cvar("bot_join_empty") || (currentbots > 0 && time < 5)))
        {
                float realminplayers, minplayers;
                realminplayers = cvar("minplayers");
                minplayers = max(0, floor(realminplayers));
 
                float realminbots, minbots;
-               if(teamplay && cvar("bot_vs_human"))
-                       realminbots = ceil(fabs(cvar("bot_vs_human")) * activerealplayers);
-               else
-                       realminbots = cvar("bot_number");
+               realminbots = cvar("bot_number");
                minbots = max(0, floor(realminbots));
 
                bots = min(max(minbots, minplayers - activerealplayers), maxclients - realplayers);