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.

144 lines
4.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "c_tf_projectile_rocket.h"
  8. #include "particles_new.h"
  9. #include "tf_gamerules.h"
  10. IMPLEMENT_NETWORKCLASS_ALIASED( TFProjectile_Rocket, DT_TFProjectile_Rocket )
  11. BEGIN_NETWORK_TABLE( C_TFProjectile_Rocket, DT_TFProjectile_Rocket )
  12. RecvPropBool( RECVINFO( m_bCritical ) ),
  13. END_NETWORK_TABLE()
  14. //-----------------------------------------------------------------------------
  15. // Purpose:
  16. //-----------------------------------------------------------------------------
  17. C_TFProjectile_Rocket::C_TFProjectile_Rocket( void )
  18. {
  19. pEffect = NULL;
  20. }
  21. //-----------------------------------------------------------------------------
  22. // Purpose:
  23. //-----------------------------------------------------------------------------
  24. C_TFProjectile_Rocket::~C_TFProjectile_Rocket( void )
  25. {
  26. if ( pEffect )
  27. {
  28. ParticleProp()->StopEmission( pEffect );
  29. }
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Purpose:
  33. //-----------------------------------------------------------------------------
  34. void C_TFProjectile_Rocket::OnDataChanged(DataUpdateType_t updateType)
  35. {
  36. BaseClass::OnDataChanged(updateType);
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. //-----------------------------------------------------------------------------
  41. void C_TFProjectile_Rocket::CreateTrails( void )
  42. {
  43. if ( IsDormant() )
  44. return;
  45. bool bUsingCustom = false;
  46. if ( pEffect )
  47. {
  48. ParticleProp()->StopEmission( pEffect );
  49. pEffect = NULL;
  50. }
  51. int iAttachment = LookupAttachment( "trail" );
  52. if ( iAttachment == INVALID_PARTICLE_ATTACHMENT )
  53. return;
  54. if ( enginetrace->GetPointContents( GetAbsOrigin() ) & MASK_WATER )
  55. {
  56. ParticleProp()->Create( "rockettrail_underwater", PATTACH_POINT_FOLLOW, "trail" );
  57. bUsingCustom = true;
  58. }
  59. else if ( GetTeamNumber() == TEAM_UNASSIGNED )
  60. {
  61. ParticleProp()->Create( "rockettrail_underwater", PATTACH_POINT_FOLLOW, "trail" );
  62. bUsingCustom = true;
  63. }
  64. else
  65. {
  66. // Halloween Spell Effect Check
  67. int iHalloweenSpell = 0;
  68. // if the owner is a Sentry, Check its owner
  69. CBaseObject *pSentry = GetOwnerEntity() && GetOwnerEntity()->IsBaseObject() ? assert_cast<CBaseObject*>( GetOwnerEntity() ) : NULL;
  70. if ( TF_IsHolidayActive( kHoliday_HalloweenOrFullMoon ) )
  71. {
  72. if ( pSentry )
  73. {
  74. CALL_ATTRIB_HOOK_INT_ON_OTHER( pSentry->GetOwner(), iHalloweenSpell, halloween_pumpkin_explosions );
  75. }
  76. else
  77. {
  78. CALL_ATTRIB_HOOK_INT_ON_OTHER( GetOwnerEntity(), iHalloweenSpell, halloween_pumpkin_explosions );
  79. }
  80. }
  81. // Mini rockets from airstrike RL
  82. if ( iHalloweenSpell > 0 )
  83. {
  84. ParticleProp()->Create( "halloween_rockettrail", PATTACH_POINT_FOLLOW, iAttachment );
  85. bUsingCustom = true;
  86. }
  87. else if ( !pSentry )
  88. {
  89. if ( GetLauncher() )
  90. {
  91. int iMiniRocket = 0;
  92. CALL_ATTRIB_HOOK_INT_ON_OTHER( GetLauncher(), iMiniRocket, mini_rockets );
  93. if ( iMiniRocket )
  94. {
  95. ParticleProp()->Create( "rockettrail_airstrike", PATTACH_POINT_FOLLOW, iAttachment );
  96. bUsingCustom = true;
  97. // rockettrail_airstrike_line
  98. CTFPlayer *pPlayer = ToTFPlayer( GetOwnerEntity() );
  99. if ( pPlayer && pPlayer->m_Shared.InCond( TF_COND_BLASTJUMPING ) )
  100. {
  101. ParticleProp()->Create( "rockettrail_airstrike_line", PATTACH_POINT_FOLLOW, iAttachment );
  102. }
  103. }
  104. }
  105. }
  106. }
  107. if ( !bUsingCustom )
  108. {
  109. if ( GetTrailParticleName() )
  110. {
  111. ParticleProp()->Create( GetTrailParticleName(), PATTACH_POINT_FOLLOW, iAttachment );
  112. }
  113. }
  114. if ( m_bCritical )
  115. {
  116. switch( GetTeamNumber() )
  117. {
  118. case TF_TEAM_BLUE:
  119. pEffect = ParticleProp()->Create( "critical_rocket_blue", PATTACH_ABSORIGIN_FOLLOW );
  120. break;
  121. case TF_TEAM_RED:
  122. pEffect = ParticleProp()->Create( "critical_rocket_red", PATTACH_ABSORIGIN_FOLLOW );
  123. break;
  124. default:
  125. pEffect = ParticleProp()->Create( "eyeboss_projectile", PATTACH_ABSORIGIN_FOLLOW );
  126. break;
  127. }
  128. }
  129. }