Removed -bots and -host-improve command line params in favor of using CVars

This commit is contained in:
s1lentq 2024-12-11 02:06:08 +07:00
parent df7944ab88
commit 942f2e6637
9 changed files with 51 additions and 41 deletions

View File

@ -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

15
dist/game_init.cfg vendored
View File

@ -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)

View File

@ -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 };

View File

@ -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;

View File

@ -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)

View File

@ -13,7 +13,6 @@ C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable, global
gpGlobals = pGlobals;
FileSystem_Init();
Regamedll_Game_Init();
}
#if defined(_LINUX)

View File

@ -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<ModelType>(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);

View File

@ -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;

View File

@ -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()