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.

206 lines
8.3 KiB

  1. //========= Copyright � 1996-2005, 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, const unsigned int _nAITraceMask = MASK_NPCWORLDSTATIC )
  11. : hullBit( bit ), mins( _mins ), maxs( _maxs ), smallMins( _smallMins ), smallMaxs( _smallMaxs ), name( pName ), nAITraceMask( _nAITraceMask ) {}
  12. int hullBit;
  13. const char* name;
  14. Vector mins;
  15. Vector maxs;
  16. Vector smallMins;
  17. Vector smallMaxs;
  18. unsigned int nAITraceMask;
  19. };
  20. //=================================================================================
  21. // Create the hull types here.
  22. //=================================================================================
  23. #ifdef INFESTED_DLL
  24. 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) ); // Colonists
  25. 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) ); // -
  26. ai_hull_t Wide_Human_Hull (bits_WIDE_HUMAN_HULL, "WIDE_HUMAN_HULL", Vector(-20,-20, 0), Vector(20, 20, 72), Vector(-20,-20, 0), Vector(20, 20, 72) ); // Marines
  27. ai_hull_t Tiny_Hull (bits_TINY_HULL, "TINY_HULL", Vector(-12,-12, 0), Vector(12, 12, 12), Vector(-12,-12, 0), Vector(12, 12, 12) ); // Parasites/grubs
  28. ai_hull_t Wide_Short_Hull (bits_WIDE_SHORT_HULL, "WIDE_SHORT_HULL", Vector(-40,-40, 0), Vector(40, 40, 72), Vector(-24,-24, 0), Vector(24, 24, 32) ); // Harvester/Bodysnatcher/Mortarbug
  29. 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) ); // -
  30. 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) ); // Buzzer
  31. ai_hull_t Large_Hull (bits_LARGE_HULL, "LARGE_HULL", Vector(-40,-40, 0), Vector(40, 40, 110), Vector(-40,-40, 0), Vector(40, 40, 110) ); // Shieldbug
  32. ai_hull_t Large_Centered_Hull (bits_LARGE_CENTERED_HULL, "LARGE_CENTERED_HULL", Vector(-80,-80, 0), Vector(80, 80, 200), Vector(-80,-80,0), Vector(80, 80, 200) ); // Queen
  33. ai_hull_t Medium_Tall_Hull (bits_MEDIUM_TALL_HULL, "MEDIUM_TALL_HULL", Vector(-22,-22, 0), Vector(22, 22, 100), Vector(-22,-22, 0), Vector(22, 22, 100) ); // Hunter/Meatbug
  34. ai_hull_t Tiny_Fluid_Hull (bits_TINY_FLUID_HULL, "TINY_FLUID_HULL", Vector(-8,-8, 0), Vector(8, 8, 16), Vector(-8,-8, 0), Vector(8, 8, 16), MASK_NPCWORLDSTATIC_FLUID ); // Blob?
  35. ai_hull_t MediumBig_Hull (bits_MEDIUMBIG_HULL, "MEDIUMBIG_HULL", Vector(-20,-20, 0), Vector(20, 20, 69), Vector(-20,-20, 0), Vector(20, 20, 69) ); // Drones
  36. #else
  37. 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) );
  38. 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) );
  39. 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) );
  40. 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) );
  41. 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) );
  42. 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) );
  43. 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) );
  44. 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) );
  45. 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) );
  46. 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) );
  47. ai_hull_t Tiny_Fluid_Hull (bits_TINY_FLUID_HULL, "TINY_FLUID_HULL", Vector(-6.5,-6.5, 0), Vector(6.5, 6.5, 13), Vector(-6.5,-6.5, 0), Vector(6.5, 6.5, 13), MASK_NPCWORLDSTATIC_FLUID );
  48. ai_hull_t MediumBig_Hull (bits_MEDIUMBIG_HULL, "MEDIUMBIG_HULL", Vector(-17,-17, 0), Vector(17, 17, 69), Vector(-15,-15, 0), Vector(15, 15, 69) ); // asw
  49. #endif
  50. //
  51. // Array of hulls. These hulls must correspond with the enumerations in AI_Hull.h!
  52. //
  53. ai_hull_t* hull[NUM_HULLS] =
  54. {
  55. &Human_Hull,
  56. &Small_Centered_Hull,
  57. &Wide_Human_Hull,
  58. &Tiny_Hull,
  59. &Wide_Short_Hull,
  60. &Medium_Hull,
  61. &Tiny_Centered_Hull,
  62. &Large_Hull,
  63. &Large_Centered_Hull,
  64. &Medium_Tall_Hull,
  65. &Tiny_Fluid_Hull,
  66. &MediumBig_Hull,
  67. };
  68. //-----------------------------------------------------------------------------
  69. // Purpose:
  70. // Input :
  71. // Output :
  72. //-----------------------------------------------------------------------------
  73. const Vector &NAI_Hull::Mins(int id)
  74. {
  75. return hull[id]->mins;
  76. }
  77. //-----------------------------------------------------------------------------
  78. // Purpose:
  79. // Input :
  80. // Output :
  81. //-----------------------------------------------------------------------------
  82. const Vector &NAI_Hull::Maxs(int id)
  83. {
  84. return hull[id]->maxs;
  85. }
  86. //-----------------------------------------------------------------------------
  87. // Purpose:
  88. // Input :
  89. // Output :
  90. //-----------------------------------------------------------------------------
  91. const Vector &NAI_Hull::SmallMins(int id)
  92. {
  93. return hull[id]->smallMins;
  94. }
  95. //-----------------------------------------------------------------------------
  96. // Purpose:
  97. // Input :
  98. // Output :
  99. //-----------------------------------------------------------------------------
  100. const Vector &NAI_Hull::SmallMaxs(int id)
  101. {
  102. return hull[id]->smallMaxs;
  103. }
  104. //-----------------------------------------------------------------------------
  105. // Purpose:
  106. // Input :
  107. // Output :
  108. //-----------------------------------------------------------------------------
  109. float NAI_Hull::Length(int id)
  110. {
  111. return (hull[id]->maxs.x - hull[id]->mins.x);
  112. }
  113. //-----------------------------------------------------------------------------
  114. // Purpose:
  115. // Input :
  116. // Output :
  117. //-----------------------------------------------------------------------------
  118. float NAI_Hull::Width(int id)
  119. {
  120. return (hull[id]->maxs.y - hull[id]->mins.y);
  121. }
  122. //-----------------------------------------------------------------------------
  123. // Purpose:
  124. // Input :
  125. // Output :
  126. //-----------------------------------------------------------------------------
  127. float NAI_Hull::Height(int id)
  128. {
  129. return (hull[id]->maxs.z - hull[id]->mins.z);
  130. }
  131. //-----------------------------------------------------------------------------
  132. // Purpose:
  133. // Input :
  134. // Output :
  135. //-----------------------------------------------------------------------------
  136. int NAI_Hull::Bits(int id)
  137. {
  138. return hull[id]->hullBit;
  139. }
  140. //-----------------------------------------------------------------------------
  141. // Purpose:
  142. // Input :
  143. // Output :
  144. //-----------------------------------------------------------------------------
  145. const char *NAI_Hull::Name(int id)
  146. {
  147. return hull[id]->name;
  148. }
  149. //-----------------------------------------------------------------------------
  150. // Purpose:
  151. // Input :
  152. // Output :
  153. //-----------------------------------------------------------------------------
  154. unsigned int NAI_Hull::TraceMask(int id)
  155. {
  156. return hull[id]->nAITraceMask;
  157. }
  158. //-----------------------------------------------------------------------------
  159. // Purpose:
  160. // Input :
  161. // Output :
  162. //-----------------------------------------------------------------------------
  163. Hull_t NAI_Hull::LookupId(const char *szName)
  164. {
  165. int i;
  166. if (!szName)
  167. {
  168. return HULL_HUMAN;
  169. }
  170. for (i = 0; i < NUM_HULLS; i++)
  171. {
  172. if (stricmp( szName, NAI_Hull::Name( i )) == 0)
  173. {
  174. return (Hull_t)i;
  175. }
  176. }
  177. return HULL_HUMAN;
  178. }