diff --git a/inc/engine.h b/inc/engine.h index ef2bfd7..3d93303 100644 --- a/inc/engine.h +++ b/inc/engine.h @@ -28,7 +28,8 @@ CR_DECLARE_SCOPED_ENUM (Var, ReadOnly, Password, NoServer, - GameRef + GameRef, + Xash3D // registrable only on xash3d engine ) // supported cs's diff --git a/src/botlib.cpp b/src/botlib.cpp index f5a1175..460151e 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -1124,7 +1124,7 @@ void Bot::buyStuff () { const bool teamHasGoodEconomics = bots.checkTeamEco (m_team); // do this, because xash engine is not capable to run all the features goldsrc, but we have cs 1.6 on it, so buy table must be the same - const bool isOldGame = game.is (GameFlags::Legacy) && !game.is (GameFlags::Xash3D); + const bool isOldGame = game.is (GameFlags::Legacy); const bool hasDefaultPistols = (pev->weapons & (cr::bit (Weapon::USP) | cr::bit (Weapon::Glock18))); const bool isFirstRound = m_moneyAmount == mp_startmoney.int_ (); diff --git a/src/config.cpp b/src/config.cpp index 38b0db8..71e363e 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -33,7 +33,7 @@ void BotConfig::loadConfigs () { } void BotConfig::loadMainConfig (bool isFirstLoad) { - if (game.is (GameFlags::Legacy) && !game.is (GameFlags::Xash3D)) { + if (game.is (GameFlags::Legacy)) { util.setNeedForWelcome (true); } setupMemoryFiles (); @@ -357,7 +357,7 @@ void BotConfig::loadChatterConfig () { } else { cv_radio_mode.set (1); - logger.message ("Bots chatter communication disabled."); + game.print ("Bots chatter communication disabled."); } } @@ -464,13 +464,12 @@ void BotConfig::loadLanguageConfig () { setupMemoryFiles (); if (game.is (GameFlags::Legacy)) { - logger.message ("Bots multilingual system disabled."); - return; // dedicated server will use only english translation + return; // legacy versions will use only english translation } String line; MemFile file; - // localizer inititalization + // localizer initialization if (openConfig ("lang", "Specified language not found.", &file, true)) { String temp; Twin lang; @@ -509,14 +508,14 @@ void BotConfig::loadLanguageConfig () { void BotConfig::loadAvatarsConfig () { setupMemoryFiles (); - if (game.is (GameFlags::Legacy)) { + if (game.is (GameFlags::Legacy) || game.is (GameFlags::Xash3D)) { return; } String line; MemFile file; - // avatars inititalization + // avatars initialization if (openConfig ("avatars", "Avatars config file not found. Avatars will not be displayed.", &file)) { m_avatars.clear (); @@ -580,7 +579,7 @@ void BotConfig::loadDifficultyConfig () { diff->aimError.z = values[8].float_ (); }; - // avatars inititalization + // avatars initialization if (openConfig ("difficulty", "Difficulty config file not found. Loading defaults.", &file)) { while (file.getLine (line)) { @@ -633,7 +632,7 @@ void BotConfig::loadCustomConfig () { m_custom["C4ModelName"] = "c4.mdl"; m_custom["AMXParachuteCvar"] = "sv_parachute"; - // custom inititalization + // custom initialization if (openConfig ("custom", "Custom config file not found. Loading defaults.", &file)) { m_custom.clear (); @@ -664,7 +663,7 @@ void BotConfig::loadLogosConfig () { String line; MemFile file; - // logos inititalization + // logos initialization if (openConfig ("logos", "Logos config file not found. Loading defaults.", &file)) { m_logos.clear (); diff --git a/src/control.cpp b/src/control.cpp index 19da686..5353f77 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -7,7 +7,7 @@ #include -ConVar cv_display_menu_text ("yb_display_menu_text", "1", "Enables or disables display menu text, when players asks for menu. Useful only for Android."); +ConVar cv_display_menu_text ("yb_display_menu_text", "1", "Enables or disables display menu text, when players asks for menu. Useful only for Android.", false, 0.0f, 1.0f, Var::Xash3D); ConVar cv_password ("yb_password", "", "The value (password) for the setinfo key, if user sets correct password, he's gains access to bot commands and menus.", false, 0.0f, 0.0f, Var::Password); ConVar cv_password_key ("yb_password_key", "_ybpw", "The name of setinfo key used to store password to bot commands and menus.", false); @@ -1872,6 +1872,11 @@ bool BotControl::executeMenus () { void BotControl::showMenu (int id) { static bool menusParsed = false; + // xash doesn't show anything useful when menus translated by now, so disable translation for menus on xash3d + if (game.is (GameFlags::Xash3D)) { + menusParsed = true; + } + // make menus looks like we need only once if (!menusParsed) { m_ignoreTranslate = false; // always translate menus diff --git a/src/engine.cpp b/src/engine.cpp index 96c9af8..7cf7bc2 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -722,6 +722,9 @@ void Game::registerCvars (bool gameVars) { cvar_t ® = var.reg; if (var.type != Var::GameRef) { + if (var.type == Var::Xash3D && !is (GameFlags::Xash3D)) { + continue; + } self.ptr = engfuncs.pfnCVarGetPointer (reg.name); if (!self.ptr) { @@ -751,7 +754,7 @@ void Game::registerCvars (bool gameVars) { } if (!self.ptr) { - print ("Got nullptr on cvar %s!", reg.name); + logger.error ("Got nullptr on cvar %s!", reg.name); } } } @@ -818,7 +821,7 @@ bool Game::loadCSBinary () { // detect xash engine if (engfuncs.pfnCVarGetPointer ("host_ver") != nullptr) { - m_gameFlags |= (GameFlags::Legacy | GameFlags::Xash3D); + m_gameFlags |= (GameFlags::Modern | GameFlags::Xash3D); if (entity != nullptr) { m_gameFlags |= GameFlags::HasBotVoice; @@ -835,6 +838,9 @@ bool Game::loadCSBinary () { } else { m_gameFlags |= GameFlags::Legacy; + + // clear modern flag just in case + m_gameFlags &= ~GameFlags::Modern; } if (is (GameFlags::Metamod)) { @@ -874,7 +880,7 @@ bool Game::postload () { plat.setAppName (product.name.chars ()); // register bot cvars - game.registerCvars (); + registerCvars (); // handle prefixes static StringArray prefixes = { product.cmdPri, product.cmdSec }; @@ -1273,7 +1279,7 @@ template bool LightMeasure::recursiveLightPoint (const } float LightMeasure::getLightLevel (const Vector &point) { - if (game.is (GameFlags::Legacy) && !game.is (GameFlags::Xash3D)) { + if (game.is (GameFlags::Legacy)) { return 0.0f; } diff --git a/src/manager.cpp b/src/manager.cpp index 639ba5a..b800ba7 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1493,7 +1493,12 @@ void Bot::newRound () { if (rg.chance (50)) { pushChatterMessage (Chatter::NewRound); } - m_updateInterval = game.is (GameFlags::Legacy | GameFlags::Xash3D) ? 0.0f : (1.0f / cr::clamp (cv_think_fps.float_ (), 30.0f, 60.0f)); + auto interval = cr::clamp (cv_think_fps.float_ (), 24.0f, 90.0f); + + if (game.is (GameFlags::Xash3D) && interval < 50.0f) { + interval = 50.0f; // xash works acceptable at 50fps + } + m_updateInterval = game.is (GameFlags::Legacy) ? 0.0f : 1.0f / interval; } void Bot::resetPathSearchType () { diff --git a/src/navigate.cpp b/src/navigate.cpp index 3d92586..449f0fe 100644 --- a/src/navigate.cpp +++ b/src/navigate.cpp @@ -368,7 +368,7 @@ void Bot::doPlayerAvoidance (const Vector &normal) { m_hindrance = nullptr; float distance = cr::sqrf (348.0f); - if (getCurrentTaskId () == Task::Attack || isOnLadder ()) { + if (getCurrentTaskId () == Task::Attack || isOnLadder () || isInNarrowPlace ()) { return; } const auto ownPrio = bots.getPlayerPriority (ent ()); @@ -477,7 +477,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) { // not stuck? if (!m_isStuck) { - if (m_probeTime + rg.get (0.5f, 1.0f) < game.time ()) { + if (m_probeTime + rg.get (0.75f, 1.15f) < game.time ()) { resetCollision (); // reset collision memory if not being stuck for 0.5 secs } else { diff --git a/src/support.cpp b/src/support.cpp index fe1d465..9a9c673 100644 --- a/src/support.cpp +++ b/src/support.cpp @@ -496,7 +496,7 @@ void BotSupport::installSendTo () { m_sendToDetour.initialize ("ws2_32.dll", "sendto", sendToAddress); // enable only on modern games - if ((game.is (GameFlags::Modern) || game.is (GameFlags::Xash3D)) && (plat.nix || plat.win) && !plat.arm && !m_sendToDetour.detoured ()) { + if (!game.is (GameFlags::Legacy) && (plat.nix || plat.win) && !plat.arm && !m_sendToDetour.detoured ()) { m_sendToDetour.install (reinterpret_cast (BotSupport::sendTo), true); } } diff --git a/src/tasks.cpp b/src/tasks.cpp index d3b2c78..9142d7a 100644 --- a/src/tasks.cpp +++ b/src/tasks.cpp @@ -67,9 +67,10 @@ void Bot::normal_ () { // reached node is a camp node if ((m_pathFlags & NodeFlag::Camp) && !game.is (GameFlags::CSDM) && cv_camping_allowed.bool_ () && !isKnifeMode ()) { + const bool allowedCampWeapon = hasPrimaryWeapon () || (hasSecondaryWeapon () && m_numFriendsLeft > game.maxClients () / 4); // check if bot has got a primary weapon and hasn't camped before - if (hasPrimaryWeapon () && m_timeCamping + 10.0f < game.time () && !m_hasHostage) { + if (allowedCampWeapon && m_timeCamping + 10.0f < game.time () && !m_hasHostage) { bool campingAllowed = true; // Check if it's not allowed for this team to camp here