We now have logic to normally only add one bot per frame. This is all nice,
but breaks the Xonotic Bot Orchestra.
So, let's make it so that the XBO has special privileges to spawn more than
one bot per frame; in normal gameplay bot spawns remain spaced out.
void bot_clientdisconnect(entity this);
void bot_cmdhelp(string scmd);
void bot_endgame();
void bot_clientdisconnect(entity this);
void bot_cmdhelp(string scmd);
void bot_endgame();
+bool bot_fixcount(bool multiple_per_frame);
void bot_list_commands();
void bot_queuecommand(entity bot, string cmdstring);
void bot_relinkplayerlist();
void bot_list_commands();
void bot_queuecommand(entity bot, string cmdstring);
void bot_relinkplayerlist();
jumpheight_time = autocvar_sv_jumpvelocity / autocvar_sv_gravity;
}
jumpheight_time = autocvar_sv_jumpvelocity / autocvar_sv_gravity;
}
+bool bot_fixcount(bool multiple_per_frame)
{
int activerealplayers = 0;
int realplayers = 0;
{
int activerealplayers = 0;
int realplayers = 0;
// only add one bot per frame to avoid utter chaos
if(time > botframe_nextthink)
{
// 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 (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();
}
while (currentbots > bots && bots >= 0)
bot_removenewest();
if(time > botframe_nextthink)
{
if(time > botframe_nextthink)
{
+ if(!bot_fixcount(false))
botframe_nextthink = time + 10;
}
botframe_nextthink = time + 10;
}
+bool bot_fixcount(bool multiple_per_frame);
void bot_think(entity this);
void bot_setnameandstuff(entity this);
void bot_think(entity this);
void bot_setnameandstuff(entity this);
void bot_clientdisconnect(entity this) { }
void bot_cmdhelp(string scmd) { }
void bot_endgame() { }
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() { }
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");
cvar_settemp("minplayers", "0");
cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", "0");
+ bot_fixcount(false); // Kill all bots.
cvar_settemp("bot_number", argv(2));
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)
return;
}
else if (argv(1) == "load" && argc == 3)
cvar_settemp("minplayers", "0");
cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", "0");
cvar_settemp("minplayers", "0");
cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", "0");
+ bot_fixcount(false); // Kill all bots.
cvar_settemp("bot_number", argv(3));
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");
cvar_settemp("minplayers", "0");
cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", argv(1));
cvar_settemp("minplayers", "0");
cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", argv(1));