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.

125 lines
3.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Dr. Kleiner, a suave ladies man leading the fight against the evil
  4. // combine while constantly having to help his idiot assistant Gordon
  5. //
  6. //=============================================================================//
  7. //-----------------------------------------------------------------------------
  8. // Generic NPC - purely for scripted sequence work.
  9. //-----------------------------------------------------------------------------
  10. #include "cbase.h"
  11. #include "npcevent.h"
  12. #include "ai_basenpc.h"
  13. #include "ai_hull.h"
  14. #include "ai_baseactor.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. //-----------------------------------------------------------------------------
  18. // NPC's Anim Events Go Here
  19. //-----------------------------------------------------------------------------
  20. //-----------------------------------------------------------------------------
  21. // Purpose:
  22. //-----------------------------------------------------------------------------
  23. class CNPC_Kleiner : public CAI_BaseActor
  24. {
  25. public:
  26. DECLARE_CLASS( CNPC_Kleiner, CAI_BaseActor );
  27. void Spawn( void );
  28. void Precache( void );
  29. Class_T Classify ( void );
  30. void HandleAnimEvent( animevent_t *pEvent );
  31. int GetSoundInterests ( void );
  32. };
  33. LINK_ENTITY_TO_CLASS( npc_kleiner, CNPC_Kleiner );
  34. //-----------------------------------------------------------------------------
  35. // Classify - indicates this NPC's place in the
  36. // relationship table.
  37. //-----------------------------------------------------------------------------
  38. Class_T CNPC_Kleiner::Classify ( void )
  39. {
  40. return CLASS_PLAYER_ALLY_VITAL;
  41. }
  42. //-----------------------------------------------------------------------------
  43. // HandleAnimEvent - catches the NPC-specific messages
  44. // that occur when tagged animation frames are played.
  45. //-----------------------------------------------------------------------------
  46. void CNPC_Kleiner::HandleAnimEvent( animevent_t *pEvent )
  47. {
  48. switch( pEvent->event )
  49. {
  50. case 1:
  51. default:
  52. BaseClass::HandleAnimEvent( pEvent );
  53. break;
  54. }
  55. }
  56. //-----------------------------------------------------------------------------
  57. // GetSoundInterests - generic NPC can't hear.
  58. //-----------------------------------------------------------------------------
  59. int CNPC_Kleiner::GetSoundInterests ( void )
  60. {
  61. return NULL;
  62. }
  63. //-----------------------------------------------------------------------------
  64. // Spawn
  65. //-----------------------------------------------------------------------------
  66. void CNPC_Kleiner::Spawn()
  67. {
  68. // Allow custom model usage (mostly for monitors)
  69. char *szModel = (char *)STRING( GetModelName() );
  70. if (!szModel || !*szModel)
  71. {
  72. szModel = "models/kleiner.mdl";
  73. SetModelName( AllocPooledString(szModel) );
  74. }
  75. Precache();
  76. SetModel( szModel );
  77. BaseClass::Spawn();
  78. SetHullType(HULL_HUMAN);
  79. SetHullSizeNormal();
  80. SetSolid( SOLID_BBOX );
  81. AddSolidFlags( FSOLID_NOT_STANDABLE );
  82. SetMoveType( MOVETYPE_STEP );
  83. SetBloodColor( BLOOD_COLOR_RED );
  84. m_iHealth = 8;
  85. m_flFieldOfView = 0.5;// indicates the width of this NPC's forward view cone ( as a dotproduct result )
  86. m_NPCState = NPC_STATE_NONE;
  87. CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_OPEN_DOORS | bits_CAP_ANIMATEDFACE | bits_CAP_TURN_HEAD );
  88. CapabilitiesAdd( bits_CAP_FRIENDLY_DMG_IMMUNE );
  89. AddEFlags( EFL_NO_DISSOLVE | EFL_NO_MEGAPHYSCANNON_RAGDOLL | EFL_NO_PHYSCANNON_INTERACTION );
  90. NPCInit();
  91. }
  92. //-----------------------------------------------------------------------------
  93. // Precache - precaches all resources this NPC needs
  94. //-----------------------------------------------------------------------------
  95. void CNPC_Kleiner::Precache()
  96. {
  97. PrecacheModel( STRING( GetModelName() ) );
  98. BaseClass::Precache();
  99. }
  100. //-----------------------------------------------------------------------------
  101. // AI Schedules Specific to this NPC
  102. //-----------------------------------------------------------------------------