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.

45 lines
1.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Handling for the suit batteries.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "hl2_player.h"
  9. #include "basecombatweapon.h"
  10. #include "gamerules.h"
  11. #include "items.h"
  12. #include "engine/IEngineSound.h"
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. class CItemBattery : public CItem
  16. {
  17. public:
  18. DECLARE_CLASS( CItemBattery, CItem );
  19. void Spawn( void )
  20. {
  21. Precache( );
  22. SetModel( "models/items/battery.mdl" );
  23. BaseClass::Spawn( );
  24. }
  25. void Precache( void )
  26. {
  27. PrecacheModel ("models/items/battery.mdl");
  28. PrecacheScriptSound( "ItemBattery.Touch" );
  29. }
  30. bool MyTouch( CBasePlayer *pPlayer )
  31. {
  32. CHL2_Player *pHL2Player = dynamic_cast<CHL2_Player *>( pPlayer );
  33. return ( pHL2Player && pHL2Player->ApplyBattery() );
  34. }
  35. };
  36. LINK_ENTITY_TO_CLASS(item_battery, CItemBattery);
  37. PRECACHE_REGISTER(item_battery);