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.

83 lines
2.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Base class for simple projectiles
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #include "cbase.h"
  10. #include "cbaseanimatingprojectile.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. LINK_ENTITY_TO_CLASS( baseanimating_projectile, CBaseAnimatingProjectile );
  14. //---------------------------------------------------------
  15. // Save/Restore
  16. //---------------------------------------------------------
  17. BEGIN_DATADESC( CBaseAnimatingProjectile )
  18. DEFINE_FIELD( m_iDmg, FIELD_INTEGER ),
  19. DEFINE_FIELD( m_iDmgType, FIELD_INTEGER ),
  20. END_DATADESC()
  21. //---------------------------------------------------------
  22. //---------------------------------------------------------
  23. void CBaseAnimatingProjectile::Spawn( char *pszModel,
  24. const Vector &vecOrigin,
  25. const Vector &vecVelocity,
  26. edict_t *pOwner,
  27. MoveType_t iMovetype,
  28. MoveCollide_t nMoveCollide,
  29. int iDamage,
  30. int iDamageType )
  31. {
  32. Precache();
  33. SetSolid( SOLID_BBOX );
  34. SetModel( pszModel );
  35. UTIL_SetSize( this, vec3_origin, vec3_origin );
  36. m_iDmg = iDamage;
  37. m_iDmgType = iDamageType;
  38. SetMoveType( iMovetype, nMoveCollide );
  39. UTIL_SetOrigin( this, vecOrigin );
  40. SetAbsVelocity( vecVelocity );
  41. SetOwnerEntity( Instance( pOwner ) );
  42. QAngle qAngles;
  43. VectorAngles( vecVelocity, qAngles );
  44. SetAbsAngles( qAngles );
  45. }
  46. //---------------------------------------------------------
  47. //---------------------------------------------------------
  48. void CBaseAnimatingProjectile::Touch( CBaseEntity *pOther )
  49. {
  50. CBaseEntity *pOwner;
  51. pOwner = GetOwnerEntity();
  52. if( !pOwner )
  53. {
  54. pOwner = this;
  55. }
  56. trace_t tr;
  57. tr = BaseClass::GetTouchTrace( );
  58. CTakeDamageInfo info( this, pOwner, m_iDmg, m_iDmgType );
  59. GuessDamageForce( &info, (tr.endpos - tr.startpos), tr.endpos );
  60. pOther->TakeDamage( info );
  61. UTIL_Remove( this );
  62. }