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.

77 lines
1.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "dod_stickgrenade.h"
  8. #include "dod_shareddefs.h"
  9. #define GRENADE_MODEL "models/Weapons/w_stick.mdl"
  10. LINK_ENTITY_TO_CLASS( grenade_frag_ger, CDODStickGrenade );
  11. PRECACHE_WEAPON_REGISTER( grenade_frag_ger );
  12. CDODStickGrenade* CDODStickGrenade::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. CDODStickGrenade *pGrenade = (CDODStickGrenade*)CBaseEntity::Create( "grenade_frag_ger", 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. pGrenade->SetupInitialTransmittedGrenadeVelocity( velocity );
  31. // Who threw this grenade
  32. pGrenade->SetThrower( pOwner );
  33. pGrenade->ChangeTeam( pOwner->GetTeamNumber() );
  34. // How long until we explode
  35. pGrenade->SetDetonateTimerLength( timer );
  36. // Save the weapon id for stats purposes
  37. pGrenade->m_EmitterWeaponID = weaponID;
  38. return pGrenade;
  39. }
  40. void CDODStickGrenade::Spawn()
  41. {
  42. SetModel( GRENADE_MODEL );
  43. BaseClass::Spawn();
  44. }
  45. void CDODStickGrenade::Precache()
  46. {
  47. PrecacheModel( GRENADE_MODEL );
  48. PrecacheScriptSound( "HEGrenade.Bounce" );
  49. BaseClass::Precache();
  50. }
  51. void CDODStickGrenade::BounceSound( void )
  52. {
  53. EmitSound( "HEGrenade.Bounce" );
  54. }
  55. //Pass the classname of the exploding version of this grenade.
  56. char *CDODStickGrenade::GetExplodingClassname()
  57. {
  58. return "weapon_frag_ger_live";
  59. }