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.

61 lines
1.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "player.h"
  8. #include "gamerules.h"
  9. #include "items.h"
  10. #include "hl1_items.h"
  11. #include "hl1_player.h"
  12. class CItemLongJump : public CHL1Item
  13. {
  14. public:
  15. DECLARE_CLASS( CItemLongJump, CHL1Item );
  16. void Spawn( void )
  17. {
  18. Precache( );
  19. SetModel( "models/w_longjump.mdl" );
  20. BaseClass::Spawn( );
  21. CollisionProp()->UseTriggerBounds( true, 16.0f );
  22. }
  23. void Precache( void )
  24. {
  25. PrecacheModel ("models/w_longjump.mdl");
  26. }
  27. bool MyTouch( CBasePlayer *pPlayer )
  28. {
  29. CHL1_Player *pHL1Player = (CHL1_Player*)pPlayer;
  30. if ( pHL1Player->m_bHasLongJump == true )
  31. {
  32. return false;
  33. }
  34. if ( pHL1Player->IsSuitEquipped() )
  35. {
  36. pHL1Player->m_bHasLongJump = true;// player now has longjump module
  37. CSingleUserRecipientFilter user( pHL1Player );
  38. user.MakeReliable();
  39. UserMessageBegin( user, "ItemPickup" );
  40. WRITE_STRING( STRING(m_iClassname) );
  41. MessageEnd();
  42. UTIL_EmitSoundSuit( pHL1Player->edict(), "!HEV_A1" ); // Play the longjump sound UNDONE: Kelly? correct sound?
  43. return true;
  44. }
  45. return false;
  46. }
  47. };
  48. LINK_ENTITY_TO_CLASS( item_longjump, CItemLongJump );
  49. PRECACHE_REGISTER(item_longjump);