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.

187 lines
5.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "cbase.h"
  9. #include "items.h"
  10. #include "cs_player.h"
  11. #include "weapon_csbase.h"
  12. #include "cs_ammodef.h"
  13. //-----------------------------------------------------------------------------
  14. class CItemAmmo : public CItem
  15. {
  16. public:
  17. DECLARE_CLASS( CItemAmmo, CItem );
  18. bool MyTouch( CBasePlayer *pBasePlayer )
  19. {
  20. CCSPlayer *pPlayer = dynamic_cast< CCSPlayer* >( pBasePlayer );
  21. if ( !pPlayer )
  22. {
  23. Assert( false );
  24. return false;
  25. }
  26. int ammoIndex = GetCSAmmoDef()->Index( GetAmmoName() );
  27. if ( ammoIndex < 0 )
  28. {
  29. Assert( false );
  30. return false;
  31. }
  32. pPlayer->GiveAmmo( GetCSAmmoDef()->GetBuySize( ammoIndex ), ammoIndex );
  33. return true;
  34. }
  35. virtual const char * GetAmmoName( void ) const { return NULL; }
  36. };
  37. //-----------------------------------------------------------------------------
  38. class CItemAmmo50AE : public CItemAmmo
  39. {
  40. public:
  41. DECLARE_CLASS( CItemAmmo50AE, CItemAmmo );
  42. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_50AE; }
  43. };
  44. LINK_ENTITY_TO_CLASS( ammo_50ae, CItemAmmo50AE );
  45. //-----------------------------------------------------------------------------
  46. class CItemAmmo762MM : public CItemAmmo
  47. {
  48. public:
  49. DECLARE_CLASS( CItemAmmo762MM, CItemAmmo );
  50. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_762MM; }
  51. };
  52. LINK_ENTITY_TO_CLASS( ammo_762mm, CItemAmmo762MM );
  53. //-----------------------------------------------------------------------------
  54. class CItemAmmo556MM : public CItemAmmo
  55. {
  56. public:
  57. DECLARE_CLASS( CItemAmmo556MM, CItemAmmo );
  58. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_556MM; }
  59. };
  60. LINK_ENTITY_TO_CLASS( ammo_556mm, CItemAmmo556MM );
  61. class CItemAmmo556MM_SMALL : public CItemAmmo
  62. {
  63. public:
  64. DECLARE_CLASS( CItemAmmo556MM_SMALL, CItemAmmo );
  65. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_556MM_SMALL; }
  66. };
  67. LINK_ENTITY_TO_CLASS( ammo_556mm_small, CItemAmmo556MM_SMALL );
  68. //-----------------------------------------------------------------------------
  69. class CItemAmmo556MM_BOX : public CItemAmmo
  70. {
  71. public:
  72. DECLARE_CLASS( CItemAmmo556MM_BOX, CItemAmmo );
  73. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_556MM_BOX; }
  74. };
  75. LINK_ENTITY_TO_CLASS( ammo_556mm_box, CItemAmmo556MM_BOX );
  76. //-----------------------------------------------------------------------------
  77. class CItemAmmo338MAG : public CItemAmmo
  78. {
  79. public:
  80. DECLARE_CLASS( CItemAmmo338MAG, CItemAmmo );
  81. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_338MAG; }
  82. };
  83. LINK_ENTITY_TO_CLASS( ammo_338mag, CItemAmmo338MAG );
  84. //-----------------------------------------------------------------------------
  85. class CItemAmmo9MM : public CItemAmmo
  86. {
  87. public:
  88. DECLARE_CLASS( CItemAmmo9MM, CItemAmmo );
  89. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_9MM; }
  90. };
  91. LINK_ENTITY_TO_CLASS( ammo_9mm, CItemAmmo9MM );
  92. //-----------------------------------------------------------------------------
  93. class CItemAmmoBuckshot : public CItemAmmo
  94. {
  95. public:
  96. DECLARE_CLASS( CItemAmmoBuckshot, CItemAmmo );
  97. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_BUCKSHOT; }
  98. };
  99. LINK_ENTITY_TO_CLASS( ammo_buckshot, CItemAmmoBuckshot );
  100. //-----------------------------------------------------------------------------
  101. class CItemAmmo45ACP : public CItemAmmo
  102. {
  103. public:
  104. DECLARE_CLASS( CItemAmmo45ACP, CItemAmmo );
  105. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_45ACP; }
  106. };
  107. LINK_ENTITY_TO_CLASS( ammo_45acp, CItemAmmo45ACP );
  108. //-----------------------------------------------------------------------------
  109. class CItemAmmo357SIG : public CItemAmmo
  110. {
  111. public:
  112. DECLARE_CLASS( CItemAmmo357SIG, CItemAmmo );
  113. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_357SIG; }
  114. };
  115. LINK_ENTITY_TO_CLASS( ammo_357sig, CItemAmmo357SIG );
  116. //-----------------------------------------------------------------------------
  117. class CItemAmmo357SIG_P250 : public CItemAmmo
  118. {
  119. public:
  120. DECLARE_CLASS( CItemAmmo357SIG_P250, CItemAmmo );
  121. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_357SIG_P250; }
  122. };
  123. LINK_ENTITY_TO_CLASS( ammo_357sig_p250, CItemAmmo357SIG_P250 );
  124. //-----------------------------------------------------------------------------
  125. class CItemAmmo357SIG_SMALL : public CItemAmmo
  126. {
  127. public:
  128. DECLARE_CLASS( CItemAmmo357SIG_SMALL, CItemAmmo );
  129. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_357SIG_SMALL; }
  130. };
  131. LINK_ENTITY_TO_CLASS( ammo_357sig_small, CItemAmmo357SIG_SMALL );
  132. //-----------------------------------------------------------------------------
  133. class CItemAmmo357SIG_MIN : public CItemAmmo
  134. {
  135. public:
  136. DECLARE_CLASS( CItemAmmo357SIG_MIN, CItemAmmo );
  137. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_357SIG_MIN; }
  138. };
  139. LINK_ENTITY_TO_CLASS( ammo_357sig_np_reserve, CItemAmmo357SIG_MIN );
  140. //-----------------------------------------------------------------------------
  141. class CItemAmmo57MM : public CItemAmmo
  142. {
  143. public:
  144. DECLARE_CLASS( CItemAmmo57MM, CItemAmmo );
  145. virtual const char * GetAmmoName( void ) const { return BULLET_PLAYER_57MM; }
  146. };
  147. LINK_ENTITY_TO_CLASS( ammo_57mm, CItemAmmo57MM );
  148. //-----------------------------------------------------------------------------