From 28db0abd0bd3c55855dd7dbe0c018dbd7d60aaa0 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 22 Jan 2024 22:38:13 +0500 Subject: [PATCH] HL 25th anniversary update satchel changes. --- dlls/satchel.cpp | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 38ebec0859..93ab07e47e 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -192,6 +192,8 @@ LINK_ENTITY_TO_CLASS( weapon_satchel, CSatchel ) int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) { CSatchel *pSatchel; + int nNumSatchels, nSatchelsInPocket; + CBaseEntity *pStartEntity; #if CLIENT_DLL if( bIsMultiplayer() ) @@ -199,9 +201,22 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) if( g_pGameRules->IsMultiplayer() ) #endif { + if( !pOriginal->m_pPlayer ) + return TRUE; + + nNumSatchels = 0; + nSatchelsInPocket = pOriginal->m_pPlayer->m_rgAmmo[pOriginal->PrimaryAmmoIndex()]; + pStartEntity = NULL; + + while( ( pStartEntity = UTIL_FindEntityInSphere( pStartEntity, pOriginal->m_pPlayer->pev->origin, 4096 )) != NULL ) + { + if( FClassnameIs( pStartEntity->pev, "monster_satchel" )) + nNumSatchels += pStartEntity->pev->owner == pOriginal->m_pPlayer->edict(); + } + pSatchel = (CSatchel *)pOriginal; - if( pSatchel->m_chargeReady != SATCHEL_IDLE ) + if( pSatchel->m_chargeReady != SATCHEL_IDLE || nSatchelsInPocket + nNumSatchels <= SATCHEL_MAX_CARRY - 1 ) { // player has some satchels deployed. Refuse to add more. return FALSE; @@ -330,14 +345,19 @@ void CSatchel::Holster( int skiplocal /* = 0 */ ) } } -void CSatchel::PrimaryAttack() +void CSatchel::PrimaryAttack( void ) +{ + if( m_chargeReady != SATCHEL_RELOAD ) + { + Throw(); + } +} + +void CSatchel::SecondaryAttack() { switch( m_chargeReady ) { case SATCHEL_IDLE: - { - Throw(); - } break; case SATCHEL_READY: { @@ -370,14 +390,6 @@ void CSatchel::PrimaryAttack() } } -void CSatchel::SecondaryAttack( void ) -{ - if( m_chargeReady != SATCHEL_RELOAD ) - { - Throw(); - } -} - void CSatchel::Throw( void ) { if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )