feat: allow bots to be added into the game even if no default spawn points (ref #511)
This commit is contained in:
parent
a2bb32f80b
commit
05e10bae6e
6 changed files with 36 additions and 4 deletions
|
|
@ -651,6 +651,7 @@ void BotConfig::loadCustomConfig () {
|
|||
|
||||
m_custom["C4ModelName"] = "c4.mdl";
|
||||
m_custom["AMXParachuteCvar"] = "sv_parachute";
|
||||
m_custom["CustomCSDMSpawnPoint"] = "view_spawn";
|
||||
|
||||
// custom initialization
|
||||
if (openConfig ("custom", "Custom config file not found. Loading defaults.", &file)) {
|
||||
|
|
|
|||
|
|
@ -1054,6 +1054,10 @@ void Game::searchEntities (const Vector &position, float radius, EntitySearch fu
|
|||
}
|
||||
}
|
||||
|
||||
bool Game::hasEntityInGame (StringRef classname) {
|
||||
return !isNullEntity (engfuncs.pfnFindEntityByString (nullptr, "classname", classname.chars ()));
|
||||
}
|
||||
|
||||
void Game::printBotVersion () {
|
||||
String gameVersionStr;
|
||||
StringArray botRuntimeFlags;
|
||||
|
|
|
|||
|
|
@ -441,7 +441,12 @@ void BotManager::maintainQuota () {
|
|||
else {
|
||||
desiredBotCount = cr::min <int> (desiredBotCount, maxClients - humanPlayersInGame);
|
||||
}
|
||||
int maxSpawnCount = game.getSpawnCount (Team::Terrorist) + game.getSpawnCount (Team::CT) - humanPlayersInGame;
|
||||
auto maxSpawnCount = game.getSpawnCount (Team::Terrorist) + game.getSpawnCount (Team::CT) - humanPlayersInGame;
|
||||
|
||||
// if has some custom spawn points, max out spawn point counter
|
||||
if (desiredBotCount > botsInGame && hasCustomCSDMSpawnEntities ()) {
|
||||
maxSpawnCount = game.maxClients () + 1;
|
||||
}
|
||||
|
||||
// sent message only to console from here
|
||||
ctrl.setFromConsole (true);
|
||||
|
|
@ -760,6 +765,16 @@ bool BotManager::kickRandom (bool decQuota, Team fromTeam) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BotManager::hasCustomCSDMSpawnEntities () {
|
||||
if (!game.is (GameFlags::CSDM | GameFlags::FreeForAll)) {
|
||||
return false;
|
||||
}
|
||||
auto customSpawnClass = conf.fetchCustom ("CustomCSDMSpawnPoint");
|
||||
|
||||
// check for custom entity
|
||||
return game.hasEntityInGame (customSpawnClass);
|
||||
}
|
||||
|
||||
void BotManager::setLastWinner (int winner) {
|
||||
m_lastWinner = winner;
|
||||
m_roundOver = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue