This commit is contained in:
speedvoltage 2025-03-30 17:00:56 -07:00 committed by GitHub
commit 893b3084c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 34 deletions

View file

@ -400,6 +400,38 @@ void CBaseHudWeaponSelection::UserCmd_Slot10(void)
SelectSlot( 10 );
}
void ClientInstantPhysSwap()
{
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
if ( !pPlayer )
return;
C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
if ( !pWeapon )
return;
const char *strWeaponName = pWeapon->GetName();
if ( !Q_stricmp( strWeaponName, "weapon_physcannon" ) )
{
input->MakeWeaponSelection( pPlayer->GetLastWeapon() ); // back to previous weapon
}
else
{
for ( int i = 0; i < pPlayer->WeaponCount(); ++i )
{
C_BaseCombatWeapon *pWeapon = pPlayer->GetWeapon( i );
if ( pWeapon && !Q_stricmp( pWeapon->GetClassname(), "weapon_physcannon" ) ) // switch to physcannon
{
input->MakeWeaponSelection( pWeapon );
return;
}
}
}
}
static ConCommand cl_physswap( "phys_swap", ClientInstantPhysSwap, "Client-predicted physcannon swap for low-latency switching." );
//-----------------------------------------------------------------------------
// Purpose: returns true if the CHudMenu should take slot1, etc commands
//-----------------------------------------------------------------------------

View file

@ -1038,40 +1038,6 @@ void CC_Player_TestDispatchEffect( const CCommand &args )
static ConCommand test_dispatcheffect("test_dispatcheffect", CC_Player_TestDispatchEffect, "Test a clientside dispatch effect.\n\tUsage: test_dispatcheffect <effect name> <distance away> <flags> <magnitude> <scale>\n\tDefaults are: <distance 1024> <flags 0> <magnitude 0> <scale 0>\n", FCVAR_CHEAT);
#ifdef HL2_DLL
//-----------------------------------------------------------------------------
// Purpose: Quickly switch to the physics cannon, or back to previous item
//-----------------------------------------------------------------------------
void CC_Player_PhysSwap( void )
{
CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );
if ( pPlayer )
{
CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
if ( pWeapon )
{
// Tell the client to stop selecting weapons
engine->ClientCommand( UTIL_GetCommandClient()->edict(), "cancelselect" );
const char *strWeaponName = pWeapon->GetName();
if ( !Q_stricmp( strWeaponName, "weapon_physcannon" ) )
{
PhysCannonForceDrop( pWeapon, NULL );
pPlayer->SelectLastItem();
}
else
{
pPlayer->SelectItem( "weapon_physcannon" );
}
}
}
}
static ConCommand physswap("phys_swap", CC_Player_PhysSwap, "Automatically swaps the current weapon for the physcannon and back again." );
#endif
//-----------------------------------------------------------------------------
// Purpose: Quickly switch to the bug bait, or back to previous item
//-----------------------------------------------------------------------------