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.

185 lines
7.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=============================================================================//
  4. #include "cbase.h"
  5. #include "ai_hull.h"
  6. // memdbgon must be the last include file in a .cpp file!!!
  7. #include "tier0/memdbgon.h"
  8. struct ai_hull_t
  9. {
  10. ai_hull_t( int bit, const char *pName, const Vector &_mins, const Vector &_maxs, const Vector &_smallMins, const Vector &_smallMaxs )
  11. : hullBit( bit ), mins( _mins ), maxs( _maxs ), smallMins( _smallMins ), smallMaxs( _smallMaxs ), name( pName ) {}
  12. int hullBit;
  13. const char* name;
  14. Vector mins;
  15. Vector maxs;
  16. Vector smallMins;
  17. Vector smallMaxs;
  18. };
  19. //=================================================================================
  20. // Create the hull types here.
  21. //=================================================================================
  22. #ifdef HL1_DLL
  23. ai_hull_t Human_Hull (bits_HUMAN_HULL, "HUMAN_HULL", Vector(-13,-13, 0), Vector(13, 13, 72), Vector(-8,-8, 0), Vector( 8, 8, 72) );
  24. ai_hull_t Small_Centered_Hull (bits_SMALL_CENTERED_HULL, "SMALL_CENTERED_HULL", Vector(-20,-20, -20), Vector(20, 20, 20), Vector(-12,-12,-12), Vector(12, 12, 12) );
  25. ai_hull_t Wide_Human_Hull (bits_WIDE_HUMAN_HULL, "WIDE_HUMAN_HULL", Vector(-32,-32, 0), Vector(32, 32, 72), Vector(-10,-10, 0), Vector(10, 10, 72) );
  26. ai_hull_t Tiny_Hull (bits_TINY_HULL, "TINY_HULL", Vector(-12,-12, 0), Vector(12, 12, 24), Vector(-12,-12, 0), Vector(12, 12, 24) );
  27. ai_hull_t Wide_Short_Hull (bits_WIDE_SHORT_HULL, "WIDE_SHORT_HULL", Vector(-35,-35, 0), Vector(35, 35, 32), Vector(-20,-20, 0), Vector(20, 20, 32) );
  28. ai_hull_t Medium_Hull (bits_MEDIUM_HULL, "MEDIUM_HULL", Vector(-16,-16, 0), Vector(16, 16, 64), Vector(-8,-8, 0), Vector(8, 8, 64) );
  29. ai_hull_t Tiny_Centered_Hull (bits_TINY_CENTERED_HULL, "TINY_CENTERED_HULL", Vector(-8, -8, -4), Vector(8, 8, 4), Vector(-8,-8, -4), Vector( 8, 8, 4) );
  30. ai_hull_t Large_Hull (bits_LARGE_HULL, "LARGE_HULL", Vector(-40,-40, 0), Vector(40, 40, 100), Vector(-40,-40, 0), Vector(40, 40, 100) );
  31. ai_hull_t Large_Centered_Hull (bits_LARGE_CENTERED_HULL, "LARGE_CENTERED_HULL", Vector(-38,-38, -38), Vector(38, 38, 38), Vector(-30,-30,-30), Vector(30, 30, 30) );
  32. ai_hull_t Medium_Tall_Hull (bits_MEDIUM_TALL_HULL, "MEDIUM_TALL_HULL", Vector(-18,-18, 0), Vector(18, 18, 100), Vector(-12,-12, 0), Vector(12, 12, 100) );
  33. #else
  34. ai_hull_t Human_Hull (bits_HUMAN_HULL, "HUMAN_HULL", Vector(-13,-13, 0), Vector(13, 13, 72), Vector(-8,-8, 0), Vector( 8, 8, 72) );
  35. ai_hull_t Small_Centered_Hull (bits_SMALL_CENTERED_HULL, "SMALL_CENTERED_HULL", Vector(-20,-20, -20), Vector(20, 20, 20), Vector(-12,-12,-12), Vector(12, 12, 12) );
  36. ai_hull_t Wide_Human_Hull (bits_WIDE_HUMAN_HULL, "WIDE_HUMAN_HULL", Vector(-15,-15, 0), Vector(15, 15, 72), Vector(-10,-10, 0), Vector(10, 10, 72) );
  37. ai_hull_t Tiny_Hull (bits_TINY_HULL, "TINY_HULL", Vector(-12,-12, 0), Vector(12, 12, 24), Vector(-12,-12, 0), Vector(12, 12, 24) );
  38. ai_hull_t Wide_Short_Hull (bits_WIDE_SHORT_HULL, "WIDE_SHORT_HULL", Vector(-35,-35, 0), Vector(35, 35, 32), Vector(-20,-20, 0), Vector(20, 20, 32) );
  39. ai_hull_t Medium_Hull (bits_MEDIUM_HULL, "MEDIUM_HULL", Vector(-16,-16, 0), Vector(16, 16, 64), Vector(-8,-8, 0), Vector(8, 8, 64) );
  40. ai_hull_t Tiny_Centered_Hull (bits_TINY_CENTERED_HULL, "TINY_CENTERED_HULL", Vector(-8, -8, -4), Vector(8, 8, 4), Vector(-8,-8, -4), Vector( 8, 8, 4) );
  41. ai_hull_t Large_Hull (bits_LARGE_HULL, "LARGE_HULL", Vector(-40,-40, 0), Vector(40, 40, 100), Vector(-40,-40, 0), Vector(40, 40, 100) );
  42. ai_hull_t Large_Centered_Hull (bits_LARGE_CENTERED_HULL, "LARGE_CENTERED_HULL", Vector(-38,-38, -38), Vector(38, 38, 38), Vector(-30,-30,-30), Vector(30, 30, 30) );
  43. ai_hull_t Medium_Tall_Hull (bits_MEDIUM_TALL_HULL, "MEDIUM_TALL_HULL", Vector(-18,-18, 0), Vector(18, 18, 100), Vector(-12,-12, 0), Vector(12, 12, 100) );
  44. #endif//HL1_DLL
  45. //
  46. // Array of hulls. These hulls must correspond with the enumerations in AI_Hull.h!
  47. //
  48. ai_hull_t* hull[NUM_HULLS] =
  49. {
  50. &Human_Hull,
  51. &Small_Centered_Hull,
  52. &Wide_Human_Hull,
  53. &Tiny_Hull,
  54. &Wide_Short_Hull,
  55. &Medium_Hull,
  56. &Tiny_Centered_Hull,
  57. &Large_Hull,
  58. &Large_Centered_Hull,
  59. &Medium_Tall_Hull,
  60. };
  61. //-----------------------------------------------------------------------------
  62. // Purpose:
  63. // Input :
  64. // Output :
  65. //-----------------------------------------------------------------------------
  66. const Vector &NAI_Hull::Mins(int id)
  67. {
  68. return hull[id]->mins;
  69. }
  70. //-----------------------------------------------------------------------------
  71. // Purpose:
  72. // Input :
  73. // Output :
  74. //-----------------------------------------------------------------------------
  75. const Vector &NAI_Hull::Maxs(int id)
  76. {
  77. return hull[id]->maxs;
  78. }
  79. //-----------------------------------------------------------------------------
  80. // Purpose:
  81. // Input :
  82. // Output :
  83. //-----------------------------------------------------------------------------
  84. const Vector &NAI_Hull::SmallMins(int id)
  85. {
  86. return hull[id]->smallMins;
  87. }
  88. //-----------------------------------------------------------------------------
  89. // Purpose:
  90. // Input :
  91. // Output :
  92. //-----------------------------------------------------------------------------
  93. const Vector &NAI_Hull::SmallMaxs(int id)
  94. {
  95. return hull[id]->smallMaxs;
  96. }
  97. //-----------------------------------------------------------------------------
  98. // Purpose:
  99. // Input :
  100. // Output :
  101. //-----------------------------------------------------------------------------
  102. float NAI_Hull::Length(int id)
  103. {
  104. return (hull[id]->maxs.x - hull[id]->mins.x);
  105. }
  106. //-----------------------------------------------------------------------------
  107. // Purpose:
  108. // Input :
  109. // Output :
  110. //-----------------------------------------------------------------------------
  111. float NAI_Hull::Width(int id)
  112. {
  113. return (hull[id]->maxs.y - hull[id]->mins.y);
  114. }
  115. //-----------------------------------------------------------------------------
  116. // Purpose:
  117. // Input :
  118. // Output :
  119. //-----------------------------------------------------------------------------
  120. float NAI_Hull::Height(int id)
  121. {
  122. return (hull[id]->maxs.z - hull[id]->mins.z);
  123. }
  124. //-----------------------------------------------------------------------------
  125. // Purpose:
  126. // Input :
  127. // Output :
  128. //-----------------------------------------------------------------------------
  129. int NAI_Hull::Bits(int id)
  130. {
  131. return hull[id]->hullBit;
  132. }
  133. //-----------------------------------------------------------------------------
  134. // Purpose:
  135. // Input :
  136. // Output :
  137. //-----------------------------------------------------------------------------
  138. const char *NAI_Hull::Name(int id)
  139. {
  140. return hull[id]->name;
  141. }
  142. //-----------------------------------------------------------------------------
  143. // Purpose:
  144. // Input :
  145. // Output :
  146. //-----------------------------------------------------------------------------
  147. Hull_t NAI_Hull::LookupId(const char *szName)
  148. {
  149. int i;
  150. if (!szName)
  151. {
  152. return HULL_HUMAN;
  153. }
  154. for (i = 0; i < NUM_HULLS; i++)
  155. {
  156. if (stricmp( szName, NAI_Hull::Name( i )) == 0)
  157. {
  158. return (Hull_t)i;
  159. }
  160. }
  161. return HULL_HUMAN;
  162. }