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.

135 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef GRENADE_BUGBAIT_H
  8. #define GRENADE_BUGBAIT_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "smoke_trail.h"
  13. #include "basegrenade_shared.h"
  14. //Radius of the bugbait's effect on other creatures
  15. extern ConVar bugbait_radius;
  16. extern ConVar bugbait_hear_radius;
  17. extern ConVar bugbait_distract_time;
  18. extern ConVar bugbait_grenade_radius;
  19. #define SF_BUGBAIT_SUPPRESS_CALL 0x00000001
  20. #define SF_BUGBAIT_NOT_THROWN 0x00000002 // Don't detect player throwing the bugbait near this point
  21. #define SF_BUGBAIT_NOT_SQUEEZE 0x00000004 // Don't detect player squeezing the bugbait
  22. //=============================================================================
  23. // Bugbait sensor
  24. //=============================================================================
  25. class CBugBaitSensor : public CPointEntity
  26. {
  27. public:
  28. DECLARE_CLASS( CBugBaitSensor, CPointEntity );
  29. DECLARE_DATADESC();
  30. CBugBaitSensor( void );
  31. ~CBugBaitSensor( void );
  32. bool Baited( CBaseEntity *pOther )
  33. {
  34. if ( !m_bEnabled )
  35. return false;
  36. m_OnBaited.FireOutput( pOther, this );
  37. return true;
  38. }
  39. void InputEnable( inputdata_t &data )
  40. {
  41. m_bEnabled = true;
  42. }
  43. void InputDisable( inputdata_t &data )
  44. {
  45. m_bEnabled = false;
  46. }
  47. void InputToggle( inputdata_t &data )
  48. {
  49. m_bEnabled = !m_bEnabled;
  50. }
  51. bool SuppressCall( void )
  52. {
  53. return ( HasSpawnFlags( SF_BUGBAIT_SUPPRESS_CALL ) );
  54. }
  55. bool DetectsSqueeze( void )
  56. {
  57. return ( !HasSpawnFlags( SF_BUGBAIT_NOT_SQUEEZE ) );
  58. }
  59. bool DetectsThrown( void )
  60. {
  61. return ( !HasSpawnFlags( SF_BUGBAIT_NOT_THROWN ) );
  62. }
  63. float GetRadius( void ) const
  64. {
  65. if ( m_flRadius == 0 )
  66. return bugbait_radius.GetFloat();
  67. return m_flRadius;
  68. }
  69. bool IsDisabled( void ) const
  70. {
  71. return !m_bEnabled;
  72. }
  73. protected:
  74. float m_flRadius;
  75. bool m_bEnabled;
  76. COutputEvent m_OnBaited;
  77. public:
  78. CBugBaitSensor *m_pNext;
  79. };
  80. //
  81. // Bug Bait Grenade
  82. //
  83. class CGrenadeBugBait : public CBaseGrenade
  84. {
  85. DECLARE_CLASS( CGrenadeBugBait, CBaseGrenade );
  86. public:
  87. void Spawn( void );
  88. void Precache( void );
  89. void ThinkBecomeSolid( void );
  90. void SetGracePeriod( float duration );
  91. void BugBaitTouch( CBaseEntity *pOther );
  92. // Activate nearby bugbait targets
  93. static bool ActivateBugbaitTargets( CBaseEntity *pOwner, Vector vecOrigin, bool bSqueezed );
  94. DECLARE_DATADESC();
  95. protected:
  96. void CreateTarget( const Vector &position, CBaseEntity *pOther );
  97. float m_flGracePeriodEndsAt;
  98. SporeTrail *m_pSporeTrail;
  99. };
  100. extern CGrenadeBugBait *BugBaitGrenade_Create( const Vector &position, const QAngle &angles, const Vector &velocity, const QAngle &angVelocity, CBaseEntity *owner );
  101. #endif // GRENADE_BUGBAIT_H