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.

148 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "NextBot/C_NextBot.h"
  8. #include "c_merasmus.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. #undef NextBot
  12. //-----------------------------------------------------------------------------
  13. IMPLEMENT_CLIENTCLASS_DT( C_Merasmus, DT_Merasmus, CMerasmus )
  14. RecvPropBool( RECVINFO( m_bRevealed ) ),
  15. RecvPropBool( RECVINFO( m_bIsDoingAOEAttack ) ),
  16. RecvPropBool( RECVINFO( m_bStunned ) ),
  17. END_RECV_TABLE()
  18. //-----------------------------------------------------------------------------
  19. C_Merasmus::C_Merasmus()
  20. {
  21. m_ghostEffect = NULL;
  22. m_aoeEffect = NULL;
  23. m_stunEffect = NULL;
  24. m_bRevealed = false;
  25. m_bWasRevealed = false;
  26. m_bIsDoingAOEAttack = false;
  27. m_bStunned = false;
  28. }
  29. //-----------------------------------------------------------------------------
  30. C_Merasmus::~C_Merasmus()
  31. {
  32. if ( m_ghostEffect )
  33. {
  34. ParticleProp()->StopEmission( m_ghostEffect );
  35. m_ghostEffect = NULL;
  36. }
  37. if ( m_aoeEffect )
  38. {
  39. ParticleProp()->StopEmission( m_aoeEffect );
  40. m_aoeEffect = NULL;
  41. }
  42. if ( m_stunEffect )
  43. {
  44. ParticleProp()->StopEmission( m_stunEffect );
  45. m_stunEffect = NULL;
  46. }
  47. }
  48. //-----------------------------------------------------------------------------
  49. void C_Merasmus::Spawn( void )
  50. {
  51. BaseClass::Spawn();
  52. m_vecViewOffset = Vector( 0, 0, 100.0f );
  53. }
  54. //-----------------------------------------------------------------------------
  55. // Return the origin for player observers tracking this target
  56. Vector C_Merasmus::GetObserverCamOrigin( void )
  57. {
  58. return EyePosition();
  59. }
  60. //-----------------------------------------------------------------------------
  61. void C_Merasmus::OnPreDataChanged( DataUpdateType_t updateType )
  62. {
  63. BaseClass::OnPreDataChanged( updateType );
  64. m_bWasRevealed = m_bRevealed;
  65. }
  66. //-----------------------------------------------------------------------------
  67. void C_Merasmus::OnDataChanged( DataUpdateType_t updateType )
  68. {
  69. BaseClass::OnDataChanged( updateType );
  70. if ( m_bRevealed != m_bWasRevealed )
  71. {
  72. if ( m_bRevealed )
  73. {
  74. if ( !m_ghostEffect )
  75. {
  76. m_ghostEffect = ParticleProp()->Create( "merasmus_ambient_body", PATTACH_ABSORIGIN_FOLLOW );
  77. }
  78. }
  79. else
  80. {
  81. if ( m_ghostEffect )
  82. {
  83. ParticleProp()->StopEmission( m_ghostEffect );
  84. m_ghostEffect = NULL;
  85. }
  86. }
  87. }
  88. // book attack
  89. if ( m_bIsDoingAOEAttack )
  90. {
  91. if ( !m_aoeEffect )
  92. {
  93. m_aoeEffect = ParticleProp()->Create( "merasmus_book_attack", PATTACH_POINT_FOLLOW, LookupAttachment( "effect_hand_R" ), Vector( 16.f, 0.f, 0.f ) );
  94. }
  95. }
  96. else
  97. {
  98. if ( m_aoeEffect )
  99. {
  100. ParticleProp()->StopEmission( m_aoeEffect );
  101. m_aoeEffect = NULL;
  102. }
  103. }
  104. // stunned
  105. if ( m_bStunned )
  106. {
  107. if ( !m_stunEffect )
  108. {
  109. m_stunEffect = ParticleProp()->Create( "merasmus_dazed", PATTACH_POINT_FOLLOW, LookupAttachment( "head" ) );
  110. }
  111. }
  112. else
  113. {
  114. if ( m_stunEffect )
  115. {
  116. ParticleProp()->StopEmission( m_stunEffect );
  117. m_stunEffect = NULL;
  118. }
  119. }
  120. }
  121. int C_Merasmus::GetSkin()
  122. {
  123. return ( m_bIsDoingAOEAttack || m_bStunned ) ? 0 : 1;
  124. }