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.

179 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef NPC_HYDRA_H
  8. #define NPC_HYDRA_H
  9. #if defined( _WIN32 )
  10. #pragma once
  11. #endif
  12. #include "ai_basenpc.h"
  13. #include "soundenvelope.h"
  14. class CNPC_Hydra;
  15. //-----------------------------------------------------------------------------
  16. // CNPC_Hydra
  17. //
  18. //-----------------------------------------------------------------------------
  19. class HydraBone
  20. {
  21. public:
  22. HydraBone( void )
  23. {
  24. vecPos = Vector( 0, 0, 0 );
  25. vecDelta = Vector( 0, 0, 0 );
  26. //vecBendDelta = Vector( 0, 0, 0 );
  27. //vecGoalDelta = Vector( 0, 0, 0 );
  28. //flBendTension = 0.0;
  29. flIdealLength = 1.0;
  30. flGoalInfluence = 0.0;
  31. bStuck = false;
  32. bOnFire = false;
  33. };
  34. Vector vecPos;
  35. Vector vecDelta;
  36. //float flBendTension;
  37. float flIdealLength;
  38. bool bStuck;
  39. bool bOnFire;
  40. float flActualLength;
  41. //Vector vecBendDelta;
  42. //Vector vecGoalDelta;
  43. // float flAccumLength;
  44. Vector vecGoalPos;
  45. float flGoalInfluence;
  46. DECLARE_SIMPLE_DATADESC();
  47. };
  48. class CNPC_Hydra : public CAI_BaseNPC
  49. {
  50. DECLARE_CLASS( CNPC_Hydra, CAI_BaseNPC );
  51. DECLARE_SERVERCLASS();
  52. DECLARE_DATADESC();
  53. public:
  54. CNPC_Hydra()
  55. {
  56. }
  57. void Spawn( void );
  58. void Precache( void );
  59. void Activate( void );
  60. Class_T Classify( void );
  61. void RunAI( void );
  62. float MaxYawSpeed( void );
  63. int TranslateSchedule( int scheduleType );
  64. int SelectSchedule( void );
  65. void PrescheduleThink( void );
  66. void HandleAnimEvent( animevent_t *pEvent );
  67. void StartTask( const Task_t *pTask );
  68. void RunTask( const Task_t *pTask );
  69. #define CHAIN_LINKS 32
  70. CNetworkArray( Vector, m_vecChain, CHAIN_LINKS );
  71. int m_activeChain;
  72. bool m_bHasStuckSegments;
  73. float m_flCurrentLength;
  74. Vector m_vecHeadGoal;
  75. float m_flHeadGoalInfluence;
  76. CNetworkVector( m_vecHeadDir );
  77. CNetworkVar( float, m_flRelaxedLength );
  78. Vector m_vecOutward;
  79. CUtlVector < HydraBone > m_body;
  80. float m_idealLength;
  81. float m_idealSegmentLength;
  82. Vector TestPosition( float t );
  83. void CalcGoalForces( void );
  84. void MoveBody( void );
  85. void AdjustLength( void );
  86. void CheckLength( void );
  87. bool m_bExtendSoundActive;
  88. CSoundPatch *m_pExtendTentacleSound;
  89. void Nudge( CBaseEntity *pHitEntity, const Vector &vecContact, const Vector &vecSpeed );
  90. void Stab( CBaseEntity *pHitEntity, const Vector &vecSpeed, trace_t &ptr );
  91. void Kick( CBaseEntity *pHitEntity, const Vector &vecContact, const Vector &vecSpeed );
  92. void Splash( const Vector &vecSplashPos );
  93. // float FreeNeckLength( void );
  94. virtual Vector EyePosition( void );
  95. virtual const QAngle &EyeAngles( void );
  96. virtual Vector BodyTarget( const Vector &posSrc, bool bNoisy) ;
  97. void AimHeadInTravelDirection( float flInfluence );
  98. float m_seed;
  99. // --------------------------------
  100. Vector m_vecTarget;
  101. Vector m_vecTargetDir;
  102. float m_flLastAdjustmentTime;
  103. float m_flTaskStartTime;
  104. float m_flTaskEndTime;
  105. float m_flLengthTime; // time of last successful length adjustment time
  106. // --------------------------------
  107. bool ContractFromHead( void );
  108. bool ContractBetweenStuckSegments( void );
  109. bool ContractFromRoot( void );
  110. int VirtualRoot( void );
  111. bool AddNodeBefore( int iNode );
  112. bool AddNodeAfter( int iNode );
  113. bool GrowFromVirtualRoot( void );
  114. bool GrowFromMostStretched( void );
  115. void CalcRelaxedLength( void );
  116. bool IsValidConnection( int iNode0, int iNode1 );
  117. void AttachStabbedEntity( CBaseAnimating *pAnimating, Vector vecForce, trace_t &tr );
  118. void UpdateStabbedEntity( void );
  119. void DetachStabbedEntity( bool playSound );
  120. void GetDesiredImpaledPosition( Vector *vecOrigin, QAngle *vecAngles );
  121. bool m_bStabbedEntity;
  122. DEFINE_CUSTOM_AI;
  123. private:
  124. };
  125. //-----------------------------------------------------------------------------
  126. #endif // NPC_HYDRA_H