Counter Strike : Global Offensive Source Code
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.

163 lines
5.4 KiB

  1. // Inferno.h
  2. // An Inferno
  3. // Author: Michael S. Booth, February 2005
  4. // Copyright (c) 2005 Turtle Rock Studios, Inc. - All Rights Reserved
  5. #ifndef _INFERNO_H_
  6. #define _INFERNO_H_
  7. #include "nav.h" // for extent class - should be moved somewhere more general
  8. #include "GameEventListener.h"
  9. // Forward declaration
  10. class CBasePlayer;
  11. /**
  12. * The server-side Inferno entity.
  13. * This entity manages the growth of the flames and damage-dealing.
  14. * Keep this in sync with C_Inferno on the client, which manages the fire rendering
  15. */
  16. enum
  17. {
  18. INFERNO_TYPE_FIRE = 0,
  19. INFERNO_TYPE_INCGREN_FIRE, // incendiary grenade fire, used to play a different sound
  20. INFERNO_TYPE_FIREWORKS,
  21. };
  22. class CInferno : public CBaseEntity, public CGameEventListener
  23. {
  24. public:
  25. DECLARE_CLASS( CInferno, CBaseEntity );
  26. DECLARE_SERVERCLASS();
  27. DECLARE_DATADESC();
  28. CInferno();
  29. virtual ~CInferno();
  30. virtual void Precache( void );
  31. virtual void Spawn( void );
  32. void SetMaxFlames( int nMaxFlames ) { m_nMaxFlames = nMaxFlames; }
  33. virtual int UpdateTransmitState( void )
  34. {
  35. return FL_EDICT_ALWAYS;
  36. }
  37. void StartBurning( const Vector &pos, const Vector &normal, const Vector &velocity, int initialDepth = 0 ); // start the Inferno burning
  38. void InfernoThink( void );
  39. bool BShouldExtinguishSmokeGrenadeBounce( CBaseEntity *entity, Vector &posDropSmoke ) const;
  40. bool IsTouching( const Vector &from, const Vector &to, Vector *where = NULL ) const; // return true if given ray intersects any fires, point of intersection in "where" if non-NULL
  41. bool IsTouching( const CNavArea *area ) const; // return true if given area overlaps any fires
  42. bool WasCreatedInSmoke( void ) const { return m_bWasCreatedInSmoke; }
  43. virtual int GetDamageType() { return DMG_BURN; }
  44. virtual float GetDamagePerSecond();
  45. // I've moved some functionality into these member functions in order to
  46. // make the insect swarm easier to implement (sjb)
  47. virtual const char *GetParticleEffectName();
  48. virtual const char *GetImpactParticleEffectName();
  49. virtual float GetFlameLifetime() const;
  50. virtual bool CanHarm( CBaseEntity *pEnt ) const { return true; }
  51. virtual float GetFlameSpreadDelay() { return 0.0f; }
  52. int GetInfernoType() const { return m_nInfernoType; }
  53. void SetInfernoType( int type ) { m_nInfernoType = type; }
  54. void SetSourceWeaponInfo( const CCSWeaponInfo* pWeaponInfo ) { m_pWeaponInfo = pWeaponInfo; }
  55. const CCSWeaponInfo* GetSourceWeaponInfo() const { return m_pWeaponInfo; }
  56. protected:
  57. void FireGameEvent( IGameEvent *event );
  58. int ExtinguishFlamesAroundSmokeGrenade( Vector vecStart ); // returns count of fire patches extinguished
  59. void ExtinguishIndividualFlameBySmokeGrenade( int iFire, Vector vecStart );
  60. // Checks if all flames have expired and we should delete the inferno
  61. bool CheckExpired();
  62. // Marks covered areas as damaging so bots will avoid them
  63. void MarkCoveredAreaAsDamaging();
  64. private:
  65. enum { MAX_INFERNO_FIRES = 64 };
  66. enum ECreateFireResult_t
  67. {
  68. k_ECreateFireResult_OK,
  69. k_ECreateFireResult_LimitExceeded,
  70. k_ECreateFireResult_AlreadyOnFire,
  71. k_ECreateFireResult_InSmoke,
  72. k_ECreateFireResult_AllSolid,
  73. };
  74. CNetworkArray( int, m_fireXDelta, MAX_INFERNO_FIRES );
  75. CNetworkArray( int, m_fireYDelta, MAX_INFERNO_FIRES );
  76. CNetworkArray( int, m_fireZDelta, MAX_INFERNO_FIRES );
  77. CNetworkArray( bool, m_bFireIsBurning, MAX_INFERNO_FIRES );
  78. CNetworkArray( Vector, m_BurnNormal, MAX_INFERNO_FIRES );
  79. CNetworkVar( int, m_fireCount ); // total number of flames spawned
  80. CNetworkVar( int, m_nInfernoType );
  81. bool m_bWasCreatedInSmoke;
  82. struct FireInfo
  83. {
  84. Vector m_pos; // location of this fire
  85. Vector m_center; // center of fire
  86. Vector m_normal; // surface normal at this fire
  87. bool m_burning;
  88. int m_treeDepth;
  89. int m_spawnCount;
  90. FireInfo *m_parent; // the fire that spawned us
  91. CountdownTimer m_spawnLifetime; // how long we attempt to spawn new fires
  92. CountdownTimer m_spawnTimer; // when we try to spawn a new fire
  93. CountdownTimer m_lifetime; // lifetime of this fire
  94. float m_flWaterHeight; // how much we were raised above water
  95. };
  96. bool IsFirePosInSmokeCloud( const Vector &pos ) const;
  97. void Spread( const Vector &spreadVelocity );
  98. ECreateFireResult_t CreateFire( const Vector &pos, const Vector &normal, FireInfo *parent, int depth ); // create an actual fire entity at the given position
  99. FireInfo *m_fire[ MAX_INFERNO_FIRES ]; // set of all active fires
  100. Extent m_extent;
  101. void RecomputeExtent( void );
  102. CountdownTimer m_damageTimer;
  103. CountdownTimer m_damageRampTimer; // damage starts at zero and ramps up
  104. bool IsTouching( CBaseEntity *entity, float radius, bool checkLOS ) const; // return true if position is in contact with a fire within the Inferno
  105. Vector m_splashVelocity; // the velocity of the flame-causing incendiary that hit
  106. Vector m_startPos; // the ignition point of the entire inferno
  107. IntervalTimer m_activeTimer; // How long this inferno has been active.
  108. int m_fireSpawnOffset;
  109. int m_nMaxFlames;
  110. CountdownTimer m_BookkeepingTimer; // Only check spread / force expiry checks every 0.1s;
  111. CountdownTimer m_NextSpreadTimer;
  112. // the weapon info for the grenade type (if any) that spawned this inferno
  113. const CCSWeaponInfo* m_pWeaponInfo;
  114. };
  115. class CFireCrackerBlast : public CInferno
  116. {
  117. public:
  118. DECLARE_CLASS( CFireCrackerBlast, CInferno );
  119. DECLARE_SERVERCLASS();
  120. virtual void Spawn();
  121. virtual const char *GetParticleEffectName();
  122. virtual const char *GetImpactParticleEffectName();
  123. };
  124. #endif // _INFERNO_H_