if(file < 0)
{
- LOG_INFO(strcat("Error: Can not open the bot configuration file '",autocvar_bot_config_file,"'\n"));
+ LOG_INFOF("Error: Can not open the bot configuration file '%s'", autocvar_bot_config_file);
readfile = "";
}
else
continue;
s = argv(0);
prio = 1;
- FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_BOT_CLIENT(it), {
if(s == it.cleanname)
{
prio = 0;
break;
}
- ));
+ });
RandomSelection_AddString(readfile, 1, prio);
}
readfile = RandomSelection_chosen_string;
// number bots with identical names
int j = 0;
- FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_BOT_CLIENT(it), {
if(it.cleanname == name)
++j;
- ));
+ });
if (j)
this.netname = this.netname_freeme = strzone(strcat(prefix, name, "(", ftos(j), ")", suffix));
else
else if(this.bot_forced_team==4)
this.team = NUM_TEAM_4;
else
- JoinBestTeam(this, false, true);
+ JoinBestTeam(this, true);
havocbot_setupbot(this);
}
bestbot = -1;
bestplayer = -1;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(IS_REAL_CLIENT(it))
bestplayer = max(bestplayer, it.totalfrags - it.totalfrags_lastcheck);
else
bestbot = max(bestbot, it.totalfrags - it.totalfrags_lastcheck);
- ));
+ });
LOG_DEBUG("autoskill: best player got ", ftos(bestplayer), ", ");
LOG_DEBUG("best bot got ", ftos(bestbot), "; ");
// don't reset counters, wait for them to accumulate
}
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.totalfrags_lastcheck = it.totalfrags));
+ FOREACH_CLIENT(IS_PLAYER(it), { it.totalfrags_lastcheck = it.totalfrags; });
}
void bot_calculate_stepheightvec()
{
stepheightvec = autocvar_sv_stepheight * '0 0 1';
- jumpstepheightvec = stepheightvec +
- ((autocvar_sv_jumpvelocity * autocvar_sv_jumpvelocity) / (2 * autocvar_sv_gravity)) * '0 0 0.85';
- // 0.75 factor is for safety to make the jumps easy
+ jumpheight_vec = (autocvar_sv_jumpvelocity ** 2) / (2 * autocvar_sv_gravity) * '0 0 1';
+ jumpstepheightvec = stepheightvec + jumpheight_vec * 0.85; // reduce it a bit to make the jumps easy
}
float bot_fixcount()
activerealplayers = M_ARGV(0, int);
realplayers = M_ARGV(1, int);
} else {
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
if(IS_PLAYER(it))
++activerealplayers;
++realplayers;
- ));
+ });
+ }
+ if(currentbots == -1)
+ {
+ currentbots = 0;
+ // human players joining early may cause weird issues (bots appearing on
+ // the scoreboard as spectators) when switching map with the gotomap
+ // command, as it doesn't remove bots of the previous match, and with
+ // minplayers > 1, so ignore human players in the first bot frame
+ // TODO maybe find a cleaner solution
+ activerealplayers = 0;
}
int bots;
// only add one bot per frame to avoid utter chaos
if(time > botframe_nextthink)
{
- //dprint(ftos(bots), " ? ", ftos(currentbots), "\n");
- while (currentbots < bots)
+ if (currentbots < bots)
{
if (bot_spawn() == NULL)
{
return;
if (time < 2)
+ {
+ currentbots = -1;
return;
+ }
+
+ if(autocvar_skill != skill)
+ {
+ float wpcost_update = false;
+ if(skill >= autocvar_bot_ai_bunnyhop_skilloffset && autocvar_skill < autocvar_bot_ai_bunnyhop_skilloffset)
+ wpcost_update = true;
+ if(skill < autocvar_bot_ai_bunnyhop_skilloffset && autocvar_skill >= autocvar_bot_ai_bunnyhop_skilloffset)
+ wpcost_update = true;
+
+ skill = autocvar_skill;
+ if (wpcost_update)
+ waypoint_updatecost_foralllinks();
+ }
bot_calculate_stepheightvec();
bot_navigation_movemode = ((autocvar_bot_navigation_ignoreplayers) ? MOVE_NOMONSTERS : MOVE_NORMAL);
botframe_spawnedwaypoints = true;
waypoint_loadall();
if(!waypoint_load_links())
- waypoint_schedulerelinkall();
+ waypoint_schedulerelinkall(); // link all the autogenerated waypoints (teleporters)
}
if (bot_list)