X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fdefault%2Fbot.qc;h=3911d596dc51859afd8058272ec394bf402014a7;hb=797bf448a96c0c13d783c7c919bb2caf6fa16707;hp=50c4fd06a775038394b4ce56792b00a11635c39b;hpb=5d7faa5a29c0eb014b973c34e057b8774d3f0db9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index 50c4fd06a..3911d596d 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -41,6 +41,8 @@ #include #include +STATIC_INIT(bot) { bot_calculate_stepheightvec(); } + // TODO: remove this function! its only purpose is to update these fields since bot_setnameandstuff is called before ClientState void bot_setclientfields(entity this) { @@ -123,6 +125,9 @@ void bot_think(entity this) // if dead, just wait until we can respawn if (IS_DEAD(this)) { + if (bot_waypoint_queue_owner == this) + bot_waypoint_queue_owner = NULL; + this.aistatus = 0; CS(this).movement = '0 0 0'; if (this.deadflag == DEAD_DEAD) { @@ -210,13 +215,13 @@ void bot_setnameandstuff(entity this) prio = 6; - #define READSKILL(f, w, r) MACRO_BEGIN { \ + #define READSKILL(f, w, r) MACRO_BEGIN \ if(argv(prio) != "") \ this.f = stof(argv(prio)) * w; \ else \ this.f = (!autocvar_g_campaign) * (2 * random() - 1) * r * w; \ prio++; \ - } MACRO_END + MACRO_END //print(bot_name, ": ping=", argv(9), "\n"); READSKILL(havocbot_keyboardskill, 0.5, 0.5); // keyboard skill @@ -575,7 +580,7 @@ void bot_calculate_stepheightvec() jumpstepheightvec = stepheightvec + jumpheight_vec * 0.85; // reduce it a bit to make the jumps easy } -float bot_fixcount() +bool bot_fixcount() { int activerealplayers = 0; int realplayers = 0; @@ -591,8 +596,6 @@ float bot_fixcount() } int bots; - // add/remove bots if needed to make sure there are at least - // minplayers+bot_number, or remove all bots if no one is playing // But don't remove bots immediately on level change, as the real players // usually haven't rejoined yet bots_would_leave = false; @@ -600,15 +603,19 @@ float bot_fixcount() bots = min(ceil(fabs(autocvar_bot_vs_human) * activerealplayers), maxclients - realplayers); else if ((realplayers || autocvar_bot_join_empty || (currentbots > 0 && time < 5))) { - float realminplayers, minplayers; - realminplayers = autocvar_minplayers; - minplayers = max(0, floor(realminplayers)); + int minplayers = max(0, floor(autocvar_minplayers)); + if (teamplay) + minplayers = max(0, floor(autocvar_minplayers_per_team) * AvailableTeams()); + int minbots = max(0, floor(autocvar_bot_number)); - float realminbots, minbots; - realminbots = autocvar_bot_number; - minbots = max(0, floor(realminbots)); + // add bots to reach minplayers if needed + bots = max(minbots, minplayers - activerealplayers); + // cap bots to the max players allowed by the server + int player_limit = GetPlayerLimit(); + if(player_limit) + bots = min(bots, max(player_limit - activerealplayers, 0)); + bots = min(bots, maxclients - realplayers); - bots = min(max(minbots, minplayers - activerealplayers), maxclients - realplayers); if(bots > minbots) bots_would_leave = true; } @@ -629,7 +636,7 @@ float bot_fixcount() return false; } } - while (currentbots > bots) + while (currentbots > bots && bots >= 0) bot_removenewest(); }