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.

75 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Game-specific impact effect hooks
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "c_te_effect_dispatch.h"
  8. #include "tempent.h"
  9. #include "c_te_legacytempents.h"
  10. #include "tf_shareddefs.h"
  11. //-----------------------------------------------------------------------------
  12. // Purpose: TF Eject Brass
  13. //-----------------------------------------------------------------------------
  14. void TF_ThrowCigaretteCallback( const CEffectData &data )
  15. {
  16. C_BaseEntity *pEntity = ClientEntityList().GetEnt( data.entindex() );
  17. if ( !pEntity )
  18. return;
  19. int iTeam = pEntity->GetTeamNumber();
  20. Vector vForward, vRight, vUp;
  21. AngleVectors( data.m_vAngles, &vForward, &vRight, &vUp );
  22. QAngle vecShellAngles;
  23. VectorAngles( -vUp, vecShellAngles );
  24. Vector vecVelocity = 180 * vForward +
  25. random->RandomFloat( -20, 20 ) * vRight +
  26. random->RandomFloat( 0, 20 ) * vUp;
  27. vecVelocity.z += 100;
  28. float flLifeTime = 10.0f;
  29. const char *pszCigaretteModel = "models/weapons/shells/shell_cigarrette.mdl"; // sic
  30. model_t *pModel = (model_t *)engine->LoadModel( pszCigaretteModel );
  31. if ( !pModel )
  32. return;
  33. int flags = FTENT_FADEOUT | FTENT_GRAVITY | FTENT_COLLIDEALL | FTENT_ROTATE;
  34. Assert( pModel );
  35. C_LocalTempEntity *pTemp = tempents->SpawnTempModel( pModel, data.m_vOrigin, vecShellAngles, vecVelocity, flLifeTime, FTENT_NEVERDIE );
  36. if ( pTemp == NULL )
  37. return;
  38. pTemp->m_nSkin = ( iTeam == TF_TEAM_RED ) ? 0 : 1;
  39. pTemp->m_vecTempEntAngVelocity[0] = random->RandomFloat(-512,511);
  40. pTemp->m_vecTempEntAngVelocity[1] = random->RandomFloat(-255,255);
  41. pTemp->m_vecTempEntAngVelocity[2] = random->RandomFloat(-255,255);
  42. pTemp->SetGravity( 0.4 );
  43. pTemp->m_flSpriteScale = 10;
  44. pTemp->flags = flags;
  45. // don't collide with owner
  46. pTemp->clientIndex = data.entindex();
  47. if ( pTemp->clientIndex < 0 )
  48. {
  49. pTemp->clientIndex = 0;
  50. }
  51. // ::ShouldCollide decides what this collides with
  52. pTemp->flags |= FTENT_COLLISIONGROUP;
  53. pTemp->SetCollisionGroup( COLLISION_GROUP_DEBRIS );
  54. }
  55. DECLARE_CLIENT_EFFECT( "TF_ThrowCigarette", TF_ThrowCigaretteCallback );