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.

127 lines
4.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Dr. Magnusson, a grumpy bastard who builds satellites and rockets
  4. // at the White Forest missile silo. Instantly unlikeable, he is also
  5. // the inventor of the Magnusson Device aka "strider buster", which
  6. // is purported to resemble his cantelope-like head.
  7. //
  8. //=============================================================================
  9. //-----------------------------------------------------------------------------
  10. // Generic NPC - purely for scripted sequence work.
  11. //-----------------------------------------------------------------------------
  12. #include "cbase.h"
  13. #include "npcevent.h"
  14. #include "ai_basenpc.h"
  15. #include "ai_hull.h"
  16. #include "ai_baseactor.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_Magnusson : public CAI_BaseActor
  26. {
  27. public:
  28. DECLARE_CLASS( CNPC_Magnusson, CAI_BaseActor );
  29. void Spawn( void );
  30. void Precache( void );
  31. Class_T Classify ( void );
  32. void HandleAnimEvent( animevent_t *pEvent );
  33. int GetSoundInterests ( void );
  34. };
  35. LINK_ENTITY_TO_CLASS( npc_magnusson, CNPC_Magnusson );
  36. //-----------------------------------------------------------------------------
  37. // Classify - indicates this NPC's place in the
  38. // relationship table.
  39. //-----------------------------------------------------------------------------
  40. Class_T CNPC_Magnusson::Classify ( void )
  41. {
  42. return CLASS_PLAYER_ALLY_VITAL;
  43. }
  44. //-----------------------------------------------------------------------------
  45. // HandleAnimEvent - catches the NPC-specific messages
  46. // that occur when tagged animation frames are played.
  47. //-----------------------------------------------------------------------------
  48. void CNPC_Magnusson::HandleAnimEvent( animevent_t *pEvent )
  49. {
  50. switch( pEvent->event )
  51. {
  52. case 1:
  53. default:
  54. BaseClass::HandleAnimEvent( pEvent );
  55. break;
  56. }
  57. }
  58. //-----------------------------------------------------------------------------
  59. // GetSoundInterests - generic NPC can't hear.
  60. //-----------------------------------------------------------------------------
  61. int CNPC_Magnusson::GetSoundInterests ( void )
  62. {
  63. return NULL;
  64. }
  65. //-----------------------------------------------------------------------------
  66. // Spawn
  67. //-----------------------------------------------------------------------------
  68. void CNPC_Magnusson::Spawn()
  69. {
  70. // Allow custom model usage (mostly for monitors)
  71. char *szModel = (char *)STRING( GetModelName() );
  72. if (!szModel || !*szModel)
  73. {
  74. szModel = "models/magnusson.mdl";
  75. SetModelName( AllocPooledString(szModel) );
  76. }
  77. Precache();
  78. SetModel( szModel );
  79. BaseClass::Spawn();
  80. SetHullType(HULL_HUMAN);
  81. SetHullSizeNormal();
  82. SetSolid( SOLID_BBOX );
  83. AddSolidFlags( FSOLID_NOT_STANDABLE );
  84. SetMoveType( MOVETYPE_STEP );
  85. SetBloodColor( BLOOD_COLOR_RED );
  86. m_iHealth = 8;
  87. m_flFieldOfView = 0.5;// indicates the width of this NPC's forward view cone ( as a dotproduct result )
  88. m_NPCState = NPC_STATE_NONE;
  89. CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_OPEN_DOORS | bits_CAP_ANIMATEDFACE | bits_CAP_TURN_HEAD );
  90. CapabilitiesAdd( bits_CAP_FRIENDLY_DMG_IMMUNE );
  91. AddEFlags( EFL_NO_DISSOLVE | EFL_NO_MEGAPHYSCANNON_RAGDOLL | EFL_NO_PHYSCANNON_INTERACTION );
  92. NPCInit();
  93. }
  94. //-----------------------------------------------------------------------------
  95. // Precache - precaches all resources this NPC needs
  96. //-----------------------------------------------------------------------------
  97. void CNPC_Magnusson::Precache()
  98. {
  99. PrecacheModel( STRING( GetModelName() ) );
  100. BaseClass::Precache();
  101. }
  102. //-----------------------------------------------------------------------------
  103. // AI Schedules Specific to this NPC
  104. //-----------------------------------------------------------------------------