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.

68 lines
1.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //
  4. //=============================================================================
  5. #include "cbase.h"
  6. #include "tf_weapon_decoy.h"
  7. #if !defined( CLIENT_DLL )
  8. #include "tf_player.h"
  9. #include "bot_npc/bot_npc_decoy.h"
  10. #else
  11. #include "c_tf_player.h"
  12. #endif
  13. IMPLEMENT_NETWORKCLASS_ALIASED( TFDecoy, DT_WeaponDecoy )
  14. BEGIN_NETWORK_TABLE( CTFDecoy, DT_WeaponDecoy )
  15. END_NETWORK_TABLE()
  16. /*
  17. // Server specific.
  18. #ifndef CLIENT_DLL
  19. BEGIN_DATADESC( CTFDecoy )
  20. END_DATADESC()
  21. #endif
  22. */
  23. LINK_ENTITY_TO_CLASS( tf_weapon_decoy, CTFDecoy );
  24. PRECACHE_WEAPON_REGISTER( tf_weapon_decoy );
  25. //-----------------------------------------------------------------------------
  26. CTFDecoy::CTFDecoy()
  27. {
  28. }
  29. //-----------------------------------------------------------------------------
  30. void CTFDecoy::PrimaryAttack( void )
  31. {
  32. // Are we capable of firing again?
  33. if ( m_flNextPrimaryAttack > gpGlobals->curtime )
  34. return;
  35. #if !defined( CLIENT_DLL )
  36. CTFPlayer *pOwner = ToTFPlayer( GetOwner() );
  37. if ( !pOwner )
  38. {
  39. return;
  40. }
  41. if ( !CanAttack() )
  42. return;
  43. CBotNPCDecoy *decoy = (CBotNPCDecoy *)CreateEntityByName( "bot_npc_decoy" );
  44. if ( decoy )
  45. {
  46. decoy->SetOwnerEntity( pOwner );
  47. DispatchSpawn( decoy );
  48. m_flNextPrimaryAttack = gpGlobals->curtime + 5.0f;
  49. }
  50. #endif // CLIENT_DLL
  51. }