void CGETKnife::PickupTouch( CBaseEntity *pOther ) { // Vehicles can touch items + pick them up if ( pOther->GetServerVehicle() ) { pOther = pOther->GetServerVehicle()->GetPassenger(); if ( !pOther ) return; } CBaseCombatCharacter *pPicker = pOther->MyCombatCharacterPointer(); if ( !pPicker ) return; // Must be a valid pickup scenario (no blocking). Though this is a more expensive // check than some that follow, this has to be first because it's the only one // that inhibits firing the output OnCacheInteraction. if ( UTIL_ItemCanBeTouchedByPlayer( this, ToGEPlayer(pPicker) ) == false ) return; // Can I even pick stuff up? if ( !pPicker->IsAllowedToPickupWeapons() ) return; if ( MyTouch( pPicker ) ) { SetTouch( NULL ); SetThink( NULL ); UTIL_Remove( this ); } }
//----------------------------------------------------------------------------- // Purpose: Whether or not the item can be touched and picked up by the player, taking // into account obstructions and other hinderances // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CItem::ItemCanBeTouchedByPlayer( CBasePlayer *pPlayer ) { // Vanilla HL2 can always touch the item if ( hl2_episodic.GetBool() == false ) return true; return UTIL_ItemCanBeTouchedByPlayer( this, pPlayer ); }
//----------------------------------------------------------------------------- // Purpose: Whether or not the item can be touched and picked up by the player, taking // into account obstructions and other hinderances // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CItem::ItemCanBeTouchedByPlayer( CBasePlayer *pPlayer ) { return UTIL_ItemCanBeTouchedByPlayer( this, pPlayer ); }