diff --git a/README.md b/README.md index 3d1201bf7..7bdfc9f81 100644 --- a/README.md +++ b/README.md @@ -128,11 +128,11 @@ This means that plugins that do binary code analysis (Orpheu for example) probab ## How to install zBot for CS 1.6? * Extract all the files from an [archive](regamedll/extra/zBot/bot_profiles.zip?raw=true) -* Enter `-bots` option at the command line HLDS +* Enable CVar `bot_enable 1` in `cstrike/game_init.cfg` (if this config file does not exist, create it) -## How to install CSCZ hostage AI for CS 1.6? +## How to install CS:CZ hostage AI for CS 1.6? * Extract all the files from an [archive](regamedll/extra/HostageImprov/host_improv.zip?raw=true) -* Enter `-host-improv` option at the command line HLDS +* Enable CVar `hostage_ai_enable 1` in `cstrike/game_init.cfg` (if this config file does not exist, create it) ## Build instructions ### Checking requirements diff --git a/dist/game_init.cfg b/dist/game_init.cfg index 90e31b2d5..de6cb5326 100644 --- a/dist/game_init.cfg +++ b/dist/game_init.cfg @@ -1,3 +1,18 @@ +// Enables ZBots for the server +// NOTE: ZBots are always enabled on a listen server, regardless of this cvar +// 0 - disabled +// 1 - enabled +// +// Default value: "0" +bot_enable "0" + +// Enables the improve AI for hostages from CS:CZ +// 0 - disabled (classic hostage) +// 1 - enabled (improved hostage) +// +// Default value: "0" +hostage_ai_enable "0" + // Sets mins/maxs hull bounds for the player. // 0 - disabled (default behaviour, sets engine) // 1 - enabled (sets gamedll) diff --git a/regamedll/dlls/bot/cs_bot_init.cpp b/regamedll/dlls/bot/cs_bot_init.cpp index 1bf7aec00..665b3c337 100644 --- a/regamedll/dlls/bot/cs_bot_init.cpp +++ b/regamedll/dlls/bot/cs_bot_init.cpp @@ -28,6 +28,7 @@ #include "precompiled.h" +cvar_t cv_bot_enable = { "bot_enable", "0", 0, 0.0f, nullptr }; cvar_t cv_bot_traceview = { "bot_traceview", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_stop = { "bot_stop", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_show_nav = { "bot_show_nav", "0", FCVAR_SERVER, 0.0f, nullptr }; diff --git a/regamedll/dlls/bot/cs_bot_init.h b/regamedll/dlls/bot/cs_bot_init.h index 8687e3f7f..b50e020c3 100644 --- a/regamedll/dlls/bot/cs_bot_init.h +++ b/regamedll/dlls/bot/cs_bot_init.h @@ -28,6 +28,7 @@ #pragma once +extern cvar_t cv_bot_enable; extern cvar_t cv_bot_traceview; extern cvar_t cv_bot_stop; extern cvar_t cv_bot_show_nav; diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 3f26b8554..12f63c1a7 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -460,9 +460,18 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&vote_flags); CVAR_REGISTER(&votemap_min_time); + CVAR_REGISTER(&cv_bot_enable); + CVAR_REGISTER(&cv_hostage_ai_enable); + // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); + // execute initial pre-configurations + SERVER_COMMAND("exec game_init.cfg\n"); + SERVER_EXECUTE(); + + Regamedll_Game_Init(); + #endif // REGAMEDLL_ADD Bot_RegisterCVars(); @@ -473,12 +482,6 @@ void EXT_FUNC GameDLLInit() VoiceGameMgr_RegisterCVars(); #endif -#ifdef REGAMEDLL_ADD - // execute initial pre-configurations - SERVER_COMMAND("exec game_init.cfg\n"); - SERVER_EXECUTE(); -#endif - } SpewRetval_t GameDLL_SpewHandler(SpewType_t spewType, int level, const char *pMsg) diff --git a/regamedll/dlls/h_export.cpp b/regamedll/dlls/h_export.cpp index 486a3eedf..544a92ffb 100644 --- a/regamedll/dlls/h_export.cpp +++ b/regamedll/dlls/h_export.cpp @@ -13,7 +13,6 @@ C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable, global gpGlobals = pGlobals; FileSystem_Init(); - Regamedll_Game_Init(); } #if defined(_LINUX) diff --git a/regamedll/dlls/hostage/hostage.cpp b/regamedll/dlls/hostage/hostage.cpp index 7ef34b222..e3ddd6750 100644 --- a/regamedll/dlls/hostage/hostage.cpp +++ b/regamedll/dlls/hostage/hostage.cpp @@ -28,6 +28,7 @@ #include "precompiled.h" +cvar_t cv_hostage_ai_enable = { "hostage_ai_enable", "1", 0, 1.0f, nullptr }; cvar_t cv_hostage_debug = { "hostage_debug", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_hostage_stop = { "hostage_stop", "0", FCVAR_SERVER, 0.0f, nullptr }; @@ -273,6 +274,7 @@ void CHostage::Precache() static int which = 0; switch (which) { + default: case REGULAR_GUY: pev->model = MAKE_STRING("models/hostageA.mdl"); break; @@ -285,22 +287,25 @@ void CHostage::Precache() case GOOFY_GUY: pev->model = MAKE_STRING("models/hostageD.mdl"); break; - default: - break; } m_whichModel = static_cast(which); if (++which > 3) which = 0; + + if (!g_pFileSystem->FileExists(pev->model)) + { + // It seems that the model is missing, so use classic hostages + g_bHostageImprov = false; + pev->model = iStringNull; + } } - else + + if (pev->model.IsNull()) { m_whichModel = REGULAR_GUY; - if (pev->model.IsNull()) - { - pev->model = MAKE_STRING("models/scientist.mdl"); - } + pev->model = MAKE_STRING("models/scientist.mdl"); } PRECACHE_MODEL(pev->model); diff --git a/regamedll/dlls/hostage/hostage.h b/regamedll/dlls/hostage/hostage.h index 44a501235..6bacec2dc 100644 --- a/regamedll/dlls/hostage/hostage.h +++ b/regamedll/dlls/hostage/hostage.h @@ -77,6 +77,7 @@ enum HostageChatterType extern CHostageManager *g_pHostages; extern int g_iHostageNumber; +extern cvar_t cv_hostage_ai_enable; extern cvar_t cv_hostage_debug; extern cvar_t cv_hostage_stop; diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index de6159469..b1102c470 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -1660,14 +1660,12 @@ int UTIL_ReadFlags(const char *c) // Determine whether bots can be used or not bool UTIL_AreBotsAllowed() { -#ifdef REGAMEDLL_ADD - if (g_engfuncs.pfnEngCheckParm == nullptr) - return false; -#endif - if (AreRunningCZero()) { #ifdef REGAMEDLL_ADD + if (g_engfuncs.pfnEngCheckParm == nullptr) + return false; + // If they pass in -nobots, don't allow bots. This is for people who host servers, to // allow them to disallow bots to enforce CPU limits. int nobots = ENG_CHECK_PARM("-nobots", nullptr); @@ -1687,15 +1685,10 @@ bool UTIL_AreBotsAllowed() return true; } - // allow the using of bots for CS 1.6 - int bots = ENG_CHECK_PARM("-bots", nullptr); - if (bots) - { - return true; - } -#endif - + return cv_bot_enable.value > 0; +#else return false; +#endif } bool UTIL_IsBeta() @@ -1728,18 +1721,10 @@ bool UTIL_AreHostagesImprov() } #ifdef REGAMEDLL_ADD - if (g_engfuncs.pfnEngCheckParm == nullptr) - return false; - - // someday in CS 1.6 - int improv = ENG_CHECK_PARM("-host-improv", nullptr); - if (improv) - { - return true; - } -#endif - + return cv_hostage_ai_enable.value > 0; +#else return false; +#endif } int UTIL_GetNumPlayers()