From 9b10456590136d8eb648be23c1c73f481a7728e3 Mon Sep 17 00:00:00 2001 From: Alejo <53284952+aleeperezz16@users.noreply.github.com> Date: Sat, 5 Dec 2020 10:14:53 -0300 Subject: [PATCH] Add newest feature of _cl_autowepswitch (#568) --- regamedll/dlls/multiplay_gamerules.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 0c21bf3e3..ff687dab4 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -3212,9 +3212,14 @@ BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(FShouldSwitchWeapon)(CBasePlayer *p return TRUE; } - if (!pPlayer->m_iAutoWepSwitch) + if (pPlayer->m_iAutoWepSwitch == 0) return FALSE; +#ifdef REGAMEDLL_ADD + if (pPlayer->m_iAutoWepSwitch == 2 && (pPlayer->m_afButtonLast & (IN_ATTACK | IN_ATTACK2))) + return FALSE; +#endif + if (!pPlayer->m_pActiveItem->CanHolster()) { // can't put away the active item. @@ -3742,10 +3747,19 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerSpawn)(CBasePlayer *pPlayer) if (pPlayer->m_bJustConnected) return; +#ifdef REGAMEDLL_ADD + int iAutoWepSwitch = pPlayer->m_iAutoWepSwitch; + pPlayer->m_iAutoWepSwitch = 1; +#endif + pPlayer->pev->weapons |= (1 << WEAPON_SUIT); pPlayer->OnSpawnEquip(); pPlayer->SetPlayerModel(false); +#ifdef REGAMEDLL_ADD + pPlayer->m_iAutoWepSwitch = iAutoWepSwitch; +#endif + #ifdef REGAMEDLL_ADD if (respawn_immunitytime.value > 0) pPlayer->SetSpawnProtection(respawn_immunitytime.value);