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.

192 lines
5.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef MONSTERMAKER_H
  7. #define MONSTERMAKER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "cbase.h"
  12. //-----------------------------------------------------------------------------
  13. // Spawnflags
  14. //-----------------------------------------------------------------------------
  15. #define SF_NPCMAKER_START_ON 1 // start active ( if has targetname )
  16. #define SF_NPCMAKER_NPCCLIP 8 // Children are blocked by NPCclip
  17. #define SF_NPCMAKER_FADE 16 // Children's corpses fade
  18. #define SF_NPCMAKER_INF_CHILD 32 // Infinite number of children
  19. #define SF_NPCMAKER_NO_DROP 64 // Do not adjust for the ground's position when checking for spawn
  20. #define SF_NPCMAKER_HIDEFROMPLAYER 128 // Don't spawn if the player's looking at me
  21. #define SF_NPCMAKER_ALWAYSUSERADIUS 256 // Use radius spawn whenever spawning
  22. #define SF_NPCMAKER_NOPRELOADMODELS 512 // Suppress preloading into the cache of all referenced .mdl files
  23. //=========================================================
  24. //=========================================================
  25. class CNPCSpawnDestination : public CPointEntity
  26. {
  27. DECLARE_CLASS( CNPCSpawnDestination, CPointEntity );
  28. public:
  29. CNPCSpawnDestination();
  30. bool IsAvailable(); // Is this spawn destination available for selection?
  31. void OnSpawnedNPC( CAI_BaseNPC *pNPC ); // Notify this spawn destination that an NPC has spawned here.
  32. float m_ReuseDelay; // How long to be unavailable after being selected
  33. string_t m_RenameNPC; // If not NULL, rename the NPC that spawns here to this.
  34. float m_TimeNextAvailable;// The time at which this destination will be available again.
  35. COutputEvent m_OnSpawnNPC;
  36. DECLARE_DATADESC();
  37. };
  38. abstract_class CBaseNPCMaker : public CBaseEntity
  39. {
  40. public:
  41. DECLARE_CLASS( CBaseNPCMaker, CBaseEntity );
  42. void Spawn( void );
  43. virtual int ObjectCaps( void ) { return BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
  44. void MakerThink( void );
  45. bool HumanHullFits( const Vector &vecLocation );
  46. bool CanMakeNPC( bool bIgnoreSolidEntities = false );
  47. virtual void DeathNotice( CBaseEntity *pChild );// NPC maker children use this to tell the NPC maker that they have died.
  48. virtual void MakeNPC( void ) = 0;
  49. virtual void ChildPreSpawn( CAI_BaseNPC *pChild ) {};
  50. virtual void ChildPostSpawn( CAI_BaseNPC *pChild );
  51. CBaseNPCMaker(void) {}
  52. // Input handlers
  53. void InputSpawnNPC( inputdata_t &inputdata );
  54. void InputEnable( inputdata_t &inputdata );
  55. void InputDisable( inputdata_t &inputdata );
  56. void InputToggle( inputdata_t &inputdata );
  57. void InputSetMaxChildren( inputdata_t &inputdata );
  58. void InputAddMaxChildren( inputdata_t &inputdata );
  59. void InputSetMaxLiveChildren( inputdata_t &inputdata );
  60. void InputSetSpawnFrequency( inputdata_t &inputdata );
  61. // State changers
  62. void Toggle( void );
  63. virtual void Enable( void );
  64. virtual void Disable( void );
  65. virtual bool IsDepleted( void );
  66. DECLARE_DATADESC();
  67. int m_nMaxNumNPCs; // max number of NPCs this ent can create
  68. float m_flSpawnFrequency; // delay (in secs) between spawns
  69. enum HullCheckMode_t
  70. {
  71. HULLCHECK_DEFAULT = 0,
  72. HULLCHECK_NONE = 1,
  73. };
  74. int m_nHullCheckMode;
  75. COutputEHANDLE m_OnSpawnNPC;
  76. COutputEvent m_OnAllSpawned;
  77. COutputEvent m_OnAllSpawnedDead;
  78. COutputEvent m_OnAllLiveChildrenDead;
  79. int m_nLiveChildren; // how many NPCs made by this NPC maker that are currently alive
  80. int m_nMaxLiveChildren; // max number of NPCs that this maker may have out at one time.
  81. bool m_bDisabled;
  82. EHANDLE m_hIgnoreEntity;
  83. string_t m_iszIngoreEnt;
  84. };
  85. class CNPCMaker : public CBaseNPCMaker
  86. {
  87. public:
  88. DECLARE_CLASS( CNPCMaker, CBaseNPCMaker );
  89. CNPCMaker( void );
  90. void Precache( void );
  91. virtual void MakeNPC( void );
  92. DECLARE_DATADESC();
  93. string_t m_iszNPCClassname; // classname of the NPC(s) that will be created.
  94. string_t m_SquadName;
  95. string_t m_strHintGroup;
  96. string_t m_spawnEquipment;
  97. string_t m_RelationshipString; // Used to load up relationship keyvalues
  98. string_t m_ChildTargetName;
  99. };
  100. class CTemplateNPCMaker : public CBaseNPCMaker
  101. {
  102. public:
  103. DECLARE_CLASS( CTemplateNPCMaker, CBaseNPCMaker );
  104. CTemplateNPCMaker( void )
  105. {
  106. m_iMinSpawnDistance = 0;
  107. }
  108. virtual void Precache();
  109. virtual CNPCSpawnDestination *FindSpawnDestination();
  110. virtual void MakeNPC( void );
  111. CAI_BaseNPC *MakeNPCFromTemplate( void );
  112. void MakeNPCInRadius( void );
  113. void MakeNPCInLine( void );
  114. virtual void MakeMultipleNPCS( int nNPCs );
  115. protected:
  116. virtual void PrecacheTemplateEntity( CBaseEntity *pEntity );
  117. bool PlaceNPCInRadius( CAI_BaseNPC *pNPC );
  118. bool PlaceNPCInLine( CAI_BaseNPC *pNPC );
  119. // Inputs
  120. void InputSpawnInRadius( inputdata_t &inputdata ) { MakeNPCInRadius(); }
  121. void InputSpawnInLine( inputdata_t &inputdata ) { MakeNPCInLine(); }
  122. void InputSpawnMultiple( inputdata_t &inputdata );
  123. void InputChangeDestinationGroup( inputdata_t &inputdata );
  124. void InputSetMinimumSpawnDistance( inputdata_t &inputdata );
  125. float m_flRadius;
  126. DECLARE_DATADESC();
  127. string_t m_iszTemplateName; // The name of the NPC that will be used as the template.
  128. string_t m_iszTemplateData; // The keyvalue data blob from the template NPC that will be used to spawn new ones.
  129. string_t m_iszDestinationGroup;
  130. int m_iMinSpawnDistance;
  131. enum ThreeStateYesNo_t
  132. {
  133. TS_YN_YES = 0,
  134. TS_YN_NO,
  135. TS_YN_DONT_CARE,
  136. };
  137. enum ThreeStateDist_t
  138. {
  139. TS_DIST_NEAREST = 0,
  140. TS_DIST_FARTHEST,
  141. TS_DIST_DONT_CARE,
  142. };
  143. ThreeStateYesNo_t m_CriterionVisibility;
  144. ThreeStateDist_t m_CriterionDistance;
  145. };
  146. #endif // MONSTERMAKER_H