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
1.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "dod_handgrenade.h"
  8. #include "dod_shareddefs.h"
  9. #define GRENADE_MODEL "models/Weapons/w_frag.mdl"
  10. LINK_ENTITY_TO_CLASS( grenade_frag_us, CDODHandGrenade );
  11. PRECACHE_WEAPON_REGISTER( grenade_frag_us );
  12. CDODHandGrenade* CDODHandGrenade::Create(
  13. const Vector &position,
  14. const QAngle &angles,
  15. const Vector &velocity,
  16. const AngularImpulse &angVelocity,
  17. CBaseCombatCharacter *pOwner,
  18. float timer,
  19. DODWeaponID weaponID )
  20. {
  21. CDODHandGrenade *pGrenade = (CDODHandGrenade*)CBaseEntity::Create( "grenade_frag_us", position, angles, pOwner );
  22. Assert( pGrenade );
  23. if( !pGrenade )
  24. return NULL;
  25. IPhysicsObject *pPhysicsObject = pGrenade->VPhysicsGetObject();
  26. if ( pPhysicsObject )
  27. {
  28. pPhysicsObject->AddVelocity( &velocity, &angVelocity );
  29. }
  30. // Who threw this grenade
  31. pGrenade->SetThrower( pOwner );
  32. pGrenade->ChangeTeam( pOwner->GetTeamNumber() );
  33. // How long until we explode
  34. pGrenade->SetDetonateTimerLength( timer );
  35. // Save the weapon id for stats purposes
  36. pGrenade->m_EmitterWeaponID = weaponID;
  37. return pGrenade;
  38. }
  39. void CDODHandGrenade::Spawn()
  40. {
  41. SetModel( GRENADE_MODEL );
  42. BaseClass::Spawn();
  43. }
  44. void CDODHandGrenade::Precache()
  45. {
  46. PrecacheModel( GRENADE_MODEL );
  47. PrecacheScriptSound( "HEGrenade.Bounce" );
  48. BaseClass::Precache();
  49. }
  50. void CDODHandGrenade::BounceSound( void )
  51. {
  52. EmitSound( "HEGrenade.Bounce" );
  53. }
  54. //Pass the classname of the exploding version of this grenade.
  55. char *CDODHandGrenade::GetExplodingClassname()
  56. {
  57. return "weapon_frag_us_live";
  58. }