.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Cyborg Factory > POD-Bot mm > Ideas
Ideas One idea per thread please! :)

Reply
 
Thread Tools
Remove all bots when there is no human player on the server
Old
  (#1)
e-t172
French
 
e-t172's Avatar
 
Status: Offline
Posts: 3
Join Date: Apr 2007
Location: FRANCE
Arrow Remove all bots when there is no human player on the server - 24-04-2007

I'm using PODBot MM on a dedicated server. My problem is that when there is no human player on the server, the bots continue to play, and thus continue to use a big deal of CPU.

It would be great to have an option to automatically remove bots when there is no human player on the server (and to make them automatically rejoin when a human player joins). The official bots for CS:S have such an option.

So I'm looking forward for a new CVAR
  
Reply With Quote
Re: Remove all bots when there is no human player on the server
Old
  (#2)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,425
Join Date: Apr 2004
Default Re: Remove all bots when there is no human player on the server - 24-04-2007

This is exactly as a contrary to this:
http://forums.bots-united.com/showthread.php?t=6253

Sorry - I'm not able to make everyone happy.

About that big CPU usage - try out V3B16c version - it should take less CPU.
  
Reply With Quote
Re: Remove all bots when there is no human player on the server
Old
  (#3)
e-t172
French
 
e-t172's Avatar
 
Status: Offline
Posts: 3
Join Date: Apr 2007
Location: FRANCE
Idea Re: Remove all bots when there is no human player on the server - 24-04-2007

I hate wasting the CPU time of my machines so I coded it myself. Here is the patch :

Code:
diff -r -u podbot-orig/bot_globals.cpp podbot/bot_globals.cpp
--- podbot-orig/bot_globals.cpp    2007-03-24 14:58:48.000000000 +0100
+++ podbot/bot_globals.cpp    2007-04-24 20:00:07.000000000 +0200
@@ -151,6 +151,7 @@
 int g_i_botthink_index;  // KWo - 02.05.2006
 float g_fAutoKillTime = 0.0;  // KWo - 02.05.2006
 bool g_bAliveHumansPrevious = FALSE;  // KWo - 02.05.2006
+bool g_bHumansPrevious = true;
 int g_iUpdGlExpState = 0;  // KWo - 02.05.2006
 bool g_bRecalcKills = FALSE;  // KWo - 02.05.2006
 
@@ -180,6 +181,7 @@
 float g_f_cv_dangerfactor;         // KWo - 06.04.2006
 bool g_b_cv_chat;                  // KWo - 06.04.2006
 bool g_b_cv_autokill;              // KWo - 02.05.2006
+bool g_b_cv_autoremove;
 float g_f_cv_autokilldelay;        // KWo - 02.05.2006
 bool g_b_cv_ffa;                   // KWo - 04.10.2006
 bool g_b_cv_radio;                 // KWo - 03.02.2007
@@ -236,6 +238,7 @@
    "pb_" "aim_target_anticipation_ratio",  // KWo - 04.03.2006
    "pb_" "aim_type",
    "pb_" "autokill",        // KWo - 02.05.2006
+   "pb_" "autoremove",
    "pb_" "autokilldelay",   // KWo - 02.05.2006
    "pb_" "bot_join_team",   // KWo - 16.09.2006
    "pb_" "bot_quota_match", // KWo - 16.09.2006
diff -r -u podbot-orig/bot_globals.h podbot/bot_globals.h
--- podbot-orig/bot_globals.h    2007-03-24 14:58:40.000000000 +0100
+++ podbot/bot_globals.h    2007-04-24 19:55:14.000000000 +0200
@@ -144,6 +144,7 @@
 extern float g_f_cv_dangerfactor; // KWo 06.04.2006
 extern bool g_b_cv_chat; // KWo 06.04.2006
 extern bool g_b_cv_autokill;  // KWo - 02.05.2006
+extern bool g_b_cv_autoremove;
 extern float g_f_cv_autokilldelay;  // KWo - 02.05.2006
 extern bool g_b_cv_ffa;  // KWo - 04.10.2006
 extern bool g_b_cv_radio;  // KWo - 03.02.2007
@@ -168,6 +169,7 @@
 extern int g_i_botthink_index;      // KWo - 02.05.2006
 extern float g_fAutoKillTime;       // KWo - 02.05.2006
 extern bool g_bAliveHumansPrevious; // KWo - 02.05.2006
+extern bool g_bHumansPrevious;
 extern int g_iUpdGlExpState;        // KWo - 02.05.2006
 extern bool g_bRecalcKills;         // KWo - 02.05.2006
 
diff -r -u podbot-orig/bot.h podbot/bot.h
--- podbot-orig/bot.h    2007-03-26 22:04:12.000000000 +0200
+++ podbot/bot.h    2007-04-24 19:49:52.000000000 +0200
@@ -118,6 +118,7 @@
    PBCVAR_AIM_TARGET_ANTICIPATION_RATIO,  // KWo - 04.03.2006
    PBCVAR_AIM_TYPE,
    PBCVAR_AUTOKILL,          // KWo - 02.05.2006
+   PBCVAR_AUTOREMOVE,
    PBCVAR_AUTOKILLDELAY,     // KWo - 02.05.2006
    PBCVAR_BOTJOINTEAM,       // KWo - 16.09.2006
    PBCVAR_BOTQUOTAMATCH,     // KWo - 16.09.2006
diff -r -u podbot-orig/dll.cpp podbot/dll.cpp
--- podbot-orig/dll.cpp    2007-03-24 21:38:44.000000000 +0100
+++ podbot/dll.cpp    2007-04-24 20:26:25.000000000 +0200
@@ -41,6 +41,7 @@
    {const_cast<char *>(g_rgpszPbCvars[PBCVAR_AIM_TARGET_ANTICIPATION_RATIO]), "2.2", FCVAR_SERVER | FCVAR_EXTDLL},  // KWo - 04.03.2006
    {const_cast<char *>(g_rgpszPbCvars[PBCVAR_AIM_TYPE]),                 "4",    FCVAR_SERVER | FCVAR_EXTDLL},
    {const_cast<char *>(g_rgpszPbCvars[PBCVAR_AUTOKILL]),                 "0.0",  FCVAR_SERVER | FCVAR_EXTDLL},      // KWo - 02.05.2006
+   {const_cast<char *>(g_rgpszPbCvars[PBCVAR_AUTOREMOVE]),               "0.0",  FCVAR_SERVER | FCVAR_EXTDLL},
    {const_cast<char *>(g_rgpszPbCvars[PBCVAR_AUTOKILLDELAY]),            "45.0",  FCVAR_SERVER | FCVAR_EXTDLL},     // KWo - 02.05.2006
    {const_cast<char *>(g_rgpszPbCvars[PBCVAR_BOTJOINTEAM]),              "ANY",  FCVAR_SERVER | FCVAR_EXTDLL},      // KWo - 16.09.2006
    {const_cast<char *>(g_rgpszPbCvars[PBCVAR_BOTQUOTAMATCH]),            "0.0",  FCVAR_SERVER | FCVAR_EXTDLL},      // KWo - 16.09.2006
@@ -1761,6 +1762,9 @@
    bool bAliveHumans; // KWo - 02.05.2006
 
    g_bPathWasCalculated = FALSE; // KWo 24.03.2007
+   
+   char kickcmd[80];
+   int iSkill, iPersonality, iTeam, iClass;
 
    max_bots = g_i_cv_MaxBots;    // KWo - 06.04.2006
    min_bots = g_i_cv_MinBots;    // KWo - 06.04.2006
@@ -2095,6 +2099,95 @@
          UTIL_ServerPrint (g_szWaypointMessage);
       }
    }
+   
+   if (g_b_cv_autoremove && (g_bHumansPrevious) && num_humans <= 0)
+   {
+       g_bHumansPrevious = false;
+       
+       UTIL_HostPrint ("No more human players, removing bots\n");
+       
+       // taken from lines 2644-2667 (removebots) :
+       
+       // removebots is against BotsQuotaMatch - needs make it zero;
+      if (g_i_cv_BotsQuotaMatch > 0) // 16.09.2006
+      {
+         CVAR_SET_STRING (g_rgpszPbCvars[PBCVAR_BOTQUOTAMATCH], "0");
+         g_i_cv_BotsQuotaMatch = 0;
+      }
+
+      g_iPeoBotsKept = ((g_i_cv_MinBots == 0) && !g_bIsDedicatedServer)? 1 : g_i_cv_MinBots;
+
+      for (bot_index = 0; bot_index < gpGlobals->maxClients; bot_index++)
+      {
+         // Reset our Creation Tab if there are still Bots waiting to be spawned
+         memset (&BotCreateTab[bot_index], 0, sizeof (createbot_t));
+         botcreation_time = 0.0;
+
+         // is this slot used?
+         if (bots[bot_index].is_used && !FNullEnt (bots[bot_index].pEdict))
+         {
+            snprintf (kickcmd, sizeof (kickcmd), "kick \"%s\"\n", STRING (bots[bot_index].pEdict->v.netname));
+            SERVER_COMMAND (kickcmd); // kick the bot using (kick "name")
+            bots[bot_index].is_used = FALSE; // KWo - 11.02.2006
+         }
+      }
+   }
+   
+   if (g_b_cv_autoremove && (!g_bHumansPrevious) && num_humans > 0)
+   {
+       g_bHumansPrevious = true;
+       
+       UTIL_HostPrint ("A human is playing, filling server with bots\n");
+       
+       // taken from lines 2540-2585 (fillserver) :
+       
+       // fillserver is against BotsQuotaMatch - needs make it zero;
+      if (g_i_cv_BotsQuotaMatch > 0) // 16.09.2006
+      {
+         CVAR_SET_STRING (g_rgpszPbCvars[PBCVAR_BOTQUOTAMATCH], "0");
+         g_i_cv_BotsQuotaMatch = 0;
+      }
+      if ((arg1 != NULL) && (*arg1 != 0))
+         iSkill = atoi (arg1);
+      else
+         iSkill = 101;
+
+      if ((arg2 != NULL) && (*arg2 != 0))
+         iPersonality = atoi (arg2) - 1;
+      else
+         iPersonality = 5;
+
+      if ((arg3 != NULL) && (*arg3 != 0))
+      {
+         iTeam = atoi (arg3);
+         CVAR_SET_STRING ("mp_limitteams", "0");
+         CVAR_SET_STRING ("mp_autoteambalance", "0");
+      }
+      else
+         iTeam = 5;
+
+      if ((arg4 != NULL) && (*arg4 != 0))
+         iClass = atoi (arg4);
+      else
+         iClass = 5;
+
+      for (bot_index = 0; bot_index < gpGlobals->maxClients; bot_index++)
+      {
+         if (!BotCreateTab[bot_index].bNeedsCreation)
+         {
+            memset (&BotCreateTab[bot_index], 0, sizeof (createbot_t));
+            BotCreateTab[bot_index].bot_skill = iSkill;
+            BotCreateTab[bot_index].bot_personality = iPersonality;
+            BotCreateTab[bot_index].bot_team = iTeam;
+            BotCreateTab[bot_index].bot_class = iClass;
+            BotCreateTab[bot_index].bNeedsCreation = TRUE;
+         }
+      }
+      g_iPeoBotsKept = (max_bots == 0) ? gpGlobals->maxClients : max_bots;
+
+      if (botcreation_time == 0.0)
+         botcreation_time = gpGlobals->time;
+   }
 
 // autokill function here - KWo 02.05.2006
  
diff -r -u podbot-orig/util.cpp podbot/util.cpp
--- podbot-orig/util.cpp    2007-03-25 21:07:36.000000000 +0200
+++ podbot/util.cpp    2007-04-24 19:48:10.000000000 +0200
@@ -886,6 +886,18 @@
       if (CVAR_GET_FLOAT(g_rgpszPbCvars[PBCVAR_AUTOKILL]) > 0.f)
          g_b_cv_autokill = true;
    }
+   
+   g_b_cv_autoremove = false;
+   if (g_rgcvarPointer[PBCVAR_AUTOREMOVE])  // KWo - 13.10.2006
+   {
+      if (g_rgcvarPointer[PBCVAR_AUTOREMOVE]->value > 0.f)
+         g_b_cv_autoremove = true;
+   }
+   else
+   {
+      if (CVAR_GET_FLOAT(g_rgpszPbCvars[PBCVAR_AUTOREMOVE]) > 0.f)
+         g_b_cv_autoremove = true;
+   }
 
    if (g_rgcvarPointer[PBCVAR_AUTOKILLDELAY])  // KWo - 13.10.2006
       g_f_cv_autokilldelay = g_rgcvarPointer[PBCVAR_AUTOKILLDELAY]->value;
To use the new feature : pb_autoremove 1. It has been designed not to interfere too much with manually adding/removing the bots. Basically, it works by doing "removebots" when there is no more human players on the server, and by doing "fillserver" when there is human players on the server.
Hope it'll be useful to someone

Last edited by e-t172; 25-04-2007 at 00:14..
  
Reply With Quote
Re: Remove all bots when there is no human player on the server
Old
  (#4)
Ancient
PodBot MM's Laziest Waypointer
 
Ancient's Avatar
 
Status: Offline
Posts: 1,010
Join Date: Jan 2005
Location: Nebraska, United States of America
Default Re: Remove all bots when there is no human player on the server - 25-04-2007

I don't understand how this feature will help?

The bots are to attract players in the first place....
Unless you have a private server then I could understand.


[Web Designer][Waypointer][Gamer]
CFE Games Administrator
[CFE]Games.com
[Never Trust the Untrusted]
  
Reply With Quote
Re: Remove all bots when there is no human player on the server
Old
  (#5)
e-t172
French
 
e-t172's Avatar
 
Status: Offline
Posts: 3
Join Date: Apr 2007
Location: FRANCE
Default Re: Remove all bots when there is no human player on the server - 25-04-2007

Quote:
Originally Posted by Ancient View Post
I don't understand how this feature will help?

The bots are to attract players in the first place....
Unless you have a private server then I could understand.
It's for a very small LAN (4 PCs). 4 players is not very exciting, so we play with bots. But when there is no human playing, the bots are completly useless. Therefore I did this patch.
  
Reply With Quote
Re: Remove all bots when there is no human player on the server
Old
  (#6)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,425
Join Date: Apr 2004
Default Re: Remove all bots when there is no human player on the server - 25-04-2007

Maybe it was just sufficient to setup podbots so:
pb_minbots 0
pb_maxbots 10
pb_bot_quota_match 1

No humans on the server - no bots is there. One human enters - one bot joins. Next human enters - one bot more joins and it works so until reaching Your pb_maxbots value. If one human disconnects - one bot gets kicked (unless there is more than pb_maxbots humans).

Maybe Your patch wasn't needed at all (but this above might not work with Your code now - try it with original V3B18c).
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com