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.

151 lines
4.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Dr. Mossman, stalwart heroine, doing what is right in the face of
  4. // near certain doom, all while fighting off the clumsy advances of her
  5. // misogynistic colleges.
  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. #include "ai_playerally.h"
  16. #include "ai_behavior_follow.h"
  17. // memdbgon must be the last include file in a .cpp file!!!
  18. #include "tier0/memdbgon.h"
  19. //-----------------------------------------------------------------------------
  20. // NPC's Anim Events Go Here
  21. //-----------------------------------------------------------------------------
  22. //-----------------------------------------------------------------------------
  23. // Purpose:
  24. //-----------------------------------------------------------------------------
  25. class CNPC_Mossman : public CAI_PlayerAlly
  26. {
  27. public:
  28. DECLARE_CLASS( CNPC_Mossman, CAI_PlayerAlly );
  29. DECLARE_DATADESC();
  30. void Spawn( void );
  31. void Precache( void );
  32. Class_T Classify ( void );
  33. void HandleAnimEvent( animevent_t *pEvent );
  34. int GetSoundInterests ( void );
  35. bool CreateBehaviors( void );
  36. int SelectSchedule( void );
  37. private:
  38. CAI_FollowBehavior m_FollowBehavior;
  39. };
  40. LINK_ENTITY_TO_CLASS( npc_mossman, CNPC_Mossman );
  41. BEGIN_DATADESC( CNPC_Mossman )
  42. // DEFINE_FIELD( m_FollowBehavior, FIELD_EMBEDDED ), (auto saved by AI)
  43. END_DATADESC()
  44. //-----------------------------------------------------------------------------
  45. // Classify - indicates this NPC's place in the
  46. // relationship table.
  47. //-----------------------------------------------------------------------------
  48. Class_T CNPC_Mossman::Classify ( void )
  49. {
  50. return CLASS_PLAYER_ALLY_VITAL;
  51. }
  52. //-----------------------------------------------------------------------------
  53. // HandleAnimEvent - catches the NPC-specific messages
  54. // that occur when tagged animation frames are played.
  55. //-----------------------------------------------------------------------------
  56. void CNPC_Mossman::HandleAnimEvent( animevent_t *pEvent )
  57. {
  58. switch( pEvent->event )
  59. {
  60. case 1:
  61. default:
  62. BaseClass::HandleAnimEvent( pEvent );
  63. break;
  64. }
  65. }
  66. //-----------------------------------------------------------------------------
  67. // GetSoundInterests - generic NPC can't hear.
  68. //-----------------------------------------------------------------------------
  69. int CNPC_Mossman::GetSoundInterests ( void )
  70. {
  71. return NULL;
  72. }
  73. //-----------------------------------------------------------------------------
  74. // Spawn
  75. //-----------------------------------------------------------------------------
  76. void CNPC_Mossman::Spawn()
  77. {
  78. Precache();
  79. BaseClass::Spawn();
  80. SetModel( "models/mossman.mdl" );
  81. SetHullType(HULL_HUMAN);
  82. SetHullSizeNormal();
  83. SetSolid( SOLID_BBOX );
  84. AddSolidFlags( FSOLID_NOT_STANDABLE );
  85. SetMoveType( MOVETYPE_STEP );
  86. SetBloodColor( BLOOD_COLOR_RED );
  87. m_iHealth = 8;
  88. m_flFieldOfView = 0.5;// indicates the width of this NPC's forward view cone ( as a dotproduct result )
  89. m_NPCState = NPC_STATE_NONE;
  90. CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_OPEN_DOORS | bits_CAP_ANIMATEDFACE | bits_CAP_TURN_HEAD );
  91. CapabilitiesAdd( bits_CAP_FRIENDLY_DMG_IMMUNE );
  92. AddEFlags( EFL_NO_DISSOLVE | EFL_NO_MEGAPHYSCANNON_RAGDOLL | EFL_NO_PHYSCANNON_INTERACTION );
  93. NPCInit();
  94. }
  95. //-----------------------------------------------------------------------------
  96. // Precache - precaches all resources this NPC needs
  97. //-----------------------------------------------------------------------------
  98. void CNPC_Mossman::Precache()
  99. {
  100. PrecacheModel( "models/mossman.mdl" );
  101. BaseClass::Precache();
  102. }
  103. //=========================================================
  104. // Purpose:
  105. //=========================================================
  106. bool CNPC_Mossman::CreateBehaviors()
  107. {
  108. AddBehavior( &m_FollowBehavior );
  109. return BaseClass::CreateBehaviors();
  110. }
  111. //-----------------------------------------------------------------------------
  112. // Purpose:
  113. //-----------------------------------------------------------------------------
  114. int CNPC_Mossman::SelectSchedule( void )
  115. {
  116. if ( !BehaviorSelectSchedule() )
  117. {
  118. }
  119. return BaseClass::SelectSchedule();
  120. }
  121. //-----------------------------------------------------------------------------
  122. // AI Schedules Specific to this NPC
  123. //-----------------------------------------------------------------------------