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.

176 lines
5.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Base combat character with no AI
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef AI_NODE_H
  14. #define AI_NODE_H
  15. #pragma once
  16. #include "ai_hull.h"
  17. #include "bitstring.h"
  18. #include "utlvector.h"
  19. enum AI_ZoneIds_t
  20. {
  21. AI_NODE_ZONE_UNKNOWN = 0,
  22. AI_NODE_ZONE_SOLO = 1,
  23. AI_NODE_ZONE_UNIVERSAL = 3,
  24. AI_NODE_FIRST_ZONE = 4,
  25. };
  26. class CAI_Network;
  27. class CAI_Link;
  28. class CAI_Hint;
  29. class CAI_BaseNPC;
  30. #define NOT_CACHED -2 // Returned if data not in cache
  31. #define NO_NODE -1 // Returned when no node meets the qualification
  32. #define MAX_NODE_LINK_DIST 60*12 // Maximum connection length between nodes as well as furthest
  33. #define MAX_NODE_LINK_DIST_SQ (MAX_NODE_LINK_DIST*MAX_NODE_LINK_DIST) // distance allowed to travel to node via local moves
  34. #define MAX_AIR_NODE_LINK_DIST 120*12 // Maximum connection length between air nodes as well as furthest
  35. #define MAX_AIR_NODE_LINK_DIST_SQ (MAX_AIR_NODE_LINK_DIST*MAX_AIR_NODE_LINK_DIST) // distance allowed to travel to node via local moves
  36. #define NODE_HEIGHT 8 // how high to lift nodes off the ground after we drop them all (make stair/ramp mapping easier)
  37. #define NODE_CLIMB_OFFSET 8
  38. #define HULL_TEST_STEP_SIZE 16 // how far the test hull moves on each step
  39. //=========================================================
  40. // The type of node
  41. //=========================================================
  42. enum NodeType_e
  43. {
  44. NODE_ANY, // Used to specify any type of node (for search)
  45. NODE_DELETED, // Used in wc_edit mode to remove nodes during runtime
  46. NODE_GROUND,
  47. NODE_AIR,
  48. NODE_CLIMB,
  49. NODE_WATER
  50. };
  51. enum NodeInfoBits_e
  52. {
  53. bits_NODE_CLIMB_BOTTOM = (1 << 0), // Node at bottom of ladder
  54. bits_NODE_CLIMB_ON = (1 << 1), // Node on ladder somewhere
  55. bits_NODE_CLIMB_OFF_FORWARD = (1 << 2), // Dismount climb by going forward
  56. bits_NODE_CLIMB_OFF_LEFT = (1 << 3), // Dismount climb by going left
  57. bits_NODE_CLIMB_OFF_RIGHT = (1 << 4), // Dismount climb by going right
  58. bits_NODE_CLIMB_EXIT = bits_NODE_CLIMB_OFF_FORWARD| bits_NODE_CLIMB_OFF_LEFT | bits_NODE_CLIMB_OFF_RIGHT,
  59. NODE_ENT_FLAGS_SHIFT = 5,
  60. //bits_HUMAN_HULL 5
  61. //bits_SMALL_CENTERED_HULL 6
  62. //bits_WIDE_HUMAN_HULL 7
  63. //bits_TINY_HULL 8
  64. //bits_WIDE_SHORT_HULL 9
  65. //bits_MEDIUM_HULL 10
  66. //bits_TINY_CENTERED_HULL 11
  67. //bits_LARGE_HULL 12
  68. //bits_LARGE_CENTERED_HULL 13
  69. // NOTE: bits_DONT_DROP used to be here now that we need more hulls it has been moved. However, this spot needs to be held for legacy.
  70. bits_LEGACY_DONT_DROP = ( 1 << 14 ),
  71. //bits_MEDIUM_TALL_HULL 15
  72. //bits_TINY_FLUID_HULL 16
  73. //bits_MEDIUMBIG_HULL 17
  74. //ADD MORE HULLS HERE (18-26)
  75. bits_DONT_DROP = ( 1 << 27 ),
  76. /****** NOTE: Previously only the lower 16 bits were saved. This mask will allow us to save more, but ignore the final bits. ******/
  77. bits_NODE_SAVE_MASK = 0x0FFFFFFF,
  78. bits_NODE_WC_NEED_REBUILD = 0x10000000, // Used to more nodes in WC edit mode
  79. bits_NODE_WC_CHANGED = 0x20000000, // Node changed during WC edit
  80. bits_NODE_WONT_FIT_HULL = 0x40000000, // Used only for debug display
  81. bits_NODE_FALLEN = 0x80000000, // Fell through the world during initialization
  82. };
  83. //=============================================================================
  84. // >> CAI_Node
  85. //=============================================================================
  86. class CAI_Node
  87. {
  88. public:
  89. CAI_Node( int id, const Vector &origin, float yaw );
  90. CAI_Hint* GetHint() { return m_pHint; }
  91. void SetHint( CAI_Hint *pHint ) { m_pHint = pHint; }
  92. int NumLinks() const { return m_Links.Count(); }
  93. void ClearLinks() { m_Links.Purge(); }
  94. CAI_Link * GetLink( int destNodeId );
  95. CAI_Link * GetLinkByIndex( int i ) { return m_Links[i]; }
  96. bool IsLocked() const { return ( m_flNextUseTime > gpGlobals->curtime ); }
  97. void Lock( float duration ) { m_flNextUseTime = gpGlobals->curtime + duration; }
  98. void Unlock() { m_flNextUseTime = gpGlobals->curtime; }
  99. int GetZone() const { return m_zone; }
  100. void SetZone( int zone ) { m_zone = zone; }
  101. Vector GetPosition(int hull) const; // Hull specific position for a node
  102. CAI_Link* HasLink(int nNodeID); // Return link to nNodeID or NULL
  103. void ShuffleLinks(); // Called before GetShuffeledLinks to reorder
  104. CAI_Link* GetShuffeledLink(int nNum); // Used to get links in different order each time
  105. int GetId() const { return m_iID; }
  106. const Vector & GetOrigin() const { return m_vOrigin; }
  107. Vector & AccessOrigin() { return m_vOrigin; }
  108. float GetYaw() const { return m_flYaw; }
  109. NodeType_e SetType( NodeType_e type ) { return ( m_eNodeType = type ); }
  110. NodeType_e GetType() const { return m_eNodeType; }
  111. void SetNeedsRebuild() { m_eNodeInfo |= bits_NODE_WC_NEED_REBUILD; }
  112. void ClearNeedsRebuild() { m_eNodeInfo &= ~bits_NODE_WC_NEED_REBUILD; }
  113. bool NeedsRebuild() const { return ( ( m_eNodeInfo & bits_NODE_WC_NEED_REBUILD ) != 0 ); }
  114. void AddLink(CAI_Link *newLink);
  115. int m_iID; // ID for this node
  116. Vector m_vOrigin; // location of this node in space
  117. float m_flVOffset[NUM_HULLS]; // vertical offset for each hull type, assuming ground node, 0 otherwise
  118. float m_flYaw; // NPC on this node should face this yaw to face the hint, or climb a ladder
  119. NodeType_e m_eNodeType; // The type of node
  120. int m_eNodeInfo; // bits that tell us more about this nodes
  121. int m_zone;
  122. CUtlVector<CAI_Link *> m_Links; // growable array of links to this node
  123. float m_flNextUseTime; // When can I be used again?
  124. CAI_Hint* m_pHint; // hint attached to this node
  125. int m_iFirstShuffledLink; // first link to check
  126. };
  127. extern float GetFloorZ(const Vector &origin);
  128. extern float GetFloorDistance(const Vector &origin);
  129. #endif // AI_NODE_H