bot: disable fake bot features by default (ref #575)

This commit is contained in:
jeefo 2024-05-24 14:17:37 +03:00 committed by jeefo
commit b72f8a2ef9
9 changed files with 104 additions and 32 deletions

View file

@ -670,6 +670,7 @@ void BotConfig::loadCustomConfig () {
m_custom["ZMDetectCvar"] = "zp_delay";
m_custom["ZMDelayCvar"] = "zp_delay";
m_custom["ZMInfectedTeam"] = "T";
m_custom["EnableFakeBotFeatures"] = "no";
};
setDefaults ();

View file

@ -72,6 +72,9 @@ void Game::levelInitialize (edict_t *entities, int max) {
// execute main config
conf.loadMainConfig ();
// ensure the server admin is confident about features he's using
game.ensureHealthyGameEnvironment ();
// load map-specific config
conf.loadMapSpecificConfig ();
@ -1010,6 +1013,9 @@ void Game::slowFrame () {
// refresh bomb origin in case some plugin moved it out
graph.setBombOrigin ();
// ensure the server admin is confident about features he's using
game.ensureHealthyGameEnvironment ();
// update next update time
m_halfSecondFrame = nextUpdate * 0.25f + time ();
}
@ -1150,6 +1156,44 @@ void Game::printBotVersion () {
ctrl.msg ("\n%s v%s successfully loaded for game: Counter-Strike %s.\n\tFlags: %s.\n", product.name, product.version, gameVersionStr, botRuntimeFlags.empty () ? "None" : String::join (botRuntimeFlags, ", "));
}
void Game::ensureHealthyGameEnvironment () {
if (!isDedicated ()) {
return; // listen servers doesn't care about it at all
}
// magic string that's enable's the features
constexpr auto kAllowHash = StringRef::fnv1a32 ("i'm confident for what i'm doing");
// fetch custom variable, so fake features are explicitly enabled
static auto enableFakeFeatures = StringRef::fnv1a32 (conf.fetchCustom ("EnableFakeBotFeatures").chars ());
// if string matches, do not affect the cvars
if (enableFakeFeatures == kAllowHash) {
return;
}
// disable fake latency
if (cv_show_latency.as <int> () > 1) {
cv_show_latency.set (0);
game.print ("Cvar \"%s_show_latency\" reverted to peaceful value.", product.cmdPri);
}
// disable fake avatars
if (cv_show_avatars) {
cv_show_avatars.set (0);
game.print ("Cvar \"%s_show_avatars\" reverted to peaceful value.", product.cmdPri);
}
// disable fake queries
if (cv_enable_query_hook) {
cv_enable_query_hook.set (0);
game.print ("Cvar \"%s_enable_query_hook\" reverted to peaceful value.", product.cmdPri);
}
}
void LightMeasure::initializeLightstyles () {
// this function initializes lighting information...

View file

@ -704,7 +704,7 @@ CR_LINKAGE_C int GetEngineFunctions (enginefuncs_t *table, int *) {
// using pfnMessageBegin (), it will know what message ID number to send, and the engine will
// know what to do, only for non-metamod version
return msgs.add (name, engfuncs.pfnRegUserMsg (name, size)); // return privously registered message
return msgs.add (name, engfuncs.pfnRegUserMsg (name, size)); // return previously registered message
};
}

View file

@ -31,8 +31,9 @@ ConVar cv_difficulty_max ("difficulty_max", "-1", "Upper bound of random difficu
ConVar cv_difficulty_auto ("difficulty_auto", "0", "Allows each bot to balance their own difficulty based kd-ratio of team.", true, 0.0f, 1.0f);
ConVar cv_difficulty_auto_balance_interval ("difficulty_auto_balance_interval", "30", "Interval in which bots will balance their difficulty.", true, 30.0f, 240.0f);
ConVar cv_show_avatars ("show_avatars", "1", "Enables or disables displaying bot avatars in front of their names in scoreboard. Note, that is currently you can see only avatars of your steam friends.");
ConVar cv_show_latency ("show_latency", "2", "Enables latency display in scoreboard.\nAllowed values: '0', '1', '2'.\nIf '0', there is nothing displayed.\nIf '1', there is a 'BOT' is displayed.\nIf '2' fake ping is displayed.", true, 0.0f, 2.0f);
ConVar cv_show_avatars ("show_avatars", "0", "Enables or disables displaying bot avatars in front of their names in scoreboard. Note, that is currently you can see only avatars of your steam friends.");
ConVar cv_show_latency ("show_latency", "0", "Enables latency display in scoreboard.\nAllowed values: '0', '1', '2'.\nIf '0', there is nothing displayed.\nIf '1', there is a 'BOT' is displayed.\nIf '2' fake ping is displayed.", true, 0.0f, 2.0f);
ConVar cv_save_bots_names ("save_bots_names", "1", "Allows to save bot names upon changelevel, so bot names will be the same after a map change.", true, 0.0f, 1.0f);
ConVar cv_botskin_t ("botskin_t", "0", "Specifies the bots wanted skin for Terrorist team.", true, 0.0f, 5.0f);

View file

@ -286,7 +286,7 @@ void BotSupport::checkWelcome () {
" http://www.botepidemic.com/podbot for Updates\n";
// it's should be send in very rare cases
const bool sendLegacyWelcome = rg.chance (2);
const bool sendLegacyWelcome = rg.chance (game.is (GameFlags::Legacy) ? 25 : 2);
if (!graphAuthor.startsWith (product.name)) {
authorStr.assignf ("Navigation Graph by: %s", graphAuthor);