Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add newest feature of _cl_autowepswitch #568

Merged
merged 2 commits into from
Dec 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -3739,10 +3744,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);
Expand Down