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.

73 lines
1.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "basegrenade_shared.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. class CBaseGrenadeTimed : public CBaseGrenade
  12. {
  13. public:
  14. DECLARE_CLASS( CBaseGrenadeTimed, CBaseGrenade );
  15. void Spawn( void );
  16. void Precache( void );
  17. };
  18. LINK_ENTITY_TO_CLASS( npc_handgrenade, CBaseGrenadeTimed );
  19. void CBaseGrenadeTimed::Spawn( void )
  20. {
  21. SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
  22. SetSolid( SOLID_BBOX );
  23. SetCollisionGroup( COLLISION_GROUP_PROJECTILE );
  24. SetModel( "models/Weapons/w_grenade.mdl" );
  25. UTIL_SetSize(this, Vector( -4, -4, -4), Vector(4, 4, 4));
  26. QAngle angles;
  27. Vector vel = GetAbsVelocity();
  28. VectorAngles( vel, angles );
  29. SetLocalAngles( angles );
  30. SetTouch( &CBaseGrenadeTimed::BounceTouch ); // Bounce if touched
  31. // Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
  32. // will insert a DANGER sound into the world sound list and delay detonation for one second so that
  33. // the grenade explodes after the exact amount of time specified in the call to ShootTimed().
  34. SetThink( &CBaseGrenadeTimed::TumbleThink );
  35. SetNextThink( gpGlobals->curtime + 0.1f );
  36. // if the delay is < 0.1 seconds, don't fly anywhere
  37. if ((m_flDetonateTime - gpGlobals->curtime) < 0.1)
  38. {
  39. SetNextThink( gpGlobals->curtime );
  40. SetAbsVelocity( vec3_origin );
  41. }
  42. // Tumble through the air
  43. // pGrenade->m_vecAngVelocity.x = -400;
  44. SetGravity(1.0); // Don't change or throw calculations will be off!
  45. SetFriction(0.8);
  46. m_flDamage = 100; // ????
  47. m_takedamage = DAMAGE_NO;
  48. }
  49. void CBaseGrenadeTimed::Precache( void )
  50. {
  51. BaseClass::Precache( );
  52. PrecacheModel("models/weapons/w_grenade.mdl");
  53. }