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.

71 lines
1.7 KiB

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