Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "cbase.h"
  9. #include "items.h"
  10. #include "cs_player.h"
  11. class CItemNvgs : public CItem
  12. {
  13. public:
  14. DECLARE_CLASS( CItemNvgs, CItem );
  15. void Spawn( void )
  16. {
  17. Precache( );
  18. BaseClass::Spawn( );
  19. }
  20. void Precache( void )
  21. {
  22. PrecacheScriptSound( "BaseCombatCharacter.ItemPickup2" );
  23. }
  24. bool MyTouch( CBasePlayer *pBasePlayer )
  25. {
  26. CCSPlayer *pPlayer = dynamic_cast< CCSPlayer* >( pBasePlayer );
  27. if ( !pPlayer )
  28. {
  29. Assert( false );
  30. return false;
  31. }
  32. pPlayer->m_bHasNightVision = true;
  33. if ( pPlayer->IsDead() == false )
  34. {
  35. CPASAttenuationFilter filter( pPlayer );
  36. EmitSound( filter, entindex(), "BaseCombatCharacter.ItemPickup2" );
  37. CSingleUserRecipientFilter user( pPlayer );
  38. UserMessageBegin( user, "ItemPickup" );
  39. WRITE_STRING( "item_nvgs" );
  40. MessageEnd();
  41. }
  42. return true;
  43. }
  44. };
  45. LINK_ENTITY_TO_CLASS( item_nvgs, CItemNvgs );