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.

132 lines
4.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Dr. Breen, the oft maligned genius, heroically saving humanity from
  4. // its own worst enemy, itself.
  5. //=============================================================================//
  6. //-----------------------------------------------------------------------------
  7. // Generic NPC - purely for scripted sequence work.
  8. //-----------------------------------------------------------------------------
  9. #include "cbase.h"
  10. #include "npcevent.h"
  11. #include "ai_basenpc.h"
  12. #include "ai_hull.h"
  13. #include "ai_baseactor.h"
  14. // memdbgon must be the last include file in a .cpp file!!!
  15. #include "tier0/memdbgon.h"
  16. // Spawnflags
  17. #define SF_BREEN_BACKGROUND_TALK ( 1 << 16 ) // 65536
  18. //-----------------------------------------------------------------------------
  19. // Purpose:
  20. //-----------------------------------------------------------------------------
  21. class CNPC_Breen : public CAI_BaseActor
  22. {
  23. public:
  24. DECLARE_CLASS( CNPC_Breen, CAI_BaseActor );
  25. void Spawn( void );
  26. void Precache( void );
  27. Class_T Classify ( void );
  28. void HandleAnimEvent( animevent_t *pEvent );
  29. int GetSoundInterests ( void );
  30. bool UseSemaphore( void );
  31. };
  32. LINK_ENTITY_TO_CLASS( npc_breen, CNPC_Breen );
  33. //-----------------------------------------------------------------------------
  34. // Classify - indicates this NPC's place in the
  35. // relationship table.
  36. //-----------------------------------------------------------------------------
  37. Class_T CNPC_Breen::Classify ( void )
  38. {
  39. return CLASS_NONE;
  40. }
  41. //-----------------------------------------------------------------------------
  42. // HandleAnimEvent - catches the NPC-specific messages
  43. // that occur when tagged animation frames are played.
  44. //-----------------------------------------------------------------------------
  45. void CNPC_Breen::HandleAnimEvent( animevent_t *pEvent )
  46. {
  47. switch( pEvent->event )
  48. {
  49. case 1:
  50. default:
  51. BaseClass::HandleAnimEvent( pEvent );
  52. break;
  53. }
  54. }
  55. //-----------------------------------------------------------------------------
  56. // GetSoundInterests - generic NPC can't hear.
  57. //-----------------------------------------------------------------------------
  58. int CNPC_Breen::GetSoundInterests ( void )
  59. {
  60. return NULL;
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Spawn
  64. //-----------------------------------------------------------------------------
  65. void CNPC_Breen::Spawn()
  66. {
  67. // Breen is allowed to use multiple models, because he has a torso version for monitors.
  68. // He defaults to his normal model.
  69. char *szModel = (char *)STRING( GetModelName() );
  70. if (!szModel || !*szModel)
  71. {
  72. szModel = "models/breen.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_Breen::Precache()
  96. {
  97. PrecacheModel( STRING( GetModelName() ) );
  98. BaseClass::Precache();
  99. }
  100. bool CNPC_Breen::UseSemaphore( void )
  101. {
  102. if ( HasSpawnFlags( SF_BREEN_BACKGROUND_TALK ) )
  103. return false;
  104. return BaseClass::UseSemaphore();
  105. }
  106. //-----------------------------------------------------------------------------
  107. // AI Schedules Specific to this NPC
  108. //-----------------------------------------------------------------------------