Skip to content

Commit

Permalink
Removed -bots and -host-improve command line params in favor of using…
Browse files Browse the repository at this point in the history
… CVars
  • Loading branch information
s1lentq committed Dec 10, 2024
1 parent df7944a commit 942f2e6
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 41 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions dist/game_init.cfg
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/bot/cs_bot_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/bot/cs_bot_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 9 additions & 6 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion regamedll/dlls/h_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable, global
gpGlobals = pGlobals;

FileSystem_Init();
Regamedll_Game_Init();
}

#if defined(_LINUX)
Expand Down
19 changes: 12 additions & 7 deletions regamedll/dlls/hostage/hostage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/hostage/hostage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
33 changes: 9 additions & 24 deletions regamedll/dlls/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 942f2e6

Please sign in to comment.