Counter Strike : Global Offensive Source Code
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.8 KiB

  1. //========= Copyright � 1996-2005, 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. extern ConVar sk_plr_dmg_grenade;
  12. // ==========================================================================================
  13. class CBaseGrenadeContact : public CBaseGrenade
  14. {
  15. DECLARE_CLASS( CBaseGrenadeContact, CBaseGrenade );
  16. public:
  17. void Spawn( void );
  18. void Precache( void );
  19. };
  20. LINK_ENTITY_TO_CLASS( npc_contactgrenade, CBaseGrenadeContact );
  21. void CBaseGrenadeContact::Spawn( void )
  22. {
  23. // point sized, solid, bouncing
  24. SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
  25. SetSolid( SOLID_BBOX );
  26. SetCollisionGroup( COLLISION_GROUP_PROJECTILE );
  27. SetModel( "models/weapons/w_grenade.mdl" ); // BUG: wrong model
  28. UTIL_SetSize(this, vec3_origin, vec3_origin);
  29. // contact grenades arc lower
  30. SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see
  31. QAngle angles;
  32. VectorAngles(GetAbsVelocity(), angles);
  33. SetLocalAngles( angles );
  34. // make NPCs afaid of it while in the air
  35. SetThink( &CBaseGrenadeContact::DangerSoundThink );
  36. SetNextThink( gpGlobals->curtime );
  37. // Tumble in air
  38. QAngle vecAngVelocity( random->RandomFloat ( -100, -500 ), 0, 0 );
  39. SetLocalAngularVelocity( vecAngVelocity );
  40. // Explode on contact
  41. SetTouch( &CBaseGrenadeContact::ExplodeTouch );
  42. m_flDamage = sk_plr_dmg_grenade.GetFloat();
  43. // Allow player to blow this puppy up in the air
  44. m_takedamage = DAMAGE_YES;
  45. m_iszBounceSound = NULL_STRING;
  46. }
  47. void CBaseGrenadeContact::Precache( void )
  48. {
  49. BaseClass::Precache( );
  50. PrecacheModel("models/weapons/w_grenade.mdl");
  51. }