void bot_clientdisconnect(entity this);
void bot_cmdhelp(string scmd);
void bot_endgame();
-bool bot_fixcount();
+bool bot_fixcount(bool multiple_per_frame);
void bot_list_commands();
void bot_queuecommand(entity bot, string cmdstring);
void bot_relinkplayerlist();
jumpheight_time = autocvar_sv_jumpvelocity / autocvar_sv_gravity;
}
-bool bot_fixcount()
+bool bot_fixcount(bool multiple_per_frame)
{
int activerealplayers = 0;
int realplayers = 0;
// only add one bot per frame to avoid utter chaos
if(time > botframe_nextthink)
{
- if (currentbots < bots)
+ while (currentbots < bots)
{
if (bot_spawn() == NULL)
{
bprint("Can not add bot, server full.\n");
return false;
}
+ if (!multiple_per_frame)
+ {
+ break;
+ }
}
while (currentbots > bots && bots >= 0)
bot_removenewest();
if(time > botframe_nextthink)
{
- if(!bot_fixcount())
+ if(!bot_fixcount(false))
botframe_nextthink = time + 10;
}
*/
entity bot_spawn();
-bool bot_fixcount();
+bool bot_fixcount(bool multiple_per_frame);
void bot_think(entity this);
void bot_setnameandstuff(entity this);
void bot_clientdisconnect(entity this) { }
void bot_cmdhelp(string scmd) { }
void bot_endgame() { }
-bool bot_fixcount() { return true; }
+bool bot_fixcount(bool multiple_per_frame) { return true; }
void bot_list_commands() { }
void bot_queuecommand(entity bot, string cmdstring) { }
void bot_relinkplayerlist() { }
cvar_settemp("minplayers", "0");
cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", "0");
- bot_fixcount();
+ bot_fixcount(false); // Kill all bots.
cvar_settemp("bot_number", argv(2));
- if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count");
+ if (!bot_fixcount(true)) LOG_INFO("Sorry, could not set requested bot count");
return;
}
else if (argv(1) == "load" && argc == 3)
cvar_settemp("minplayers", "0");
cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", "0");
- bot_fixcount();
+ bot_fixcount(false); // Kill all bots.
cvar_settemp("bot_number", argv(3));
- if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count");
+ if (!bot_fixcount(true)) LOG_INFO("Sorry, could not set requested bot count");
}
else
{
cvar_settemp("minplayers", "0");
cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", argv(1));
- bot_fixcount();
+ bot_fixcount(true);
return;
}
}