Guest User

Untitled

a guest
Nov 25th, 2010
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.01 KB | None | 0 0
  1. #include "cbase.h"
  2. #include "basecombatweapon_shared.h"
  3. #include "gamerules.h"
  4. #include "mathlib/mathlib.h"
  5. #include "in_buttons.h"
  6. #include "vstdlib/random.h"
  7.  
  8. class C_WeaponItem : public C_BaseCombatWeapon
  9. {
  10. public:
  11.     DECLARE_CLASS( C_WeaponItem, C_BaseCombatWeapon );
  12.     DECLARE_CLIENTCLASS();
  13.  
  14.     C_WeaponItem();
  15.  
  16.     virtual void        Spawn( void );
  17.     virtual void        PrecacheSpecial( void );
  18.  
  19.     virtual int         GetSlot( void ) const;
  20.     virtual int         GetPosition( void ) const;
  21.     virtual const char  *GetViewModel( void ) const;
  22.     virtual const char  *GetWorldModel( void ) const;
  23.     virtual const char  *GetPrintName( void ) const;
  24.  
  25. private:
  26.  
  27.     int                 m_iBucket1;
  28.     int                 m_iBucket2;
  29.     char                m_szWorldModel[ MAX_PATH ];
  30.     char                m_szViewModel[ MAX_PATH ];
  31.     char                m_szDisplayName[ MAX_PATH ];
  32. };
  33.  
  34. IMPLEMENT_CLIENTCLASS_DT( C_WeaponItem, DT_WeaponItem, CWeaponItem )
  35.     RecvPropInt( RECVINFO( m_iBucket1 ) ),
  36.     RecvPropInt( RECVINFO( m_iBucket2 ) ),
  37.     RecvPropString( RECVINFO( m_szViewModel ) ),
  38.     RecvPropString( RECVINFO( m_szWorldModel ) ),
  39.     RecvPropString( RECVINFO( m_szDisplayName ) ),
  40. END_RECV_TABLE()
  41.  
  42.  
  43. C_WeaponItem::C_WeaponItem( void )
  44. {
  45. }
  46.  
  47. void C_WeaponItem::Spawn( void )
  48. {
  49.     PrecacheSpecial();
  50.  
  51.     SetSolid( SOLID_BBOX );
  52.     m_flNextEmptySoundTime = 0.0f;
  53.  
  54.     // Weapons won't show up in trace calls if they are being carried...
  55.     RemoveEFlags( EFL_USE_PARTITION_WHEN_NOT_SOLID );
  56.  
  57.     m_iState = WEAPON_NOT_CARRIED;
  58.     // Assume
  59.     m_nViewModelIndex = 0;
  60.  
  61.     GiveDefaultAmmo();
  62.  
  63.     SetModel( GetWorldModel() );
  64.  
  65.     if( IsX360() )
  66.     {
  67.         AddEffects( EF_ITEM_BLINK );
  68.     }
  69.  
  70.     SetCollisionGroup( COLLISION_GROUP_WEAPON );
  71.     m_takedamage = DAMAGE_EVENTS_ONLY;
  72.  
  73.     SetBlocksLOS( false );
  74.  
  75.     // Bloat the box for player pickup
  76.     CollisionProp()->UseTriggerBounds( true, 36 );
  77.  
  78.     // Use more efficient bbox culling on the client. Otherwise, it'll setup bones for most
  79.     // characters even when they're not in the frustum.
  80.     AddEffects( EF_BONEMERGE_FASTCULL );
  81.  
  82.     Msg("VM: %s \n", m_szViewModel);
  83. }
  84.  
  85.  
  86. void C_WeaponItem::PrecacheSpecial( void )
  87. {
  88.     m_iPrimaryAmmoType = m_iSecondaryAmmoType = -1;
  89.     m_iViewModelIndex = 0;
  90.     m_iWorldModelIndex = 0;
  91.  
  92.     const char *tmpView = (char *)STRING( m_szViewModel );
  93.     const char *tmpWorld = (char *)STRING( m_szWorldModel );
  94.  
  95.     if ( tmpView && tmpView[0] )
  96.     {
  97.         m_iViewModelIndex = CBaseEntity::PrecacheModel( tmpView );
  98.     }
  99.     if ( tmpWorld && tmpWorld[0] )
  100.     {
  101.         m_iWorldModelIndex = CBaseEntity::PrecacheModel( tmpWorld );
  102.     }
  103. }
  104.  
  105. int C_WeaponItem::GetSlot( void ) const
  106. {
  107.     return m_iBucket1;
  108. }
  109.  
  110. int C_WeaponItem::GetPosition( void ) const
  111. {
  112.     return m_iBucket2;
  113. }
  114.  
  115. const char *C_WeaponItem::GetViewModel( void ) const
  116. {
  117.     const char *szModel = (char *)STRING( m_szViewModel );
  118.     return szModel;
  119. }
  120.  
  121. const char *C_WeaponItem::GetWorldModel( void ) const
  122. {
  123.     const char *szModel = (char *)STRING( m_szWorldModel );
  124.     return szModel;
  125. }
  126.  
  127. const char *C_WeaponItem::GetPrintName( void ) const
  128. {
  129.     const char *szModel = (char *)STRING( m_szDisplayName );
  130.     return szModel;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment