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.

108 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: TF Death Calling card version based off the stickybolt code.
  4. //=============================================================================//
  5. #include "cbase.h"
  6. #include "c_basetempentity.h"
  7. #include "fx.h"
  8. #include "decals.h"
  9. #include "iefx.h"
  10. #include "engine/IEngineSound.h"
  11. #include "materialsystem/imaterialvar.h"
  12. #include "IEffects.h"
  13. #include "engine/IEngineTrace.h"
  14. #include "vphysics/constraints.h"
  15. #include "engine/ivmodelinfo.h"
  16. #include "tempent.h"
  17. #include "c_te_legacytempents.h"
  18. #include "engine/ivdebugoverlay.h"
  19. #include "c_te_effect_dispatch.h"
  20. #include "c_tf_player.h"
  21. #include "GameEventListener.h"
  22. #include "tf_shareddefs.h"
  23. // memdbgon must be the last include file in a .cpp file!!!
  24. #include "tier0/memdbgon.h"
  25. extern IPhysicsSurfaceProps *physprops;
  26. IPhysicsObject *GetWorldPhysObject( void );
  27. extern CBaseEntity *BreakModelCreateSingle( CBaseEntity *pOwner, breakmodel_t *pModel, const Vector &position,
  28. const QAngle &angles, const Vector &velocity, const AngularImpulse &angVelocity, int nSkin, const breakablepropparams_t &params );
  29. //-----------------------------------------------------------------------------
  30. // Purpose: Creates a "Calling Card" prop at the victim's location
  31. //-----------------------------------------------------------------------------
  32. void CreateDeathCallingCard(
  33. const Vector &vecOrigin,
  34. const QAngle &vAngle,
  35. const int iVictimIndex,
  36. const int iShooterIndex,
  37. const int iCallingCardIndex
  38. ) {
  39. if ( iCallingCardIndex < 1 || iCallingCardIndex > TF_CALLING_CARD_MODEL_COUNT )
  40. {
  41. Warning( "Attempted to Call CreateDeathCallingCard With invalid index %d", iCallingCardIndex );
  42. return;
  43. }
  44. const char* pszModelName = g_pszDeathCallingCardModels[iCallingCardIndex];
  45. CTFPlayer *pVictim = ToTFPlayer( UTIL_PlayerByIndex( iVictimIndex ) );
  46. if ( !pVictim )
  47. return;
  48. breakablepropparams_t breakParams( vecOrigin, vAngle, vec3_origin, vec3_origin );
  49. breakParams.impactEnergyScale = 1.0f;
  50. breakmodel_t breakModel;
  51. Q_strncpy( breakModel.modelName, pszModelName, sizeof(breakModel.modelName) );
  52. breakModel.health = 1;
  53. breakModel.fadeTime = RandomFloat(7,10);
  54. breakModel.fadeMinDist = 0.0f;
  55. breakModel.fadeMaxDist = 0.0f;
  56. breakModel.burstScale = 1.0f;
  57. breakModel.collisionGroup = COLLISION_GROUP_DEBRIS;
  58. breakModel.isRagdoll = false;
  59. breakModel.isMotionDisabled = false;
  60. breakModel.placementName[0] = 0;
  61. breakModel.placementIsBone = false;
  62. breakModel.offset = Vector( 0, 0, 50 );
  63. CBaseEntity * pBreakModel = BreakModelCreateSingle(
  64. pVictim,
  65. &breakModel,
  66. pVictim->GetAbsOrigin() + Vector( 0, 0, 50 ),
  67. QAngle(0, vAngle.y, 0 ),
  68. vec3_origin,
  69. vec3_origin,
  70. 0,
  71. breakParams
  72. );
  73. // Scale down the tombstones a bit
  74. if ( pBreakModel )
  75. {
  76. CBaseAnimating *pAnim = dynamic_cast < CBaseAnimating * > ( pBreakModel );
  77. if ( pAnim )
  78. {
  79. pAnim->SetModelScale( 0.9f );
  80. }
  81. }
  82. }
  83. //-----------------------------------------------------------------------------
  84. // Purpose:
  85. //-----------------------------------------------------------------------------
  86. void DeathCallingCard( const CEffectData &data )
  87. {
  88. CreateDeathCallingCard(
  89. data.m_vOrigin,
  90. data.m_vAngles,
  91. data.m_nAttachmentIndex, // Victim
  92. data.m_nHitBox, // iShooter
  93. data.m_fFlags // Calling card Index
  94. );
  95. }
  96. DECLARE_CLIENT_EFFECT( "TFDeathCallingCard", DeathCallingCard );