Merge branch 'master' into chatter-fixes-and-improvements

This commit is contained in:
Владислав Сухов 2024-05-26 06:26:03 +00:00
commit de38555aa1
11 changed files with 112 additions and 36 deletions

View file

@ -50,3 +50,11 @@ ZMDelayCvar = zp_delay
; Valid values: T, CT. ; Valid values: T, CT.
; ;
ZMInfectedTeam = T ZMInfectedTeam = T
;
; This decides if fake features (like a fake time, fake SID (avatar), fakeping)
; should be enabled whitin bot code. By default it's off. To enable it you're
; should provide variable with: "i'm confident for what i'm doing" value.
;
EnableFakeBotFeatures = no

View file

@ -259,9 +259,9 @@ yb_chat_percent "30"
// //
// Specifies whether bots able to fire at enemies behind the wall, if they hearing or suspecting them. // Specifies whether bots able to fire at enemies behind the wall, if they hearing or suspecting them.
// --- // ---
// Default: "1", Min: "0", Max: "3" // Default: "2", Min: "0", Max: "3"
// //
yb_shoots_thru_walls "1" yb_shoots_thru_walls "2"
// //
// Enables or disables searching world for enemies. // Enables or disables searching world for enemies.
@ -333,6 +333,13 @@ yb_password ""
// //
yb_password_key "_ybpw" yb_password_key "_ybpw"
//
// Allows to use classic bot kill on issuing end-round command in menus, instead of gamedll endround.
// ---
// Default: "0"
//
yb_bots_kill_on_endround "0"
// //
// Enables or disables CSDM / FFA mode for bots. // Enables or disables CSDM / FFA mode for bots.
// Allowed values: '0', '1', '2', '3'. // Allowed values: '0', '1', '2', '3'.
@ -369,10 +376,38 @@ yb_grenadier_mode "0"
// //
// Make bots ignore enemies for a specified here time in seconds on new round. Useful for Zombie Plague mods. // Make bots ignore enemies for a specified here time in seconds on new round. Useful for Zombie Plague mods.
// --- // ---
// Default: "0", Min: "0", Max: "540" // Default: "0"
// //
yb_ignore_enemies_after_spawn_time "0" yb_ignore_enemies_after_spawn_time "0"
//
// Lower bound for base bot ping shown in scoreboard upon creation.
// ---
// Default: "5", Min: "0", Max: "100"
//
yb_ping_base_min "5"
//
// Upper bound for base bot ping shown in scoreboard upon creation.
// ---
// Default: "20", Min: "0", Max: "100"
//
yb_ping_base_max "20"
//
// Count player pings when calculating average ping for bots. If no, some random ping chosen for bots.
// ---
// Default: "1", Min: "0", Max: "1"
//
yb_ping_count_real_players "1"
//
// Interval in which fakeping get updated in scoreboard.
// ---
// Default: "1.2", Min: "0.1", Max: "10.0"
//
yb_ping_updater_interval "1.2"
// //
// Specifies whether bot should not 'fix' camp directions of camp waypoints when loading old PWF format. // Specifies whether bot should not 'fix' camp directions of camp waypoints when loading old PWF format.
// --- // ---
@ -540,9 +575,9 @@ yb_difficulty_auto_balance_interval "30"
// //
// 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. // 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.
// --- // ---
// Default: "1", Min: "0", Max: "1" // Default: "0", Min: "0", Max: "1"
// //
yb_show_avatars "1" yb_show_avatars "0"
// //
// Enables latency display in scoreboard. // Enables latency display in scoreboard.
@ -551,9 +586,9 @@ yb_show_avatars "1"
// If '1', there is a 'BOT' is displayed. // If '1', there is a 'BOT' is displayed.
// If '2' fake ping is displayed. // If '2' fake ping is displayed.
// --- // ---
// Default: "2", Min: "0", Max: "2" // Default: "0", Min: "0", Max: "2"
// //
yb_show_latency "2" yb_show_latency "0"
// //
// Allows to save bot names upon changelevel, so bot names will be the same after a map change. // Allows to save bot names upon changelevel, so bot names will be the same after a map change.
@ -585,20 +620,6 @@ yb_botskin_ct "0"
// //
yb_preferred_personality "none" yb_preferred_personality "none"
//
// Lower bound for base bot ping shown in scoreboard upon creation.
// ---
// Default: "7", Min: "0", Max: "100"
//
yb_ping_base_min "7"
//
// Upper bound for base bot ping shown in scoreboard upon creation.
// ---
// Default: "34", Min: "0", Max: "100"
//
yb_ping_base_max "34"
// //
// Interval in which bots are added to the game. // Interval in which bots are added to the game.
// --- // ---
@ -711,13 +732,6 @@ yb_breakable_health_limit "500.0"
// //
yb_enable_fake_steamids "0" yb_enable_fake_steamids "0"
//
// Count player pings when calculating average ping for bots. If no, some random ping chosen for bots.
// ---
// Default: "1", Min: "0", Max: "1"
//
yb_count_players_for_fakeping "1"
// //
// Specifies whether bots able to use 'shift' if they thinks that enemy is near. // Specifies whether bots able to use 'shift' if they thinks that enemy is near.
// --- // ---

View file

@ -227,6 +227,9 @@ public:
// print the version to server console on startup // print the version to server console on startup
void printBotVersion (); void printBotVersion ();
// ensure prosperous gaming environment as per: https://github.com/yapb/yapb/issues/575
void ensureHealthyGameEnvironment ();
// public inlines // public inlines
public: public:
// get the current time on server // get the current time on server

View file

@ -892,6 +892,7 @@ extern ConVar cv_ignore_objectives;
extern ConVar cv_chat; extern ConVar cv_chat;
extern ConVar cv_language; extern ConVar cv_language;
extern ConVar cv_show_latency; extern ConVar cv_show_latency;
extern ConVar cv_show_avatars;
extern ConVar cv_enable_query_hook; extern ConVar cv_enable_query_hook;
extern ConVar cv_chatter_path; extern ConVar cv_chatter_path;
extern ConVar cv_quota; extern ConVar cv_quota;

View file

@ -917,7 +917,7 @@ void Bot::instantChatter (int type) {
void Bot::pushRadioMessage (int message) { void Bot::pushRadioMessage (int message) {
// this function inserts the radio message into the message queue // this function inserts the radio message into the message queue
if (cv_radio_mode.as <int> () == 0 || m_numFriendsLeft == 0) { if (cv_radio_mode.as <int> () == 0 || m_numFriendsLeft == 0 || m_isCreature) {
return; return;
} }
m_forceRadio = !game.is (GameFlags::HasBotVoice) m_forceRadio = !game.is (GameFlags::HasBotVoice)
@ -931,7 +931,7 @@ void Bot::pushRadioMessage (int message) {
void Bot::pushChatterMessage (int message) { void Bot::pushChatterMessage (int message) {
// this function inserts the voice message into the message queue (mostly same as above) // this function inserts the voice message into the message queue (mostly same as above)
if (!game.is (GameFlags::HasBotVoice) || cv_radio_mode.as <int> () != 2 || !conf.hasChatterBank (message) || m_numFriendsLeft == 0) { if (!game.is (GameFlags::HasBotVoice) || m_isCreature || cv_radio_mode.as <int> () != 2 || !conf.hasChatterBank (message) || m_numFriendsLeft == 0) {
return; return;
} }
bool sendMessage = false; bool sendMessage = false;
@ -2345,7 +2345,7 @@ void Bot::checkRadioQueue () {
// don't allow bot listen you if bot is busy // don't allow bot listen you if bot is busy
if (m_radioOrder != Radio::ReportInTeam && (getCurrentTaskId () == Task::DefuseBomb || getCurrentTaskId () == Task::PlantBomb || m_hasHostage || m_hasC4)) { if (getCurrentTaskId () == Task::DefuseBomb || getCurrentTaskId () == Task::PlantBomb || m_hasHostage || m_hasC4 || m_isCreature) {
m_radioOrder = 0; m_radioOrder = 0;
return; return;
} }

View file

@ -374,7 +374,7 @@ void Bot::checkForChat () {
void Bot::sendToChat (StringRef message, bool teamOnly) { void Bot::sendToChat (StringRef message, bool teamOnly) {
// this function prints saytext message to all players // this function prints saytext message to all players
if (message.empty () || !cv_chat) { if (m_isCreature || message.empty () || !cv_chat) {
return; return;
} }
issueCommand ("%s \"%s\"", teamOnly ? "say_team" : "say", message); issueCommand ("%s \"%s\"", teamOnly ? "say_team" : "say", message);

View file

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

View file

@ -72,6 +72,9 @@ void Game::levelInitialize (edict_t *entities, int max) {
// execute main config // execute main config
conf.loadMainConfig (); conf.loadMainConfig ();
// ensure the server admin is confident about features he's using
game.ensureHealthyGameEnvironment ();
// load map-specific config // load map-specific config
conf.loadMapSpecificConfig (); conf.loadMapSpecificConfig ();
@ -1010,6 +1013,9 @@ void Game::slowFrame () {
// refresh bomb origin in case some plugin moved it out // refresh bomb origin in case some plugin moved it out
graph.setBombOrigin (); graph.setBombOrigin ();
// ensure the server admin is confident about features he's using
game.ensureHealthyGameEnvironment ();
// update next update time // update next update time
m_halfSecondFrame = nextUpdate * 0.25f + time (); m_halfSecondFrame = nextUpdate * 0.25f + time ();
} }
@ -1150,6 +1156,48 @@ 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, ", ")); 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 () || game.is (GameFlags::Legacy | GameFlags::Xash3D)) {
return; // listen servers doesn't care about it at all
}
// magic string that's enables 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;
}
auto notifyPeacefulRevert = [] (const ConVar &cv) {
game.print ("Cvar \"%s\" reverted to peaceful value.", cv.name ());
};
// disable fake latency
if (cv_show_latency.as <int> () > 1) {
cv_show_latency.set (0);
notifyPeacefulRevert (cv_show_latency);
}
// disable fake avatars
if (cv_show_avatars) {
cv_show_avatars.set (0);
notifyPeacefulRevert (cv_show_avatars);
}
// disable fake queries
if (cv_enable_query_hook) {
cv_enable_query_hook.set (0);
notifyPeacefulRevert (cv_enable_query_hook);
}
}
void LightMeasure::initializeLightstyles () { void LightMeasure::initializeLightstyles () {
// this function initializes lighting information... // 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 // using pfnMessageBegin (), it will know what message ID number to send, and the engine will
// know what to do, only for non-metamod version // 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 ("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_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_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", "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_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_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); 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"; " http://www.botepidemic.com/podbot for Updates\n";
// it's should be send in very rare cases // 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)) { if (!graphAuthor.startsWith (product.name)) {
authorStr.assignf ("Navigation Graph by: %s", graphAuthor); authorStr.assignf ("Navigation Graph by: %s", graphAuthor);