diff --git a/regamedll/dlls/globals.cpp b/regamedll/dlls/globals.cpp index 3f698d59..d02c8fee 100644 --- a/regamedll/dlls/globals.cpp +++ b/regamedll/dlls/globals.cpp @@ -11,4 +11,3 @@ BOOL gDisplayTitle; bool g_bIsBeta = false; bool g_bIsCzeroGame = false; bool g_bAllowedCSBot = false; -bool g_bHostageImprov = false; diff --git a/regamedll/dlls/globals.h b/regamedll/dlls/globals.h index 02024291..805fd12a 100644 --- a/regamedll/dlls/globals.h +++ b/regamedll/dlls/globals.h @@ -38,4 +38,3 @@ extern BOOL gDisplayTitle; extern bool g_bIsBeta; extern bool g_bIsCzeroGame; extern bool g_bAllowedCSBot; -extern bool g_bHostageImprov; diff --git a/regamedll/dlls/hostage/hostage.cpp b/regamedll/dlls/hostage/hostage.cpp index 91c43018..c6f57091 100644 --- a/regamedll/dlls/hostage/hostage.cpp +++ b/regamedll/dlls/hostage/hostage.cpp @@ -28,7 +28,7 @@ #include "precompiled.h" -cvar_t cv_hostage_ai_enable = { "hostage_ai_enable", "1", 0, 1.0f, nullptr }; +cvar_t cv_hostage_ai_enable = { "hostage_ai_enable", "0", 0, 0.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 }; @@ -269,36 +269,41 @@ void CHostage::Spawn() void CHostage::Precache() { - if (AreImprovAllowed()) + if (cv_hostage_ai_enable.value) { + string_t model = iStringNull; + static int which = 0; switch (which) { default: case REGULAR_GUY: - pev->model = MAKE_STRING("models/hostageA.mdl"); + model = MAKE_STRING("models/hostageA.mdl"); break; case OLD_GUY: - pev->model = MAKE_STRING("models/hostageB.mdl"); + model = MAKE_STRING("models/hostageB.mdl"); break; case BLACK_GUY: - pev->model = MAKE_STRING("models/hostageC.mdl"); + model = MAKE_STRING("models/hostageC.mdl"); break; case GOOFY_GUY: - pev->model = MAKE_STRING("models/hostageD.mdl"); + model = MAKE_STRING("models/hostageD.mdl"); break; } m_whichModel = static_cast(which); - if (++which > 3) - which = 0; + if (++which > GOOFY_GUY) + which = REGULAR_GUY; - if (!g_pFileSystem->FileExists(pev->model)) + if (g_pFileSystem->FileExists(model)) + { + pev->model = model; + } + else { // It seems that the model is missing, so use classic hostages - g_bHostageImprov = false; - pev->model = iStringNull; + CVAR_SET_FLOAT("hostage_ai_enable", 0); } } @@ -347,7 +352,7 @@ void CHostage::IdleThink() const float giveUpTime = (1 / 30.0f); float const updateRate = 0.1f; - if (AreImprovAllowed() && !TheNavAreaList.empty()) + if (cv_hostage_ai_enable.value && !TheNavAreaList.empty()) { if (!m_improv) { @@ -776,7 +781,7 @@ void CHostage::SetDeathActivity() return; } - if (AreImprovAllowed()) + if (cv_hostage_ai_enable.value) { switch (m_LastHitGroup) { @@ -1402,7 +1407,7 @@ void Hostage_RegisterCVars() { // These cvars are only used in czero #ifdef REGAMEDLL_FIXES - if (!AreImprovAllowed()) + if (!cv_hostage_ai_enable.value) return; #endif @@ -1437,7 +1442,7 @@ void CHostageManager::ServerActivate() AddHostage(pHostage); } - if (AreImprovAllowed()) + if (cv_hostage_ai_enable.value) { for (auto& snd : hostageSoundStruct) { m_chatter.AddSound(snd.type, snd.fileName); @@ -1573,6 +1578,9 @@ void SimpleChatter::AddSound(HostageChatterType type, char *filename) Q_snprintf(actualFilename, sizeof(actualFilename), "sound\\%s", filename); + if (!g_pFileSystem->FileExists(actualFilename)) + return; + chatter->file[chatter->count].filename = CloneString(filename); chatter->file[chatter->count].duration = (double)GET_APPROX_WAVE_PLAY_LEN(actualFilename) / 1000.0; @@ -1610,6 +1618,9 @@ void SimpleChatter::Shuffle(ChatterSet *chatter) char *SimpleChatter::GetSound(HostageChatterType type, float *duration) { ChatterSet *chatter = &m_chatter[type]; + if (chatter->count == 0) + return nullptr; + char *sound; Shuffle(chatter); diff --git a/regamedll/dlls/hostage/hostage.h b/regamedll/dlls/hostage/hostage.h index 6bacec2d..f869cacf 100644 --- a/regamedll/dlls/hostage/hostage.h +++ b/regamedll/dlls/hostage/hostage.h @@ -285,11 +285,5 @@ private: SimpleChatter m_chatter; }; -// Determine whether hostage improv can be used or not -inline bool AreImprovAllowed() -{ - return g_bHostageImprov; -} - void Hostage_RegisterCVars(); void InstallHostageManager(); diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 95acb843..3f23a629 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -4173,7 +4173,7 @@ void CBasePlayer::PlayerUse() } } - bool useNewHostages = !TheNavAreaList.empty() && AreImprovAllowed(); + bool useNewHostages = !TheNavAreaList.empty() && cv_hostage_ai_enable.value; CBaseEntity *pObject = nullptr; CBaseEntity *pClosest = nullptr; Vector vecLOS; diff --git a/regamedll/regamedll/regamedll.cpp b/regamedll/regamedll/regamedll.cpp index 5e6190d1..9602faa1 100644 --- a/regamedll/regamedll/regamedll.cpp +++ b/regamedll/regamedll/regamedll.cpp @@ -33,7 +33,6 @@ void Regamedll_Game_Init() g_bIsBeta = UTIL_IsBeta(); g_bIsCzeroGame = UTIL_IsGame("czero"); g_bAllowedCSBot = UTIL_AreBotsAllowed(); // determine whether bots can be used or not - g_bHostageImprov = UTIL_AreHostagesImprov(); // determine whether hostage improv can be used or not WeaponInfoReset(); }