diff --git a/README.md b/README.md
index 7b8f57c1..3f245c6e 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
| mp_auto_reload_weapons | 0 | 0 | 1 | Automatically reload each weapon on player spawn
`0` disabled
`1` enabled |
| mp_refill_bpammo_weapons | 0 | 0 | 2 | Refill amount of backpack ammo up to the max
`0` disabled
`1` refill backpack ammo on player spawn
`2` refill backpack ammo on each weapon reload |
| bot_deathmatch | 0 | 0 | 1 | Set's the mode for the zBot
`0` disabled
`1` enable mode Deathmatch and not allow to do the scenario |
+| mp_auto_join_team | 0 | 0 | 1 | Automatically joins the team
`0` disabled
`1` enable (Use in conjunction with the cvar humans_join_team any/CT/T) |
## How to install zBot for CS 1.6?
* Extract all the files from an [archive](regamedll/extra/zBot/bot_profiles.zip?raw=true)
diff --git a/dist/game.cfg b/dist/game.cfg
index 418e9921..8ef1d87e 100644
--- a/dist/game.cfg
+++ b/dist/game.cfg
@@ -70,3 +70,10 @@ mp_refill_bpammo_weapons 0
//
// Default value: "0"
bot_deathmatch 0
+
+// Automatically joins the team
+// 0 - disabled
+// 1 - enable (Use in conjunction with the cvar humans_join_team any/CT/T)
+//
+// Default value: "0"
+mp_auto_join_team 0
diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp
index cbc6873c..4a96587b 100644
--- a/regamedll/dlls/client.cpp
+++ b/regamedll/dlls/client.cpp
@@ -211,11 +211,25 @@ void __API_HOOK(ShowMenu)(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplay
MESSAGE_END();
}
-LINK_HOOK_VOID_CHAIN(ShowVGUIMenu, (CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu, bool bForceOldMenu), pPlayer, MenuType, BitMask, szOldMenu, bForceOldMenu);
+LINK_HOOK_VOID_CHAIN(ShowVGUIMenu, (CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu), pPlayer, MenuType, BitMask, szOldMenu);
-void __API_HOOK(ShowVGUIMenu)(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu, bool bForceOldMenu)
+void __API_HOOK(ShowVGUIMenu)(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu)
{
- if (!bForceOldMenu && (pPlayer->m_bVGUIMenus || MenuType > VGUI_Menu_Buy_Item))
+#ifdef REGAMEDLL_ADD
+ if (CSGameRules()->ShouldSkipShowMenu()) {
+ CSGameRules()->MarkShowMenuSkipped();
+ pPlayer->m_iMenu = Menu_OFF;
+ return;
+ }
+
+ if (pPlayer->CSPlayer()->m_bForceShowMenu) {
+ ShowMenu(pPlayer, BitMask, -1, 0, szOldMenu);
+ return;
+ }
+
+#endif
+
+ if (pPlayer->m_bVGUIMenus || MenuType > VGUI_Menu_Buy_Item)
{
MESSAGE_BEGIN(MSG_ONE, gmsgVGUIMenu, NULL, pPlayer->pev);
WRITE_BYTE(MenuType);
@@ -1736,7 +1750,11 @@ BOOL __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot)
return FALSE;
}
- if (team != SPECTATOR && !player->IsBot())
+ if (team != SPECTATOR && !player->IsBot()
+#ifdef REGAMEDLL_ADD
+ && auto_join_team.value != 1.0f
+#endif
+ )
{
int humanTeam = UNASSIGNED;
@@ -1751,7 +1769,12 @@ BOOL __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot)
if (humanTeam != UNASSIGNED && team != humanTeam)
{
+ // TODO: These localization strings are not defined on the client CS 1.6, only for CZero
+#ifdef REGAMEDLL_FIXES
+ ClientPrint(player->pev, HUD_PRINTCENTER, (team == TERRORIST) ? "Humans can only be CT!" : "Humans can only be terrorists!");
+#else
ClientPrint(player->pev, HUD_PRINTCENTER, (team == TERRORIST) ? "#Humans_Join_Team_CT" : "#Humans_Join_Team_T");
+#endif
return FALSE;
}
}
@@ -1799,33 +1822,38 @@ BOOL __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot)
SET_MODEL(ENT(player->pev), "models/player.mdl");
}
- if (!CSGameRules()->IsCareer())
+#ifdef REGAMEDLL_ADD
+ if (!CSGameRules()->ShouldSkipShowMenu())
+#endif
{
- switch (team)
+ if (!CSGameRules()->IsCareer())
{
- case CT:
- if (g_bIsCzeroGame)
- ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#CT_Select");
- else
- ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#CT_Select");
- break;
+ switch (team)
+ {
+ case CT:
+ if (g_bIsCzeroGame)
+ ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#CT_Select");
+ else
+ ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#CT_Select");
+ break;
- case TERRORIST:
- if (g_bIsCzeroGame)
- ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#Terrorist_Select");
- else
- ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#Terrorist_Select");
- break;
+ case TERRORIST:
+ if (g_bIsCzeroGame)
+ ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#Terrorist_Select");
+ else
+ ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#Terrorist_Select");
+ break;
+ }
}
- }
- player->m_iMenu = Menu_ChooseAppearance;
+ player->m_iMenu = Menu_ChooseAppearance;
- // Show the appropriate Choose Appearance menu
- // This must come before ClientKill() for CheckWinConditions() to function properly
- if (player->pev->deadflag == DEAD_NO)
- {
- ClientKill(player->edict());
+ // Show the appropriate Choose Appearance menu
+ // This must come before ClientKill() for CheckWinConditions() to function properly
+ if (player->pev->deadflag == DEAD_NO)
+ {
+ ClientKill(player->edict());
+ }
}
// Switch their actual team...
@@ -2575,6 +2603,21 @@ void EXT_FUNC ClientCommand(edict_t *pEntity)
case Menu_ChooseTeam:
{
+#ifdef REGAMEDLL_ADD
+ if (!player->m_bVGUIMenus || player->CSPlayer()->m_bForceShowMenu)
+ {
+ player->CSPlayer()->m_bForceShowMenu = false;
+
+ if (!HandleMenu_ChooseTeam(player, slot))
+ {
+ player->m_iMenu = Menu_ChooseTeam;
+ if (player->m_iJoiningState == JOINED)
+ ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0), "#IG_Team_Select");
+ else
+ ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5), "#Team_Select");
+ }
+ }
+#else
if (!player->m_bVGUIMenus && !HandleMenu_ChooseTeam(player, slot))
{
player->m_iMenu = Menu_ChooseTeam;
@@ -2583,6 +2626,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity)
else
ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5), "#Team_Select");
}
+#endif
break;
}
case Menu_IGChooseTeam:
@@ -2807,9 +2851,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity)
else if (FStrEq(pcmd, "chooseteam"))
{
if (player->m_iMenu == Menu_ChooseAppearance)
- {
return;
- }
if (player->m_bTeamChanged)
{
diff --git a/regamedll/dlls/client.h b/regamedll/dlls/client.h
index 1db472d9..5163d4c8 100644
--- a/regamedll/dlls/client.h
+++ b/regamedll/dlls/client.h
@@ -121,8 +121,8 @@ void respawn(entvars_t *pev, BOOL fCopyCorpse = FALSE);
void ClientKill(edict_t *pEntity);
void ShowMenu(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText);
void ShowMenu_(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText);
-void ShowVGUIMenu(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu, bool bForceOldMenu = false);
-void ShowVGUIMenu_(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu, bool bForceOldMenu = false);
+void ShowVGUIMenu(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu);
+void ShowVGUIMenu_(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu);
void ListPlayers(CBasePlayer *current);
void ProcessKickVote(CBasePlayer *pVotingPlayer, CBasePlayer *pKickPlayer);
TeamName SelectDefaultTeam();
diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp
index 1791c495..ffb1cebe 100644
--- a/regamedll/dlls/game.cpp
+++ b/regamedll/dlls/game.cpp
@@ -104,6 +104,7 @@ cvar_t roundrespawn_time = { "mp_roundrespawn_time", "20", 0, 20.0f, nullptr };
cvar_t auto_reload_weapons = { "mp_auto_reload_weapons", "0", 0, 0.0f, nullptr };
cvar_t refill_bpammo_weapons = { "mp_refill_bpammo_weapons", "0", 0, 0.0f, nullptr }; // Useful for mods like DeathMatch, GunGame, ZombieMod etc
cvar_t freeforall = { "mp_freeforall", "0", FCVAR_SERVER, 0.0f, nullptr };
+cvar_t auto_join_team = { "mp_auto_join_team", "0", 0, 0.0f, nullptr };
void GameDLL_Version_f()
{
@@ -234,6 +235,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&auto_reload_weapons);
CVAR_REGISTER(&refill_bpammo_weapons);
CVAR_REGISTER(&freeforall);
+ CVAR_REGISTER(&auto_join_team);
// print version
CONSOLE_ECHO("ReGameDLL build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")\n");
diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h
index 3635be14..1a352136 100644
--- a/regamedll/dlls/game.h
+++ b/regamedll/dlls/game.h
@@ -141,6 +141,7 @@ extern cvar_t roundrespawn_time;
extern cvar_t auto_reload_weapons;
extern cvar_t refill_bpammo_weapons;
extern cvar_t freeforall;
+extern cvar_t auto_join_team;
#endif
diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h
index 62d1434b..b2f61658 100644
--- a/regamedll/dlls/gamerules.h
+++ b/regamedll/dlls/gamerules.h
@@ -600,6 +600,8 @@ public:
void SetCareerMatchLimit(int minWins, int winDifference);
bool IsInCareerRound();
void CareerRestart();
+ bool ShouldSkipShowMenu() const { return m_bSkipShowMenu; }
+ void MarkShowMenuSkipped() { m_bSkipShowMenu = false; }
bool ShouldSkipSpawn() const { return m_bSkipSpawn; }
void MarkSpawnSkipped() { m_bSkipSpawn = false; }
void PlayerJoinedTeam(CBasePlayer *pPlayer) { }
@@ -735,6 +737,7 @@ protected:
bool m_bSkipSpawn;
// custom
+ bool m_bSkipShowMenu;
bool m_bNeededPlayers;
float m_flEscapeRatio;
};
diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp
index 9bacc594..7bca3561 100644
--- a/regamedll/dlls/multiplay_gamerules.cpp
+++ b/regamedll/dlls/multiplay_gamerules.cpp
@@ -3523,6 +3523,12 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerThink)(CBasePlayer *pPlayer)
{
team = MENU_SLOT_TEAM_CT;
}
+#ifdef REGAMEDLL_ADD
+ else if (!Q_stricmp(humans_join_team.string, "any") && auto_join_team.value != 0.0f)
+ {
+ team = MENU_SLOT_TEAM_RANDOM;
+ }
+#endif
else
{
if (allow_spectators.value == 0.0f)
@@ -3536,6 +3542,17 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerThink)(CBasePlayer *pPlayer)
if (team != MENU_SLOT_TEAM_UNDEFINED && !pPlayer->IsBot())
{
+#ifdef REGAMEDLL_ADD
+ m_bSkipShowMenu = (auto_join_team.value != 0.0f);
+ HandleMenu_ChooseTeam(pPlayer, team);
+
+ if (team != MENU_SLOT_TEAM_SPECT && (IsCareer() || m_bSkipShowMenu))
+ {
+ // slot 6 - chooses randomize the appearance to model player
+ HandleMenu_ChooseAppearance(pPlayer, 6);
+ }
+ m_bSkipShowMenu = false;
+#else
HandleMenu_ChooseTeam(pPlayer, team);
if (team != MENU_SLOT_TEAM_SPECT && IsCareer())
@@ -3543,6 +3560,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerThink)(CBasePlayer *pPlayer)
// slot 6 - chooses randomize the appearance to model player
HandleMenu_ChooseAppearance(pPlayer, 6);
}
+#endif
}
}
}
diff --git a/regamedll/extra/cssdk/dlls/gamerules.h b/regamedll/extra/cssdk/dlls/gamerules.h
index 9e868d18..16e01d59 100644
--- a/regamedll/extra/cssdk/dlls/gamerules.h
+++ b/regamedll/extra/cssdk/dlls/gamerules.h
@@ -426,8 +426,12 @@ public:
virtual bool IsBombPlanted() = 0;
public:
+ bool ShouldSkipShowMenu() const { return m_bSkipShowMenu; }
+ void MarkShowMenuSkipped() { m_bSkipShowMenu = false; }
+
bool ShouldSkipSpawn() const { return m_bSkipSpawn; }
void MarkSpawnSkipped() { m_bSkipSpawn = false; }
+
float TimeRemaining() { return m_iRoundTimeSecs - gpGlobals->time + m_fRoundCount; }
bool IsMatchStarted() { return (m_fTeamCount != 0.0f || m_fCareerRoundMenuTime != 0.0f || m_fCareerMatchMenuTime != 0.0f); }
@@ -522,6 +526,7 @@ public:
bool m_bSkipSpawn;
// custom
+ bool m_bSkipShowMenu;
bool m_bNeededPlayers;
float m_flEscapeRatio;
};
diff --git a/regamedll/extra/cssdk/dlls/regamedll_api.h b/regamedll/extra/cssdk/dlls/regamedll_api.h
index 97484399..7286b769 100644
--- a/regamedll/extra/cssdk/dlls/regamedll_api.h
+++ b/regamedll/extra/cssdk/dlls/regamedll_api.h
@@ -210,8 +210,8 @@ typedef IVoidHookChain IReGameHook_
typedef IVoidHookChainRegistry IReGameHookRegistry_ShowMenu;
// ShowVGUIMenu hook
-typedef IVoidHookChain IReGameHook_ShowVGUIMenu;
-typedef IVoidHookChainRegistry IReGameHookRegistry_ShowVGUIMenu;
+typedef IVoidHookChain IReGameHook_ShowVGUIMenu;
+typedef IVoidHookChainRegistry IReGameHookRegistry_ShowVGUIMenu;
// CHalfLifeMultiplay::FShouldSwitchWeapon hook
typedef IHookChain IReGameHook_CSGameRules_FShouldSwitchWeapon;
diff --git a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h b/regamedll/extra/cssdk/dlls/regamedll_interfaces.h
index 4d7b1004..430eee8b 100644
--- a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h
+++ b/regamedll/extra/cssdk/dlls/regamedll_interfaces.h
@@ -51,7 +51,7 @@ class CCSArmoury: public CCSEntity {};
class CCSPlayer: public CCSMonster {
public:
- CCSPlayer()
+ CCSPlayer() : m_bForceShowMenu(false)
{
m_szModel[0] = '\0';
}
@@ -83,6 +83,7 @@ public:
CBasePlayer *BasePlayer() const;
public:
char m_szModel[32];
+ bool m_bForceShowMenu;
};
class CAPI_Bot: public CCSPlayer {};
diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h
index 319bb111..3f2a2f07 100644
--- a/regamedll/public/regamedll/regamedll_api.h
+++ b/regamedll/public/regamedll/regamedll_api.h
@@ -210,8 +210,8 @@ typedef IVoidHookChain IReGameHook_
typedef IVoidHookChainRegistry IReGameHookRegistry_ShowMenu;
// ShowVGUIMenu hook
-typedef IVoidHookChain IReGameHook_ShowVGUIMenu;
-typedef IVoidHookChainRegistry IReGameHookRegistry_ShowVGUIMenu;
+typedef IVoidHookChain IReGameHook_ShowVGUIMenu;
+typedef IVoidHookChainRegistry IReGameHookRegistry_ShowVGUIMenu;
// CHalfLifeMultiplay::FShouldSwitchWeapon hook
typedef IHookChain IReGameHook_CSGameRules_FShouldSwitchWeapon;
diff --git a/regamedll/public/regamedll/regamedll_interfaces.h b/regamedll/public/regamedll/regamedll_interfaces.h
index 63124ca3..fc86371d 100644
--- a/regamedll/public/regamedll/regamedll_interfaces.h
+++ b/regamedll/public/regamedll/regamedll_interfaces.h
@@ -51,7 +51,7 @@ class CCSArmoury: public CCSEntity {};
class CCSPlayer: public CCSMonster {
public:
- CCSPlayer()
+ CCSPlayer() : m_bForceShowMenu(false)
{
m_szModel[0] = '\0';
}
@@ -90,6 +90,7 @@ public:
CBasePlayer *BasePlayer() const;
public:
char m_szModel[32];
+ bool m_bForceShowMenu;
};
class CAPI_Bot: public CCSPlayer {};
diff --git a/regamedll/regamedll/regamedll_api_impl.h b/regamedll/regamedll/regamedll_api_impl.h
index 99be5403..3b6ddd2a 100644
--- a/regamedll/regamedll/regamedll_api_impl.h
+++ b/regamedll/regamedll/regamedll_api_impl.h
@@ -205,8 +205,8 @@ typedef IVoidHookChainImpl CReGameHook_Sh
typedef IVoidHookChainRegistryImpl CReGameHookRegistry_ShowMenu;
// ShowVGUIMenu hook
-typedef IVoidHookChainImpl CReGameHook_ShowVGUIMenu;
-typedef IVoidHookChainRegistryImpl CReGameHookRegistry_ShowVGUIMenu;
+typedef IVoidHookChainImpl CReGameHook_ShowVGUIMenu;
+typedef IVoidHookChainRegistryImpl CReGameHookRegistry_ShowVGUIMenu;
// CHalfLifeMultiplay::FShouldSwitchWeapon hook
typedef IHookChainClassImpl CReGameHook_CSGameRules_FShouldSwitchWeapon;
diff --git a/regamedll/regamedll/regamedll_interfaces_impl.cpp b/regamedll/regamedll/regamedll_interfaces_impl.cpp
index 46055d79..84d43ef6 100644
--- a/regamedll/regamedll/regamedll_interfaces_impl.cpp
+++ b/regamedll/regamedll/regamedll_interfaces_impl.cpp
@@ -67,6 +67,7 @@ bool CCSPlayer::JoinTeam(TeamName team)
UTIL_ScreenFade(pPlayer, Vector(0, 0, 0), 0.001, 0, 0, FFADE_IN);
}
+ CSGameRules()->CheckWinConditions();
return true;
}
case CT:
@@ -79,6 +80,10 @@ bool CCSPlayer::JoinTeam(TeamName team)
pPlayer->m_iIgnoreGlobalChat = IGNOREMSG_NONE;
pPlayer->m_iTeamKills = 0;
+ if (pPlayer->m_iAccount < int(startmoney.value)) {
+ pPlayer->m_iAccount = int(startmoney.value);
+ }
+
pPlayer->pev->solid = SOLID_NOT;
pPlayer->pev->movetype = MOVETYPE_NOCLIP;
pPlayer->pev->effects = EF_NODRAW;
@@ -122,6 +127,7 @@ bool CCSPlayer::JoinTeam(TeamName team)
pPlayer->m_iTeam = team;
pPlayer->TeamChangeUpdate();
+ CSGameRules()->CheckWinConditions();
return true;
}