From fee10d8ba83e84f70c70177bbd6919a8a22ff435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Mon, 12 Aug 2024 02:40:09 -0400 Subject: [PATCH 1/4] Fix Shotguns reload flag not getting reset on weapon changing (#993) --- regamedll/dlls/weapons.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 9a3d8e0c0..087f45eee 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -1671,6 +1671,10 @@ void CBasePlayerWeapon::Holster(int skiplocal) m_fInReload = FALSE; m_pPlayer->pev->viewmodel = 0; m_pPlayer->pev->weaponmodel = 0; + +#ifdef REGAMEDLL_FIXES + m_fInSpecialReload = 0; +#endif } // called by the new item with the existing item as parameter From c7bd4af9b63184822e2e479407975e262cff27f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Mon, 12 Aug 2024 02:45:21 -0400 Subject: [PATCH 2/4] Cache ObjectCaps call inside PlayerUse (#991) Not really useful, discovered while testing on 3rd party plugins that ObjectCaps was being called unnecessarily more than once per entity --- regamedll/dlls/player.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index f70dfa172..1a895df62 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -4248,11 +4248,15 @@ void CBasePlayer::PlayerUse() } } + int caps; + int iClosestCaps = 0; + if (!pClosest) { while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, MAX_PLAYER_USE_RADIUS))) { - if (pObject->ObjectCaps() & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE)) + caps = pObject->ObjectCaps(); + if (caps & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE)) { // TODO: PERFORMANCE- should this check be done on a per case basis AFTER we've determined that // this object is actually usable? This dot is being done for every object within PLAYER_SEARCH_RADIUS @@ -4267,11 +4271,21 @@ void CBasePlayer::PlayerUse() { flMaxDot = flDot; pClosest = pObject; +#ifdef REGAMEDLL_FIXES + iClosestCaps = caps; +#endif } } } } +#ifdef REGAMEDLL_FIXES + else // catch new hostages caps + { + iClosestCaps = pClosest->ObjectCaps(); + } + caps = iClosestCaps; +#endif pObject = pClosest; // Found an object @@ -4280,8 +4294,9 @@ void CBasePlayer::PlayerUse() if (!useNewHostages || CanSeeUseable(this, pObject)) { // TODO: traceline here to prevent +USEing buttons through walls +#ifndef REGAMEDLL_FIXES int caps = pObject->ObjectCaps(); - +#endif if (m_afButtonPressed & IN_USE) EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_select.wav", 0.4, ATTN_NORM); @@ -4295,7 +4310,12 @@ void CBasePlayer::PlayerUse() } // UNDONE: Send different USE codes for ON/OFF. Cache last ONOFF_USE object to send 'off' if you turn away // BUGBUG This is an "off" use - else if ((m_afButtonReleased & IN_USE) && (pObject->ObjectCaps() & FCAP_ONOFF_USE)) + else if ((m_afButtonReleased & IN_USE) +#ifdef REGAMEDLL_FIXES + && (caps & FCAP_ONOFF_USE)) +#else + && (pObject->ObjectCaps() & FCAP_ONOFF_USE)) +#endif { pObject->Use(this, this, USE_SET, 0); } From b6c2c62e8beceffa0c18310ceb9c3cc0d2bf0264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Mon, 12 Aug 2024 02:45:54 -0400 Subject: [PATCH 3/4] Added `mp_vote_flags` and `mp_votemap_min_time` cvars (#990) * Added mp_vote_flags cvar * Added mp_votemap_min_time cvar * Cvars on README * game.cfg cvars * Ensure timers check before new restrictions --- README.md | 3 +++ dist/game.cfg | 15 +++++++++++++ regamedll/dlls/client.cpp | 20 ++++++++++++++++- regamedll/dlls/game.cpp | 6 +++++ regamedll/dlls/game.h | 3 ++- regamedll/dlls/gamerules.h | 45 ++++++++++++++++++++++++-------------- 6 files changed, 73 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 0ad6361ae..90f58990d 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,9 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | mp_item_respawn_time | 30 | 0.0 | - | The respawn time for items (such as health packs, armor, etc.). | | mp_weapon_respawn_time | 20 | 0.0 | - | The respawn time for weapons. | | mp_ammo_respawn_time | 20 | 0.0 | - | The respawn time for ammunition. | +| mp_vote_flags | km | 0 | - | Vote systems enabled in server.
`0` voting disabled
`k` votekick enabled via `vote` command
`m` votemap enabled via `votemap` command | +| mp_votemap_min_time | 180 | 0.0 | - | Minimum seconds that must elapse on map before `votemap` command can be used. | + ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index 96e313aa4..c5dad01c9 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -605,3 +605,18 @@ mp_weapon_respawn_time "20" // // Default value: "20" mp_ammo_respawn_time "20" + +// Vote systems enabled in server +// +// k - votekick enabled via vote command +// m - votemap enabled via votemap command +// +// Set to "0" to disable voting systems +// +// Default value: "km" +mp_vote_flags "km" + +// Minimum seconds that must elapse on map before votemap command can be used +// +// Default value: "180" +mp_votemap_min_time "180" diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 7d3fb659e..9708fa2c8 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -2627,6 +2627,15 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa return; } +#ifdef REGAMEDLL_ADD + static const int flagKick = UTIL_ReadFlags("k"); + if ((flagKick & UTIL_ReadFlags(vote_flags.string)) == 0) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Command_Not_Available"); + return; + } +#endif + pPlayer->m_flNextVoteTime = gpGlobals->time + 3; if (pPlayer->m_iTeam != UNASSIGNED) @@ -2708,11 +2717,20 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa return; } +#ifdef REGAMEDLL_ADD + static const int flagMap = UTIL_ReadFlags("m"); + if ((flagMap & UTIL_ReadFlags(vote_flags.string)) == 0) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Command_Not_Available"); + return; + } +#endif + pPlayer->m_flNextVoteTime = gpGlobals->time + 3; if (pPlayer->m_iTeam != UNASSIGNED) { - if (gpGlobals->time < 180) + if (gpGlobals->time < CGameRules::GetVotemapMinElapsedTime()) { ClientPrint(pPlayer->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_Map"); return; diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index c4e303c51..789435938 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -185,6 +185,9 @@ cvar_t item_respawn_time = { "mp_item_respawn_time", "30", FCVAR_SERVER, 3 cvar_t weapon_respawn_time = { "mp_weapon_respawn_time", "20", FCVAR_SERVER, 20.0f, nullptr }; cvar_t ammo_respawn_time = { "mp_ammo_respawn_time", "20", FCVAR_SERVER, 20.0f, nullptr }; +cvar_t vote_flags = { "mp_vote_flags", "km", 0, 0.0f, nullptr }; +cvar_t votemap_min_time = { "mp_votemap_min_time", "180", 0, 180.0f, nullptr }; + void GameDLL_Version_f() { if (Q_stricmp(CMD_ARGV(1), "version") != 0) @@ -454,6 +457,9 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&weapon_respawn_time); CVAR_REGISTER(&ammo_respawn_time); + CVAR_REGISTER(&vote_flags); + CVAR_REGISTER(&votemap_min_time); + // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index d0924d3a3..09da5305a 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -203,10 +203,11 @@ extern cvar_t freezetime_jump; extern cvar_t defuser_allocation; extern cvar_t location_area_info; extern cvar_t chat_loc_fallback; - extern cvar_t item_respawn_time; extern cvar_t weapon_respawn_time; extern cvar_t ammo_respawn_time; +extern cvar_t vote_flags; +extern cvar_t votemap_min_time; #endif diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index cc6e9ec8f..a4f556ab9 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -31,28 +31,29 @@ #include "game_shared/voice_gamemgr.h" #include "cmdhandler.h" -const int MAX_RULE_BUFFER = 1024; -const int MAX_VOTE_MAPS = 100; -const int MAX_VIP_QUEUES = 5; -const int MAX_MONEY_THRESHOLD = 999999; // allowable money limit in the game that can be drawn on the HUD - -const int MAX_MOTD_CHUNK = 60; -const int MAX_MOTD_LENGTH = 1536; // (MAX_MOTD_CHUNK * 4) - -const float ITEM_RESPAWN_TIME = 30.0f; -const float WEAPON_RESPAWN_TIME = 20.0f; -const float AMMO_RESPAWN_TIME = 20.0f; -const float ROUND_RESPAWN_TIME = 20.0f; -const float ROUND_BEGIN_DELAY = 5.0f; // delay before beginning new round -const float ITEM_KILL_DELAY = 300.0f; -const float RADIO_TIMEOUT = 1.5f; +const int MAX_RULE_BUFFER = 1024; +const int MAX_VOTE_MAPS = 100; +const int MAX_VIP_QUEUES = 5; +const int MAX_MONEY_THRESHOLD = 999999; // allowable money limit in the game that can be drawn on the HUD + +const int MAX_MOTD_CHUNK = 60; +const int MAX_MOTD_LENGTH = 1536; // (MAX_MOTD_CHUNK * 4) + +const float ITEM_RESPAWN_TIME = 30.0f; +const float WEAPON_RESPAWN_TIME = 20.0f; +const float AMMO_RESPAWN_TIME = 20.0f; +const float ROUND_RESPAWN_TIME = 20.0f; +const float ROUND_BEGIN_DELAY = 5.0f; // delay before beginning new round +const float ITEM_KILL_DELAY = 300.0f; +const float RADIO_TIMEOUT = 1.5f; const float DEATH_ANIMATION_TIME = 3.0f; +const float VOTEMAP_MIN_TIME = 180.0f; -const int MAX_INTERMISSION_TIME = 120; // longest the intermission can last, in seconds +const int MAX_INTERMISSION_TIME = 120; // longest the intermission can last, in seconds // when we are within this close to running out of entities, items // marked with the ITEM_FLAG_LIMITINWORLD will delay their respawn -const int ENTITY_INTOLERANCE = 100; +const int ENTITY_INTOLERANCE = 100; enum { @@ -381,6 +382,7 @@ class CGameRules static float GetItemKillDelay(); static float GetRadioTimeout(); static float GetDyingTime(); + static float GetVotemapMinElapsedTime(); public: BOOL m_bFreezePeriod; // TRUE at beginning of round, set to FALSE when the period expires @@ -986,6 +988,15 @@ inline float CGameRules::GetDyingTime() #endif } +inline float CGameRules::GetVotemapMinElapsedTime() +{ +#ifdef REGAMEDLL_ADD + return votemap_min_time.value; +#else + return VOTEMAP_MIN_TIME; +#endif +} + bool IsBotSpeaking(); void SV_Continue_f(); void SV_Tutor_Toggle_f(); From f9969aceab95783a537902282d127d4c88daf5ae Mon Sep 17 00:00:00 2001 From: Vaqtincha <51029683+Vaqtincha@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:48:41 +0500 Subject: [PATCH 4/4] fix https://github.com/s1lentq/ReGameDLL_CS/issues/927 (#985) --- regamedll/dlls/wpn_shared/wpn_deagle.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/wpn_shared/wpn_deagle.cpp b/regamedll/dlls/wpn_shared/wpn_deagle.cpp index e9bbc7132..f04ab55d6 100644 --- a/regamedll/dlls/wpn_shared/wpn_deagle.cpp +++ b/regamedll/dlls/wpn_shared/wpn_deagle.cpp @@ -204,11 +204,23 @@ void CDEAGLE::WeaponIdle() if (m_flTimeWeaponIdle <= UTIL_WeaponTimeBase()) { - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20.0f; +#ifdef REGAMEDLL_FIXES + if (m_pPlayer->HasShield()) +#endif + { + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20.0f; - if (m_iWeaponState & WPNSTATE_SHIELD_DRAWN) + if (m_iWeaponState & WPNSTATE_SHIELD_DRAWN) + { + SendWeaponAnim(DEAGLE_SHIELD_IDLE_UP, UseDecrement() != FALSE); + } + } +#ifdef REGAMEDLL_FIXES + else if (m_iClip) { - SendWeaponAnim(DEAGLE_SHIELD_IDLE_UP, UseDecrement() != FALSE); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0625f; + SendWeaponAnim(DEAGLE_IDLE1, UseDecrement() != FALSE); } +#endif } }