Skip to content

Commit

Permalink
Add newest feature of _cl_autowepswitch (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeperezz16 authored Dec 5, 2020
1 parent c56982a commit 9b10456
Showing 1 changed file with 15 additions and 1 deletion.
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 @@ -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);
Expand Down

2 comments on commit 9b10456

@fl0werD
Copy link
Contributor

@fl0werD fl0werD commented on 9b10456 Dec 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

desc?

@StevenKal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #568: "Setting _cl_autowepswitch to 2 will now enable auto weapon switching on pickup of a better weapon except when holding Primary or Seconday attack."

Please sign in to comment.