Correct team kicking on quota balancing.

Try to fix low-skill bots do not search for bomb.
Bumped year and version.
This commit is contained in:
jeefo 2019-05-05 18:52:28 +03:00
commit c70e3bd756
4 changed files with 52 additions and 15 deletions

View file

@ -11,12 +11,12 @@
// general product information
#define PRODUCT_NAME "Yet Another POD-Bot"
#define PRODUCT_VERSION "2.9"
#define PRODUCT_VERSION "2.10"
#define PRODUCT_AUTHOR "YaPB Dev Team"
#define PRODUCT_URL "https://yapb.ru/"
#define PRODUCT_EMAIL "d@entix.io"
#define PRODUCT_LOGTAG "YAPB"
#define PRODUCT_END_YEAR "2018"
#define PRODUCT_END_YEAR "2019"
#define PRODUCT_DESCRIPTION PRODUCT_NAME " v" PRODUCT_VERSION " - The Counter-Strike Bot (" PRODUCT_COMMENTS ")"
#define PRODUCT_COPYRIGHT "Copyright © 1999-" PRODUCT_END_YEAR ", by " PRODUCT_AUTHOR
#define PRODUCT_LEGAL "Half-Life, Counter-Strike, Counter-Strike: Condition Zero, Steam, Valve is a trademark of Valve Corporation"
@ -25,7 +25,7 @@
#define PRODUCT_GIT_HASH "unspecified_hash"
#define PRODUCT_GIT_COMMIT_AUTHOR "unspecified_author"
#define PRODUCT_GIT_COMMIT_ID 0000
#define PRODUCT_VERSION_DWORD_INTERNAL 2, 9
#define PRODUCT_VERSION_DWORD_INTERNAL 2, 10
#define PRODUCT_VERSION_DWORD PRODUCT_VERSION_DWORD_INTERNAL, PRODUCT_GIT_COMMIT_ID
#define PRODUCT_SUPPORT_VERSION "Beta 6.6 - Condition Zero"
#define PRODUCT_COMMENTS "http://github.com/jeefo/yapb/"

View file

@ -512,7 +512,7 @@ constexpr int MAX_PATH_INDEX = 8;
constexpr int MAX_DAMAGE_VALUE = 2040;
constexpr int MAX_GOAL_VALUE = 2040;
constexpr int MAX_KILL_HISTORY = 16;
constexpr int MAX_WAYPOINTS = 3072;
constexpr int MAX_WAYPOINTS = 2048;
constexpr int MAX_ROUTE_LENGTH = MAX_WAYPOINTS / 2;
constexpr int MAX_WEAPONS = 32;
constexpr int NUM_WEAPONS = 26;
@ -1328,6 +1328,7 @@ public:
int getHumansCount (bool ignoreSpectators = false);
int getAliveHumansCount (void);
int getBotCount (void);
void countTeamPlayers (int &ts, int &cts);
void framePeriodic (void);
void frame (void);
@ -1347,7 +1348,7 @@ public:
void serverFill (int selection, int personality = PERSONALITY_NORMAL, int difficulty = -1, int numToAdd = -1);
void kickEveryone (bool instant = false, bool zeroQuota = true);
void kickRandom (bool decQuota = true);
void kickRandom (bool decQuota = true, Team fromTeam = TEAM_UNASSIGNED);
void kickBot (int index);
void kickFromTeam (Team team, bool removeAll = false);

View file

@ -2913,7 +2913,7 @@ void Bot::frame (void) {
if (g_bombPlanted && m_team == TEAM_COUNTER) {
const Vector &bombPosition = waypoints.getBombPos ();
if (!m_hasProgressBar && taskId () != TASK_ESCAPEFROMBOMB && (pev->origin - bombPosition).length () < 700.0f && !isBombDefusing (bombPosition)) {
if (!m_hasProgressBar && taskId () != TASK_ESCAPEFROMBOMB && (pev->origin - bombPosition).lengthSq () < cr::square (1540.0f) && m_moveSpeed < pev->maxspeed && !isBombDefusing (bombPosition)) {
clearTasks ();
}
}

View file

@ -423,7 +423,18 @@ void BotManager::maintainQuota (void) {
createRandom ();
}
else if (desiredBotCount < botsInGame) {
kickRandom (false);
int ts, cts = 0;
countTeamPlayers (ts, cts);
if (ts > cts) {
kickRandom (false, TEAM_TERRORIST);
}
else if (ts < cts) {
kickRandom (false, TEAM_COUNTER);
}
else {
kickRandom (false, TEAM_UNASSIGNED);
}
}
m_quotaMaintainTime = engine.timebase () + 0.40f;
}
@ -590,22 +601,30 @@ void BotManager::kickBot (int index) {
}
}
void BotManager::kickRandom (bool decQuota) {
void BotManager::kickRandom (bool decQuota, Team fromTeam) {
// this function removes random bot from server (only yapb's)
// if forTeam is unassigned, that means random team
bool deadBotFound = false;
auto updateQuota = [&](void) {
auto updateQuota = [&] (void) {
if (decQuota) {
decrementQuota ();
}
};
auto belongsTeam = [&] (Bot *bot) {
if (fromTeam == TEAM_UNASSIGNED) {
return true;
}
return bot->m_team == fromTeam;
};
// first try to kick the bot that is currently dead
for (int i = 0; i < engine.maxClients (); i++) {
auto bot = bots.getBot (i);
auto bot = m_bots[i];
if (bot != nullptr && !bot->m_notKilled) // is this slot used?
if (bot && !bot->m_notKilled && belongsTeam (bot)) // is this slot used?
{
updateQuota ();
bot->kick ();
@ -625,9 +644,9 @@ void BotManager::kickRandom (bool decQuota) {
// search bots in this team
for (int i = 0; i < engine.maxClients (); i++) {
auto bot = bots.getBot (i);
auto bot = m_bots [i];
if (bot != nullptr && bot->pev->frags < score) {
if (bot && bot->pev->frags < score && belongsTeam (bot)) {
index = i;
score = bot->pev->frags;
}
@ -643,10 +662,12 @@ void BotManager::kickRandom (bool decQuota) {
// worst case, just kick some random bot
for (int i = 0; i < engine.maxClients (); i++) {
if (m_bots[i] != nullptr) // is this slot used?
auto bot = m_bots[i];
if (bot && belongsTeam (bot)) // is this slot used?
{
updateQuota ();
m_bots[i]->kick ();
bot->kick ();
break;
}
@ -721,6 +742,21 @@ int BotManager::getBotCount (void) {
return count;
}
void BotManager::countTeamPlayers (int &ts, int &cts) {
for (int i = 0; i < engine.maxClients (); i++) {
const Client &client = g_clients[i];
if (client.flags & CF_USED) {
if (client.team2 == TEAM_TERRORIST) {
ts++;
}
else if (client.team2 == TEAM_COUNTER) {
cts++;
}
}
}
}
Bot *BotManager::getHighfragBot (int team) {
int bestIndex = 0;
float bestScore = -1;