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.

186 lines
5.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef ANTLION_MAKER_H
  7. #define ANTLION_MAKER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "npc_antlion.h"
  12. #include "monstermaker.h"
  13. #include "igamesystem.h"
  14. #include "ai_hint.h"
  15. //
  16. // Antlion maker class
  17. //
  18. #define SF_ANTLIONMAKER_RANDOM_SPAWN_NODE 0x00000400
  19. #define SF_ANTLIONMAKER_SPAWN_CLOSE_TO_TARGET 0x00000800
  20. #define SF_ANTLIONMAKER_RANDOM_FIGHT_TARGET 0x00001000
  21. #define SF_ANTLIONMAKER_DO_BLOCKEDEFFECTS 0x00002000
  22. class CAntlionTemplateMaker : public CTemplateNPCMaker
  23. {
  24. public:
  25. DECLARE_CLASS( CAntlionTemplateMaker, CTemplateNPCMaker );
  26. CAntlionTemplateMaker( void );
  27. ~CAntlionTemplateMaker( void );
  28. virtual int DrawDebugTextOverlays( void );
  29. virtual void DrawDebugGeometryOverlays( void );
  30. void MakeNPC( void );
  31. void ChildPreSpawn( CAI_BaseNPC *pChild );
  32. void ChildPostSpawn( CAI_BaseNPC *pChild );
  33. void InputSetFightTarget( inputdata_t &inputdata );
  34. void InputSetFollowTarget( inputdata_t &inputdata );
  35. void InputClearFightTarget( inputdata_t &inputdata );
  36. void InputClearFollowTarget( inputdata_t &inputdata );
  37. void InputSetSpawnRadius( inputdata_t &inputdata );
  38. void InputAddToPool( inputdata_t &inputdata );
  39. void InputSetMaxPool( inputdata_t &inputdata );
  40. void InputSetPoolRegenAmount( inputdata_t &inputdata );
  41. void InputSetPoolRegenTime( inputdata_t &inputdata );
  42. void InputChangeDestinationGroup( inputdata_t &inputdata );
  43. void Activate( void );
  44. // Do not transition
  45. int ObjectCaps( void ) { return (BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); }
  46. bool CanMakeNPC( bool bIgnoreSolidEntities = false );
  47. bool ShouldAlwaysThink( void ) { return true; }
  48. void AddChild( CNPC_Antlion *pAnt );
  49. void RemoveChild( CNPC_Antlion *pAnt );
  50. void FixupOrphans( void );
  51. void UpdateChildren( void );
  52. void CreateProxyTarget( const Vector &position );
  53. void DestroyProxyTarget( void );
  54. void SetFightTarget( string_t strTarget, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL );
  55. void SetFightTarget( CBaseEntity *pEntity );
  56. void SetFightTarget( const Vector &position );
  57. void SetFollowTarget( string_t strTarget, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL );
  58. void SetFollowTarget( CBaseEntity *pEntity );
  59. void SetChildMoveState( AntlionMoveState_e state );
  60. void DeathNotice( CBaseEntity *pVictim );
  61. bool IsDepleted( void );
  62. bool ShouldHearBugbait( void ) { return (m_bIgnoreBugbait==false); }
  63. CBaseEntity *GetFightTarget( void );
  64. CBaseEntity *GetFollowTarget( void );
  65. virtual void Enable( void );
  66. virtual void Disable( void );
  67. void BlockedCheckFunc( void );
  68. void FindNodesCloseToPlayer( void );
  69. void DoBlockedEffects( CBaseEntity *pBlocker, Vector vOrigin );
  70. CBaseEntity *AllHintsFromClusterBlocked( CAI_Hint *pNode, bool &bChosenHintBlocked );
  71. void ActivateAllSpores( void );
  72. void ActivateSpore( const char* sporename, Vector vOrigin );
  73. void DisableSpore( const char* sporename );
  74. void DisableAllSpores( void );
  75. protected:
  76. void PrecacheTemplateEntity( CBaseEntity *pEntity );
  77. bool FindHintSpawnPosition( const Vector &origin, float radius, string_t hintGroupName, CAI_Hint **pHint, bool bRandom = false );
  78. bool FindNearTargetSpawnPosition( Vector &origin, float radius, CBaseEntity *pTarget );
  79. //These are used by FindNearTargetSpawnPosition
  80. bool FindPositionOnFoot( Vector &origin, float radius, CBaseEntity *pTarget );
  81. bool FindPositionOnVehicle( Vector &origin, float radius, CBaseEntity *pTarget );
  82. bool ValidateSpawnPosition( Vector &vOrigin, CBaseEntity *pTarget = NULL );
  83. // Pool behavior for coast
  84. void PoolAdd( int iNumToAdd );
  85. void PoolRegenThink( void );
  86. protected:
  87. // FIXME: The m_strSpawnGroup is redundant to the m_iszDestinationGroup in the base class NPC template maker
  88. string_t m_strSpawnGroup; // if present, spawn children on the nearest node of this group (to the player)
  89. string_t m_strSpawnTarget; // name of target to spawn near
  90. float m_flSpawnRadius; // radius around target to attempt to spawn in
  91. float m_flWorkerSpawnRate; // Percentage chance of spawning a worker when we spawn an antlion [0..1].
  92. string_t m_strFightTarget; // target entity name that all children will be told to fight to
  93. string_t m_strFollowTarget; // entity name that all children will follow
  94. bool m_bIgnoreBugbait; // Whether or not to ignore bugbait
  95. AntlionMoveState_e m_nChildMoveState;
  96. EHANDLE m_hFightTarget; // A normal entity pointer for fight position
  97. EHANDLE m_hProxyTarget; // This is a self-held target that is created and used when a vector is passed in as a fight
  98. // goal, instead of an entity
  99. EHANDLE m_hFollowTarget; // Target to follow
  100. CUtlVector< CHandle< CNPC_Antlion > > m_Children;
  101. // Pool behavior for coast
  102. int m_iPool;
  103. int m_iMaxPool;
  104. int m_iPoolRegenAmount;
  105. float m_flPoolRegenTime;
  106. float m_flVehicleSpawnDistance;
  107. int m_iSkinCount;
  108. float m_flBlockedBumpTime;
  109. bool m_bBlocked;
  110. COutputEvent m_OnAllBlocked;
  111. bool m_bCreateSpores;
  112. DECLARE_DATADESC();
  113. };
  114. // ========================================================
  115. // Antlion maker manager
  116. // ========================================================
  117. class CAntlionMakerManager : public CAutoGameSystem
  118. {
  119. public:
  120. CAntlionMakerManager( char const *name ) : CAutoGameSystem( name )
  121. {
  122. }
  123. void LevelInitPostEntity( void );
  124. void BroadcastFightGoal( const Vector &vFightGoal );
  125. void BroadcastFightGoal( CBaseEntity *pFightGoal );
  126. void BroadcastFollowGoal( CBaseEntity *pFollowGoal );
  127. protected:
  128. void GatherMakers( void );
  129. CUtlVector< CHandle< CAntlionTemplateMaker > > m_Makers;
  130. };
  131. extern CAntlionMakerManager g_AntlionMakerManager;
  132. #endif // ANTLION_MAKER_H